Constructing a SphericalRepresentation object with a negative distance is impossible
See original GitHub issueThe explicit kwarg in the error dosen’t seem to work.
In [2]: from astropy.coordinates import Distance, SphericalRepresentation; import astropy.units as u
In [3]: SphericalRepresentation(10*u.deg, 10*u.deg, Distance(-100*u.m, allow_negative=True))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/Git/astropy/astropy/coordinates/representation.py in __init__(self, lon, lat, distance, differentials, copy)
1569 try:
-> 1570 self._distance = Distance(self._distance, copy=False)
1571 except ValueError as e:
~/Git/astropy/astropy/coordinates/distances.py in __new__(cls, value, unit, z, cosmology, distmod, parallax, dtype, copy, order, subok, ndmin, allow_negative)
183 if not allow_negative and np.any(distance.value < 0):
--> 184 raise ValueError("Distance must be >= 0. Use the argument "
185 "'allow_negative=True' to allow negative values.")
ValueError: Distance must be >= 0. Use the argument 'allow_negative=True' to allow negative values.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-3-bc5d4ae3542b> in <module>
----> 1 SphericalRepresentation(10*u.deg, 10*u.deg, Distance(-100*u.m, allow_negative=True))
~/Git/astropy/astropy/coordinates/representation.py in __init__(self, lon, lat, distance, differentials, copy)
1571 except ValueError as e:
1572 if e.args[0].startswith('Distance must be >= 0'):
-> 1573 raise ValueError("Distance must be >= 0. To allow negative "
1574 "distance values, you must explicitly pass"
1575 " in a `Distance` object with the the "
ValueError: Distance must be >= 0. To allow negative distance values, you must explicitly pass in a `Distance` object with the the argument 'allow_negative=True'.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Merging multiple views using a spherical representation
To obtain the spherical representation, we ... building object models from observation. ... spherical surface such that the distance between vertices is.
Read more >astropy.coordinates.baseframe — gala v1.3
If an item is set to `None`, it will be guessed from the base class. ... SphericalRepresentation) and 'distance' not in repr_kwargs): representation_cls ......
Read more >Source code for astropy.coordinates.baseframe
SphericalRepresentation ) and "distance" not in repr_kwargs ... proceeds in a difficult-to-predict manner in the # case that one of the class objects...
Read more >Spherical and Hyperbolic Embeddings of Data
positive and negative components which sum together to give the total distance. A pseudo-Euclidean space is however non- metric, which makes it difficult...
Read more >Lines of Curvature as Pseudospherical Surfaces. - JSTOR
spherical surfaces-have been the object of study of the geometers since the days ... 114 EISENHART: Surfaces with the Same Spherical Representation.
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
This was fixed in #11113:
p.s. Though frankly I’d prefer it if we moved this use of distance out of the representation class altogether, and instead did it inside frames.