Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update numpy deprecation of product and test dependency issues #38

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions geos-ats/src/geos/ats/helpers/curve_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ def interpolate_values_time( ta, xa, tb ):
"""
N = list( np.shape( xa ) )
M = len( tb )
ta = np.ascontiguousarray( np.squeeze( ta ) )
tb = np.ascontiguousarray( np.squeeze( tb ) )
Comment on lines +36 to +37
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that the issue we ran into was due to these time vectors changing shape from (N,) to (N, 1) was the issue that triggered the interpolation issue.


if ( len( N ) == 1 ):
return interp1d( ta, xa )( tb )
else:
# Reshape the input array so that we can work on the non-time axes
S = np.product( N[ 1: ] )
S = np.prod( N[ 1: ] )
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fixes the numpy.product deprecation

xc = np.reshape( xa, ( N[ 0 ], S ) )
xd = np.zeros( ( len( tb ), S ) )
for ii in range( S ):
xd[ :, ii ] = interp1d( ta, xc[ :, ii ] )( tb )
xd[ :, ii ] = interp1d( ta, xc[ :, ii ], bounds_error=False, fill_value='extrapolate' )( tb )
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's often not great, but I'm allowing the interpolator to extrapolate the comparison here (there will always be an error in this case due to changes in the time vector though... this is purely to check how much the curves changed if they were on the same time basis)


# Return the array to it's expected shape
N[ 0 ] = M
Expand Down
Loading