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.

`SkyCoord == str` raises an error, instead of returning `False`

See original GitHub issue

Description

When doing an equality check between a SkyCoord and a str, an error is raised.

Expected behavior

Returns False.

Actual behavior

Raised an error.

Steps to Reproduce

from astropy import units as u
from astropy.coordinates import SkyCoord
c = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')
print(c == 'my_string')
Traceback (most recent call last):
  File "/Users/dstansby/github/sunpy/test.py", line 4, in <module>
    print(c == 'my_string')
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/astropy/coordinates/sky_coordinate.py", line 368, in __eq__
    for attr in self._extra_frameattr_names | value._extra_frameattr_names:
AttributeError: 'str' object has no attribute '_extra_frameattr_names'

System Details

macOS-10.16-x86_64-i386-64bit Python 3.9.1 (default, Dec 11 2020, 06:28:49) [Clang 10.0.0 ] Numpy 1.19.3 astropy 4.2.1 Scipy 1.5.4 Matplotlib 3.4.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dstansbycommented, Apr 29, 2021

👍

0reactions
pllimcommented, Apr 29, 2021

@dstansby , since it is your idea, do you want to open a PR implementing https://github.com/astropy/astropy/issues/11661#issuecomment-829366618? 😸

Read more comments on GitHub >

github_iconTop Results From Across the Web

SkyCoord — Astropy v5.2
Insert coordinate values before the given indices in the object and return a new Frame object. The values to be inserted must conform...
Read more >
Error when creating a SkyCoord object. · Issue #3399
I haven't managed to track down the error explicitly, but the exception I get if I try passing a string (rather than byte)...
Read more >
Source code for astropy.coordinates.sky_coordinate
_sky_coord_frame.has_data: raise ValueError('Cannot create a SkyCoord without data') @property def frame(self): return self._sky_coord_frame @property def ...
Read more >
astropy.coordinates.baseframe — gala v0.1.2
We copy attributes instead of linking to make sure there's no ... return value, False def __get__(self, instance, frame_cls=None): out = None if...
Read more >
galpy.orbit.Orbits — galpy v1.7.2 documentation
coordinates import SkyCoord except ImportError: SkyCoord = None _APY_COORD_LOADED= False if _APY_LOADED: from astropy import units # Separate like this, because ...
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