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: Deprecation of numpy.typeDict #94

Merged
merged 1 commit into from Jun 11, 2022
Merged

Conversation

NiMlr
Copy link
Member

@NiMlr NiMlr commented Mar 27, 2022

This PR addresses #92.

The proposed alternative numpy.sctypeDict seems to be discouraged in numpy/numpy#17585.

Based on our relatively shallow current usage of numpy.typeDict:

_UNSAFE_DTYPES = [numx.typeDict[d] for d in

I propose to replace numpy.typeDict[d] by the generic numpy.dtype(d).type as:

# excluded the invalid inputs; see below
>>> [numpy.typeDict[d]==numpy.dtype(d).type for d in ['float16', 'float128', 'complex256']]
# [True, True, True]

This change to a function (as opposed to dictionary) has the downside of having to exclude the check:

if d in numx.typeDict]

However, we learn that exactly 2 of the current 5 checks will return false in the most recent release of numpy as of 03/27/22:

>>> 'float96' in numpy.typeDict or 'complex192' in numpy.typeDict
# False
>>> 'float16' in numpy.typeDict and 'float128' in numpy.typeDict and 'complex256' in numpy.typeDict
# True
>>> numpy.__version__
# '1.22.3'

I excluded the invalid ones and dropped the check. I think it is likely this will not create problems down the line.

General note:
I am not sure the functionality of checking for unsafe types generically is still up-to-date. Especially as it is only run if one is not using scipy.linalg.eigh:

if (_safe and not mdp.config.has_symeig == 'scipy.linalg.eigh'

@Stewori
Copy link
Member

Stewori commented Jun 11, 2022

Since this passes local tests and given that #95 requires it to pass, I will merge this now.

@Stewori Stewori merged commit ab3bd10 into mdp-toolkit:master Jun 11, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants