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

Error in estimating error of (a**x) #7

Open
Codeprey opened this issue Dec 11, 2023 · 1 comment
Open

Error in estimating error of (a**x) #7

Codeprey opened this issue Dec 11, 2023 · 1 comment

Comments

@Codeprey
Copy link

Hello,
I am trying to estimate the error of a formula, and the code goes to a dead loop.
After some attempts I find the problem lies in the (a**x) like formula, which belongs to 'rpow' type.

A simple example for a dead loop is like:

alpha=N(20,1)
10**alpha
Traceback (most recent call last):
File "", line 1, in
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
(984 loops skipped...)
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/soerp/init.py", line 426, in rpow
return _make_UF_compatible_object(ADF.rpow(self, val))
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 787, in rpow
return to_auto_diff(val)**self
File "/opt/anaconda3/lib/python3.7/site-packages/ad/init.py", line 39, in to_auto_diff
if isinstance(x, ADF):
RecursionError: maximum recursion depth exceeded while calling a Python object

In soerp/init.py:
def rpow(self, val):
return _make_UF_compatible_object(ADF.rpow(self, val))

In ad/init.py:
def rpow(self,val):
return to_auto_diff(val)**self

Please solve this problem, thanks!

Sincerely,
Peter

@Codeprey
Copy link
Author

Also a small fix in soerp/umath/umath.py:

line 163-165:

def pow(x):
return _make_UF_compatible_object(admath.pow(x))
all.append('pow')

It should be
def pow(x,y):
return _make_UF_compatible_object(admath.pow(x,y))
all.append('pow')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant