-
-
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
Quantities from dtype object arrays #14014
Comments
This mostly is a numpy weird behaviour, that
Now,
In contrast, for the ragged arrays, the objects are lists and |
Note that I think this is a "bug" only in the sense that perhaps we should not accept any object arrays. The main reason we do is to support arrays of |
Complex thoughts on whether / how we should support object arrays. For now I think we should, for the reasons @mhvk mentioned. numpy has tricky issues with object arrays (e.g. see the very bottom of https://docs.astropy.org/en/latest/api/astropy.cosmology.z_at_value.html), so I think this is mostly their problem. |
Hi humans 👋 - this issue was labeled as Close? approximately 9 hours ago. If you think this issue should not be closed, a maintainer should remove the Close? label - otherwise, I will close this issue in 7 days. If you believe I commented on this issue incorrectly, please report this here |
Hello, Thanks to all, it is indeed the same root cause then... It is quite annoying because I have columns (with units) like this one, and even though it works for visualization purposes, I don't know how to make use of it to extract or manipulate data (bonuns: as quantities). A friend redirected me to the Awkward Array library, which is dedicated to this kind of data (in which there are fields with variable-length arrays) and I plan to look into it. I have no idea how difficult it is, but do you think it would be cool if QTables supported this kind of arrays? |
@HealthyPear - you could create an object Column with
|
p.s. In principle, |
I never used awkward array but looks like they have API to convert back to Numpy, so theoretically, after you scrub things clean over there and gets back a "less awkward" array, you can then build Quantity with it. |
I'm going to close this issue as per my previous message, but if you feel that this issue should stay open, then feel free to re-open and remove the Close? label. If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here |
Description
This might be related to #13836, but I am not sure.
Expected behavior
u.Quantity(np.array([[1,2], [1,2,3], [1, 2]], dtype=object),u.m)
should work and give back
[[1, 2], [1, 2, 3], [1, 2]] m
Similarly, I would expect that
u.Quantity(np.array([[1,2], [], [1, 2]], dtype=object),u.m)
would give
[[1, 2], [], [1, 2]] m
In case all elements are long the same it works already,
u.Quantity(np.array([[1,2], [1,3], [1, 2]], dtype=object),u.m)
gives
[[1, 2], [1, 3], [1, 2]] m
Actual behavior
see above
Steps to Reproduce
See above
System Details
macOS-11.7.1-x86_64-i386-64bit
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:01:00)
[Clang 13.0.1 ]
Numpy 1.23.4
pyerfa 2.0.0.1
astropy 5.1.1
Scipy 1.9.3
Matplotlib 3.6.2
The text was updated successfully, but these errors were encountered: