Skip to content

Commit f716f24

Browse files
authored
Merge pull request #422 from NASA-Planetary-Science/421-incorrect-classification-of-namesasteroid_or_comet
fix incorrect asteroid-comet classification bug
2 parents a8415d9 + dcc38dc commit f716f24

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ sbpy.names
4141
cometary designations with fragment specifiers (e.g., "2024 A-A" and
4242
"2024 A-AA" now correctly raise TargetNameParseError exceptions) [#417]
4343

44+
- Fixed `sbpy.Names.parse_comet()' to raise an error in cases of a
45+
provisional asteroid designation submitted with no space after the
46+
year (e.g., "2015XN77"), which was previously being interpreted as a
47+
well-formed comet designation (i.e., with number=2015, type=X, and
48+
name=N77), but now raises a TargetNameParseError [#422]
49+
50+
- Fixed `sbpy.Names.parse_asteroid()' to raise an error in cases of a
51+
provisional comet designation submitted with no forward slash between
52+
the lead character and the year, and no space after the year (e.g.,
53+
"P2015XN77"), which was previously being interpreted as a packed
54+
asteroid designation, but now raises a TargetNameParseError [#422]
4455

4556
0.5.0 (2024-08-28)
4657
==================

sbpy/data/names.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ def parse_comet(s):
436436
if len(el[5]) > 0:
437437
if len(el[5]) > 1:
438438
r['name'] = el[5]
439+
if r['name'][1].isdigit():
440+
raise TargetNameParseError('{} does not appear to be a '
441+
' comet identifier'.format(s))
439442

440443
if len(r) == 0 or 'type' not in r:
441444
raise TargetNameParseError(('{} does not appear to be a '
@@ -585,7 +588,7 @@ def parse_asteroid(s):
585588
ident = el[4]
586589
r['desig'] = Names.from_packed(ident)
587590
# packed number
588-
elif len(el[5]) > 0:
591+
elif len(el[5]) > 0 and len(el[5]) == len(raw):
589592
ident = el[5]
590593
r['number'] = Names.from_packed(ident)
591594
# number

sbpy/data/tests/test_names.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ def test_parse_comet():
244244
with pytest.raises(TargetNameParseError):
245245
Names.parse_comet('2024 A')
246246

247+
with pytest.raises(TargetNameParseError):
248+
Names.parse_comet('2015XN77')
249+
247250

248251
def test_parse_asteroid():
249252
"""Test asteroid name parsing."""
@@ -271,6 +274,9 @@ def test_parse_asteroid():
271274
with pytest.raises(TargetNameParseError):
272275
Names.parse_asteroid('J1')
273276

277+
with pytest.raises(TargetNameParseError):
278+
Names.parse_asteroid('P2015XN77')
279+
274280

275281
def test_break_packed():
276282
with pytest.raises(TargetNameParseError):

0 commit comments

Comments
 (0)