Skip to content

Harden numeric input type handling across geometry/problem setup and add mixed-type coverage tests - #100

Open
rebeccamccabe with Copilot wants to merge 1 commit into
mainfrom
copilot/create-tests-for-input-validation
Open

Harden numeric input type handling across geometry/problem setup and add mixed-type coverage tests#100
rebeccamccabe with Copilot wants to merge 1 commit into
mainfrom
copilot/create-tests-for-input-validation

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Intermittent failures were traced to inconsistent handling of numeric input types (Python floats/lists vs NumPy scalar/ndarray) in core setup paths. This change standardizes those inputs and adds focused tests to ensure equivalent behavior across scalar, vector, and mixed-type call patterns.

  • Input normalization in core constructors/setters

    • SteppedBody.__init__ now normalizes a, d, and slant_angle via NumPy (np.asarray + np.atleast_1d) before length checks.
    • MEEMProblem.set_frequencies now accepts float, scalar ndarray, list, or ndarray and stores frequencies as a 1D NumPy array.
    • BasicRegionGeometry.from_vectors now normalizes a, d, and optional slant_angle to NumPy arrays and validates shape/length consistency early.
  • Type-compatibility regression coverage (minimal repetition)

    • Added package/test/test_input_type_compatibility.py with parametrized tests covering:
      • SteppedBody, ConcentricBodyGroup, BasicRegionGeometry, MEEMProblem, MEEMEngine
      • multi_equations methods for:
        • float vs scalar ndarray (scalar inputs)
        • list vs ndarray (vector inputs)
        • mixed list/ndarray inputs
    • Tests compare numerical equivalence across representations rather than duplicating per-type logic.
  • Failure modes addressed

    • Scalar SteppedBody construction no longer fails on len(float).
    • from_vectors no longer fails on list inputs with mapped indexing.
    • set_frequencies no longer rejects/incorrectly processes non-ndarray scalar/list inputs.
# Before: type-dependent failures in setup paths
geom = BasicRegionGeometry.from_vectors(
    a=[1.0, 2.0],               # list
    d=np.array([0.5, 0.8]),     # ndarray
    h=np.array(10.0),           # scalar ndarray
    NMK=[3, 3, 3],
    body_map=[0, 1],
    heaving_map=[True, False],
)

problem = MEEMProblem(geom)
problem.set_frequencies(np.array(0.7))  # scalar ndarray accepted

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.42105%. Comparing base (0a1a4f0) to head (9b13a16).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
package/src/openflash/basic_region_geometry.py 71.42857% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##                main        #100         +/-   ##
===================================================
- Coverage   98.56061%   98.42105%   -0.13956%     
===================================================
  Files             11          11                 
  Lines           1320        1330         +10     
===================================================
+ Hits            1301        1309          +8     
- Misses            19          21          +2     
Flag Coverage Δ
unit 98.42105% <81.81818%> (-0.13956%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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