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
Show file tree
Hide file tree
Changes from all 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
13 changes: 9 additions & 4 deletions geos-ats/src/geos/ats/test_case.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ats # type: ignore[import]
import ats # type: ignore[import]
import os
import shutil
import logging
Expand Down Expand Up @@ -319,7 +319,7 @@ def testCreate( self ):
priority = 1

# Setup a new test group
atsTest = None
parent_test = None
ats.tests.AtsTest.newGroup( priority=priority, path=self.path )
for stepnum, step in enumerate( self.steps ):
np = getattr( step.p, "np", 1 )
Expand All @@ -329,10 +329,10 @@ def testCreate( self ):
label = "%s_%d_%s" % ( self.name, stepnum + 1, step.label() )

# call either 'test' or 'testif'
if atsTest is None:
if parent_test is None:
func = lambda *a, **k: test( *a, **k )
else:
func = lambda *a, **k: testif( atsTest, *a, **k )
func = lambda *a, **k: testif( parent_test, *a, **k )

# Set the time limit
kw = {}
Expand All @@ -359,6 +359,11 @@ def testCreate( self ):
if self.last_status == PASSED:
atsTest.status = SKIPPED

# Set the parent test
# Note: do not make tests dependent on the result of curvecheck
if step.label() != 'curvecheck':
parent_test = atsTest

# End the group
ats.tests.AtsTest.endGroup()

Expand Down
Loading