-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Column.pprint
fails for scalars
#12584
Comments
@mhvk, I suspect many issues similar to this one exist across Astropy. |
I think this may not be related to
|
Yep table.Column([m_nu]).pprint(show_dtype=True)
None
void192
-------------
(0., 0., 0.6) |
Column.pprint
can't display dtype for numpy.void
Column.pprint
fails for scalars
pprint method for the "Column" class is originally designed for handling monotonous units. Therefore, the issue can be resolved by declaring a new Quantity with single-string unit. Output:
|
@datajungler, m_nu = u.Quantity(0.6, unit="eV")
Column(m_nu).pprint(show_dtype=True) |
I edited the original description to show the real problem, since the use of a structured Quantity is just a misdirection that is confusing since it appears somewhat array-like at first glance. At some level I feel like So what should |
While I agree on the principle, pragmatically I think the most important thing is consistency with
I think array scalars should be special cased. Unfortunate, but probably necessary. |
I've opened #15749 to attempt to fix this. I went with what felt like the most natural approach (also suggested by @nstarman) to special-case scalar columns. The patch is really small at the moment but it's not completely functional as it breaks at least one existing test. Feedback and suggestions are most welcome ! |
@neutrinoceros - I'm less sure we even want to print scalar column that way, since also the regular
I do think |
hi! would you like to share the testing with us? like how you wrote it & what the results were. TYIA! |
I'm still on the fence about this. I think of |
However, I've confirmed that not allowing |
sup. just saw the notif for this thread. are we still good on this? |
Description
Raises TypeError because object is scalar and the code expects an array object.
Expected behavior
If it can be made into a Column,
pprint
works.Actual behavior
See Description.
Steps to Reproduce
TypeError: len() of unsized object
System Details
macOS-10.16-x86_64-i386-64bit
Python 3.9.5 (default, May 18 2021, 12:31:01)
[Clang 10.0.0 ]
Numpy 1.21.4
pyerfa 2.0.0.1
astropy 5.1.dev207+gbfb9252df.d20211130
Scipy 1.7.1
Matplotlib 3.3.4
The text was updated successfully, but these errors were encountered: