Skip to content

Commit 1076427

Browse files
committed
Change when we determine if math has prod
This needs to be done before we try to compute a prod.
1 parent 0049c69 commit 1076427

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/dicomweb_client/file.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ def __init__(
565565

566566
self._create_db()
567567

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

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

0 commit comments

Comments
 (0)