Skip to content

TST: Refactor test_subtracting_two_series_with_unordered_index_and_all_nan_index #49443

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
phofl opened this issue Nov 1, 2022 · 5 comments · Fixed by #50516
Closed

TST: Refactor test_subtracting_two_series_with_unordered_index_and_all_nan_index #49443

phofl opened this issue Nov 1, 2022 · 5 comments · Fixed by #50516
Assignees
Labels
good first issue MultiIndex Testing pandas testing functions or related to the test suite

Comments

@phofl
Copy link
Member

phofl commented Nov 1, 2022

The test is hard to read and hard to understand. We should refactor it to make it more straightforward without those parametrizations. Pending #49442

@phofl phofl added Testing pandas testing functions or related to the test suite MultiIndex good first issue labels Nov 1, 2022
@shogohida
Copy link

Hi @phofl, I want to work on this! However, I'm not very sure how to refactor the test because I'm new to Pandas. Could you give me some advice? It would be really helpful

@phofl
Copy link
Member Author

phofl commented Nov 5, 2022

It would be helpful to remove the parametrisation and split the content into two tests so that it is easier to read. But would be good to wait till the linked pr is merged, because it changed the behavior of the test

@shogohida
Copy link

take

@shogohida
Copy link

Thanks for your comment! Now I understand that I need to separate result and expected. I will wait until the linked PR is merged

def test_subtracting_two_series_with_unordered_index_and_all_nan_index(
self, data_result, data_expected
):
# GH 38439
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)
a_index_expected = MultiIndex.from_tuples(data_expected[0])
b_index_expected = MultiIndex.from_tuples(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)
a_series_expected.index = a_series_expected.index.set_levels(
[
a_series_expected.index.levels[0].astype("float"),
a_series_expected.index.levels[1].astype("float"),
]
)
b_series_expected.index = b_series_expected.index.set_levels(
[
b_series_expected.index.levels[0].astype("float"),
b_series_expected.index.levels[1].astype("float"),
]
)
tm.assert_series_equal(result[0], a_series_expected)
tm.assert_series_equal(result[1], b_series_expected)

@shogohida
Copy link

Some tests failed but I wanted to make sure if my understanding is correct at first. Can you have a look?

#49698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue MultiIndex Testing pandas testing functions or related to the test suite
Projects
None yet
2 participants