Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead #104

Open
JensBloemer opened this issue Mar 13, 2020 · 5 comments

Comments

@JensBloemer
Copy link

Hi Greg,

color_diff.py uses numpy.asscalar(), could this be changed to using numpy.ndarray.item() to be able using Numpy >= 1.16 without warnings or 1.18.1 without errors?
Thanks in advance, best regards
Jens

@JensBloemer
Copy link
Author

Ah, sorry, just saw it's already fixed in the code... is there any release planned soonish?

@DarLador
Copy link

I'm having the same issue. With Numpy 1.16.5 I'm getting this warning:
DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead 'a.item() instead', DeprecationWarning, stacklevel=1)

@aleferna12
Copy link

aleferna12 commented Aug 4, 2022

Since the release of numpy 1.23 has officially removed asscalar, I think this thread became relevant again.

Now colormath is no longer compatible with the latest version of numpy. The issue is fixed already, maybe its time to roll a new release?

A package of mine depends on colormath and builds are no longer passing. I'm going to downgrade numpy requirements, but it would be lovely to see this issue fixed with a minor 3.0.1 release!

@jbh2155
Copy link

jbh2155 commented Sep 2, 2022

I'm having the same issue as @DarLador. I agree with @aleferna12 that it would be awesome not to have to downgrade to a previous numpy version. Thanks in advance!

@Tasse00
Copy link

Tasse00 commented Sep 15, 2022

temporary solution, this worked for my case

import numpy

def patch_asscalar(a):
    return a.item()

setattr(numpy, "asscalar", patch_asscalar)

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

No branches or pull requests

5 participants