Skip to content

type: add type annotations to 1D solvers#75

Open
formeo wants to merge 1 commit intodjsilva99:developfrom
formeo:type-1d-solvers
Open

type: add type annotations to 1D solvers#75
formeo wants to merge 1 commit intodjsilva99:developfrom
formeo:type-1d-solvers

Conversation

@formeo
Copy link
Copy Markdown

@formeo formeo commented Apr 2, 2026

Related to #45

What changed

All 5 files in dimension_1/solvers/ now have full type annotations:

  • Function signatures: parameter types + return types
  • Local variables: annotated where non-obvious
  • NumPy docstrings: updated with types in Parameters/Returns sections
  • TYPE_CHECKING guard used for Object import (avoids circular import)

Runtime type checks added to all public functions:

  • apply_latent_heat() raises TypeError if nx is not a list
    or obj lacks required thermal attributes
  • All 4 solver functions raise TypeError if obj is not a thermal
    Object (checked via hasattr(obj, 'num_points'))

New test file: test/unit/dimansion_1/test_solvers_1d.py

  • 14 tests covering TypeError for all solvers + apply_latent_heat
  • Parametrized across all 4 solvers (string, None, int inputs)

What didn't change

  • Solver logic, FDM stencils, latent heat computation
  • Function signatures (no new parameters)
  • Existing test results

Testing

All 40 tests pass (26 existing + 14 new).
Solver coverage: 97% (explicit/implicit), 68% (_latent_heat).

- Annotate all functions in dimension_1/solvers/ with param + return types
- Add TypeError checks for invalid obj/nx arguments
- Use TYPE_CHECKING guard to avoid circular Object import
- Add 14 unit tests for type validation

Related to djsilva99#45
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 95.18072% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.06%. Comparing base (71522f1) to head (4c585e2).

Files with missing lines Patch % Lines
heatrapy/dimension_1/solvers/_latent_heat.py 69.23% 4 Missing ⚠️
@@             Coverage Diff             @@
##           develop      #75      +/-   ##
===========================================
+ Coverage    72.79%   73.06%   +0.26%     
===========================================
  Files           22       22              
  Lines         2272     2294      +22     
===========================================
+ Hits          1654     1676      +22     
  Misses         618      618              
Files with missing lines Coverage Δ
heatrapy/dimension_1/solvers/explicit_general.py 96.55% <100.00%> (+0.55%) ⬆️
heatrapy/dimension_1/solvers/explicit_k.py 96.55% <100.00%> (+0.55%) ⬆️
heatrapy/dimension_1/solvers/implicit_general.py 96.66% <100.00%> (+0.51%) ⬆️
heatrapy/dimension_1/solvers/implicit_k.py 96.55% <100.00%> (+0.55%) ⬆️
heatrapy/dimension_1/solvers/_latent_heat.py 67.74% <69.23%> (+7.74%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@formeo formeo mentioned this pull request Apr 2, 2026
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.

1 participant