Uses features of newer numpy-versions without warning.
julian-goettingen opened this issue · comments
Describe the bug
The comparison for array-equality ueses 'equal_nan'-keyword without checking if it is available.
To Reproduce
use an older numpy-version, I have 1.16.6
>>> from deepdiff import DeepDiff
>>> import numpy as np
>>> DeepDiff(np.array([1,2,3]),np.array([1,3,2]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\user\code\agd_py\venv\lib\site-packages\deepdiff\diff.py", line 308, in __init__
self._diff(root, parents_ids=frozenset({id(t1)}), _original_type=_original_type)
File "C:\user\code\agd_py\venv\lib\site-packages\deepdiff\diff.py", line 1552, in _diff
self._diff_numpy_array(level, parents_ids, local_tree=local_tree)
File "C:\user\code\agd_py\venv\lib\site-packages\deepdiff\diff.py", line 1387, in _diff_numpy_array
if np.array_equal(level.t1, level.t2, equal_nan=self.ignore_nan_inequality):
TypeError: array_equal() got an unexpected keyword argument 'equal_nan'
Expected behavior
I do not expect you to maintain fallbacks for old optional dependencies, but it would be very cool if you would check if numpy.__version__
is new enough and print a warning if it is not.
OS, DeepDiff version and Python version (please complete the following information):
- OS: windows
- Version 10
- Python Version 3.7.9
- DeepDiff Version 6.3.1
- numpy version 1.16.6
Additional context
The error does not appear when using your requirements-dev as that installs a newer numpy. But when installing DeepDiff from pip like most users will, pip does not enforce any version of numpy, so it is easily possible to end up with an incompatible numpy and DeepDiff.
@julian-goettingen Thanks for reporting the issue. Good idea, we will make it check if Numpy is too old. Seems like it was added in Numpy 1.19.0.