Skip to content

Conversation

@rburghol
Copy link
Contributor

@rburghol rburghol commented Jan 31, 2026

Ready to merge @PaulDudaRESPEC -- This PR restricts non-dev installs to be < pandas 3.0.0, but adds code that is preliminarily valid for pandas 3.0.0. That is, code the will execute without error under pandas 3.0.0 and and this same code produces identical numerical results to hspf in pandas < 3.0.0. The test coverage that fails when run with pandas-3.0.0 will be covered in #209 (Note: the test error IS related to pandas update, and is what I believe to be both an error in the test code, AND a legit simulation difference that needs to be scoped out -- elaborated on in the issue).
This PR:

  • Adds a close() method to the custom local HDF5 class (yes it is fine to have but no really needed per @austinorr
    • Implements the with statement in run() to insure clean handling in the event of an error in runtime
  • Integrates the changes to utilities.py and main.py from Pandas 3.0, create new HDF5 close() method #216
  • Enhances the changes from a brief comment to trigger git #207 to do all timeseries transformations correctly.
  • Fixes the value comparison problems in python < 3.11
  • Adds a script examples/pretest/cmd_regression.py that creates a brief command prompt friendly tester, as well as leveraging the intermediate products of the RegressTest class for simulation debugging.
  • Updates the class RegressTest in the file tests/convert/regression_base.py to have a silent mode to be a bit more screen friendly (@austinorr this is False by default so no change in previous behavior is made).
  • The model has run successfully under pandas 3.0.0, and I have manually verified the model flow values are identical with hspf. However, this should just be considered a first step in pandas 3.0.0 update, as for the sediment there is an offset of a few days that is troubling see Verify HSP* and Update RegressTest to run under Pandas 3.0.0 #209

THIS IS NOT YET Pandas 3.0 safe. The change to pandas3 are substantial. Most specifically, there have been some things removed from classes, such as the to_timedelta() method of the .delta property of a pandas.timerseries.freq, but most importantly, pandas no longer allows Timedelta to have things like Y, or M me valid intervals, since they are non-ambiguous. Thus, I am not super optimistic about the IF-THEN constructs in the utilities.py transform() function continuing to work since it looks at things like the string value of a frequency to see if they have the characters Y and M. The results look OK with test10, but I think we should consider that with more complicated datasets we could definitely encounter timeseries resampling issues. Or maybe not. We can track that in #209

@austinorr
Copy link
Contributor

This PR has a bunch of good changes in it, but they're not all pandas related. Let's start with #218 and use these changes in this PR as a starting point for fully supporting pandas 3.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

@timcera @PaulDudaRESPEC can we get a couple more sets of eyes on this file? Robert and I talked about this and I left some notes/questions/comments/concerns in #216. I'm not sure why it's in this pandas3 prep PR, maybe Robert can chime in about how it relates to pandas 3 or maybe we should move it to its own PR if it it's important to Robert. Moving this to its own PR could help us all collaborate and understand the need for this file, why it's a good example, and then how to best share/communicate the example to the public in our repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@austinorr @timcera @PaulDudaRESPEC

It's a testing file. I know it is useful for development, and having sample dev code synchronously in git record with the developments that are happening IS actually a best practice IMO.

Especially since we are firmly in the development stage, not release stage, trying to eliminate every file that conflicts with goals of directory tree purity seems onerous and discourages development.

@rburghol
Copy link
Contributor Author

rburghol commented Feb 1, 2026

Disagree on #218 as the path forward. This has useful, easily understandable, non-destructive changes that solve errors, rather than raising a set of minimum versions. It is clean, and ready to commit IMO.

@austinorr @PaulDudaRESPEC @timcera

@austinorr
Copy link
Contributor

For the record, #218 is just a subset of this PR, not an alternate or conflicting approach.

"""

tsfreq = ts.index.freq
freq = Minute(siminfo["delt"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Could all these changes be avoided by calling .to_unit(‘ns’) here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I volunteer to test this alternative so we don’t have to change the primary semantics of our ‘freq’ variable and add a new separate one just to drive resampling.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rburghol what about this idea in #221? It modifies far fewer lines, uses the same pattern in each function, and lets the variable freq be used in both comparisons and in the resample call.

Copy link
Contributor

Choose a reason for hiding this comment

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

tests on that PR currently fail on purpose, since pandas<3.0 is not merged yet.

@PaulDudaRESPEC PaulDudaRESPEC merged commit 858d4a1 into respec:develop Feb 2, 2026
11 checks passed
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.

3 participants