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: Changed repr of np.bool_ #17592
base: main
Are you sure you want to change the base?
Conversation
|
Some tests are forming cores, will send the mail to the mailing list, once that's fixed |
|
Do macs have a different set of tests? I noticed this is failing. |
|
It's working in linux: (Pdb) p numpy_f
<function any at 0x7f78f15e7310>
(Pdb) p numpy_f(a, axis=1, keepdims=True)[...,:-1]
masked_array(
data=[[[True, False, True]],
[[True, False, True]]],
mask=[[[False, False, False]],
[[False, False, False]]],
fill_value=numpy.True_)> /home/ganesh/open-source/numpy/build/testenv/lib/python3.8/site-packages/numpy/ma/tests/test_core.py(4948)testkeepdims()
-> assert_equal(ma_f(a, keepdims=True).shape,
(Pdb) p ma_f(a, axis=1, keepdims=True)[...,:-1]
masked_array(
data=[[[True, False, True]],
[[True, False, True]]],
mask=[[[False, False, False]],
[[False, False, False]]],
fill_value=numpy.True_)
(Pdb) p f
'any'numpy/numpy/ma/tests/test_core.py Lines 4958 to 4960 in 32f1359
Any idea why it's failing only on Mac? |
|
The test that is failing is a documentation test, and I guess the documentation tests are only run on mac? You need to update the docstrings to use the new printing. |
|
The incantation is |
4dd12ce
to
9ae76ee
Compare
|
I have emailed the mailing list (nabble link, pipermail link)for their opinion @eric-wieser, as mentioned in the issue. |
Can you add an "improvements" release note, like we did when we improved void.__repr__ with https://numpy.org/doc/stable/release/1.14.0-notes.html#void-datatype-elements-are-now-printed-in-hex-notation?
|
@eric-wieser , any more changes needed? |
|
Thanks Eric, sure |
|
Happy to put this in as such, although I wonder a bit whether this has the potential to be a slightly noisy transition, and 1.20 is already a big release. |
|
This is different from every other NumPy scalar, Also reprs don't usually include the module. |
|
We are a bit unsure whether this is a good idea at all, could you propose this on the mailing list, since it is an API change? |
|
This already hit the mailing list and was meet with silence |
|
In a triage discussion we seem to prefer fixing this across all scalars and not just |
|
Sounds good @mattip , I'll use this PR to change the repr of all classes. When time comes, we can merge all together. |
|
I have made some change to reflect like this: >>> np.int64(42)
numpy.int64(42)Only for ints as of now. If it's breaking too much stuff let's put a hold on this. |
| if ((dtype = PyObject_GetAttrString(self, "dtype")) == NULL) { | ||
| return NULL; | ||
| } | ||
|
|
||
| if ((dtype_name = PyObject_GetAttrString(dtype, "name")) == NULL) { | ||
| return NULL; | ||
| } | ||
|
|
||
| item_str = PyUString_FromFormat("numpy.%S(%S)", dtype_name, 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.
This feels like overkill - does the following work?
| if ((dtype = PyObject_GetAttrString(self, "dtype")) == NULL) { | |
| return NULL; | |
| } | |
| if ((dtype_name = PyObject_GetAttrString(dtype, "name")) == NULL) { | |
| return NULL; | |
| } | |
| item_str = PyUString_FromFormat("numpy.%S(%S)", dtype_name, item); | |
| item_str = PyUString_FromFormat("%s(%S)", Py_TYPE(self)->tp_name, 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.
This is much better
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.
@eric-wieser , so just a doubt regarding debugging, how do you gdb into that code? currently, I put raise(SIGINT) and do gdb python, then do run code.py that hits that. Is there a better way?
[edit] or any numpy specific tools/best practice to debug
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 haven't had to jump into GDB in a while, so I'm afraid I don't remember my usual trick. Are you asking because this is giving the wrong result?
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 I see, I was just curious about how numpy folks debug in general, some uncommon techniques/tools, etc to simplify stuff than just raw gdb. The results are as expected, thanks
|
This needs a rebase. |
|
Lot of test failures, but the logs have expired. |
|
Summarizing the current status:
|
Changes:
Changed repr of np.bool_
resolves #12950
refers: #5942, #7913
After Fix:
Note:
I expect a lot of UT and Doc failures, will fix as we go along.
cc: @eric-wieser , @seberg