Skip to content

Refactor Converter class#29

Merged
php1ic merged 12 commits into
mainfrom
refactor
May 3, 2026
Merged

Refactor Converter class#29
php1ic merged 12 commits into
mainfrom
refactor

Conversation

@php1ic
Copy link
Copy Markdown
Owner

@php1ic php1ic commented May 2, 2026

#27

This started as a refactor and splitting of the Converter class into more appropriate entities but there has been some scope creep.

When setting the start and end positions for each parameter in the various data files across the years, we used a large match case statement setting all values each time, unless they were identical between years. We have now changed this and for each file type, created a storage dataclass with either the initial file layout, or the one most common as the default and we override the necessary values on construction for the specific year. We have also changed the naming convention of the start and end variables to match the column names used in the dataframe so we can dynamically create column limits and other required containers.

The user will not see any changes, but there has been a significant reshuffle of files and their contents at the core of the parsing.

php1ic added 10 commits April 30, 2026 15:50
The algorithm is identical between NUBASE and AME so a minor update to
also take the name means we can share it.
A few major changes here:
- Inheritance was not the correct technique to use so stop doing that
  and use the static Converter methods and make the parameter locations
  in the datafile a member so we can still access.
- Instead of a large match case on the year to set the majority of the
  members to the same value most of the time, create a dataclass to
  store the values and tweak as required for each year by creating a new
  instance.
- The use of the dataclass also allows us to set the column names at the
  same time as the parameter start and end line positions and automate
  the creation of other variables. Ideally we would remove all manual
  setting of anything related to columns, but we often do different
  things with different subsets so it's not clear how achieve this.
The utils/ directory was created to allow the separation of
functionality but everything ended up in a single class for ease. Before
the repo grows too large let's split up as planned.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 2, 2026

Codecov Report

❌ Patch coverage is 99.60159% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.55%. Comparing base (3a85975) to head (d495383).

Files with missing lines Patch % Lines
src/nuclearmasses/utils/dataframe_utils.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
- Coverage   99.73%   99.55%   -0.18%     
==========================================
  Files          12       15       +3     
  Lines         749      451     -298     
==========================================
- Hits          747      449     -298     
  Misses          2        2              

☔ View full report in Codecov by Sentry.
📢 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.

@php1ic php1ic merged commit b43e28a into main May 3, 2026
13 checks passed
@php1ic php1ic deleted the refactor branch May 3, 2026 15:08
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.

2 participants