Have coordinate transformations preserve (float?) dtypes
See original GitHub issueThis may be more a part of units
/Quantity
than coordinates
, but the proximate problem is coordinates so I’m starting there… the core problem is this:
>>> import numpy as np
>>> from astropy import units as u
>>> from astropy import coordinates as coo
>>> icrs = coo.ICRS(coo.CartesianRepresentation(np.array([1,2,3], dtype='float32')*u.kpc))
>>> icrs.data.xyz.dtype
dtype('float32')
>>> icrs.transform_to(coo.Galactic).data.xyz.dtype
dtype('float64')
that is, if I start with a dtype that’s float32
the transformation process turns it into float64
. It’s not clear we formally expected it to stay the same, but it would be useful for some applications of the dtype is preserved…
cc @adrn
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Implicit dtype conversion happening when indexing ... - GitHub
Implicit dtype conversion happening when indexing CartesianRepresentation #8614 ... Have coordinate transformations preserve (float?) dtypes #8870.
Read more >Image data types and what they mean — skimage v0.19.2 docs
Note that float images should be restricted to the range -1 to 1 even though the data type itself can exceed this range;...
Read more >How to convert a Numpy 2D array with object dtype to a ...
I am wondering if there is any better way with array conversion tools of numpy ? I tried a few things and could...
Read more >Astronomical Coordinate Systems (astropy.coordinates)
These transformations are all stored in the astropy. coordinates. frame_transform_graph , and new transformations can be created by users.
Read more >fvcore.transforms.transform — detectron2 0.6 documentation
This function should correctly transform coordinates outside the image as well. ... The array should have integer or bool dtype.
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
I agree that for some erfa routines it really should not be difficult - and that particularly includes the transformation routines we need for the representations. I think we’d want to use particular numpy types rather than C types (
npy_double
), etc., but that is really an implementation detail - it will just set us up more easily for when numpy does get a properfloat128
…p.s. Of course, for many other erfa routines, like the time conversion ones, it makes no sense, as those really are written for doubles.
Either, really, but it is a generally true for ufuncs that they allow “same_kind” casting. In principle, we could avoid this by adding
casting='safe'
, though given that we do not have full precision routines, it seems rather pointless.