Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integer to a power bug #10

Merged
merged 9 commits into from
May 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix interger to a power bug
Uncertainty was incorrectly calculated when an integer was raised to a power where the power had some uncertainty.
  • Loading branch information
hvparks committed May 7, 2020
commit 30040faee04ed079e0fab9693312be5aa3d0d683
24 changes: 16 additions & 8 deletions metrolopy/ummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,10 +958,14 @@ def _pow(self,b):
x = self._x**b._x
dua = b._x*self._x**(b._x-1)*self._u
lgx = log(self._x)
try:
lgx = type(self._x)(lgx)
except:
pass

# don't exactly remember why I did this,
# but it causes problems if x is int.
#try:
#lgx = type(self._x)(lgx)
#except:
#pass

dub = lgx*self._x**b._x*b._u
u = _combu(dua,dub,c)

Expand Down Expand Up @@ -1002,10 +1006,14 @@ def _rpow(self,b):
raise ValueError('a negative number cannot raised to a power which has an uncertainty')

lgb = log(b)
try:
lgb = type(b)(lgb)
except:
pass

# don't exactly remember why I did this,
# but it causes problems if x is int.
#try:
#lgb = type(b)(lgb)
#except:
#pass

u = abs(b**self._x*lgb*self._u)
refs = -self._refs if b < 0 else self._refs
return type(self)(x,u,dof=self._ref,utype=refs)
Expand Down