Skip to content

TST: Refactor test_subtracting_two_series_with_unordered_index_and_all_nan_index #49698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pandas/tests/indexing/multiindex/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,28 @@ def test_rename_multiindex_with_duplicates(self):
),
],
)
def test_subtracting_two_series_with_unordered_index_and_all_nan_index(
self, data_result, data_expected

def generate_result(
self, data_result
):
# GH 38439
# TODO: Refactor. This is impossible to understand GH#49443
a_index_result = MultiIndex.from_tuples(data_result[0])
b_index_result = MultiIndex.from_tuples(data_result[1])
a_series_result = Series(data_result[2], index=a_index_result)
b_series_result = Series(data_result[3], index=b_index_result)
result = a_series_result.align(b_series_result)
return a_series_result.align(b_series_result)

def generate_series_expected(
self, data_expected
):
# GH 38439
a_index_expected = MultiIndex.from_arrays(data_expected[0])
b_index_expected = MultiIndex.from_arrays(data_expected[1])
a_series_expected = Series(data_expected[2], index=a_index_expected)
b_series_expected = Series(data_expected[3], index=b_index_expected)
return Series(data_expected[2], index=a_index_expected).align(Series(data_expected[3], index=b_index_expected))

tm.assert_series_equal(result[0], a_series_expected)
tm.assert_series_equal(result[1], b_series_expected)
def test_result_and_series(self):
tm.assert_series_equal(TestMultiIndexBasic.generate_result[0], TestMultiIndexBasic.generate_series_expected[0])
tm.assert_series_equal(TestMultiIndexBasic.generate_result[1], TestMultiIndexBasic.generate_series_expected[1])

def test_nunique_smoke(self):
# GH 34019
Expand Down