Skip to content

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Jun 11, 2025

  • use dataclass
  • add type hints and update some docstrings
  • coerce input arrays to the expected dtype with astype
  • fix an issue where the default tsmult value was int, not float
  • support passing scalars to the initializer for a single stress period
  • implement eq. we can't use the one from dataclass, lists play nice with == but not numpy arrays, and dataclasses.field doesn't let you override the comparator. but attrs does and we could make ModelTime an attrs class when we bring that dependency in, as planned for 4.x.

A caveat. This sacrifices the ability to parse from string when setting time_units and start_datetime after initialization. dataclasses.field doesn't support converters as attrs.field does. Do we expect people to mutate ModelTime? It's easy enough to create a new one — it could even be a frozen dataclass. If we want it to stay mutable, I will just close this for now and reconsider when attrs is available. Or we could just bring in attrs now. It is dependency free.

@codecov
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 8 lines in your changes missing coverage. Please review.

Project coverage is 55.9%. Comparing base (556c088) to head (d3ea500).
Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/discretization/modeltime.py 90.9% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #2528     +/-   ##
==========================================
+ Coverage     55.5%    55.9%   +0.4%     
==========================================
  Files          644      640      -4     
  Lines       124135   123778    -357     
==========================================
+ Hits         68947    69255    +308     
+ Misses       55188    54523    -665     
Files with missing lines Coverage Δ
flopy/discretization/modeltime.py 78.1% <90.9%> (+1.2%) ⬆️

... and 71 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpbonelli wpbonelli marked this pull request as ready for review June 11, 2025 19:34
@wpbonelli wpbonelli requested a review from jlarsen-usgs June 11, 2025 19:37
@wpbonelli
Copy link
Member Author

this now preserves unit and start time mutability while still using dataclass — no behavior change just refactor

@wpbonelli wpbonelli merged commit 08fac5a into modflowpy:develop Jul 14, 2025
20 checks passed
@wpbonelli wpbonelli deleted the modeltime branch July 14, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant