Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hvparks committed Jul 10, 2021
1 parent 2647062 commit 109256d
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 11 deletions.
Binary file modified dist/metrolopy-0.6.2-py3-none-any.whl
Binary file not shown.
Binary file modified dist/metrolopy-0.6.2.tar.gz
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/metrolopy.tests.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ version history
* Verison 0.6.0, built 19 October 2020, added the `Quantity` and `immy` classes
as well as a library of physical constants.
* Version 0.6.1 built 19 October 2020, bug fixes
* Version 0.6.1 built 10 July 2021, bug fixes
* Version 0.6.2 built 10 July 2021, bug fixes


author
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h2>version history<a class="headerlink" href="#version-history" title="Permalin
<li><p>Verison 0.6.0, built 19 October 2020, added the <cite>Quantity</cite> and <cite>immy</cite> classes
as well as a library of physical constants.</p></li>
<li><p>Version 0.6.1 built 19 October 2020, bug fixes</p></li>
<li><p>Version 0.6.1 built 10 July 2021, bug fixes</p></li>
<li><p>Version 0.6.2 built 10 July 2021, bug fixes</p></li>
</ul>
</section>
<section id="author">
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ version history
* Verison 0.6.0, built 19 October 2020, added the `Quantity` and `immy` classes
as well as a library of physical constants.
* Version 0.6.1 built 19 October 2020, bug fixes
* Version 0.6.1 built 10 July 2021, bug fixes
* Version 0.6.2 built 10 July 2021, bug fixes


author
Expand Down
51 changes: 51 additions & 0 deletions metrolopy/gummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,58 @@ def covariance_matrix(gummys):
return [[b.covariance(a) if isinstance(b,ummy) else 0
for b in m] for a in m]

def correlation_sim(self,gummy):
"""
Returns the correlation coefficient, calculated from Monte-Carlo data,
between the owning gummy and the gummy `g`.
See the method `gummy.correlation(g)` for the corresponding result based
on first order error propagation.
"""
if isinstance(gummy,Quantity):
gummy = gummy.value
return self.value.correlation_sim(gummy)

def covariance_sim(self,gummy):
"""
Returns the covariance, calculated from Monte-Carlo data, between the
owning gummy and the gummy `g.`
See the method `gummy.covariance(g)` for the corresponding result based
on first order error propagation.
"""
if isinstance(gummy,Quantity):
gummy = gummy.value
return self.value.covariance_sim(gummy)

@staticmethod
def correlation_matrix_sim(gummys):
"""
The staticmethod takes a list of gummys an returns the correlation
matrix calculated from Monte-Carlo data. The return value is numpy
ndarray.
See the method `gummy.correlation_matrix(gummys)` for the corresponding
result based on first order error propagation.
"""
m = [g.value if isinstance(g,Quantity) else g for g in gummys]
return [[b.correlation_sim(a) if isinstance(b,nummy) else 0
for b in m] for a in m]

@staticmethod
def covariance_matrix_sim(gummys):
"""
The staticmethod takes a list of gummys an returns the variance-covariance
matrix calculated from Monte-Carlo data. The return value is numpy
ndarray.
See the method gummy.covariance_matrix(gummys) for the corresponding
result based on first order error propagation.
"""
m = [g.value if isinstance(g,Quantity) else g for g in gummys]
return [[b.covariance_sim(a) if isinstance(b,nummy) else 0
for b in m] for a in m]

@property
def finfo(self):
return self.value.finfo
Expand Down
14 changes: 7 additions & 7 deletions metrolopy/logunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,38 +108,38 @@ def zero(self):

def _add(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())
if bunit is not self:
raise IncompatibleUnitsError('a quantity with unit ' + self.tostring() + ' may not be added to a quantity with unit ' + bunit.tostring() + '; automatic conversion is disabled with LogUnit instances')
return (a + b,self)

def _radd(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if bunit is not self:
raise IncompatibleUnitsError('a quantity with unit ' + self.tostring() + ' may not be added to a quantity with unit ' + bunit.tostring() + '; automatic conversion is disabled with LogUnit instances')
return (b + a,self)

def _sub(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if bunit is not self:
raise IncompatibleUnitsError('a quantity with unit ' + bunit.tostring() + ' may not be subtracted from a quantity with unit ' + self.tostring() + '; automatic conversion is disabled with LogUnit instances')
return (a - b,self)

def _rsub(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if bunit is not self:
raise IncompatibleUnitsError('a quantity with unit ' + self.tostring() + ' may not be subtracted from a quantity with unit ' + bunit.tostring() + '; automatic conversion is disabled with LogUnit instances')
return (a + b,self)

def _mul(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if not bunit.linear:
raise IncompatibleUnitsError('only quantities with linear units may multiply or divide a quanity with unit ' + self.tostring())
Expand All @@ -153,7 +153,7 @@ def _mul(self,a,bunit,b,aconv):

def _rmul(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if not bunit.linear:
raise IncompatibleUnitsError('only quantities with linear units may multiply or divide a quanity with unit ' + self.tostring())
Expand All @@ -167,7 +167,7 @@ def _rmul(self,a,bunit,b,aconv):

def _truediv(self,a,bunit,b,aconv):
if self.conversion._dim:
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring)
raise IncompatibleUnitsError('operation not allowed with unit ' + self.tostring())

if not bunit.linear:
raise IncompatibleUnitsError('only quantities with linear units may multiply or divide a quanity with unit ' + self.tostring())
Expand Down
2 changes: 1 addition & 1 deletion metrolopy/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_gummy_init(n=None,exception_on_warning=True,prnt=False,plot=False):
else:
assert abs(g.x - x) < 1e-10

if unit is 'degF':
if unit == 'degF':
assert g.unit in [uc.Unit.unit('degF'),uc.Unit.unit('degF-i')]
else:
assert g.unit is uc.Unit.unit(unit)
Expand Down

0 comments on commit 109256d

Please sign in to comment.