Skip to content

Fix roman_to_int ignoring characters it cannot parse - #3837

Merged
connor-mcclellan merged 2 commits into
tardis-sn:masterfrom
G26karthik:fix-roman-to-int-leftover
Nov 24, 2026
Merged

connor-mcclellan merged 2 commits into
tardis-sn:masterfrom
G26karthik:fix-roman-to-int-leftover

Conversation

@G26karthik

Copy link
Copy Markdown
Contributor

📝 Description

Type: 🪲 bugfix

roman_to_int returned the sum of the numerals it had read and dropped the rest of the string, so "VX" gave 5 and species_string_to_tuple("Si VX") gave Si V (14, 4). It now raises ValueError unless the whole string was read, and species_string_to_tuple then raises its existing MalformedSpeciesError. Valid numerals give the same values as before.

I added type hints to the touched function and my entry to .mailmap.

Fixes #3830

📌 Resources

I compared the old and new roman_to_int on 30,865 strings (every 1 to 5 letter combination of IVXLCDM, the numerals for 1 to 4999, lower case forms and random strings). The only differences are strings with unread characters, which now raise. All numerals from int_to_roman(1) to int_to_roman(4999) still round-trip.

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

pytest tardis/tests/test_util.py in a pip venv with the lockfile versions of numpy, pandas and astropy, without the repo conftest: the new cases fail on master (6 failed, DID NOT RAISE) and pass with the fix (56 passed). The species tests in tardis/visualization/tests/test_plot_util.py also pass. Ruff reports nothing on the changed lines.

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

roman_to_int returned the value of the numerals it had read so far and
ignored the rest of the string, so "VX" gave 5 and "IXX" gave 9. Through
species_string_to_tuple, "Si VX" became Si V instead of raising
MalformedSpeciesError. Check that the whole string was consumed.

Also add my entry to .mailmap.
andrewfullard
andrewfullard previously approved these changes Nov 11, 2026
@tardis-bot

Copy link
Copy Markdown
Contributor

👋 Welcome @G26karthik! Thank you for your first contribution to this repository!

A reviewer will take a look at your pull request soon.

Please mark the pull request as draft if you are not ready for review yet or if there are things you will be adding.

@tardis-bot

Copy link
Copy Markdown
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and I noticed that your email is not associated with an ORCID ID in our database.

Please add your email and ORCID ID to the .orcid.csv file in your current branch and push the changes to this pull request.

If you don't have an ORCID ID yet, you can create one for free at orcid.org. ORCID IDs help ensure you get proper credit for your scientific contributions.

The format should be:

email,orcid
your.email@example.com,0000-0000-0000-0000

Runs: ORCID check · comment publisher

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.35%. Comparing base (f98eeca) to head (19cd66d).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3837      +/-   ##
==========================================
+ Coverage   70.94%   71.35%   +0.40%     
==========================================
  Files         207      207              
  Lines       15940    15983      +43     
==========================================
+ Hits        11309    11404      +95     
+ Misses       4631     4579      -52     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@G26karthik

Copy link
Copy Markdown
Contributor Author

The two red jobs (build and tests ubuntu-latest) failed only at the artifact upload step, where GitHub returned an error page for CreateArtifact; the test steps in both passed. A re-run should clear them. I also added my ORCID to .orcid.csv as the bot asked.

@G26karthik

Copy link
Copy Markdown
Contributor Author

@andrewfullard your approval was dismissed when I pushed the ORCID commit the bot asked for (19cd66d); the code is the same as in a20acac. The one red job, benchmarks build, failed only at its artifact upload step. Would you have a moment to approve it again?

@connor-mcclellan
connor-mcclellan merged commit d788996 into tardis-sn:master Nov 24, 2026
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roman_to_int ignores characters it cannot parse ("VX" returns 5)

4 participants