Skip to content

Conversation

@ssolson
Copy link
Contributor

@ssolson ssolson commented May 20, 2025

This PR removes the ignore all future warnings added when some packages were suggesting updating to numpy 2.0 but mhkit needed other packages to update before that could happen.

@ssolson ssolson self-assigned this May 20, 2025
@akeeste akeeste linked an issue Jul 17, 2025 that may be closed by this pull request
akeeste added 2 commits July 29, 2025 09:54
…tamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC)
@akeeste
Copy link
Contributor

akeeste commented Jul 29, 2025

With regards to DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC)

There are two places we use this: test_cdip and dolfyn.time.epoch2date(). There is a very specific comment in the DOLfYN code to not update this, though in my very brief testing the two methods above return the same result if we use
datetime.fromtimestamp(t, timezone.utc).replace(tzinfo=None) in place of datetime.utcfromtimestamp(t)

akeeste added 5 commits July 29, 2025 13:53
… is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC)
@akeeste akeeste marked this pull request as ready for review August 13, 2025 14:17
@akeeste
Copy link
Contributor

akeeste commented Aug 13, 2025

The tests are largely passing now except for an issue with the runner being overloaded and not working.

The ADCP TRTS notebook was taking longer to run (limit was 20 minutes) so I bumped the limit up to 40 minutes to check the time required and it's back down to 18 now so not sure what was going on there. Either way it's working now and has a similar run time as previously.

Comment on lines -126 to +136
######### IMPORTANT #########
# Note the use of `utcfromtimestamp` here, rather than `fromtimestamp`
# This is CRITICAL! See the difference between those functions here:
# https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp
# Long story short: `fromtimestamp` used system-specific timezone
# info to calculate the datetime object, but returns a
# timezone-agnostic object.
if offset_hr != 0:
delta = timedelta(hours=offset_hr)
time = [datetime.utcfromtimestamp(t) + delta for t in ep_time]
time = [
datetime.fromtimestamp(t, timezone.utc).replace(tzinfo=None) + delta
for t in ep_time
]
else:
time = [datetime.utcfromtimestamp(t) for t in ep_time]
time = [
datetime.fromtimestamp(t, timezone.utc).replace(tzinfo=None)
for t in ep_time
]
Copy link
Contributor

Choose a reason for hiding this comment

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

@jmcvey3 can you review this solution to using datetime.utcfromtimestamp()? I don't know the timeline on deprecation but we'll have to move away from this eventually

Copy link
Contributor

Choose a reason for hiding this comment

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

@akeeste Yeah we discovered a long time ago that using the "fromtimestamp" function returns a different result depending on what timezone your local machine is running in. Using "utcfromtimestamp" was the only way to guarantee that the epoch time in seconds (what those return) is always the same value.

I think your solution here will work

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks @jmcvey3. I saw the same behavior when fromtimestamp is used without a timezone argument. Using it with timezone.utc however gives an identical datetime as utcfromtimestamp but with timezone metadata. I scrub tzinfo from the output to match exactly what utcfromtimestamp returns.

@akeeste
Copy link
Contributor

akeeste commented Aug 13, 2025

Thanks @ssolson. I reviewed your work, and added a couple fixes.

One specific question for @jmcvey3 given the very particular in-line DOLfYN comment and then we can merge this PR

@akeeste akeeste merged commit fb005ce into MHKiT-Software:develop Aug 19, 2025
54 checks passed
akeeste added a commit to akeeste/MHKiT-Python that referenced this pull request Sep 30, 2025
This PR removes the ignore all future warnings added when some packages
were suggesting updating to numpy 2.0 but mhkit needed other packages to
update before that could happen.

---------

Co-authored-by: akeeste <[email protected]>
@akeeste akeeste mentioned this pull request Sep 30, 2025
akeeste added a commit that referenced this pull request Sep 30, 2025
v1.0.0
# MHKiT v1.0.0
## New Features
* Sound Exposure Level by @jmcvey3 in #388
* Add discharge function to MHKiT by @jmcvey3 in #385

## Functionality enhancements
* Fix for corrupted Nortek files by @jmcvey3 in #372
* Update integral length scale function by @jmcvey3 in #376
* Fix ever-changing RDI RiverPro depth bin ranges by @jmcvey3 in #378
* Allow clean functions to handle _avg variables by @jmcvey3 in #377
* IEC TS 62600 updates by @akeeste in #382
* MLER explanation updates/corrections by @rgcoe in #393
* Improve Nortek2 index file creator functions by @jmcvey3 in #397
* Read Sentinel V specific data packets by @jmcvey3 in #396
* Short list of VMDAS updates by @jmcvey3 in #405
* Allow user to specify universal Kolmogorov constant for TKE dissipation rate function by @jmcvey3 in #406
* Nortek Dual Profile Dataset Rotation by @jmcvey3 in #414

## Source code improvements
* Lint Tidal by @ssolson in #386
* Lint river module by @ssolson in #389
* Lint hindcast by @ssolson in #398
* Modernize Package Configuration by @ssolson in #400
* Configure specific warnings by @ssolson in #401

## Bug fixes
* Avoid failing to scan very large files by @jmcvey3 in #371
* Acoustics SPL bugfix by @jmcvey3 in #379
* DOLfYN/RDI: Set  `fs` to NaN when typical calculation methods yield error (#408) by @simmsa in #409

## Testing and Continuous Integration Updates
* Fix Jupyter Notebook tests running Python 3.13 by @ssolson in #380
* CI Test Clean Up: Mock USGS, Acoustic Tolerances by @ssolson in #404
* Speed up tests with concurrency checks to prevent duplicate workflows on PRs from develop into main or from main into develop by @akeeste
* Define MPLBACKEND to decrease intermittent matplotlib errors in tests by @akeeste

## Documentation and Examples
* Add WEC-Sim power performance example  by @akeeste in #395
* Update dolfyn function docstrings and associated notebooks by @jmcvey3 in #412
* Update examples by @akeeste in #417
* Update installation instructions in README.md by @akeeste
* Adjust acoustics test tolerances by @akeeste in #420

**Full Changelog**: v0.9.0...v1.0.0
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.

Ignoring All Future warnings

3 participants