You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the output is not an object array it is an array of UTPM
I'm not sure what's going on in this issue, but it shows some confusion about object arrays. In your example, the rhs array has dtype=object so it's an object array.
For some reason, the outer UTPM container of x is being treated as an iterable, so NumPy is calling utpm.sin on each item, and creating an object array of UTPM.
Calling using UTPM.sin methods seems to fix the problem.
importnumpyasnpfromalgopyimportUTPM, zeros, sin, cosimportnumdifftools.nd_algopyasndaimportnumdifftoolsasnddeff(x):
nobs=x.shape[1:]
f0=x[0]**2*sin(x[1])**2# use UTPM version of sinf1=x[0]**2*cos(x[1])**2# use UTPM version of sinout=zeros((2,) +nobs, dtype=x)
out[0,:] =f0out[1,:] =f1returnoutx=np.array([(1, 2, 3, 4), (5, 6, 7, 8)], dtype=float)
y=f(x)
xj=UTPM.init_jacobian(x)
j=UTPM.extract_jacobian(f(xj))
But it would be awesome if AlgoPy could be used without having to change the code. It should be possible to use UTPM.as_utpm() to fix this before doing other operations.
Given the example:
returns this traceback
but the output is not an object array it is an array of UTPM, which has gotten unpacked somehow:
So I need to figure out how to monkey patch algorithms.py to keep these together.
The text was updated successfully, but these errors were encountered: