Skip to content

Commit

Permalink
Merge pull request #101 from manthey/numpy-2
Browse files Browse the repository at this point in the history
Support numpy >= 2.x on Python >= 3.8
  • Loading branch information
pieper authored Oct 16, 2024
2 parents 39dc8a7 + 9cfbe00 commit 10a2538
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 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 = getattr(math, 'prod', np.prod)

self._attributes = {
_QueryResourceType.STUDIES: self._get_attributes(
_QueryResourceType.STUDIES
Expand Down Expand Up @@ -857,7 +862,7 @@ def _update_db(self):
getattr(ds, 'NumberOfFrames', '1')
),
number_of_pixels_per_frame=int(
np.prod([
self._prod([ # type: ignore
ds.Rows,
ds.Columns,
ds.SamplesPerPixel,
Expand Down Expand Up @@ -2027,7 +2032,7 @@ def insert_instances(
getattr(ds, 'NumberOfFrames', '1')
),
number_of_pixels_per_frame=int(
np.prod([
self._prod([ # type: ignore
ds.Rows,
ds.Columns,
ds.SamplesPerPixel
Expand Down

0 comments on commit 10a2538

Please sign in to comment.