Astropy units do not convert correctly with `np.array`
See original GitHub issueCompare:
>>> import astropy.units as u
>>> import numpy as np
>>> a = 3600 * u.s
>>> b = 1 * u.h
>>> ratio = a / b
>>> float(ratio)
1.0
>>> np.array(ratio)
array(3600.0)
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Units and Quantities (astropy.units) — Astropy v5.2
The most convenient way to create a Quantity is to multiply or divide a value by one of the built-in units. It works...
Read more >Quantity — Astropy v5.2
Quantity objects are converted to float by default. Furthermore, any data passed in are copied, which for large arrays may not be optimal....
Read more >Source code for astropy.units.quantity
It allows iterating over the array as if it were a 1-D array, ... return unit # Quantity does not (yet) properly extend...
Read more >Known Issues — Astropy v5.2
Known Deficiencies. Quantities Lose Their Units with Some Operations. Numpy array creation functions cannot be used to initialize Quantity. Quantities Lose ...
Read more >Source code for astropy.units.core
but because these are mutable types we don't want to create # conflicts so ... are used if no explicit equivalencies are given,...
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 Free
Top 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
p.s. And maybe with a note in the docs saying that this is not supported?
This works as expected though: