Skip to content

Commit dcc38dc

Browse files
committed
fixed additional bug where comet designations were being interpreted as packed asteroid desigs
Fixed additional bug where a provisional comet designation with no forward slash and no spaces (e.g., "P2015XN77") was being interpreted as a packed asteroid designation (using only the "P2015" portion of the designation, which is technically unpackable into "252015"), but now raises a TargetNameParseError with the addition of a check to make sure a detected packed designation is not just a portion of a longer input string.
1 parent 2b33b00 commit dcc38dc

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGES.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ sbpy.names
3535
cometary designations with fragment specifiers (e.g., "2024 A-A" and
3636
"2024 A-AA" now correctly raise TargetNameParseError exceptions) [#417]
3737

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

44+
- Fixed `sbpy.Names.parse_asteroid()' to raise an error in cases of a
45+
provisional comet designation submitted with no forward slash between
46+
the lead character and the year, and no space after the year (e.g.,
47+
"P2015XN77"), which was previously being interpreted as a packed
48+
asteroid designation, but now raises a TargetNameParseError [#422]
49+
4450
0.5.0 (2024-08-28)
4551
==================
4652

sbpy/data/names.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def parse_asteroid(s):
588588
ident = el[4]
589589
r['desig'] = Names.from_packed(ident)
590590
# packed number
591-
elif len(el[5]) > 0:
591+
elif len(el[5]) > 0 and len(el[5]) == len(raw):
592592
ident = el[5]
593593
r['number'] = Names.from_packed(ident)
594594
# number

sbpy/data/tests/test_names.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ def test_parse_asteroid():
274274
with pytest.raises(TargetNameParseError):
275275
Names.parse_asteroid('J1')
276276

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

278281
def test_break_packed():
279282
with pytest.raises(TargetNameParseError):

0 commit comments

Comments
 (0)