cds-astro / ipyaladin

An IPython Widget for Aladin Lite, the sky viewer.
https://cds-astro.github.io/ipyaladin/
BSD 3-Clause "New" or "Revised" License
126 stars 26 forks source link

Target regression #94

Closed ManonMarchand closed 3 months ago

ManonMarchand commented 3 months ago
from ipyaladin import Aladin
aladin = Aladin()
aladin
aladin.target = "Galactic Center"
Details

``` ValueError Traceback (most recent call last) File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py:308](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py#line=307), in _AngleParser.parse(self, angle, unit, debug) 307 try: --> 308 found_angle, found_unit = self._thread_local._parser.parse( 309 angle, lexer=self._thread_local._lexer, debug=debug 310 ) 311 except ValueError as e: File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/utils/parsing.py:120](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/utils/parsing.py#line=119), in ThreadSafeParser.parse(self, *args, **kwargs) 119 with self._lock: --> 120 return self.parser.parse(*args, **kwargs) File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/yacc.py:333](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/yacc.py#line=332), in LRParser.parse(self, input, lexer, debug, tracking, tokenfunc) 332 else: --> 333 return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/yacc.py:1063](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/yacc.py#line=1062), in LRParser.parseopt_notrack(self, input, lexer, debug, tracking, tokenfunc) 1062 if not lookaheadstack: -> 1063 lookahead = get_token() # Get the next token 1064 else: File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/lex.py:386](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/extern/ply/lex.py#line=385), in Lexer.token(self) 385 self.lexpos = lexpos --> 386 newtok = self.lexerrorf(tok) 387 if lexpos == self.lexpos: 388 # Error method didn't change text position at all. This is an error. File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py:156](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py#line=155), in _AngleParser._make_parser..t_error(t) 155 def t_error(t): --> 156 raise ValueError(f"Invalid character at col {t.lexpos}") ValueError: Invalid character at col 0 The above exception was the direct cause of the following exception: ValueError Traceback (most recent call last) Cell In[6], line 1 ----> 1 aladin.target = "Galactic Center" File [~/Documents/cds-astro-github/ipyaladin/src/ipyaladin/aladin.py:209](http://localhost:8889/home/manon.marchand/Documents/cds-astro-github/ipyaladin/src/ipyaladin/aladin.py#line=208), in Aladin.target(self, target) 206 @target.setter 207 def target(self, target: Union[str, SkyCoord]) -> None: 208 if isinstance(target, str): # If the target is str, parse it --> 209 target = parse_coordinate_string(target) 210 elif not isinstance(target, SkyCoord): # If the target is not str or SkyCoord 211 raise ValueError( 212 "target must be a string or an astropy.coordinates.SkyCoord object" 213 ) File [~/Documents/cds-astro-github/ipyaladin/src/ipyaladin/coordinate_parser.py:25](http://localhost:8889/home/manon.marchand/Documents/cds-astro-github/ipyaladin/src/ipyaladin/coordinate_parser.py#line=24), in parse_coordinate_string(string) 23 coordinates: Tuple[str, str] = _split_coordinate_string(string) 24 # Parse ra and dec to astropy Angle objects ---> 25 dec: Angle = Angle(coordinates[1], unit="deg") 26 if _is_hour_angle_string(coordinates[0]): 27 ra = Angle(coordinates[0], unit="hour") File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/core.py:164](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/core.py#line=163), in Angle.__new__(cls, angle, unit, dtype, copy, **kwargs) 155 raise TypeError( 156 "Creating an Angle with a tuple of degrees (or hours), minutes, and seconds " 157 "is no longer supported, as it has ambiguous behavior when the degree " (...) 160 "will be interpreted simply as a sequence with the given unit." 161 ) 163 if isinstance(angle, str): --> 164 angle, angle_unit = formats.parse_angle(angle, unit) 165 if angle_unit is None: 166 angle_unit = unit File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py:399](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py#line=398), in parse_angle(angle, unit, debug) 368 def parse_angle(angle, unit=None, debug=False): 369 """ 370 Parses an input string value into an angle value. 371 (...) 397 string. 398 """ --> 399 return _AngleParser().parse(angle, unit, debug=debug) File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py:312](http://localhost:8889/home/manon.marchand/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/astropy/coordinates/angles/formats.py#line=311), in _AngleParser.parse(self, angle, unit, debug) 308 found_angle, found_unit = self._thread_local._parser.parse( 309 angle, lexer=self._thread_local._lexer, debug=debug 310 ) 311 except ValueError as e: --> 312 raise ValueError( 313 f"{str(e) or 'syntax error'} parsing angle {angle!r}" 314 ) from e 316 if unit is None and found_unit is None: 317 raise u.UnitsError("No unit specified") ```

ValueError: Invalid character at col 0 parsing angle 'Center'
ManonMarchand commented 3 months ago

Matches [JGB].* here:

https://github.com/cds-astro/ipyaladin/blob/3a895b1a5ab8079003fa1b7578c0d9154543003b/src/ipyaladin/coordinate_parser.py#L52C17-L52C24