feature: handle Numpy type deprecation & backwards compatibility#8
feature: handle Numpy type deprecation & backwards compatibility#8hmallen merged 3 commits intohmallen:masterfrom ns-rse:ns-rse/numpy_complex_deprecation
Conversation
Closes #7 Detects Numpy version on the fly and sets the types for `float` and `complex` conditional on whether `np.__version__ < "2.0.0"`. Includes a warning advising users to consider updating them if using an old version of Numpy. No idea if this is a sensible way of approaching such issues so happy to be advised/guided on better ways of handling such issues.
hmallen
left a comment
There was a problem hiding this comment.
Really appreciate the compatibility update. Looks great.
Quick suggestion: For comparing version numbers, you can use the packaging library’s parse_version function instead of just comparing strings. It handles weird cases like pre-releases (for example, "2.0.0rc1") better. For example:
from packaging.version import parse as parse_version
if parse_version(np.__version__) < parse_version("2.0.0"):
# old types
else:
# new typesTotally up to you if you want to add it here. I'm happy to merge and make a follow-up change.
Thanks again!
ns-rse
left a comment
There was a problem hiding this comment.
Adding suggested parse_version() option.
Thanks @hmallen I wasn't even aware of that library/function but it makes total sense as I hadn't thought about release candidate versions and how they would be handled. (Lazily) I've committed the suggestions via the PR. |
Thanks a lot for the help! Will merge the changes. |
The fix I submitted [upstream](hmallen/numpyencoder#8) to detect the Numpy version being used and handle type deprecation whilst providing backwards compatibility has now been merged. We can therefore revert to using upstream PyPI released version of `numpyencoder` and remove the use of the forked [AFM-SPM-numpyencoder](https://github.com/AFM-SPM/numpyencoder) version where the same fix had been applied. This in turn means that releases to PyPI will work again (as you can't release to PyPI when you have dependencies that come from Git repos).
|
Sorry for missing this, I see it was merged and you've subsequently addressed the required install and migrated to |
No worries, thanks again for your help along the way. |
Closes #7
Detects Numpy version on the fly and sets the types for
floatandcomplexconditional on whethernp.__version__ < "2.0.0".Includes a warning advising users to consider updating them if using an old version of Numpy.
No idea if this is a sensible way of approaching such issues so happy to be advised/guided on better ways of handling such issues.