File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 1616from functools import reduce
1717from operator import getitem , mul
1818from os .path import exists , splitext
19- from typing import Any
2019
2120import numpy as np
2221
@@ -1366,7 +1365,7 @@ def shape_zoom_affine(
13661365 return aff
13671366
13681367
1369- def rec2dict (rec : np .ndarray ) -> dict [str , Any ]:
1368+ def rec2dict (rec : np .record ) -> dict [str , np . generic | np . ndarray ]:
13701369 """Convert recarray to dictionary
13711370
13721371 Also converts scalar values to scalars
@@ -1388,10 +1387,8 @@ def rec2dict(rec: np.ndarray) -> dict[str, Any]:
13881387 >>> d == {'x': 0, 's': b''}
13891388 True
13901389 """
1391- dct : dict [str , Any ] = {}
1392- if rec .dtype .fields is None :
1393- return dct
1394- for key in rec .dtype .fields :
1390+ dct = {}
1391+ for key in rec .dtype .fields or ():
13951392 val = rec [key ]
13961393 try :
13971394 val = val .item ()
You can’t perform that action at this time.
0 commit comments