allensdk.test_utilities.custom_comparators module

class allensdk.test_utilities.custom_comparators.WhitespaceStrippedString(string: str, whitespace_chars: str = '\s', ASCII: bool = False)[source]

Bases: object

Comparator class to compare strings that have been stripped of whitespace. By default removes any unicode whitespace character that matches the regex s, (which includes [ tnrfv], and other unicode whitespace characters).

allensdk.test_utilities.custom_comparators.safe_df_comparison(expected: pandas.core.frame.DataFrame, obtained: pandas.core.frame.DataFrame, expect_identical_column_order: bool = False)[source]

Compare two dataframes in a way that is agnostic to column order and datatype of NULL values

expected: pd.DataFrame
obtained: pd.DataFrame
expect_identical_column_order: bool

If True, raise an error if columns are not in the same order (default=False)

  • dataframes do not have the same columns
  • dataframes do not have identical indexes
  • dataframe columns do not have identical contents

When comparing the contents of dataframe columns, the function:

  • verifies that NULL values (whether None or NaN) are in the same location
  • loops over non-null values, casts arrays into lists, and compares with ==