cudf.testing.testing.assert_index_equal#

cudf.testing.testing.assert_index_equal(left, right, exact='equiv', check_names: bool = True, check_less_precise: Union[bool, int] = False, check_exact: bool = True, check_categorical: bool = True, check_order: bool = True, rtol: float = 1e-05, atol: float = 1e-08, obj: str = 'Index')#

Check that left and right Index are equal

This function is intended to compare two Index and output any differences. Additional parameters allow varying the strictness of the equality checks performed.

Parameters
leftIndex

left Index to compare

rightIndex

right Index to compare

exactbool or {‘equiv’}, default ‘equiv’

Whether to check the Index class, dtype and inferred_type are identical. If ‘equiv’, then RangeIndex can be substituted for Int8Index, Int16Index, Int32Index, Int64Index as well.

check_namesbool, default True

Whether to check the names attribute.

check_less_precisebool or int, default False

Not yet supported

check_exactbool, default False

Whether to compare number exactly.

check_categoricalbool, default True

Whether to compare internal Categorical exactly.

check_orderbool, default True

Whether to compare the order of index entries as well as their values. If True, both indexes must contain the same elements, in the same order. If False, both indexes must contain the same elements, but in any order.

rtolfloat, default 1e-5

Relative tolerance. Only used when check_exact is False.

atolfloat, default 1e-8

Absolute tolerance. Only used when check_exact is False.

objstr, default ‘Index’

Specify object name being compared, internally used to show appropriate assertion message.

Examples

>>> import cudf
>>> id1 = cudf.Index([1, 2, 3, 4])
>>> id2 = cudf.Index([1, 2, 3, 5])
>>> cudf.testing.assert_index_equal(id1, id2)
......
......
AssertionError: ColumnBase are different

values are different (25.0 %)
[left]:  [1 2 3 4]
[right]: [1 2 3 5]
>>> id2 = cudf.Index([1, 2, 3, 4], name="b")
>>> cudf.testing.assert_index_equal(id1, id2)
......
......
AssertionError: Index are different

name mismatch
[left]:  a
[right]: b

This will pass without any hitch:

>>> id2 = cudf.Index([1, 2, 3, 4], name="a")
>>> cudf.testing.assert_index_equal(id1, id2)