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

Numpy 2.0 compatibility #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jvansanten
Copy link
Contributor

search_htm_ind caches the name of the index file and its contents in the same global dictionary, and checks whether the dictionary values contain a particular key. Since those values include the actual index contents, this compares the key to the index contents, which is a numpy array. On Numpy 1.2, this raised a warning and returned False:

/apps/catalogmatch/venv/lib/python3.9/site-packages/catsHTM/script.py:286: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if VarName not in list(d.values()):

With Numpy 2.0, however, this is a hard error:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

This PR replaces the global dictionary with a caching decorator, making the code simpler, faster, and compatible with Numpy 2.0.

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.

1 participant