Skip to content

Commit

Permalink
identify invalid comet designation with fragment (#417)
Browse files Browse the repository at this point in the history
Added code to check to see if comet designation without a fragment is a valid designation or not (e.g., not passing 2024 A-A when 2024 A is not a valid designation).  Basically just checks to see if the remaining designation without the fragment suffix has enough characters to be turned into a normal packed designation.
  • Loading branch information
hhsieh00 authored Nov 12, 2024
1 parent bcc18c5 commit 5a3f9be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ sbpy.activity.gas
- Replaced calls to the deprecated function `scipy.integrate.romberg` with
`scipy.integrate.quad`. [#412]

sbpy.names
^^^^^^^^^^
- Fixed `sbpy.Names.to_packed()' to raise an error in cases of invalid
cometary designations with fragment specifiers (e.g., "2024 A-A" and
"2024 A-AA" now correctly raise TargetNameParseError exceptions) [#417]


0.5.0 (2024-08-28)
==================
Expand Down
7 changes: 6 additions & 1 deletion sbpy/data/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ def to_packed(s):
):
if s[-2] == '-':
frag = s[-1]
num = s[6:-2]
if len(s[:-2]) > 6:
num = s[6:-2]
else:
raise TargetNameParseError(
('{} cannot be turned into a '
'packed designation').format(s))
else:
frag = '0'
num = s[6:]
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 @@ -238,6 +238,12 @@ def test_parse_comet():
with pytest.raises(TargetNameParseError):
Names.parse_comet('2001 a2')

with pytest.raises(TargetNameParseError):
Names.parse_comet('2024 A-A')

with pytest.raises(TargetNameParseError):
Names.parse_comet('2024 A')


def test_parse_asteroid():
"""Test asteroid name parsing."""
Expand Down

0 comments on commit 5a3f9be

Please sign in to comment.