Skip to content

ENH: clarify error message of broadcast #6900

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

Merged
merged 1 commit into from
Jan 4, 2016
Merged

Conversation

kohr-h
Copy link
Contributor

@kohr-h kohr-h commented Dec 30, 2015

Fix for #6898. What about the brackets around the maximum number of arguments? Could also be removed while we're at it.

@gfyoung
Copy link
Contributor

gfyoung commented Dec 30, 2015

There are several other instances of that ValueError with the exact same message in the same file. You might want to look at those too, but you can wait to see what one of the owners think.

@kohr-h
Copy link
Contributor Author

kohr-h commented Dec 30, 2015

Sure, a common formulation in "Numpy style" would be good.

@jaimefrio
Copy link
Member

There is certainly no need for the brackets. Since the second value will be numeric, it probably makes sense that the first one is as well. And the wording should be identical for all instances of the same error, but I don't think we have a NumPy style for this, use your best judgement, and whatever you come up with should be good.

FWIW, I like the at least / at most wording better than the (inclusive) one...

@kohr-h
Copy link
Contributor Author

kohr-h commented Dec 30, 2015

I found 3 places with similar messages in the same file and applied the same style at least / at most to all of them. Brackets are gone and numbers are printed as numeric values now.

@@ -1458,8 +1458,8 @@ PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ...)
ntot = n + nadd;
if (ntot < 2 || ntot > NPY_MAXARGS) {
PyErr_Format(PyExc_ValueError,
"Need between 2 and (%d) " \
"array objects (inclusive).", NPY_MAXARGS);
"Need at least 2 and at most %d " \
Copy link
Member

Choose a reason for hiding this comment

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

You can get rid of the \ also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did that.

charris added a commit that referenced this pull request Jan 4, 2016
ENH: clarify error message of broadcast
@charris charris merged commit e072d79 into numpy:master Jan 4, 2016
@charris
Copy link
Member

charris commented Jan 4, 2016

Thanks @kohr-h .

@charris
Copy link
Member

charris commented Jan 4, 2016

For future reference, this is more MAINT than ENH ;)

@kohr-h
Copy link
Contributor Author

kohr-h commented Jan 4, 2016

Alright, got it. ;-)

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.

4 participants