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.

Have coordinate transformations preserve (float?) dtypes

See original GitHub issue

This 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:open
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Jun 20, 2019

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 proper float128

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.

0reactions
mhvkcommented, Jun 21, 2019

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.

Read more comments on GitHub >

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

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