示例#1
0
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)
示例#2
0
def log10(x, **kwargs):
    _dimless_warn('numpy.log10', x)
    return Qty(mag=np.log10(x.mag, **kwargs))
示例#3
0
def exp2(x, **kwargs):
    _dimless_warn('numpy.exp2', x)
    return Qty(mag=np.exp2(x.mag, **kwargs))
示例#4
0
def exp(x, **kwargs):
    pass
    _dimless_warn('numpy.exp', x)
    return Qty(mag=np.exp(x.mag, **kwargs))
示例#5
0
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))
示例#6
0
def sign(x, **kwargs):
    return Qty(mag=np.sign(x.mag, **kwargs))
示例#7
0
def sinc(x, **kwargs):
    _dimless_warn('numpy.sinc', x)
    return Qty(mag=np.sinc(x.mag, **kwargs))
示例#8
0
def i0(x, **kwargs):
    _dimless_warn('numpy.i0', x)
    return Qty(mag=np.i0(x.mag, **kwargs))
示例#9
0
def logaddexp2(x, **kwargs):
    _dimless_warn('numpy.logaddexp2', x)
    return Qty(mag=np.logaddexp2(x.mag, **kwargs))