/usr/local/lib64/python3.6/site-packages/pandas/tests/util
NameSizeModeActions
__pycache__/-0755rm
conftest.py4760644editdlrm
test_assert_almost_equal.py114990644editdlrm
test_assert_categorical_equal.py27490644editdlrm
test_assert_extension_array_equal.py34710644editdlrm
test_assert_frame_equal.py88350644editdlrm
test_assert_index_equal.py56640644editdlrm
test_assert_interval_array_equal.py23640644editdlrm
test_assert_numpy_array_equal.py63610644editdlrm
test_assert_produces_warning.py5470644editdlrm
test_assert_series_equal.py90890644editdlrm
test_deprecate.py16260644editdlrm
test_deprecate_kwarg.py20430644editdlrm
test_deprecate_nonkeyword_arguments.py27130644editdlrm
test_doc.py14920644editdlrm
test_hashing.py108600644editdlrm
test_numba.py3080644editdlrm
test_safe_import.py10200644editdlrm
test_show_versions.py11870644editdlrm
test_util.py19820644editdlrm
test_validate_args.py18440644editdlrm
test_validate_args_and_kwargs.py23910644editdlrm
test_validate_kwargs.py17400644editdlrm
__init__.py00644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/pandas/tests/util/test_assert_index_equal.py (5664B)
import numpy as np import pytest from pandas import Categorical, Index, MultiIndex, NaT import pandas._testing as tm def test_index_equal_levels_mismatch(): msg = """Index are different Index levels are different \\[left\\]: 1, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\) \\[right\\]: 2, MultiIndex\\(\\[\\('A', 1\\), \\('A', 2\\), \\('B', 3\\), \\('B', 4\\)\\], \\)""" idx1 = Index([1, 2, 3]) idx2 = MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3), ("B", 4)]) with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, exact=False) def test_index_equal_values_mismatch(check_exact): msg = """MultiIndex level \\[1\\] are different MultiIndex level \\[1\\] values are different \\(25\\.0 %\\) \\[left\\]: Int64Index\\(\\[2, 2, 3, 4\\], dtype='int64'\\) \\[right\\]: Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)""" idx1 = MultiIndex.from_tuples([("A", 2), ("A", 2), ("B", 3), ("B", 4)]) idx2 = MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3), ("B", 4)]) with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, check_exact=check_exact) def test_index_equal_length_mismatch(check_exact): msg = """Index are different Index length are different \\[left\\]: 3, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\) \\[right\\]: 4, Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)""" idx1 = Index([1, 2, 3]) idx2 = Index([1, 2, 3, 4]) with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, check_exact=check_exact) def test_index_equal_class_mismatch(check_exact): msg = """Index are different Index classes are different \\[left\\]: Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\) \\[right\\]: Float64Index\\(\\[1\\.0, 2\\.0, 3\\.0\\], dtype='float64'\\)""" idx1 = Index([1, 2, 3]) idx2 = Index([1, 2, 3.0]) with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, exact=True, check_exact=check_exact) def test_index_equal_values_close(check_exact): idx1 = Index([1, 2, 3.0]) idx2 = Index([1, 2, 3.0000000001]) if check_exact: msg = """Index are different Index values are different \\(33\\.33333 %\\) \\[left\\]: Float64Index\\(\\[1.0, 2.0, 3.0], dtype='float64'\\) \\[right\\]: Float64Index\\(\\[1.0, 2.0, 3.0000000001\\], dtype='float64'\\)""" with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, check_exact=check_exact) else: tm.assert_index_equal(idx1, idx2, check_exact=check_exact) def test_index_equal_values_less_close(check_exact, rtol): idx1 = Index([1, 2, 3.0]) idx2 = Index([1, 2, 3.0001]) kwargs = dict(check_exact=check_exact, rtol=rtol) if check_exact or rtol < 0.5e-3: msg = """Index are different Index values are different \\(33\\.33333 %\\) \\[left\\]: Float64Index\\(\\[1.0, 2.0, 3.0], dtype='float64'\\) \\[right\\]: Float64Index\\(\\[1.0, 2.0, 3.0001\\], dtype='float64'\\)""" with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, **kwargs) else: tm.assert_index_equal(idx1, idx2, **kwargs) def test_index_equal_values_too_far(check_exact, rtol): idx1 = Index([1, 2, 3]) idx2 = Index([1, 2, 4]) kwargs = dict(check_exact=check_exact, rtol=rtol) msg = """Index are different Index values are different \\(33\\.33333 %\\) \\[left\\]: Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\) \\[right\\]: Int64Index\\(\\[1, 2, 4\\], dtype='int64'\\)""" with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, **kwargs) def test_index_equal_level_values_mismatch(check_exact, rtol): idx1 = MultiIndex.from_tuples([("A", 2), ("A", 2), ("B", 3), ("B", 4)]) idx2 = MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3), ("B", 4)]) kwargs = dict(check_exact=check_exact, rtol=rtol) msg = """MultiIndex level \\[1\\] are different MultiIndex level \\[1\\] values are different \\(25\\.0 %\\) \\[left\\]: Int64Index\\(\\[2, 2, 3, 4\\], dtype='int64'\\) \\[right\\]: Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)""" with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, **kwargs) @pytest.mark.parametrize( "name1,name2", [(None, "x"), ("x", "x"), (np.nan, np.nan), (NaT, NaT), (np.nan, NaT)], ) def test_index_equal_names(name1, name2): idx1 = Index([1, 2, 3], name=name1) idx2 = Index([1, 2, 3], name=name2) if name1 == name2 or name1 is name2: tm.assert_index_equal(idx1, idx2) else: name1 = "'x'" if name1 == "x" else name1 name2 = "'x'" if name2 == "x" else name2 msg = f"""Index are different Attribute "names" are different \\[left\\]: \\[{name1}\\] \\[right\\]: \\[{name2}\\]""" with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2) def test_index_equal_category_mismatch(check_categorical): msg = """Index are different Attribute "dtype" are different \\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\) \\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \ ordered=False\\)""" idx1 = Index(Categorical(["a", "b"])) idx2 = Index(Categorical(["a", "b"], categories=["a", "b", "c"])) if check_categorical: with pytest.raises(AssertionError, match=msg): tm.assert_index_equal(idx1, idx2, check_categorical=check_categorical) else: tm.assert_index_equal(idx1, idx2, check_categorical=check_categorical)