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

ENH: assert_array_less should report max violations instead of max differences #24369

Merged

Conversation

undermyumbrella1
Copy link
Contributor

@undermyumbrella1 undermyumbrella1 commented Aug 9, 2023

Fixes #23894

@ngoldbaum
Copy link
Member

Looks like some docstrings need to be updated, the test failures are real.

@undermyumbrella1
Copy link
Contributor Author

ok updated, is the travis ci pull request build failure an issue on my end too?

@ngoldbaum
Copy link
Member

Nope, that one's unrelated. The Travis PPC64LE runners have been flaky for quite a while
now.

Copy link
Member

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

I think this is a clear improvement, thank you for working on this, it will make the debugging experience for the entire PyData ecosystem nicer when a test using this assert fails.

The implementation looks correct and the new tests make sense. I think you can substantially slim down the new tests you've added by checking for a matching message directly in pytest.raises, see comments below.

self._assert_func(x, y)
msg = str(exc_info.value)
assert_('Mismatched elements: 1 / 1 (100%)\n'
in msg)
Copy link
Member

Choose a reason for hiding this comment

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

nit, here and below: you can pass a match=some_regex to pytest.raises to check for a matching message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review, i have updated the error message checks to use match

# assert_('Mismatched elements: 2 / 2 (100%)\n'
# 'Max absolute difference among violations: 2.\n'
# 'Max relative difference among violations: inf'
# in msg)
Copy link
Member

Choose a reason for hiding this comment

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

why is this commented out?

Copy link
Contributor Author

@undermyumbrella1 undermyumbrella1 Aug 21, 2023

Choose a reason for hiding this comment

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

I have uncommented this out, just to confirm the mismatched elements is 1 / 2 and max relative difference among violations should be inf right? (as per the results in the original numpy on the main branch)

@undermyumbrella1
Copy link
Contributor Author

Hi, any updates on this pr? thank you

@ngoldbaum ngoldbaum added the triage review Issue/PR to be discussed at the next triage meeting label Sep 2, 2023
@ngoldbaum
Copy link
Member

I added the triage review label so hopefully this will get a look at the next triage meeting unless someone else merges in the meantime. This is a lot of code so I want another set of eyes before merging.

@undermyumbrella1
Copy link
Contributor Author

ok, thank you

@ngoldbaum
Copy link
Member

It looks like there's a conflict that needs to be fixed

@ngoldbaum
Copy link
Member

It looks like there's a conflict that needs to be fixed

Went ahead and fixed it, I'll merge if this is still passing all the tests.

@ngoldbaum
Copy link
Member

Thanks @ellaella12!

@ngoldbaum ngoldbaum merged commit fc30e98 into numpy:main Oct 18, 2023
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Enhancement triage review Issue/PR to be discussed at the next triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: assert_array_less should report max violations instead of max differences
2 participants