Skip to content

Commit bfaa984

Browse files
authored
Apply suggestions from code review
1 parent 1ed2b6c commit bfaa984

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

nibabel/volumeutils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from functools import reduce
1717
from operator import getitem, mul
1818
from os.path import exists, splitext
19-
from typing import Any
2019

2120
import 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()

0 commit comments

Comments
 (0)