Skip to content

Commit

Permalink
Change when we determine if math has prod
Browse files Browse the repository at this point in the history
This needs to be done before we try to compute a prod.
  • Loading branch information
manthey committed Oct 16, 2024
1 parent 0049c69 commit 1076427
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/dicomweb_client/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ def __init__(

self._create_db()

# numpy 2 no longer has prod, but Python >= 3.8 does. We either have
# one or the other, so use the python math.prod method when available
# and fall abck to np if not.
self._prod = math.prod if hasattr(math, 'prod') else np.prod

self._attributes = {
_QueryResourceType.STUDIES: self._get_attributes(
_QueryResourceType.STUDIES
Expand All @@ -584,10 +589,6 @@ def __init__(
end = time.time()
elapsed = round(end - start)
logger.info(f'updated database in {elapsed} seconds')
# numpy 2 no longer has prod, but Python >= 3.8 does. We either have
# one or the other, so use the python math.prod method when available
# and fall abck to np if not.
self._prod = math.prod if hasattr(math, 'prod') else np.prod

def __getstate__(self) -> dict:
"""Customize state for serialization via pickle module.
Expand Down

0 comments on commit 1076427

Please sign in to comment.