question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quantities from dtype object arrays

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Nov 16, 2022

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 and Fraction.

0reactions
github-actions[bot]commented, Nov 25, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found