Coverage for kwave/utils/datautils.py: 27%

1 import numpy as np

2

3

4 def get_smallest_possible_type(max_array_val, target_type_group, default=None):

5 types = {'uint', 'int'}

6 assert target_type_group in types

7

8 for bit_count in [8, 16, 32]:

9 type_ = f'{target_type_group}{bit_count}'

10 if max_array_val < intmax(type_):

11 return type_

12

13 return default

14

15

16 def intmax(dtype: str):

17 return np.iinfo(getattr(np, dtype)).max