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 16
16
from functools import reduce
17
17
from operator import getitem , mul
18
18
from os .path import exists , splitext
19
- from typing import Any
20
19
21
20
import numpy as np
22
21
@@ -1366,7 +1365,7 @@ def shape_zoom_affine(
1366
1365
return aff
1367
1366
1368
1367
1369
- def rec2dict (rec : np .ndarray ) -> dict [str , Any ]:
1368
+ def rec2dict (rec : np .record ) -> dict [str , np . generic | np . ndarray ]:
1370
1369
"""Convert recarray to dictionary
1371
1370
1372
1371
Also converts scalar values to scalars
@@ -1388,10 +1387,8 @@ def rec2dict(rec: np.ndarray) -> dict[str, Any]:
1388
1387
>>> d == {'x': 0, 's': b''}
1389
1388
True
1390
1389
"""
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 ():
1395
1392
val = rec [key ]
1396
1393
try :
1397
1394
val = val .item ()
You can’t perform that action at this time.
0 commit comments