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 deprecated/removed numpy attribute asscalar. #281

Open
bnubald opened this issue Mar 9, 2023 · 0 comments · Fixed by #282
Open

Fix deprecated/removed numpy attribute asscalar. #281

bnubald opened this issue Mar 9, 2023 · 0 comments · Fixed by #282
Labels
Milestone

Comments

@bnubald
Copy link
Member

bnubald commented Mar 9, 2023

On newer versions of numpy, the attribute asscalar has been deprecated (in version 1.16) and removed as of version 1.23.

Older versions will trigger the following error:

AttributeError: module 'numpy' has no attribute 'asscalar'

Solution should be to switch to numpy.ndarray.item() instead.


Lines to fix:

objective = lambda x: k*np.asscalar(f(x))

constraint = lambda x: np.asscalar(g(x))

self.f_old = np.asscalar(self.f[ind_min])

return np.asscalar(f)

res = optimize.minimize(lambda x: np.asscalar(my_poly.get_polyfit(x)), self.s_old, method='TNC', \

res = optimize.minimize(lambda x: np.asscalar(my_poly.get_polyfit(np.dot(x,self.U))), self.s_old, \

del_m = np.asscalar(my_poly.get_polyfit(self.s_old)) - m_new

del_m = np.asscalar(my_poly.get_polyfit(np.dot(self.s_old,self.U))) - m_new

fe = 0.5*(np.asscalar(np.dot(r.T,r)) - epsilon**2)

cqe = np.asscalar(np.dot(r.T,r)) - epsilon**2

dV[:,l,:,j] = np.asscalar(vectord[l])*(X.T*current[:,j])

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

Successfully merging a pull request may close this issue.

1 participant