Skip to content

Numpy 2.0 compatibility#6

Open
jvansanten wants to merge 2 commits into
maayane:masterfrom
AmpelAstro:index-cache
Open

Numpy 2.0 compatibility#6
jvansanten wants to merge 2 commits into
maayane:masterfrom
AmpelAstro:index-cache

Conversation

@jvansanten

Copy link
Copy Markdown
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