diff --git a/.DS_Store b/.DS_Store index 6bb4f15..4a15d2a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 6550998..edfc02e 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,10 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or download the tutorial as Jupyter notebook) * [the documentation](https://nrc-cnrc.github.io/MetroloPy/) * [the issues page on GitHub](https://github.com/nrc-cnrc/Metrolopy/issues) +* [a list of the units built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/units.html) +* [a list of the physical constants built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/constants.html) -## New in version 0.6.0 +## new in version 0.6.0 * A constant library has been added with physical constants that can be accessed by name or alias with the `constant` function. The `search_constants` function diff --git a/dist/metrolopy-0.5.7-py3-none-any.whl b/dist/metrolopy-0.5.7-py3-none-any.whl deleted file mode 100644 index c2d704b..0000000 Binary files a/dist/metrolopy-0.5.7-py3-none-any.whl and /dev/null differ diff --git a/dist/metrolopy-0.5.7.tar.gz b/dist/metrolopy-0.5.7.tar.gz deleted file mode 100644 index 3bd5a4f..0000000 Binary files a/dist/metrolopy-0.5.7.tar.gz and /dev/null differ diff --git a/dist/metrolopy-0.6.0-py3-none-any.whl b/dist/metrolopy-0.6.0-py3-none-any.whl new file mode 100644 index 0000000..411d6ad Binary files /dev/null and b/dist/metrolopy-0.6.0-py3-none-any.whl differ diff --git a/dist/metrolopy-0.6.0.tar.gz b/dist/metrolopy-0.6.0.tar.gz new file mode 100644 index 0000000..770f154 Binary files /dev/null and b/dist/metrolopy-0.6.0.tar.gz differ diff --git a/docs/.DS_Store b/docs/.DS_Store index c2d8f23..10d89e6 100644 Binary files a/docs/.DS_Store and b/docs/.DS_Store differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index 55cdfbb..752212a 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/hand_made_doc.doctree b/docs/_build/doctrees/hand_made_doc.doctree index bd63c89..be4d1a7 100644 Binary files a/docs/_build/doctrees/hand_made_doc.doctree and b/docs/_build/doctrees/hand_made_doc.doctree differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index f221fc5..b821286 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/metrolopy.doctree b/docs/_build/doctrees/metrolopy.doctree index 68eb0ca..091b86d 100644 Binary files a/docs/_build/doctrees/metrolopy.doctree and b/docs/_build/doctrees/metrolopy.doctree differ diff --git a/docs/_build/html/_sources/hand_made_doc.rst.txt b/docs/_build/html/_sources/hand_made_doc.rst.txt index fa19c6a..171491b 100644 --- a/docs/_build/html/_sources/hand_made_doc.rst.txt +++ b/docs/_build/html/_sources/hand_made_doc.rst.txt @@ -4,7 +4,11 @@ MetroloPy ========= Most of the functionality in the MetroloPy package lies in the -gummy_ object. +gummy_ object which combines the functionality of the Unit_ and ``Quantity`` +classes for dealing with units, the ummy_ class for first order propagation +of uncertainty, and the Distribution_ class for Monte Carlo propagation of +uncertianty. The ``immy`` and jummy_ classes support calculations with +complex numbers. .. _gummy: @@ -1194,8 +1198,11 @@ class Distribution and sub-classes The ``Distribution`` class is the abstract base class for objects which represent the the probability distributions that the gummy Monte-Carlo samples are drawn from. Instances of these ``Distributions`` can used as -the *x* parameter when creating gummys. The -distributions below are built into the gummy package and custom +the *x* parameter when creating gummys or can be used independantly as +mathematical operations between ``Distributions`` produce ``Convolutions``. +See the auto-generated documentation for the ``Distribution`` methods and +properties. +The distributions below are built into the gummy package and custom distributions can also be defined by the user. .. _arcsindist: @@ -1547,8 +1554,11 @@ metrolopy.\ **trunc(x)**: x rounded towards zero class Unit ========== -The gummy class uses ``Unit`` instances to represent physical units. A -number of units are loaded with the gummy package. See the +The gummy class uses ``Unit`` instances to represent physical units or units +cns be multiplied or divided by other ``Unit`` instances to create composite +units or multiply or divider numerical values to create ``Quantity`` instances. +See the auto-generated documentation for the deatils of the ``Quantity`` class. +A number of units are loaded with the gummy package. See the search_units_ function to get a list of all available units. Custom units can also be defined by creating instances of the ``Unit`` class or a sub-class. Though you @@ -1560,7 +1570,6 @@ can be accessed using string names. E.g. we can define: >>> Unit('weird meter','wm',conversion=Conversion('m',0.9144),add_symbol=True) >>> gummy(3.3,unit='wm') 3.3 wm - class metrolopy.\ **Unit(name, symbol, conversion=None, short_name=None, add_symbol=False, @@ -1788,7 +1797,8 @@ class metrolopy.\ **jummy(real=None,imag=None,r=None,phi=None,cov=None,unit=one** A jummy object represents a complex valued quantity with gummy real and -imaginary components. +imaginary components. See the ``immy`` class in the autogenerated docs for +a class with ``ummy`` real and imaginary components. jummy parameters ---------------- diff --git a/docs/_build/html/_sources/index.rst.txt b/docs/_build/html/_sources/index.rst.txt index 9d47735..f3ad0aa 100644 --- a/docs/_build/html/_sources/index.rst.txt +++ b/docs/_build/html/_sources/index.rst.txt @@ -1,148 +1,151 @@ -.. metrolopy documentation master file, created by - sphinx-quickstart on Fri Feb 22 16:15:02 2019. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - -=================== -MetroloPy, the docs -=================== - -tools for dealing with physical quantities: uncertainty propagation and unit -conversion - - -getting started -=============== - -MetroloPy is a pure python package and requires Python 3 and the -`SciPy `_ stack (NumPy, SciPy, Pandas, and IPython). -It looks best in a `Jupyter notebook `_. - +.. metrolopy documentation master file, created by + sphinx-quickstart on Fri Feb 22 16:15:02 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + +=================== +MetroloPy, the docs +=================== + +tools for dealing with physical quantities: uncertainty propagation and unit +conversion + + +getting started +=============== + +MetroloPy is a pure python package and requires Python 3 and the +`SciPy `_ stack (NumPy, SciPy, Pandas, and IPython). +It looks best in a `Jupyter notebook `_. + Install MetroloPy with ``pip install metrolopy`` or -``conda install -c conda-forge metrolopy``. - -Physical quantities can then be represented in Python as `gummy`_ objects -with an uncertainty and (or) a unit: - -.. _gummy: hand_made_doc.html#class-gummy - -.. raw:: html - -
>>> import metrolopy as uc
-    >>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
-    >>> a
-    1.234(23) cm
-    
-    >>> b = uc.gummy(3.034,u=0.174,unit='mm')
-    >>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
-    >>> p = f/(a*b)
-    >>> p
-    2.50(21) N/cm2
-    
-    >>> p.unit = 'kPa'
-    >>> p.uunit = '%'
-    >>> p
-    25.0 kPa ± 8.5%
-    
-
- -MetroloPy can do much more including `Monte-Carlo uncertainty propagation`_, -generating `uncertainty budget tables`_, and `curve fitting`_. It can also handle -`expanded uncertainties`_, `degrees of freedom`_, `correlated quantities`_, and -`complex valued quantities`_. - -.. _Monte-Carlo uncertainty propagation: _static/tutorial.html#Monte-Carlo-uncertainty-propagation - -.. _uncertainty budget tables: _static/tutorial.html#an-uncertainty-budget - -.. _curve fitting: _static/tutorial.html#curve-fitting - -.. _expanded uncertainties: _static/tutorial.html#expanded-uncertainty - -.. _degrees of freedom: _static/tutorial.html#degrees-of-freedom-and-uncertainty-types - -.. _correlated quantities: _static/tutorial.html#creating-correlated-gummys - -.. _complex valued quantities: hand_made_doc.html#jummy - -further reading -=============== - -* `a tutorial <_static/tutorial.html>`_ (or :download:`download the tutorial as a Jupyter notebook `) -* :ref:`the API documentation ` (see the auto-generated docs below for an alternative set of documentation) -* `a list of the measurement units built into MetroloPy <_static/units.html>`_ -* :ref:`package development and to do ` -* `the issues page on GitHub `_ -* `the source code on GitHub `_ - - -the auto-generated docs (indices and tables) -============================================ - -These pages were automatically generated from the doc strings in the source -code. They are slightly more comprehensive but perhaps slightly more confusing -than the handmade API docs referenced in the further reading section above. - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - - -Where did the name for the gummy class come from? -================================================= - -The name comes from the -`JGCM/ISO Guide to the Expression of Uncertainty in Measurement `_ -which is also known as the GUM. The GUM is the international standard used by -metrology institutes and calibration labs for expressing and propagating -measurement uncertainty. The gummy object implements many of the -recommendations outlined in the GUM. - -Other references of note are the -`draft 9th edition of the SI Brochure `_ -which contains the definitions of the SI units, and -`NIST Special Publication 1038 `_ -where many of the US customary units are defined. Some physical constants -used for unit definitions are from the -`2014 CODATA recommended values `_ -and the -`IAU 2009 system of astronomical constants `_. - - -version history -=============== - -* Version 0.5.0, built 26 March 2019, is the first public release. -* Version 0.5.1, built 2 April 2019, fixed a major bug that generated negative - uncertainties in some cases and fixed some other minor bugs. Improved support - for fraction.Fraction and mpmath.mpf values. -* Version 0.5.2, built 5 April 2019, fixed a major bug that propagated - uncertainty incorrectly if a gummy was created with an uncertainty set with - an integer data type. Fixed several other minor bugs. -* Version 0.5.3, built 10 April 2019, minor bug fixes. +``conda install -c conda-forge metrolopy``. + +Physical quantities can then be represented in Python as `gummy`_ objects +with an uncertainty and (or) a unit: + +.. _gummy: hand_made_doc.html#class-gummy + +.. raw:: html + +
>>> import metrolopy as uc
+    >>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
+    >>> a
+    1.234(23) cm
+    
+    >>> b = uc.gummy(3.034,u=0.174,unit='mm')
+    >>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
+    >>> p = f/(a*b)
+    >>> p
+    2.50(21) N/cm2
+    
+    >>> p.unit = 'kPa'
+    >>> p.uunit = '%'
+    >>> p
+    25.0 kPa ± 8.5%
+    
+
+ +MetroloPy can do much more including `Monte-Carlo uncertainty propagation`_, +generating `uncertainty budget tables`_, and `curve fitting`_. It can also handle +`expanded uncertainties`_, `degrees of freedom`_, `correlated quantities`_, and +`complex valued quantities`_. + +.. _Monte-Carlo uncertainty propagation: _static/tutorial.html#Monte-Carlo-uncertainty-propagation + +.. _uncertainty budget tables: _static/tutorial.html#an-uncertainty-budget + +.. _curve fitting: _static/tutorial.html#curve-fitting + +.. _expanded uncertainties: _static/tutorial.html#expanded-uncertainty + +.. _degrees of freedom: _static/tutorial.html#degrees-of-freedom-and-uncertainty-types + +.. _correlated quantities: _static/tutorial.html#creating-correlated-gummys + +.. _complex valued quantities: hand_made_doc.html#jummy + +further reading +=============== + +* `a tutorial <_static/tutorial.html>`_ (or :download:`download the tutorial as a Jupyter notebook `) +* :ref:`the API documentation ` (see the auto-generated docs below for an alternative set of documentation) +* `a list of the measurement units built into MetroloPy <_static/units.html>`_ +* `a list of the physical constants built into MetroloPy <_static/constants.html>`_ +* :ref:`package development and to do ` +* `the issues page on GitHub `_ +* `the source code on GitHub `_ + + +the auto-generated docs (indices and tables) +============================================ + +These pages were automatically generated from the doc strings in the source +code. They are slightly more comprehensive but perhaps slightly more confusing +than the handmade API docs referenced in the further reading section above. + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + + +Where did the name for the gummy class come from? +================================================= + +The name comes from the +`JGCM/ISO Guide to the Expression of Uncertainty in Measurement `_ +which is also known as the GUM. The GUM is the international standard used by +metrology institutes and calibration labs for expressing and propagating +measurement uncertainty. The gummy object implements many of the +recommendations outlined in the GUM. + +Other references of note are the +`draft 9th edition of the SI Brochure `_ +which contains the definitions of the SI units, and +`NIST Special Publication 1038 `_ +where many of the US customary units are defined. Some physical constants +used for unit definitions are from the +`2014 CODATA recommended values `_ +and the +`IAU 2009 system of astronomical constants `_. + + +version history +=============== + +* Version 0.5.0, built 26 March 2019, is the first public release. +* Version 0.5.1, built 2 April 2019, fixed a major bug that generated negative + uncertainties in some cases and fixed some other minor bugs. Improved support + for fraction.Fraction and mpmath.mpf values. +* Version 0.5.2, built 5 April 2019, fixed a major bug that propagated + uncertainty incorrectly if a gummy was created with an uncertainty set with + an integer data type. Fixed several other minor bugs. +* Version 0.5.3, built 10 April 2019, minor bug fixes. * Version 0.5.4, built 15 April 2019, minor bug fixes. * Version 0.5.5, built 7 May 2020, minor bug fixes. * Version 0.5.6, built 24 September 2020, minor bug fixes. -* Version 0.5.7, built 26 September 2020, minor change to setup.py. - - -author -====== - -Harold Parks, parksh@nrc.ca, National Research Council Canada - - -license -======= - -MetroloPy is distributed as free software under the terms of the -`GNU General Public License version 3 `_. -In practice, this license imposes -no restriction on using MetroloPy. However, if you want to further convey -verbatim or modified versions of the code you must do so under the same license -terms. Please contact NRC if you wish to license MetroloPy under different -terms. +* Version 0.5.7, built 26 September 2020, minor change to setup.py. +* Verison 0.6.0, built xx October 2020, added the `Quantity` and `immy` classes + as well as a library of physical constants. + + +author +====== + +Harold Parks, parksh@nrc.ca, National Research Council Canada + + +license +======= + +MetroloPy is distributed as free software under the terms of the +`GNU General Public License version 3 `_. +In practice, this license imposes +no restriction on using MetroloPy. However, if you want to further convey +verbatim or modified versions of the code you must do so under the same license +terms. Please contact NRC if you wish to license MetroloPy under different +terms. diff --git a/docs/_build/html/genindex.html b/docs/_build/html/genindex.html index 1d55ef5..c03a821 100644 --- a/docs/_build/html/genindex.html +++ b/docs/_build/html/genindex.html @@ -5,7 +5,7 @@ - Index — metrolopy 0.5.7 documentation + Index — metrolopy 0.6.0 documentation @@ -25,7 +25,7 @@

Navigation

  • modules |
  • - + @@ -54,10 +54,12 @@

    Index

    | N | O | P + | Q | R | S | T | U + | V | W | X | Y @@ -70,15 +72,13 @@

    A

  • absolute() (in module metrolopy.functions)
  • add() (in module metrolopy.functions) -
  • -
  • alias() (metrolopy.unit.Unit static method) -
  • -
  • aliases() (metrolopy.unit.Unit property)
  • angle() (in module metrolopy.functions)
  • -
  • autoconvert (metrolopy.gummy.gummy attribute) -
  • autocorrelation() (in module metrolopy.mean)
  • @@ -125,10 +125,14 @@

    A

    B

    - + - +
    -
  • sci_notation (metrolopy.ummy.ummy attribute) +
  • sci_notation (metrolopy.gummy.gummy attribute) + +
  • +
  • sci_notation() (metrolopy.gummy.MetaGummy property)
  • -
  • sci_notation_low (metrolopy.ummy.ummy attribute) +
  • sci_notation_high (metrolopy.gummy.gummy attribute) + +
  • +
  • sci_notation_high() (metrolopy.gummy.MetaGummy property) +
  • +
  • sci_notation_low (metrolopy.gummy.gummy attribute) + +
  • +
  • sci_notation_low() (metrolopy.gummy.MetaGummy property)
  • search_units() (in module metrolopy.unitutils)
  • @@ -1070,8 +1198,6 @@

    S

  • set_tag() (metrolopy.ummy.GummyTag static method) -
  • -
  • shadowed_aliases() (metrolopy.unit.Unit property)
  • shadowed_units() (in module metrolopy.unitutils)
  • @@ -1084,7 +1210,11 @@

    S

  • show_k (metrolopy.gummy.gummy attribute)
  • show_name (metrolopy.gummy.gummy attribute) + +
  • show_p (metrolopy.gummy.gummy attribute)
  • show_s (metrolopy.budget.Budget attribute) @@ -1093,17 +1223,23 @@

    S

  • sign() (in module metrolopy.functions)
  • -
    +
  • splonk() (metrolopy.gummy.gummy method) + +
  • +
  • splonk_func_ret (metrolopy.unit.Quantity attribute) +
  • sqrt() (in module metrolopy.functions)
  • square() (in module metrolopy.functions) @@ -1142,9 +1294,17 @@

    S

  • stdev() (metrolopy.distributions.Distribution property)
  • style (metrolopy.gummy.gummy attribute) + +
  • style() (metrolopy.gummy.MetaGummy property) + +
  • subtract() (in module metrolopy.functions)
  • sum() (in module metrolopy.functions) @@ -1165,11 +1325,21 @@

    T

  • test_gummy_init() (in module metrolopy.tests.test_create)
  • -
  • thousand_spaces (metrolopy.ummy.ummy attribute) +
  • thousand_spaces (metrolopy.gummy.gummy attribute) + +
  • +
  • thousand_spaces() (metrolopy.gummy.MetaGummy property) +
  • +
  • to() (metrolopy.logunit.LogConversion method)
  • @@ -1186,13 +1356,13 @@

    T

  • tofloat() (metrolopy.dfunc.Dfunc method)
  • -
  • ubreakdown() (metrolopy.gummy.gummy property)
  • -
  • ufrom() (metrolopy.nummy.nummy method) +
  • ufrom() (metrolopy.gummy.gummy method)
  • @@ -1309,12 +1497,14 @@

    U

  • Unit (class in metrolopy.unit)
  • -
  • unit() (metrolopy.gummy.gummy property) +
  • unit() (in module metrolopy.unit)
  • +

    V

    + + +
    +

    W

    @@ -36,7 +36,11 @@

    Navigation

    MetroloPy

    Most of the functionality in the MetroloPy package lies in the -gummy object.

    +gummy object which combines the functionality of the Unit_ and Quantity +classes for dealing with units, the ummy_ class for first order propagation +of uncertainty, and the Distribution class for Monte Carlo propagation of +uncertianty. The immy and jummy classes support calculations with +complex numbers.

    class gummy

    @@ -1104,8 +1108,11 @@

    gummy display methodsThe Distribution class is the abstract base class for objects which represent the the probability distributions that the gummy Monte-Carlo samples are drawn from. Instances of these Distributions can used as -the x parameter when creating gummys. The -distributions below are built into the gummy package and custom +the x parameter when creating gummys or can be used independantly as +mathematical operations between Distributions produce Convolutions. +See the auto-generated documentation for the Distribution methods and +properties. +The distributions below are built into the gummy package and custom distributions can also be defined by the user.

    @@ -75,6 +75,7 @@

    further readinga tutorial (or download the tutorial as a Jupyter notebook)

  • the API documentation (see the auto-generated docs below for an alternative set of documentation)

  • a list of the measurement units built into MetroloPy

  • +
  • a list of the physical constants built into MetroloPy

  • package development and to do

  • the issues page on GitHub

  • the source code on GitHub

  • @@ -124,6 +125,8 @@

    version history @@ -192,7 +195,7 @@

    Navigation

  • modules |
  • - + @@ -298,8 +298,8 @@

    Submodules

    metrolopy.dfunc module

    -

    Class Dfunc is an abstract base class inherited by gummy and jummy to provides -some support for numpy broadcasting for functions and operators.

    +

    Class Dfunc is an abstract base class inherited by ummy and immy to provide +support for numpy ufunc functions.

    class metrolopy.dfunc.Dfunc
    @@ -434,8 +434,8 @@

    Submodules

    metrolopy.distributions module

    -

    This module contains the classed that represent distributions for use with -gummy objects

    +

    This module contains the classed that represent distributions for Monte Carlo +calculations.

    class metrolopy.distributions.ArcSinDist(center=None, half_width=None, lower_limit=None, upper_limit=None)
    @@ -1383,6 +1383,12 @@

    Submodulesmetrolopy.exceptions.UnitError

    +
    +
    +exception metrolopy.exceptions.ConstantNotFoundError
    +

    Bases: ValueError

    +
    +
    exception metrolopy.exceptions.FitWarning
    @@ -3510,7 +3516,64 @@

    Submodules
    class metrolopy.gummy.MetaGummy
    -

    Bases: metrolopy.printing.MetaPrettyPrinter, metrolopy.nummy.MetaNummy

    +

    Bases: metrolopy.printing.MetaPrettyPrinter

    +
    +
    +property bayesian
    +

    bool

    +

    Read/write at the class level, but read-only at the instance level. +The default value is False; this should only be changed once at the +beginning of the session. This property affects how the level of +confidence p (sometimes called coverage probability) of an expanded +uncertainty is related to the coverage factor k for a gummy based on +data with finite degrees of freedom.

    +

    Standard uncertainties are often based on the standard deviation of a set +of measurements (and the assumption that these measurements are drawn +from a normally distributed population). Traditionally (e.g. the GUM +2008 edition) the standard uncertainty is taken to be the standard +deviation of the mean (s/sqrt(n), where s is the sample standard deviation +and n is the number of measurements). However there is some “extra +uncertainty” because the sample standard devation not exactly equal to +the population standard deviation. This is taken into account by using +a Student’s t distribution to calculate the expanded uncertainty. However +it has been pointed out, by those who advocate a Bayesian point of view, +that the probability distribution for the measurand here is best described +by a shifted and scaled Student’s t distribution. So the standard +uncertainty should be the standard deviation of this distribution which +is s*sqrt{(n-1)/[n*(n-3)]}. Thus

    +

    u(bayesian) = [dof/(dof - 2)]*u(traditional)

    +

    where dof = n - 1 and the “extra uncertainty” is incorporated directly +into the standard uncertainty.

    +

    Example

    +
    >>> gummy.bayesian = True
    +>>> g = gummy(1,0.03,dof=5)
    +>>> g.bayesian
    +True
    +
    +
    +
    + +
    +
    +property cimethod
    +

    str in {‘shortest’, ‘symmetric’}

    +

    Get or set the method for calculating the confidence interval from +Monte-Carlo data. If this property is set at the class level, it will +change the default cimethod value for new gummys but will not affect +gummys that have already been created.

    +

    Can be set either to the string ‘shortest’ or the string ‘symmetric’. +This property gets or sets the method for calculating confidence +intervals from Monte-Carlo data.

    +

    If it is set to ‘shortest’, the confidence interval will be taken to be +the shortest interval that includes the desired fraction of the probability +distribution.

    +

    If it is set to ‘symmetric’, then the confidence interval will be set so +that, for n Monte-Carlo samples and a coverage probability of p, then +n`*(1-`p)/2 samples lie below the lower limit of the confidence interval +and the same number of samples lie above the upper limit of the confidence +interval.

    +
    +
    property cmp_k
    @@ -3525,6 +3588,29 @@

    Submodules +
    +property max_digits
    +

    int

    +

    Gets or sets the maximum number of digits in x to display.

    +

    + +
    +
    +property max_dof
    +

    int

    +

    Gets or sets the maximum finite value for dof. Any dof larger than +max_dof will be rounded to float(‘inf’).

    +
    + +
    +
    +property nsig
    +

    int

    +

    Gets or sets the number of significant digits in the uncertainty to +display.

    +
    +
    property p_method
    @@ -3541,6 +3627,37 @@

    Submodules +
    +property rounding_u
    +

    bool

    +

    If this is set to True then the uncertainty of the ummy or gummy +includes a contribution to account for the finite resolution of the +x-value.

    +

    + +
    +
    +property sci_notation
    +

    bool or None

    +

    Setting this to True or False forces or prevents scientific notation +in the display of the value. If this is set to None thr scientific +notation will be used if the x value is below 10**sci_notation_low or +above 10**sci_notation_high.

    +
    + +
    +
    +property sci_notation_high
    +

    see the sci_notation property

    +
    + +
    +
    +property sci_notation_low
    +

    see the sci_notation property

    +
    +
    property style
    @@ -3603,12 +3720,20 @@

    Submodules +
    +property thousand_spaces
    +

    bool

    +

    Gets or sets a bool value that determines whether to insert a space to +group digits in x.

    +

    +

    -class metrolopy.gummy.gummy(x, u=0, unit=, dof=inf, k=1, p=None, uunit=None, utype=None, name=None)
    -

    Bases: metrolopy.printing.PrettyPrinter, metrolopy.nummy.nummy

    +class metrolopy.gummy.gummy(x, u=0, unit=one, dof=inf, k=1, p=None, uunit=None, utype=None, name=None) +

    Bases: metrolopy.unit.Quantity

    A gummy object represents a numerical value with an uncertainty and (or) a unit. They can be used in place of float values in Python expressions and the uncertainty can be propagated with with both first-order and @@ -3728,6 +3853,78 @@

    Submodules +
    +angle()
    +

    + +
    +
    +classmethod apply(function, derivative, *args)
    +

    A classmethod that applies a function to one or more gummy or jummy +objects propagating the uncertainty.

    +
    +
    Parameters
    +
      +
    • function (function) – The the function to be applied. For gummy.apply, ‘function’ +should take one or more float arguments and return a float value +or float array. For jummy.apply, ‘function’ may also take and +return complex values.

    • +
    • +
      derivative (function) – The name of a second function that gives the derivatives

      with respect to the arguments of function. derivative should +take an equal number of arguments as function. If function +takes one argument derivative should return a float and if +function takes more than one argument then derivative should +return a tuple, list or array of floats that contains the derivatives +with respect to each argument. In the case of jummy.apply, the +derivatives with respect to each argument may be real or complex +values, in which case function is assumed to be holomorphic. Or +the derivative may be a 2 x 2 matrix of the form:

      +
      +
      +
      [[ du/dx, du/dy ],

      [ dv/dx, dv/dy ]]

      +
      +
      +
      +
      +
      +

      where function(x + j*y) = u + j*v.

      +
    • +
    • *args (gummy, jummy, or float) – One or more arguments to which function will be applied. These +arguments need not all be Dfunc objects; arguments such as +floats will be taken to be constants with no uncertainty. +They may also be numpy ndarrays in which case the usual numpy +broadcasting rules apply.

    • +
    +
    +
    Returns
    +

    If none of the arguments are gummy or jummy +then the return value is the same type as the return value of function. +Otherwise gummy.apply returns a gummy and jummy.apply returns either a +gummy or a jummy depending on whether function has a float or +a complex return value.

    +
    +
    Return type
    +

    gummy, jummy

    +
    +
    +

    Examples

    +
    >>> import numpy as np
    +>>> x = gummy(0.678,u=0.077)
    +>>> gummy.apply(np.sin,np.cos,x)
    +0.627 +/- 0.060
    +
    +
    +
    >>> x = gummy(1.22,u=0.44)
    +>>> y = gummy(3.44,u=0.67)
    +>>> def dhypot(x,y):
    +...     return (x1/sqrt(x1**2 + x2**2),x2/np.sqrt(x1**2 + x2**2))
    +>>> gummy.apply(np.hypot,dhypot,x,y)
    +3.65 +/- 0.65
    +
    +
    +
    +
    ascii(**kwds)
    @@ -3737,8 +3934,8 @@

    Submodules -
    -autoconvert = False
    +
    +bayesian = False

    @@ -3850,30 +4047,10 @@

    Submodules -
    -property c
    -

    This read-only property is used as a conversion flag during calculations. -When an arithmetic operation is carried out between two gummys with -different units, a unit conversion on one of the input quantities may be -required to complete the calculation. Attach this flag to the unit that -you prefer be converted.

    -

    Examples

    -
    >>> a = gummy(1,u=0.01,unit='cm')
    ->>> b = gummy(2,u=0.2,unit='mm')
    ->>> a + b
    -(1.200 +/- 0.022) cm
    ->>> a.c + b
    -(12.00 +/- 0.22) mm
    ->>> a + b.c
    -(1.200 +/- 0.022) cm
    ->>> a*b
    -(0.200 +/- 0.020) cm**2
    ->>>a.c*b
    -(20.0 +/- 2.0) mm**2
    -
    -
    -

    +
    +
    +cimethod = 'shortest'
    +
    @@ -3892,28 +4069,49 @@

    Submodules -
    -convert(unit, uunit=None)
    -

    Returns a copy of the gummy with converted units. This is equivalent -to calling the copy method and then setting the unit and uunit properties -on the copied gummy.

    -
    -
    Parameters
    -
      -
    • unit (str or Unit) – The unit for the x value and if uunit is None, the -uncertainty. It must be string, None, a Unit object, or the -integer 1. Both 1 and None will be interpreted as the Unit -instance one.

    • -
    • uunit `str`, `Unit` or None, optional – The unit for the uncertainty U. If this is None then U -will have the same units as x. The default is None.

    • -
    -
    -
    +
    +conjugate()
    +

    returns a copy of the gummy

    +

    + +
    +
    +copy(formatting=True, tofloat=False)
    +

    Returns a copy of the gummy. If the formatting parameter is +True the display formatting information will be copied and if +False the display formatting will be set to the default for a +new gummy. The default for formatting is True. If tofloat +is true the x and u properties will be converted to float values +before copying.

    +
    + +
    +
    +correlation(gummy)
    +

    Returns the correlation coefficient between self and g.

    +
    + +
    +
    +static correlation_matrix(gummys)
    +

    Returns the correlation matrix of a list or array of gummys.

    +
    + +
    +
    +covariance(gummy)
    +

    Returns the covariance between self and g.

    +
    + +
    +
    +static covariance_matrix(gummys)
    +

    Returns the variance-covariance matrix of a list or array of gummys.

    -classmethod covplot(x, y, title=None, xlabel=None, ylabel=None, mean_marker=False, mean_marker_options={}, hold=False, math=None, **plot_options)
    +static covplot(x, y, title=None, xlabel=None, ylabel=None, mean_marker=False, mean_marker_options={}, hold=False, math=None, **plot_options)

    Creates scatter plot showing the covariance between two gummys.

    Parameters
    @@ -3944,7 +4142,7 @@

    Submodules
    -classmethod create(x, u=0, unit=, dof=inf, k=1, p=None, uunit=None, utype=None, name=None, correlation_matrix=None, covariance_matrix=None)
    +classmethod create(x, u=0, unit=one, dof=inf, k=1, p=None, uunit=None, utype=None, name=None, correlation_matrix=None, covariance_matrix=None)

    A class method that creates a list of correlated gummys.

    Parameters
    @@ -3984,14 +4182,76 @@

    Submodules +
    +property distribution
    +

    read-only

    +

    Returns ths Distribution instance associated with the gummy.

    +

    + +
    +
    +property dof
    +

    float, read-only

    +

    Returns the number or degrees of freedom that the uncertainty of the +gummy is based on. If the gummy was created as the result of an +operation between two or more other gummys, then the dof is the effective +number of degrees of freedom calculated using the Welch-Satterthwaite +approximation. Caution: A variation of the the Welch-Satterthwaite +approximation is used that takes into account correlations, see +[R. Willink, Metrologia, 44, 340 (2007)]. However correlations are +not handled perfectly. So if accurate dof calculations are need, care +should be taken to ensure that correlations are not generated in +intermediate calculations.

    +
    + +
    +
    +doffrom(x)
    +

    Gets the degrees of freedom contributed from particular gummys or +utypes if all other free variables are held fixed. Caution: any +correlations in the calculations can cause errors in dof calculations.

    +
    +
    Parameters
    +

    x (gummy, str, or array_like) – A gummy, a string referencing a utype or a list containing +gummys and strings.

    +
    +
    Returns
    +

    +
    +
    Return type
    +

    float

    +
    +
    +

    Example

    +
    >>>  a = gummy(1.2,0.2,dof=5,utype='A')
    +>>>  b = gummy(3.2,0.5,dof=7,utype='A')
    +>>>  c = gummy(0.9,0.2,utype='B')
    +>>>  d = a + b + c
    +>>>  d.doffrom('A')
    +9.0932962619709627
    +
    +
    +
    +
    exception_on_fmt_error = False
    +
    +
    +property finfo
    +
    + +
    +
    +get_name(fmt='unicode', norm=None)
    +
    +
    -graft(unit, uunit=None)
    +graft(unit)

    Returns a copy of the gummy with different units but the same x and u values. This is different from gummy.convert(unit) in that gummy.convert(unit) changes the x and u `values to express the @@ -3999,14 +4259,10 @@

    Submodules
    Parameters
    -
      -
    • unit (str or Unit) – The unit for the x value and if uunit is None, the +

      unit (str or Unit) – The unit for the x value and if uunit is None, the uncertainty. It must be string, None, a Unit object, or the integer 1. Both 1 and None will be interpreted as the Unit -instance one.

    • -
    • uunit `str`, `Unit` or None, optional – The unit for the uncertainty U. If this is None then U -will have the same units as x. The default is None.

    • -
    +instance one.

    @@ -4077,9 +4333,17 @@

    Submodules -
    -property k
    -

    Get or set the coverage factor; must be > 0.

    +
    +property independant
    +

    bool, read-only

    +

    Returns False if the owning gummy was created from a operation involving +other gummys and True otherwise.

    +

    + +
    +
    +property k
    +

    Get or set the coverage factor; must be > 0.

    The expanded uncertainty U (see the U property) is related to the standard uncertainty u (see the u property) by U = k`*`u. The coverage factor k can be set directly or the desired level @@ -4109,6 +4373,13 @@

    Submodules +
    +property ksim
    +

    read-only

    +

    Returns 0.5*(gummy.Usim[0] + gummy.Usim[1])/gummy.usim

    +

    +
    latex(**kwds)
    @@ -4118,11 +4389,76 @@

    Submodules +
    +max_digits = 15
    +

    +
    mulsep = False
    +
    +
    +property name
    +

    gets or sets an optional name for the gummy, may be str or None

    +
    + +
    +
    +classmethod napply(function, *args, fxx=None)
    +

    gummy.napply(function, arg1, arg2, …) and +jummy.napply(function, arg1, arg2, …)

    +

    A classmethod that applies a function to one or more gummy or jummy +objects propagating the uncertainty. This method is similar to apply +except that the derivatives are computed numerically so a derivative +function does not need to be supplied.

    +
    +
    Parameters
    +
      +
    • function (function) – The the function to be applied. For gummy.apply, ‘function’ +should take one or more float arguments and return a float value +r float array. For jummy.apply, ‘function’ may also take and +return complex values.

    • +
    • *args (gummy, jummy, or float) – One or more arguments to which function will be applied. These +arguments need not all be Dfunc objects; arguments such as +floats will be taken to be constants with no uncertainty. +They may also be numpy ndarrays in which case the usual numpy +broadcasting rules apply.

    • +
    +
    +
    Returns
    +

    If none of the arguments are gummy or jummy +then the return value is the same type as the return value of function. +Otherwise gummy.apply returns a gummy and jummy.apply returns either a +gummy or a jummy depending on whether function has a float or +a complex return value.

    +
    +
    Return type
    +

    gummy, jummy

    +
    +
    +

    Examples

    +
    >>> import numpy as np
    +>>> x = gummy(0.678,u=0.077)
    +>>> gummy.napply(np.sin,x)
    +0.627 +/- 0.060
    +
    +
    +
    >>> x = gummy(1.22,u=0.44)
    +>>> y = gummy(3.44,u=0.67)
    +>>> gummy.napply(np.hypot,x,y)
    +3.65 +/- 0.65
    +
    +
    +
    + +
    +
    +nsig = 2
    +
    +
    property p
    @@ -4157,19 +4493,26 @@

    Submodules -
    -reduce_unit()
    -

    Cancels factors in a gummy’s unit when possible. This modifies the -calling gummy and returns None.

    -

    Example

    -
    >>> g = gummy(5,unit='mm/m')
    ->>> g.reduce_unit()
    ->>> g
    -0.005
    -
    -
    +
    +property real
    +

    returns a copy of the gummy

    +
    +
    +sci_notation = None
    +
    + +
    +
    +sci_notation_high = 7
    +
    + +
    +
    +sci_notation_low = -3
    +
    +
    show_dof = None
    @@ -4210,6 +4553,22 @@

    Submodules +
    +property simdata
    +

    numpy.ndarray, read-only

    +

    Returns an array containing the Monte-Carlo simulation data. A +NoSimulatedDataError is raised if no Monte-Carlo data is available.

    +

    + +
    +
    +property simsorted
    +

    numpy.ndarray, read-only

    +

    Returns a sorted array containing the Monte-Carlo simulation data. A +NoSimulatedDataError is raised if no Monte-Carlo data is available.

    +
    +
    static simulate(gummys, n=100000, ufrom=None)
    @@ -4239,11 +4598,22 @@

    Submodulessolidus = True

    +
    +
    +splonk()
    +

    splonks the gummy

    +
    +
    style = 'concise'
    +
    +
    +thousand_spaces = True
    +
    +
    toascii(**kwds)
    @@ -4275,7 +4645,7 @@

    Submodules
    -tostring(fmt=None, style=None, k=None, p=None, show_k=None, show_p=None, show_dof=None, show_name=None, norm=None, raw=False, nsig=None, solidus=None, mulsep=None, **kwds)
    +tostring(fmt=None, style=None, k=None, p=None, show_k=None, show_p=None, show_dof=None, show_name=None, name=None, norm=None, raw=False, nsig=None, solidus=None, mulsep=None, **kwds)

    Returns a string displaying the value of the gummy in the desired format. The fmt parameter is a string with the value in {“unicode”,”latex”, “html”,”ascii”} or None. fmt will default to ‘ascii’ if self.printer @@ -4283,6 +4653,12 @@

    Submodules +
    +toummy()
    +

    returns a Quantity with an ummy value.

    +

    +
    property u
    @@ -4316,6 +4692,34 @@

    Submodules +
    +ufrom(x, sim=False)
    +

    Gets the standard uncertainty contributed from particular gummys +or utypes if all other free variables are held fixed.

    +
    +
    Parameters
    +

    x (gummy, str, or array_like) – A gummy, a string referencing a utype or a list containing +gummys and strings.

    +
    +
    Returns
    +

    +
    +
    Return type
    +

    float

    +
    +
    +

    Example

    +
    >>>  a = gummy(1.2,0.2,utype='A')
    +>>>  b = gummy(3.2,0.5,utype='A')
    +>>>  c = gummy(0.9,0.2,utype='B')
    +>>>  d = a + b + c
    +>>>  d.ufrom('A')
    +0.53851648071345048
    +
    +
    +

    +
    unicode(**kwds)
    @@ -4330,24 +4734,16 @@

    SubmodulesExamples

    -
    >>> g = gummy(0.001,0.0000012,unit='V')
    ->>> g
    -(0.001 000 0 +/- 0.000 001 2) V
    ->>> g.unit = 'uV'
    ->>> g
    -(1000.0 +/- 1.2) uV
    ->>> g.uunit = '%'
    ->>> g.unit = 'mV'
    ->>> g
    -1.0000 mV +/- 0.12%
    ->>> g.unit = 'uV'
    ->>> g
    -1000.0 uV +/- 0.12%
    ->>> g.uunit = None
    ->>> g
    -(1000.0 +/- 1.2) uV
    +Both 1 and None will be interpreted as the Unit instance one. A
    +NoUnitConversionFoundError will be raised if the unit conversion is
    +not possible.

    +

    Example

    +
    >>> x = gummy(0.001,unit='V')
    +>>> x
    +0.001 V
    +>>> x.unit = 'uV'
    +>>> x
    +1000.0 uV
     

    @@ -4360,6 +4756,13 @@

    Submodules +
    +property utype
    +

    str or None

    +

    An arbitrary string value labeling the uncertainty type.

    +

    +
    property uunit
    @@ -4432,78 +4835,40 @@

    Submodules
    -class metrolopy.gummy.jummy(real=None, imag=None, r=None, phi=None, cov=None, unit=)
    -

    Bases: metrolopy.printing.PrettyPrinter, metrolopy.dfunc.Dfunc

    -
    -
    -angle()
    -

    Returns a gummy representing Arg(jummy).

    -
    - +class metrolopy.gummy.jummy(real=None, imag=None, r=None, phi=None, cov=None, name=None) +

    Bases: metrolopy.ummy.immy

    -
    -conjugate()
    -

    Returns the (jummy valued) complex conjugate.

    -
    - -
    -
    -copy(formatting=True, tofloat=False)
    -

    Returns a copy of the jummy. If the formatting parameter is -True the display formatting information will be copied and if -False the display formatting will be set to the default for a -new jummy. The default for formatting is True. If the -tofloats parameter is True x and u for both the real and -imaginary components will be converted to floats.

    -
    +
    +get_name(fmt='unicode', norm=None)
    +

    -
    -property cov
    -

    Returns the variance-covariance matrix between jummy.real and -jummy.imag, read-only.

    -
    +
    +property name
    +
    -
    -
    -property imag
    -

    Returns a gummy representing the imaginary part of the value.

    -
    +
    +
    +show_name = True
    +
    -
    -property real
    -

    read-only -Returns a gummy representing the real part of the value.

    +
    +splonk()
    +

    splonks the jummy

    -
    -tofloat()
    -

    Returns a copy of the gummy with x an u (for both the real and -imaginary components) converted to floats.

    +
    +toimmy()
    +

    returns an immy representation of the jummy

    -tostring(fmt='unicode', norm=None, nsig=None, solidus=None, mulsep=None)
    +tostring(fmt='unicode', norm=None, show_name=None, name=None, style=None, **kwds)
    -
    -
    -property unit
    -

    Gets or sets the units of jummy.real and jummy.imag. If the -units of jummy.real are different from jummy.imag then a -tuple of Unit with length 2 is returned. Otherwise a Unit -instance is returned.

    -
    - -
    -
    -property x
    -

    Returns complex(jummy.real.x,jummy.imag.x), read-only

    -
    - @@ -4520,6 +4885,16 @@

    Submodulescopy()
    +
    +
    +frm(g)
    +
    + +
    +
    +to(g)
    +
    +
    @@ -4793,11 +5168,6 @@

    Submodulesget_composite(ul)

    -
    -
    -linear = False
    -
    -
    to_uunit(u, unit)
    @@ -4839,16 +5209,22 @@

    Submodules

    metrolopy.nummy module

    -

    The nummy object defined here was created as a super-class for gummy, -integrating the Monte-Carlo uncertainty propagation code in the distributions -module with the ummy object.

    +

    The nummy object defined here integrates the Monte-Carlo uncertainty +propagation code in the distributions module with the ummy object. The nummy +class is not intended to be used directly; rather it is utilized by the gummy +class.

    -
    -class metrolopy.nummy.MetaNummy
    -

    Bases: type

    +
    +class metrolopy.nummy.nummy(x, u=0, dof=inf, utype=None, name=None)
    +

    Bases: metrolopy.ummy.ummy

    +
    +
    +property Usim
    +
    +
    -
    -property bayesian
    +
    +property bayesian

    bool

    Read/write at the class level, but read-only at the instance level. The default value is False; this should only be changed once at the @@ -4883,12 +5259,12 @@

    Submodules -
    -property cimethod
    -

    str in {‘shortest’, ‘symmetric’}

    +
    +property cimethod
    +

    str in {‘shortest’, ‘symmetric’}), default is ‘shortest’

    Get or set the method for calculating the confidence interval from Monte-Carlo data. If this property is set at the class level, it will -change the default cimethod value for new gummys but will not affect +change the default cimethod value for new gummys but will no affect gummys that have already been created.

    Can be set either to the string ‘shortest’ or the string ‘symmetric’. This property gets or sets the method for calculating confidence @@ -4903,36 +5279,6 @@

    Submodules -
    -property mcpropagate
    -

    Setting this property to False turns of the code for Monte-Carlo -uncertainty propagation. This property should only be set once, before -any gummy instances are created. Turning mcpropagate off then on again -may have unpredictable results.

    -

    - -
    - -
    -
    -class metrolopy.nummy.nummy(x, u=0, dof=inf, utype=None, name=None)
    -

    Bases: metrolopy.ummy.ummy

    -
    -
    -property Usim
    -
    - -
    -
    -bayesian = False
    -
    - -
    -
    -cimethod = 'shortest'
    -
    -
    property cisim
    @@ -5038,6 +5384,11 @@

    Submodules +
    +get_name(fmt='unicode', norm=None)
    +

    +
    hist(xlabel=None, title=None, hold=False, **kwds)
    @@ -5058,6 +5409,11 @@

    Submodules0.5*(gummy.Usim[0] + gummy.Usim[1])/gummy.usim

    +
    +
    +property name
    +
    +
    property p
    @@ -5091,6 +5447,18 @@

    Submodulesstatic simulate(nummys, n=100000, ufrom=None)

    +
    +
    +splonk()
    +

    splonks the nummy

    +
    + +
    +
    +toummy()
    +

    returns an ummy representaion of the nummy

    +
    +
    ufrom(x, sim=False)
    @@ -5145,6 +5513,16 @@

    Submodulescopy()

    +
    +
    +frm(g)
    +
    + +
    +
    +to(g)
    +
    +

    @@ -5440,10 +5818,9 @@

    Submodules

    metrolopy.siunits module

    -

    This module is loaded by the gummy.units module and is not intended be be +

    This module is loaded by the unit module and is not intended be be imported directly.

    -

    The most of the units here are from the SI Brochure, draft 9th edition published -by the BIPM.

    +

    The most of the units here are from the SI Brochure, 9th edition.

    metrolopy.ummy module

    @@ -5480,10 +5857,124 @@

    Submodules +
    +class metrolopy.ummy.MetaImmy
    +

    Bases: metrolopy.printing.MetaPrettyPrinter

    +
    +
    +property imag_symbol
    +

    str

    +

    The symbol for the unit imaginary number. The default is ‘j’.

    +
    + +
    +
    +property style
    +

    str in {‘polar’,’cartesian’}

    +

    Sets whether to print the value using a cartesian or polar +representaion. This property can be set at the class or instance +level. The default is ‘cartesian’.

    +
    + +

    + +
    +
    +class metrolopy.ummy.immy(real=None, imag=None, r=None, phi=None, cov=None)
    +

    Bases: metrolopy.printing.PrettyPrinter, metrolopy.dfunc.Dfunc

    +
    +
    +angle()
    +

    Returns the polar angle in radians.

    +
    + +
    +
    +conjugate()
    +

    Returns the complex conjugate.

    +
    + +
    +
    +copy(formatting=True, tofloat=False)
    +

    Returns a copy of the jummy. If the formatting parameter is +True the display formatting information will be copied and if +False the display formatting will be set to the default for a +new jummy. The default for formatting is True. If the +tofloats parameter is True x and u for both the real and +imaginary components will be converted to floats.

    +
    + +
    +
    +property cov
    +

    Returns the variance-covariance matrix between the real and imaginary +parts of the value, read-only.

    +
    + +
    +
    +property imag
    +

    read-only +Returns the imaginary part of the value.

    +
    + +
    +
    +property phi
    +

    read-only +Returns the polar angle of the value.

    +
    + +
    +
    +property r
    +

    read-only +Returns the magnitude of the value.

    +
    + +
    +
    +property real
    +

    read-only +Returns real part of the value.

    +
    + +
    +
    +splonk()
    +
    + +
    +
    +style = 'cartesian'
    +
    + +
    +
    +tofloat()
    +

    Returns a copy of the gummy with x an u (for both the real and +imaginary components) converted to floats.

    +
    + +
    +
    +tostring(fmt='unicode', norm=None, nsig=None, style=None)
    +
    + +
    +
    +property x
    +

    Returns complex(self.real.x,self.imag.x), read-only

    +
    + +
    +
    class metrolopy.ummy.ummy(x, u=0, dof=inf, utype=None)
    -

    Bases: metrolopy.dfunc.Dfunc

    +

    Bases: metrolopy.dfunc.Dfunc, metrolopy.printing.PrettyPrinter

    angle()
    @@ -5494,17 +5985,10 @@

    Submodulesconjugate()

    -
    -
    -property const
    -

    bool, read-only

    -

    Returns True if the gummy represents an exact value with no uncertainty.

    -
    -
    copy(formatting=True, tofloat=False)
    -

    Returns a copy of the gummy. If the formatting parameter is +

    Returns a copy of the ummy. If the formatting parameter is True the display formatting information will be copied and if False the display formatting will be set to the default for a new gummy. The default for formatting is True. If tofloat @@ -5521,7 +6005,7 @@

    Submodules
    static correlation_matrix(gummys)
    -

    Returns the correlation matrix of a list or array of gummys.

    +

    Returns the correlation matrix of a list or array of ummys.

    @@ -5533,7 +6017,7 @@

    Submodules
    static covariance_matrix(gummys)
    -

    Returns the variance-covariance matrix of a list or array of gummys.

    +

    Returns the variance-covariance matrix of a list or array of ummys.

    @@ -5576,22 +6060,27 @@

    Submodulesproperty dof

    float, read-only

    Returns the number or degrees of freedom that the uncertainty of the -gummy is based on. If the gummy was created as the result of an +ummy is based on. If the ummy was created as the result of an operation between two or more other gummys, then the dof is the effective -number of degrees of freedom calculated using a version of the Welch- -Satterthwaite approximation that takes into account correlations, see -[R. Willink, Metrologia, 44, 340 (2007)].

    +number of degrees of freedom calculated using the Welch-Satterthwaite +approximation. Caution: A variation of the the Welch-Satterthwaite +approximation is used that takes into account correlations, see +[R. Willink, Metrologia, 44, 340 (2007)]. However correlations are +not handled perfectly. So if accurate dof calculations are need, care +should be taken to ensure that correlations are not generated in +intermediate calculations.

    doffrom(x)
    -

    Gets the degrees of freedom contributed from particular gummys or -utypes if all other free variables are held fixed.

    +

    Gets the degrees of freedom contributed from particular ummys or +utypes if all other free variables are held fixed. Caution: any +correlations in the calculations can cause errors in dof calculations.

    Parameters
    -

    x (gummy, str, or array_like) – A gummy, a string referencing a utype or a list containing -gummys and strings.

    +

    x (ummy, str, or array_like) – A ummy, a string referencing a utype or a list containing +ummys and strings.

    Returns

    @@ -5601,9 +6090,9 @@

    SubmodulesExample

    -

    +
    +
    +splonk()
    +

    returns self.x if u == 0 else returns self

    +
    +
    thousand_spaces = True
    @@ -5672,6 +6167,11 @@

    Submodules +
    +tostring(fmt='unicode', nsig=None, **kwds)
    +

    +
    property u
    @@ -5680,12 +6180,12 @@

    Submodules
    ufrom(x)
    -

    Gets the standard uncertainty contributed from particular gummys +

    Gets the standard uncertainty contributed from particular ummys or utypes if all other free variables are held fixed.

    Parameters
    -

    x (gummy, str, or array_like) – A gummy, a string referencing a utype or a list containing -gummys and strings.

    +

    x (ummy, str, or array_like) – A ummy, a string referencing a utype or a list containing +ummys and strings.

    Returns

    @@ -5695,9 +6195,9 @@

    SubmodulesExample

    -
    >>>  a = gummy(1.2,0.2,utype='A')
    ->>>  b = gummy(3.2,0.5,utype='A')
    ->>>  c = gummy(0.9,0.2,utype='B')
    +
    >>>  a = ummy(1.2,0.2,utype='A')
    +>>>  b = ummy(3.2,0.5,utype='A')
    +>>>  c = ummy(0.9,0.2,utype='B')
     >>>  d = a + b + c
     >>>  d.ufrom('A')
     0.53851648071345048
    @@ -5722,22 +6222,28 @@ 

    Submodules

    metrolopy.unit module

    -

    This module contains the procedures for defining units and unit algebera used -by the gummy class.

    +

    Classes that for handling units are defined here: Conversion, Unit, +_CompositeUnit, one, Quantity and QuantityArray

    class metrolopy.unit.Conversion(unit, factor=1)

    Bases: object

    Represents a unit conversion. This class should only be used as arguments -to Unit object initializers. Each conversion should be associated with one -and only one parent Unit.

    +to Unit object initializers. Each conversion should be associated with +one and only one parent Unit; do not re-use conversion instances with more +than one Unit instance.

    +

    The base Conversion class is defined by a single conversion factor. +More comlicated conversions overriding the to and frm methods should +inherit from the NonlinearConversion subclass and be used with units +that inherit from the NonlinearUnit subclass.

    Parameters
    • unit (str or Unit) – the Unit that the parent Unit will be converted to.

    • factor (float, optional) – The conversion factor between the parent Unit and the new Unit: -[value with new Unit] = factor * [value with parent Unit] -The default value is 1

    • +[value with new Unit] = factor * [value with parent Unit]. The +conversion factor may not have a unit, but may be an ummy of gummy +with not unit one. The default value is 1.

    @@ -5778,25 +6284,199 @@

    Submodules +
    +class metrolopy.unit.Quantity(value, unit=one)
    +

    Bases: metrolopy.printing.PrettyPrinter

    +

    Instances of this class represent a quantity with a value and a unit. +The behavior of Quantity instances under mathematical operations with +other Quanitity object or numerical values depends on the unit. E.g. +an interger of float may be added to Quantity(1,unit=’%’) but not to +Quantity(1,unit=’m/s’). For operations involving only linear units, the +units will be automatically converted to facilitate the operation, e.g. +Quantity(1,unit=’psi’) may be added to Quantity(1,unit=’psi’) but not +Quantity(1,unit=’db(uPa)’. Manual unit conversions can be realized by +calling the `Quantity.convert method, or in place by setting the +Quantity.unit property.

    +

    Quantity instances may be created directly or by multiplying or dividing +a number by a Unit instance: Quantity(2.2,unit=’cm’) is equivalent to +2.2 * unit(‘cm’).

    +
    +
    Parameters
    +
      +
    • value (number like including ummy) – the value of the Quantity

    • +
    • unit (str or Unit) – The Unit instance representing the unit of the Quantity or a string +that references the Unit instance.

    • +
    +
    +
    +
    +
    +property c
    +

    This read-only property is used as a conversion flag during calculations. +When an arithmetic operation is carried out between two Quantaties with +different units, a unit conversion on one of the input quantities may be +required to complete the calculation. Attach this flag to the unit that +you prefer be converted.

    +

    Examples

    +
    >>> a = Quantity(1,unit='cm')
    +>>> b = Quantity(2,unit='mm')
    +>>> a + b
    +1.2 cm
    +>>> a.c + b
    +12 mm
    +>>> a + b.c
    +1.2 cm
    +>>> a*b
    +0.2 cm**2
    +>>>a.c*b
    +20 mm**2
    +
    +
    +
    + +
    +
    +convert(unit)
    +

    Returns a copy of the Quantity with converted units. A +NoUnitConversionFoundError will be raised if the unit conversion is +not possible.

    +
    +
    Parameters
    +
      +
    • unit (str or Unit) – The unit for the x value and if uunit is None, the +uncertainty. It must be string, None, a Unit object, or the +integer 1. Both 1 and None will be interpreted as the Unit +instance one.

    • +
    • uunit `str`, `Unit` or None, optional – The unit for the uncertainty U. If this is None then U +will have the same units as x. The default is None.

    • +
    +
    +
    +
    + +
    +
    +copy(tofloat=False)
    +
    + +
    +
    +property imag
    +
    + +
    +
    +property real
    +
    + +
    +
    +reduce_unit()
    +

    Cancels factors in a Quantity’s unit when possible. This modifies the +calling gummy and returns None.

    +

    Example

    +
    >>> x = Quantity(5,unit='mm/m')
    +>>> x.reduce_unit()
    +>>> x
    +0.005
    +
    +
    +
    + +
    +
    +splonk()
    +

    returns self.value if self.unit is one else returns self

    +
    + +
    +
    +splonk_func_ret = False
    +
    + +
    +
    +tofloat()
    +
    + +
    +
    +tostring(fmt=None, **kwds)
    +
    + +
    +
    +totuple()
    +
    + +
    +
    +property unit
    +

    Gets or sets the unit for the Quantity.

    +

    If this property is set, a unit conversion will be performed. The value +it is set to may be a string, None, a Unit object, or the integer 1. +Both 1 and None will be interpreted as the Unit instance one. A +NoUnitConversionFoundError will be raised if the unit conversion is +not possible.

    +

    Example

    +
    >>> x = Quantity(0.001,unit='V')
    +>>> x
    +0.001 V
    +>>> x.unit = 'uV'
    +>>> x
    +1000.0 uV
    +
    +
    +
    + +
    +
    +property value
    +
    + +

    + +
    +
    +class metrolopy.unit.QuantityArray(value, unit=one)
    +

    Bases: metrolopy.unit.Quantity

    +

    A subclass of Quantity. Instance of this class represent a list, tuple, +or numpy array of values all with the same unit. Elements of the array +are returned as Quantity instances. Instances of this class can be +created directly or by multiplying a list, tuple, or numpy array by a +Unit instance.

    +
    +
    Parameters
    +
      +
    • value (list, tuple or ndarray) – the value of the Quantity

    • +
    • unit (str or Unit) – The Unit instance representing the unit of the Quantity or a string +that references the Unit instance.

    • +
    +
    +
    +
    +
    class metrolopy.unit.Unit(name, symbol, conversion=None, short_name=None, add_symbol=False, html_symbol=None, latex_symbol=None, ascii_symbol=None, description=None, order=-1, **kwds)
    -

    Bases: metrolopy.printing.PrettyPrinter

    +

    Bases: metrolopy.printing.PrettyPrinter, metrolopy.indexed.Indexed

    Creating an instance of this class creates a representation of a physical -unit and adds it to the unit library. Units already in the unit library or -derived units made up of other units in the unit library can be accessed -by passing a text string with the unit name or symbol to the static method -Unit.unit.

    +unit and adds it to the unit library. Once created the unit intance may +be retrived by passing a string with the unit name or alias to the unit +or Unit.unit functions. Units can be multiplied and divided by other +Units or Quantities and raised to numerical powers. Multiplying or +dividing a numerical value by a Unit will create a Quantity instance.

    Parameters
    • name (str) – The name of the unit. The name can be used access the unit with the -Unit.unit method, but note that if you define a Unit with an +unit function, but note that if you define a Unit with an identical name to a previously defined unit then the older name will be shadowed.

    • symbol (str) – A unicode symbol used when displaying the unit. If the add_symbol parameter is set to True, then this symbol can also be used -to access the unit with the Unit.unit method.

    • +to access the unit with the unit function.

    • conversion (Conversion or None, optional) – A conversion to another unit. When creating units be careful to avoid circular conversions, i.e. you can define:

      Unit(‘inch’,’in’,conversion=None) @@ -5816,7 +6496,8 @@

      Submodules -
      -static alias(alias, unit)
      -

      Creates an alias that can be used to reference a Unit.

      -
      -
      Parameters
      -
        -
      • alias (str) – a string containing the new alias

      • -
      • unit (str or Unit) – A string referencing the Unit that will be assigned -the alias or the Unit instance its self.

      • -
      -
      -
      -

    - -
    -
    -property aliases
    -

    read-only

    -

    Returns a set of the unshadowed aliases of this unit. To add aliases -to the unit use the Unit.alias static method.

    -
    -
    property conversion
    @@ -5875,9 +6533,7 @@

    Submodules
    convert(g, unit)
    -

    Converts a number or gummy from a quanitity with the units self to unit.

    -

    This is not intended be used directly, instead use the gummy.convert -method.

    +

    Converts a number from a quantity with the units self to unit.

    @@ -5889,19 +6545,20 @@

    Submodules property is_dimensionless

    bool, read-only

    -

    Returns True if a conversion exists between self and one, and False -if not.

    +

    Returns True if a conversion exists between self and one, and +False if not.

    -
    -
    -linear = True
    -
    -
    -
    -static load(library_name)
    -
    +
    +property linear
    +

    Gets a bool value indicating whether the Unit is linear. If the +unit is linear then any associated values will follow the standard +rules of arithmatic for Quantaties and the unit’s Conversion is +defined by multiplying or dividing by a single conversion factor. +Nonlinear units may have a more complicated conversion and may +override the unusal operator methods.

    +
    @@ -5920,30 +6577,14 @@

    Submodules -
    -property shadowed_aliases
    -

    read-only

    -

    Returns a set of the shadowed aliases of this unit.

    -

    - -
    -
    -tostring(fmt=None, **kwds)
    -

    Returns a string containing the symbol for the unit the format given by -the keyword fmt which may be set to a string the values ‘html’, ‘latex’, -‘ascii’, or ‘unicode’.

    -
    -
    static unit(txt, exception=True)
    -

    Finds an returns a Unit object from the Unit library.

    +

    Finds an returns a Unit from the unit library.

    Parameters
    @@ -5978,6 +6625,45 @@

    Submodules +
    +metrolopy.unit.unit(name, exception=True)
    +

    Finds an returns a Unit from the unit library. This function is an +alias for the Unit.unit static method.

    +
    +
    Parameters
    +
      +
    • txt (str, Unit or 1) – This may be a string representing the unit. The string can +contain the name, short name or (if the unit was created +with add_symbol set to True) the symbol of the unit or a +combination of names and/or symbols of several different +units. Spaces or the character ‘*’ represent multiplication, +the character ‘/’ represents division and the string ‘**’ +represents the power operator. For example txt can be:

      +

      ‘kg m**2/s’

      +

      or equivalently:

      +

      ‘kilogram*metre*metre*second**-1’ or ‘(kg/s)*m**2’.

      +

      If a unit name contains a space, ‘*’ or ‘/’ character then the +name must be enclosed in square brackets, e.g:

      +

      [light year]

      +

      If txt is a Unit instance that instance is returned.

      +
    • +
    • exception (bool, optional) – If this is True then a UnitNotFoundError or UnitLibError +is raised if a unit is not found that matches txt. If it is +False and a unit is not found, then Unit.unit returns +None without raising an exception. The default is True.

    • +
    +
    +
    Returns
    +

      +
    • A Unit instance or possibly None if the exception parameter is

    • +
    • set to True.

    • +
    +

    +
    +
    +

    +

    metrolopy.unitutils module

    @@ -6121,7 +6807,7 @@

    Navigation

  • modules |
  • - +
    @@ -97,7 +97,7 @@

    Navigation

  • modules |
  • - + @@ -113,7 +113,7 @@

    Navigation

  • modules |
  • - + @@ -204,7 +204,7 @@

    Navigation

  • modules |
  • - + @@ -80,7 +80,7 @@

    Navigation

  • modules |
  • - + @@ -77,7 +77,7 @@

    Navigation

  • modules |
  • - +