Skip to content

Commit 65bcc79

Browse files
committed
updated the for loop a little inside _get_best_grid_type
1 parent df03e8b commit 65bcc79

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

gridData/OpenVDB.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,26 +246,33 @@ def _get_best_grid_type(self):
246246
except KeyError:
247247
raise TypeError(f"Data type {self.grid.dtype} not supported for VDB")
248248

249-
for gridtype_downcast in vdb_gridtypes:
250-
if isinstance(gridtype_downcast, DownCastTo):
251-
gridtype = gridtype_downcast.gridType
249+
VDB_Grid = None
250+
selected_gridtype = None
251+
is_downcast = False
252+
253+
for gridtype in vdb_gridtypes:
254+
if isinstance(gridtype, DownCastTo):
255+
gridtype_name = gridtype.gridType
256+
is_downcast = True
252257
else:
253-
gridtype = gridtype_downcast
258+
gridtype_name = gridtype
259+
is_downcast = False
254260

255261
try:
256-
VDB_Grid = getattr(vdb, gridtype)
262+
VDB_Grid = getattr(vdb, gridtype_name)
257263
except AttributeError:
258264
continue
259265
else:
266+
selected_gridtype = gridtype_name
260267
break
261268
else:
262269
raise TypeError(
263270
f"Could not find any VDB grid type for numpy dtype {self.grid.dtype}"
264271
)
265272

266-
if isinstance(gridtype_downcast, DownCastTo):
273+
if is_downcast:
267274
warnings.warn(
268-
f"Grid type {vdb_gridtypes[0]} not available. Using {gridtype} instead. Data may lose precision.",
275+
f"Grid type {vdb_gridtypes[0]} not available. Using {selected_gridtype} instead. Data may lose precision.",
269276
RuntimeWarning,
270277
)
271278
return VDB_Grid()

0 commit comments

Comments
 (0)