Skip to content

Commit 10a2538

Browse files
authored
Merge pull request #101 from manthey/numpy-2
Support numpy >= 2.x on Python >= 3.8
2 parents 39dc8a7 + 9cfbe00 commit 10a2538

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/dicomweb_client/file.py

Lines changed: 7 additions & 2 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 = getattr(math, 'prod', np.prod)
572+
568573
self._attributes = {
569574
_QueryResourceType.STUDIES: self._get_attributes(
570575
_QueryResourceType.STUDIES
@@ -857,7 +862,7 @@ def _update_db(self):
857862
getattr(ds, 'NumberOfFrames', '1')
858863
),
859864
number_of_pixels_per_frame=int(
860-
np.prod([
865+
self._prod([ # type: ignore
861866
ds.Rows,
862867
ds.Columns,
863868
ds.SamplesPerPixel,
@@ -2027,7 +2032,7 @@ def insert_instances(
20272032
getattr(ds, 'NumberOfFrames', '1')
20282033
),
20292034
number_of_pixels_per_frame=int(
2030-
np.prod([
2035+
self._prod([ # type: ignore
20312036
ds.Rows,
20322037
ds.Columns,
20332038
ds.SamplesPerPixel

0 commit comments

Comments
 (0)