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

Uses features of newer numpy-versions without warning. #405

Closed
julian-goettingen opened this issue Jul 7, 2023 · 1 comment
Closed

Uses features of newer numpy-versions without warning. #405

julian-goettingen opened this issue Jul 7, 2023 · 1 comment
Assignees

Comments

@julian-goettingen
Copy link

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.

@seperman
Copy link
Owner

@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.

@seperman seperman self-assigned this Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants