Closed aphearin closed 8 months ago
All modified lines are covered by tests :white_check_mark:
Comparison is base (
85a1832
) 61.26% compared to head (f7da55a
) 61.48%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR resolves a deprecation warning in pecZ.py by replacing the use of
numpy.core.umath_tests.inner1d
with a vectorized call tojnp.dot
.Previously, the
pecZ
function computed the peculiar velocityv_pec
like this:v_pec = numpy.core.umath_tests.inner1d(v, r_rel_hat)
The above line of code computes the elementwise dot product between
v
andr_rel_hat
. Presumably,inner1d
was used becausenp.dot
only computes the dot product between a single pair of vectors, rather than an array of vectors. But importing fromnumpy.core.umath_tests
triggers a deprecation warning notifying us that this will break in future. The previous implementation addressed this warning by ignoring it:warnings.filterwarnings("ignore", category=DeprecationWarning)
This PR instead resolves this deprecation warning by computing the elementwise peculiar velocity by using JAX to vectorize
jnp.dot
as follows:This change was not straightforward to implement because
pecZ.py
had no testing. But there is now a newtest_pecZ.py
module that implements a basic unit test ensuring that at least the pecZ function returns finite-valued arrays of the expected shape.CC @evevkovacs