AutoDiff
AutoDiff copied to clipboard
numpy.product deprecated in v 1.25
The numpy.product function was deprecated in v 1.25 and in the docs. I'm using python 2.1.3 and if I run the example:
import auto_diff
import numpy as np
# Define a function f
# f can have other arguments, if they are constant wrt x
# Define the input vector, x
def f(x,):
return x*x
x = [[10.0]]
with auto_diff.AutoDiff(x) as xr:
f_eval = f(xr,)
y, Jf = auto_diff.get_value_and_jacobian(f_eval)
I get this error
AttributeError Traceback (most recent call last)
Cell In[43], line 7
4 x = [[10.0]]
6 with auto_diff.AutoDiff(x) as xr:
----> 7 f_eval = f(xr,)
8 y, Jf = auto_diff.get_value_and_jacobian(f_eval)
Cell In[43], line 2, in f(x)
1 def f(x,):
----> 2 return x*x
File /opt/venv/lib/python3.11/site-packages/numpy/lib/mixins.py:23, in _binary_method.<locals>.func(self, other)
21 if _disables_array_ufunc(other):
22 return NotImplemented
---> 23 return ufunc(self, other)
File /opt/venv/lib/python3.11/site-packages/auto_diff/vecvalder.py:62, in VecValDer.__array_ufunc__(self, ufunc, method, *args, **kwargs)
60 def __array_ufunc__(self, ufunc, method, *args, **kwargs):
61 if method == '__call__' and ufunc in _HANDLED_FUNCS_AND_UFUNCS:
---> 62 return _HANDLED_FUNCS_AND_UFUNCS[ufunc](*args, **kwargs)
63 else:
64 return NotImplemented
File /opt/venv/lib/python3.11/site-packages/auto_diff/vecvalder_funcs_and_ufuncs.py:87, in _add_out_support.<locals>.fn_with_out(out, where, *args, **kwargs)
84 raise RuntimeError("""Unknown type passed as out parameter.""")
85 #Please email [email protected] with sample code.""")
---> 87 return fn(*args, out=out, **kwargs)
File /opt/venv/lib/python3.11/site-packages/auto_diff/vecvalder_funcs_and_ufuncs.py:342, in multiply(x1, x2, out)
339 idx_iterator = _ndindex(out.val.shape)
341 if isinstance(x1, cls) and isinstance(x2, cls):
--> 342 for idx, (x1_elem, x2_elem) in zip(idx_iterator, broadcast_obj):
343 out.val[idx] = x1_elem.val * x2_elem.val
344 out.der[idx] = x1_elem.der * x2_elem.val + x1_elem.val * x2_elem.der
File /opt/venv/lib/python3.11/site-packages/auto_diff/vecvalder_funcs_and_ufuncs.py:14, in _ndindex(shape)
12 state = [0 for _ in shape]
13 total = 0
---> 14 stop_condition = np.product(shape)
15 while total < stop_condition:
16 total += 1
AttributeError: module 'auto_diff.true_np' has no attribute 'product'