Quantities from dtype object arrays
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Data type objects (dtype) — NumPy v1.24 Manual
A data type object (an instance of numpy.dtype class) describes how the bytes in the fixed-size block of memory corresponding to an array...
Read more >3. Numpy Data Objects, dtype | Numerical Programming
These numpy arrays contained solely homogenous data types. dtype objects are construed by combinations of fundamental data types.
Read more >Structured array from an array and np.dtype object
The issue here is that for the structured array creation you need a list of tuples. This is mentioned in Structured Datatype Creation, ......
Read more >Data type Object (dtype) in NumPy Python - GeeksforGeeks
Every ndarray has an associated data type (dtype) object. This data type object (dtype) informs us about the layout of the array.
Read more >1.4.1. The NumPy array object - Scipy Lecture Notes
array (object, dtype=None, copy=True, order=None, subok=False, ndmin=0, . ... And then create your own: how about odd numbers counting backwards on the first ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
Decimal
andFraction
.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