Skip to content

Commit

Permalink
rename the first positional arg in _trapz to match numpy (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
varchasgopalaswamy authored Dec 3, 2023
1 parent 5d533d6 commit b449b72
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pint/facets/numpy/numpy_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,23 +741,23 @@ def _base_unit_if_needed(a):


@implements("trapz", "function")
def _trapz(a, x=None, dx=1.0, **kwargs):
a = _base_unit_if_needed(a)
units = a.units
def _trapz(y, x=None, dx=1.0, **kwargs):
y = _base_unit_if_needed(y)
units = y.units
if x is not None:
if hasattr(x, "units"):
x = _base_unit_if_needed(x)
units *= x.units
x = x._magnitude
ret = np.trapz(a._magnitude, x, **kwargs)
ret = np.trapz(y._magnitude, x, **kwargs)
else:
if hasattr(dx, "units"):
dx = _base_unit_if_needed(dx)
units *= dx.units
dx = dx._magnitude
ret = np.trapz(a._magnitude, dx=dx, **kwargs)
ret = np.trapz(y._magnitude, dx=dx, **kwargs)

return a.units._REGISTRY.Quantity(ret, units)
return y.units._REGISTRY.Quantity(ret, units)


def implement_mul_func(func):
Expand Down

0 comments on commit b449b72

Please sign in to comment.