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.

Astropy units do not convert correctly with `np.array`

See original GitHub issue

Compare:

>>> 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:closed
  • Created 6 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
pllimcommented, May 9, 2017

p.s. And maybe with a note in the docs saying that this is not supported?

1reaction
pmplewacommented, May 10, 2017

This works as expected though:

>>> np.array([ratio])
array([ 1.])
Read more comments on GitHub >

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

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