Skip to content
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

MAINT: test-refactor of numpy/_core/numeric.py #25010

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Oct 26, 2023

This is a pure-test refactor (as well as adding a few cases), extracted from #24663.

Testing each individually has a small Pytest overhead, but has the advantage of each test being able to fail independently in case of a modification of the tested function.

It also make it much easier to add a new test, and I believe is much more readable.

@ngoldbaum
Copy link
Member

Test failure is unrelated

@Carreau
Copy link
Contributor Author

Carreau commented Oct 27, 2023

Thanks @rgommers for the rebase

Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to nitpick, I can also live with this. But these globals seem a bit annoying. Can we rewrite it as (can also be in the class even if the class is useless)

def _test_array_equal_parametrizations():
    # those are 0-d arrays, it used to be a special case
    # where (_e0 == _e0).all() would raise
    e0 = np.array(0, dtype='int')
    e1 = np.array(1, dtype='float')

    yield (e0, e0.copy(), None, True)
    yield ...

that would keep locality of the variables and comparisons and just remove the weird globals.

EDIT: Which of course means using:

@pytest.mark.parametrize("...", _test_array_equal_parametrizations())

numpy/_core/tests/test_numeric.py Outdated Show resolved Hide resolved
numpy/_core/tests/test_numeric.py Outdated Show resolved Hide resolved
@Carreau Carreau force-pushed the numpy-core-refactor branch 2 times, most recently from 389f0fc to b7fc0fd Compare October 27, 2023 09:47
This is a pure-test refactor (as well as adding a few cases), extracted
from numpy#24663.

Testing each individually has a small Pytest overhead, but has the
advantage of each test being able to fail independently in case of a
modification of the tested function.

It also make it much easier to add a new test, and I believe is much more
readable.

[skip cirrus] [skip circle] [skip azp]
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Much easier to follow now with things being closer :).

@seberg seberg merged commit cdfbdf4 into numpy:main Oct 27, 2023
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants