Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@with_doc(np.cosh)
def cosh(x, out=None):
"""
Raises a ValueError if input cannot be rescaled to a dimensionless
quantity.
"""
if not isinstance(x, Quantity):
return np.cosh(x, out)
return Quantity(
np.cosh(x.rescale(dimensionless).magnitude, out),
dimensionless,
copy=False
)
@with_doc(np.nanargmax)
def nanargmax(self,axis=None, out=None):
return np.nanargmax(self.magnitude)
@with_doc(np.ndarray.__lt__)
@wrap_comparison
def __lt__(self, other):
return self.magnitude < other
@with_doc(np.cumsum)
def cumsum(a,axis=None, dtype=None, out=None):
return a.cumsum(axis, dtype, out)
@with_doc(Quantity.__truediv__, use_header=False)
def __truediv__(self, other):
return self.view(Quantity).__truediv__(other)
@with_doc(Quantity.__rtruediv__, use_header=False)
def __rtruediv__(self, other):
temp = UncertainQuantity(
1/self.magnitude, self.dimensionality**-1,
self.relative_uncertainty/self.magnitude, copy=False
)
return other * temp
@with_doc(np.ndarray.min)
def min(self, axis=None, out=None):
idx = np.unravel_index(np.argmin(self.magnitude), self.shape)
return self[idx]
@with_doc(np.ndarray.__ge__)
@wrap_comparison
def __ge__(self, other):
return self.magnitude >= other
@with_doc(np.nansum)
def nansum(self, axis=None, dtype=None, out=None):
import numpy as np
return Quantity(
np.nansum(self.magnitude, axis, dtype, out),
self.dimensionality,
copy=False
)
@with_doc(np.sinh)
def sinh(x, out=None):
"""
Raises a ValueError if input cannot be rescaled to a dimensionless
quantity.
"""
if not isinstance(x, Quantity):
return np.sinh(x, out)
return Quantity(
np.sinh(x.rescale(dimensionless).magnitude, out),
dimensionless,
copy=False
)