B
    )²ô`
  ã               @   sV   d Z ddlmZ ddlmZ ddlmZ ddlZddlZdd„ Ze 	d¡Z
d	d
„ ZdS )z3Testing utilities for tfdbg command-line interface.é    )Úabsolute_import)Údivision)Úprint_functionNc             C   sb   |   t|ƒt|ƒdt|ƒt|ƒf ¡ x6t||ƒD ](\}}|   d | ¡ ¡d | ¡ ¡¡ q2W dS )a  Assert equality in lines, ignoring all whitespace.

  Args:
    test: An instance of unittest.TestCase or its subtypes (e.g.,
      TensorFlowTestCase).
    expected_lines: Expected lines as an iterable of strings.
    actual_lines: Actual lines as an iterable of strings.
  z)Mismatch in the number of lines: %d vs %dÚ N)ÚassertEqualÚlenÚzipÚjoinÚsplit)ÚtestZexpected_linesZactual_linesZexpected_lineZactual_line© r   úY/home/dcms/DCMS/lib/python3.7/site-packages/tensorflow/python/debug/cli/cli_test_utils.pyÚ&assert_lines_equal_ignoring_whitespace   s    	r   z(array|\(|\[|\]|\)|\||,)c             C   sR   g }x2|D ]*}t  td|¡}| dd„ | ¡ D ƒ¡ q
W |  t |¡ ¡ |¡ dS )aÝ  Assert that the array value represented by lines is close to expected.

  Note that the shape of the array represented by the `array_lines` is ignored.

  Args:
    test: An instance of TensorFlowTestCase.
    expected_array: Expected value of the array.
    array_lines: A list of strings representing the array.
      E.g., "array([[ 1.0, 2.0 ], [ 3.0, 4.0 ]])"
      Assumes that values are separated by commas, parentheses, brackets, "|"
      characters and whitespace.
  ú c             s   s   | ]}t |ƒV  qd S )N)Úfloat)Ú.0Úsr   r   r   ú	<genexpr>@   s    z+assert_array_lines_close.<locals>.<genexpr>N)	ÚreÚsubÚ_ARRAY_VALUE_SEPARATOR_REGEXÚextendr
   ZassertAllCloseÚnpÚarrayÚflatten)r   Zexpected_arrayZarray_linesÚelementsÚliner   r   r   Úassert_array_lines_close0   s
    
r   )Ú__doc__Ú
__future__r   r   r   r   Únumpyr   r   Úcompiler   r   r   r   r   r   Ú<module>   s   
