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

Rename the first positional arg in _trapz to match numpy #1796

Merged
merged 3 commits into from
Dec 3, 2023
Merged
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
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
Loading