Skip to content

Commit

Permalink
Fixes an important bug where recursion in np.gradient() dropped an ar…
Browse files Browse the repository at this point in the history
…gument
  • Loading branch information
peterdsharpe committed Mar 30, 2024
1 parent 6150789 commit 0f040d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aerosandbox/numpy/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from aerosandbox.numpy.determine_type import is_casadi_type
from aerosandbox.numpy.arithmetic_dyadic import centered_mod as _centered_mod
from aerosandbox.numpy.array import array, concatenate, reshape
from typing import Tuple


def diff(a, n=1, axis=-1, period=None):
Expand Down Expand Up @@ -134,7 +135,9 @@ def gradient(
f,
varargs[axis_i],
axis=axis_i,
edge_order=edge_order
edge_order=edge_order,
n=n,
period=period,
)
for axis_i in axis
]
Expand All @@ -152,7 +155,7 @@ def gradient(
dx_shape[axis] = shape[axis] - 1
dx = reshape(dx, dx_shape)

def get_slice(slice_obj: slice):
def get_slice(slice_obj: slice) -> Tuple[slice]:
slices = [slice(None)] * len(shape)
slices[axis] = slice_obj
return tuple(slices)
Expand Down

0 comments on commit 0f040d8

Please sign in to comment.