-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
API: Add new np.exceptions
namespace for errors and warnings
#22644
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
Conversation
.. warning:: | ||
|
||
This warning should not be used, since nose testing is not relvant | ||
anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this warning, and skipped documenting it... It seems like a remnant of a time past.
Can we please move this (and the other PR there) forward? I (+do not see) potential for controversy or code complexity here, but:
I bet there is more, but my monkey brain can only hold 3 things at once. |
AxisError Given when an axis was invalid. | ||
TooHardError Error specific to `numpy.shares_memory`. | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have autosummary elsewhere in a module docstring? This feels out of place to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, fft and polynomials used it. But I am not sure the autosummary here is actually useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this belongs somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where? Maybe @rossbar can just say.
numpy/lib/npyio.py
Outdated
Lines containing no data, including comment lines (e.g., lines | ||
starting with '#' or as specified via `comments`) are not counted | ||
Lines containing no data, including comment lines (e.g., lines | ||
starting with '#' or as specified via `comments`) are not counted | ||
towards `max_rows`. | ||
quotechar : unicode character or None, optional | ||
The character used to denote the start and end of a quoted item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree with the whitespace cleanup in files you are changing anyway, I don't think this one should be part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, not even an actual change left in the end here... (set_module
is imported via overrides
here, which seemed OKish.)
Note that this is still a WIP, might want to change that so it can be merged. |
This is still draft status. For other reviewers: it has 3 components:
|
I have a separate PR for moving the Yeah can pull out the whitespace changes there, they were not really intended, just auto-stripping by the editor. |
b7dfc6e
to
a82a155
Compare
Is this ready to go? I quite like it. |
This means moving ComplexWarning, TooHardError, and AxisError.
Both should now live in the "exceptions" module.
AxisError did exist, but e.g. ComplexWarning wasn't even properly included.
Should be ready to go now, was missing a rebase on main still. |
numpy/exceptions.py
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -707,7 +694,7 @@ def correlate(a, v, mode='valid'): | |||
-------- | |||
convolve : Discrete, linear convolution of two one-dimensional sequences. | |||
multiarray.correlate : Old, no conjugate, version of correlate. | |||
scipy.signal.correlate : uses FFT which has superior performance on large arrays. | |||
scipy.signal.correlate : uses FFT which has superior performance on large arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tripping up the linter since the line is 85, not 80. But I think it is OK.
Co-authored-by: Matti Picus <matti.picus@gmail.com>
Thanks @seberg. There is still the documentation issue, but lets leave that for a future PR. |
Xref numpy#22644 and numpy#22707 Update modules.pyi
This adds the namespace and populates it with the main public exceptions and warnings that we have. I skipped
RankWarning
for now, because we have two (and only one is in the main namespace).The UFuncTypeError is currently effectively private, so did not move it quite yet (this can be a followup).
Based of gh-22619 and thus creating as draft. I put 1.24 as version here, but most likely this will need updating.
The main point of this is really to simplify adding of new exceptions in the future, but I think the module doesn't really hurt even for 3 errors.
Mailing list thread where we discussed adding this module: https://mail.python.org/archives/list/numpy-discussion@python.org/thread/IZJQTPQBKNQGK4OGWSTREQWKGMQDSFKM/