Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ sbpy.names
cometary designations with fragment specifiers (e.g., "2024 A-A" and
"2024 A-AA" now correctly raise TargetNameParseError exceptions) [#417]

- Fixed `sbpy.Names.parse_comet()' to raise an error in cases of a
provisional asteroid designation submitted with no space after the
year (e.g., "2015XN77"), which was previously being interpreted as a
well-formed comet designation (i.e., with number=2015, type=X, and
name=N77), but now raises a TargetNameParseError [#422]

- Fixed `sbpy.Names.parse_asteroid()' to raise an error in cases of a
provisional comet designation submitted with no forward slash between
the lead character and the year, and no space after the year (e.g.,
"P2015XN77"), which was previously being interpreted as a packed
asteroid designation, but now raises a TargetNameParseError [#422]

0.5.0 (2024-08-28)
==================
Expand Down
5 changes: 4 additions & 1 deletion sbpy/data/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def parse_comet(s):
if len(el[5]) > 0:
if len(el[5]) > 1:
r['name'] = el[5]
if r['name'][1].isdigit():
raise TargetNameParseError('{} does not appear to be a '
' comet identifier'.format(s))

if len(r) == 0 or 'type' not in r:
raise TargetNameParseError(('{} does not appear to be a '
Expand Down Expand Up @@ -585,7 +588,7 @@ def parse_asteroid(s):
ident = el[4]
r['desig'] = Names.from_packed(ident)
# packed number
elif len(el[5]) > 0:
elif len(el[5]) > 0 and len(el[5]) == len(raw):
ident = el[5]
r['number'] = Names.from_packed(ident)
# number
Expand Down
6 changes: 6 additions & 0 deletions sbpy/data/tests/test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ def test_parse_comet():
with pytest.raises(TargetNameParseError):
Names.parse_comet('2024 A')

with pytest.raises(TargetNameParseError):
Names.parse_comet('2015XN77')


def test_parse_asteroid():
"""Test asteroid name parsing."""
Expand Down Expand Up @@ -271,6 +274,9 @@ def test_parse_asteroid():
with pytest.raises(TargetNameParseError):
Names.parse_asteroid('J1')

with pytest.raises(TargetNameParseError):
Names.parse_asteroid('P2015XN77')


def test_break_packed():
with pytest.raises(TargetNameParseError):
Expand Down