Repository navigation
Fix roman_to_int ignoring characters it cannot parse - #3837
Conversation
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.
|
👋 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. |
|
*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 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: Runs: ORCID check · comment publisher |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
The two red jobs ( |
|
@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 |
📝 Description
Type: 🪲
bugfixroman_to_intreturned the sum of the numerals it had read and dropped the rest of the string, so"VX"gave 5 andspecies_string_to_tuple("Si VX")gave Si V(14, 4). It now raisesValueErrorunless the whole string was read, andspecies_string_to_tuplethen raises its existingMalformedSpeciesError. 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_inton 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 fromint_to_roman(1)toint_to_roman(4999)still round-trip.🚦 Testing
How did you test these changes?
pytest tardis/tests/test_util.pyin 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 intardis/visualization/tests/test_plot_util.pyalso pass. Ruff reports nothing on the changed lines.☑️ Checklist
build_docslabel