How to use the quantities.uncertainquantity.UncertainQuantity function in quantities

To help you get started, we’ve selected a few quantities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __sub__(self, other):
        res = super(UncertainQuantity, self).__sub__(other)
        u = (self.uncertainty**2+other.uncertainty**2)**0.5
        return UncertainQuantity(res, uncertainty=u, copy=False)
github python-quantities / python-quantities / quantities / constants / _utils.py View on Github external
def _cd(name):
    entry = physical_constants[name]
    if False: #entry['precision']:
        return UncertainQuantity(
            entry['value'], entry['units'], entry['precision']
        )
    else:
        return Quantity(entry['value'], entry['units'])
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __truediv__(self, other):
        res = super(UncertainQuantity, self).__truediv__(other)
        try:
            sru = self.relative_uncertainty
            oru = other.relative_uncertainty
            ru = (sru**2+oru**2)**0.5
            u = res.view(Quantity) * ru
        except AttributeError:
            other = np.array(other, copy=False, subok=True)
            u = (self.uncertainty**2/other**2)**0.5

        res._uncertainty = u
        return res
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __rsub__(self, other):
        if not isinstance(other, UncertainQuantity):
            other = UncertainQuantity(other, copy=False)

        return UncertainQuantity.__sub__(other, self)
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def rescale(self, units):
        cls = UncertainQuantity
        ret = super(cls, self).rescale(units).view(cls)
        ret.uncertainty = self.uncertainty.rescale(units)
        return ret
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def _reference(self):
        ret = super(UncertainQuantity, self)._reference.view(UncertainQuantity)
        ret.uncertainty = self.uncertainty._reference
        return ret
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __rsub__(self, other):
        if not isinstance(other, UncertainQuantity):
            other = UncertainQuantity(other, copy=False)

        return UncertainQuantity.__sub__(other, self)
github python-quantities / python-quantities / quantities / constants / astronomy.py View on Github external
# -*- coding: utf-8 -*-
"""
"""
from __future__ import absolute_import

from ._utils import _cd
from ..uncertainquantity import UncertainQuantity
from ..unitquantity import UnitConstant


au = astronomical_unit = UnitConstant(
    'astronomical_unit',
    UncertainQuantity(149597870700, 'm', 3),
    symbol='au',
    doc='http://en.wikipedia.org/wiki/Astronomical_unit'
)
G = Newtonian_constant_of_gravitation = UnitConstant(
    'Newtonian_constant_of_gravitation',
    _cd('Newtonian constant of gravitation'),
    symbol='G'
)

del UnitConstant, UncertainQuantity, _cd
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __add__(self, other):
        res = super(UncertainQuantity, self).__add__(other)
        u = (self.uncertainty**2+other.uncertainty**2)**0.5
        return UncertainQuantity(res, uncertainty=u, copy=False)
github python-quantities / python-quantities / quantities / uncertainquantity.py View on Github external
def __rsub__(self, other):
        if not isinstance(other, UncertainQuantity):
            other = UncertainQuantity(other, copy=False)

        return UncertainQuantity.__sub__(other, self)