@@ -584,6 +584,10 @@ def __init__(
584584 end = time .time ()
585585 elapsed = round (end - start )
586586 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
587591
588592 def __getstate__ (self ) -> dict :
589593 """Customize state for serialization via pickle module.
@@ -857,12 +861,11 @@ def _update_db(self):
857861 getattr (ds , 'NumberOfFrames' , '1' )
858862 ),
859863 number_of_pixels_per_frame = int (
860- (math .prod # type: ignore
861- if hasattr (math , 'prod' ) else np .prod )([
864+ self ._prod ([ # type: ignore
862865 ds .Rows ,
863866 ds .Columns ,
864867 ds .SamplesPerPixel ,
865- ])
868+ ])
866869 ),
867870 transfer_syntax_uid = transfer_syntax_uid ,
868871 bits_allocated = ds .BitsAllocated
@@ -2028,12 +2031,11 @@ def insert_instances(
20282031 getattr (ds , 'NumberOfFrames' , '1' )
20292032 ),
20302033 number_of_pixels_per_frame = int (
2031- (math .prod # type: ignore
2032- if hasattr (math , 'prod' ) else np .prod )([
2034+ self ._prod ([ # type: ignore
20332035 ds .Rows ,
20342036 ds .Columns ,
20352037 ds .SamplesPerPixel
2036- ])
2038+ ])
20372039 ),
20382040 transfer_syntax_uid = ds .file_meta .TransferSyntaxUID ,
20392041 bits_allocated = ds .BitsAllocated
0 commit comments