Skip to content

Feature templates#19

Open
beykyle wants to merge 176 commits intomainfrom
feature-templates
Open

Feature templates#19
beykyle wants to merge 176 commits intomainfrom
feature-templates

Conversation

@beykyle
Copy link
Contributor

@beykyle beykyle commented Oct 18, 2025

Pending PR tasks

  • Consistent use of type hints based on clear developer guidelines
  • Get bfrescox tests passing. Please document and justify all test design decisions in TestData/README (e.g., adjusting threshold test value)
  • Update bfrescoxpro testing to run the same tests as bfrescox
  • Get all code passing standard adherence check (flake8 / check tox task)
  • Since this is a large PR, some clean-up efforts could be skipped in this PR to keep manageable. Determine what will be skipped and create an Issue for each distinct task and add these as tasks in alpha release Issue

PR Self-review

  • Review all changes
  • Confirm all tox tasks running locally
  • Build source distribution for both and universal wheel for bfrescox and confirm that contents are correct and minimal.
  • Assess if code coverage levels are acceptable and assess test update needs to address insufficiencies
    • Is it acceptable that a test file not have 100% coverage?
  • Confirm all actions passing

@jared321 PR Review

  • Review all changes
  • Confirm all tox tasks running locally and, for bfrescoxpro, on a variety of different machines with modules and different MPI implementations
  • Confirm correct synchronization with main
  • Confirm all actions passing

@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2025

Codecov Report

❌ Patch coverage is 80.07737% with 206 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.34%. Comparing base (2e69dc9) to head (1d7712a).

Files with missing lines Patch % Lines
common/parse_parallelization_setup.py 6.25% 60 Missing ⚠️
common/_run_frescox_simulation.py 58.88% 37 Missing ⚠️
common/parse_performance_results.py 12.82% 34 Missing ⚠️
common/Configuration.py 70.27% 11 Missing ⚠️
common/generate_inelastic_template.py 83.92% 9 Missing ⚠️
...src/bfrescox/tests/TestRunUserProvidedTemplates.py 91.52% 5 Missing ⚠️
.../bfrescoxpro/tests/TestRunUserProvidedTemplates.py 92.64% 5 Missing ⚠️
common/generate_elastic_template.py 82.75% 5 Missing ⚠️
...escox_pypkg/src/bfrescox/tests/TestElasticSuite.py 93.93% 4 Missing ⚠️
...cox_pypkg/src/bfrescox/tests/TestInelasticSuite.py 93.93% 4 Missing ⚠️
... and 13 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #19       +/-   ##
===========================================
+ Coverage   58.75%   79.34%   +20.59%     
===========================================
  Files          17       35       +18     
  Lines         320     1225      +905     
===========================================
+ Hits          188      972      +784     
- Misses        132      253      +121     

☔ 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.

@beykyle beykyle mentioned this pull request Oct 24, 2025
19 tasks
@beykyle
Copy link
Contributor Author

beykyle commented Oct 24, 2025

At this point, tests are passing for user defined templates, including tests which run a simulation and compare cross sections parsed from the output to expected values. See bfrescox_pypkg/src/bfrescox/tests/TestRunUserProvidedTemplates.py.

It should be fairly simple to copy and modify this test file to apply to a new test suite. We need test suites for problems with the template types that can be generated in bfrescox:

  • elastic
  • inelastic

There is an additional remaining task:

  • get GH actions to pass

@beykyle
Copy link
Contributor Author

beykyle commented Oct 24, 2025

Also, we could probably simplify testing with https://docs.python.org/3/library/tempfile.html

Copy link
Contributor Author

@beykyle beykyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review for feature-alpha into main. I will push some updates so that everything correctly references the main branch. The rest of the issues are documented with comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The testing support code can likely be made far more economical by adding a common/test/, which would contain common/TestData, as well as the python code in this utils file, and versions of the harness classes that inherit from unittest.TestCase. Between the two packages, the only differences in them are 1) the import (bfrescox vs bfrescoxpro) and 2) extra work to handle pro configuration from the latter (which is always included in the json testing specs anyways). Moreover, much of the functionality between each of these test harness classes (setup, tear down, parsing and iterating over tests in a json file) is common across the types of tests (elastic, inelastic, user defined).

Therefore, the various versions of these classes between the two packages should be merged into a single TestHarness class, which takes as input into __init__ a module (either bfrescox or bfrescoxpro), and a test_handler lambda which handles the specifics of running an individual test (e.g. generate_inelastic_template vs generate_elastic_template, handling pro settings, etc.).

This will greatly simplify the testing code in each of the package test dirs themselves, removing essentially repeated code and streamlining the process of standing up new kinds of tests across both packages.

Furthermore, a brief description of the test framework should be included in the documentation, so the procedure for standing up a new test point (e.g. adding an entry to TestSuite_Elastic.json for example), and for standing up a new test suite, across both packages, is clear.

Copy link
Contributor

@jared321 jared321 Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what Issue #44 is a placeholder for?

Unifying and simplifying the testing infrastructure would certainly be a welcome idea. Note that for developers it might nice to be able to use such testing tools themselves outside of the package. For instance, they might want to define a minimal test suite that they would like to use for regression testing during their current phase of development.

If this is done, perhaps that same tooling could just be used by the package with fixed, package-specific test suites.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#44 mentions adding info about testing to the documentation. This would look something like this readme. Should we just put this info in the docs and link to it here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Who is the audience for this document? Should the general user be interested in this and have easy access to it? Or is it more for developers?

One way to think about where to put this is where should we put it so that maintainers find it, read it, and update it?

Comment on lines +81 to +92
"STEP_SIZE": f"{step_size_fm:.9f}",
"RMATCH": f"{R_match_fm:.9f}",
"J_TOT_MIN": f"{float(J_tot_min):.1f}",
"J_TOT_MAX": f"{float(J_tot_max):.1f}",
"E_LAB": f"{E_lab_MeV:.9f}",
"MASS_P": f"{projectile_mass_amu:.9f}",
"CHARGE_P": f"{projectile_atomic_number:.9f}",
"MASS_T": f"{target_mass_amu:.9f}",
"CHARGE_T": f"{target_atomic_number:.9f}",
"S_PROJECTILE": f"{float(projectile_spin):.1f}",
"I_GROUND": f"{float(target_spin):.1f}",
"E_GROUND": f"{E_0_MeV:.9f}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output all fp with full precision

Comment on lines +153 to +156
if not _is_fraction_integer_or_half_integer(J_tot_min):
raise ValueError("J_tot_min must be an integer or half-integer.")
if not _is_fraction_integer_or_half_integer(J_tot_max):
raise ValueError("J_tot_max must be an integer or half-integer.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are made redundant by use of _validate_spin

Comment on lines +69 to +72
if not _is_fraction_integer_or_half_integer(J_tot_min):
raise ValueError("J_tot_min must be an integer or half-integer.")
if not _is_fraction_integer_or_half_integer(J_tot_max):
raise ValueError("J_tot_max must be an integer or half-integer.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are made redundant by _validate_spin

beykyle and others added 18 commits March 10, 2026 17:10
Left TODOs in place because we will eventually have to define what events should
lead to officially publishing the book.
Try Python 3.14 and need to use latest action versions to avoid Node.js 20
deprecations.
Include in API docs all functions that are in the public interface even if they
are prototypes.  If prototypes, this needs to be clearly noted.  The f90nml
version limit corresponds to a version from 2021.  We suspect that it is not
needed in practice.
It looks like load_tests and test were shuffled (for alphabetizing?).  See if
putting them in this order fixes issue.
Explicitly handling possibilities that a filename points to a pre-existing
directory.  In some cases, making it clear that if users are providing a working
directory, that directory must be pre-existing.

Prefer using parsing routine so that we simplify code and exercise the parsing
routine in more cases.
Fixing typos and making docs more explicit.
Make changes made in one package to similar files in other package.  Move error
checking to lower-level code.  This simplifies the higher-level code.
Cleaned up docs.  Made parsing more strict and more explicit/defensize.

Tests were still passing after making these changes.  DataFrames produced during
tests had appropriate headers.
Removed an old file that was accidentally readded during my review.
Homogenize file/directory error handling and communication.
The original implementation of this parsing routine allowed for a large amount
of variability in the format/content of the fort.16 file.  However, our test
suite does not yet check any of that flexibility and we don't yet have a clear
use case for it that we could turn into a test case.  Therefore, we make parsing
far more explicit and constrained so that any deviation in the file from the
assumptions implicit in the current test suite should be caught in an obvious
way.

All tests passing locally still.
Copy link
Contributor Author

@beykyle beykyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review only of @jared321's changes to parse_fort16.py I think this is a big improvement. I've added some suggestions to improve inline comments and error messages.

This removes parsing oddities immediately and details their cause.  Assume that
we will always get angle/sigma data and improve self-documentation of returned
results.

Tests passing locally.
@jared321
Copy link
Contributor

I have finished reviewing the main infrastructure, docs, and code. @beykyle Can you please review all of the changes that I have made since your last review?

Let me know when you finish so that I can continue reviewing the test and template code.

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.

4 participants