def trapz(y, x=None, dx=1.): try: x_units = x.units except AttributeError: if x is None: # If x is not set, infer units from dx try: x_units = dx.units except AttributeError: warn_msg = ('Inputted dx variable to numpy.trapz was not a ' 'Qty object ({}) so units cannot be inferred. ' 'Therefore the result will have the same units as ' 'y.'.format(dx)) warn(warn_msg) x_units = Qty().units else: warn_msg = ('Inputted x variable to numpy.trapz was not a ' 'Qty object ({}) so units cannot be inferred. ' 'Therefore the result will have the same units as ' 'y.'.format(x)) warn(warn_msg) x_units = Qty().units units_out = y_units + x_units return Qty._from_qty(mag=np.trapz(y.mag, **kwargs), units=units_out)
def log10(x, **kwargs): _dimless_warn('numpy.log10', x) return Qty(mag=np.log10(x.mag, **kwargs))
def exp2(x, **kwargs): _dimless_warn('numpy.exp2', x) return Qty(mag=np.exp2(x.mag, **kwargs))
def exp(x, **kwargs): pass _dimless_warn('numpy.exp', x) return Qty(mag=np.exp(x.mag, **kwargs))
def heaviside(x1, x2, **kwargs): try: x2_mag = x2.mag except AttributeError: x2_mag = x2 return Qty(mag=np.heaviside(x1=x1.mag, x2=x2_mag, **kwargs))
def sign(x, **kwargs): return Qty(mag=np.sign(x.mag, **kwargs))
def sinc(x, **kwargs): _dimless_warn('numpy.sinc', x) return Qty(mag=np.sinc(x.mag, **kwargs))
def i0(x, **kwargs): _dimless_warn('numpy.i0', x) return Qty(mag=np.i0(x.mag, **kwargs))
def logaddexp2(x, **kwargs): _dimless_warn('numpy.logaddexp2', x) return Qty(mag=np.logaddexp2(x.mag, **kwargs))