Skip to content

Conversation

@shyok21
Copy link
Contributor

@shyok21 shyok21 commented Jul 2, 2025

Summary

This PR fixes a grammatical issue in the TypeError message raised when a ufunc (such as np.hypot) receives an incorrect number of positional arguments.

Previously, the message always used:

hypot() takes from 2 to 3 positional arguments but 1 were given

This PR ensures that when exactly one argument is passed, the message reads:

hypot() takes from 2 to 3 positional arguments but 1 was given


Changes

  • Updated error message formatting logic in:
    • npy_argparse.c
    • ufunc_object.c
  • Added regression tests under test_umath.py to assert correct grammar for singular and plural argument count cases.

Related Issue

Closes #29259

Additional Notes

  • Follows TDD approach: test first, then fix.
  • Verified via pytest numpy/_core/tests/test_umath.py -k TestHypotErrorMessages
  • Thanks to maintainers for pointing to the relevant code sections.

@mattip mattip merged commit b999c61 into numpy:main Jul 2, 2025
77 checks passed
@mattip
Copy link
Member

mattip commented Jul 2, 2025

Thanks @shyok21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad grammar in error message from hypot

2 participants