Skip to content

Commit df03e8b

Browse files
committed
updated test_vdb.py and OpenVDB.py
1 parent 0231a44 commit df03e8b

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

gridData/OpenVDB.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ def _get_best_grid_type(self):
228228
"""
229229
datatypes = {
230230
numpy.dtype("bool"): ["BoolGrid"],
231-
numpy.dtype("int8"): [DownCastTo("Int32Grid"), DownCastTo("FloatGrid")],
232-
numpy.dtype("uint8"): [DownCastTo("Int32Grid"), DownCastTo("FloatGrid")],
233-
numpy.dtype("int16"): [DownCastTo("Int32Grid"), DownCastTo("FloatGrid")],
234-
numpy.dtype("uint16"): [DownCastTo("Int32Grid"), DownCastTo("FloatGrid")],
231+
numpy.dtype("int8"): ["Int32Grid", "FloatGrid"],
232+
numpy.dtype("uint8"): ["Int32Grid", "FloatGrid"],
233+
numpy.dtype("int16"): ["Int32Grid", "FloatGrid"],
234+
numpy.dtype("uint16"): ["Int32Grid", "FloatGrid"],
235235
numpy.dtype("int32"): ["Int32Grid", DownCastTo("FloatGrid")],
236-
numpy.dtype("uint32"): ["Int32Grid", DownCastTo("FloatGrid")],
236+
numpy.dtype("uint32"): [DownCastTo("Int32Grid"), DownCastTo("FloatGrid")],
237237
numpy.dtype("int64"): ["Int64Grid", DownCastTo("FloatGrid")],
238238
numpy.dtype("uint64"): ["Int64Grid", DownCastTo("FloatGrid")],
239-
numpy.dtype("float16"): [DownCastTo("HalfGrid"), DownCastTo("FloatGrid")],
239+
numpy.dtype("float16"): ["HalfGrid", "FloatGrid"],
240240
numpy.dtype("float32"): ["FloatGrid"],
241241
numpy.dtype("float64"): ["DoubleGrid", DownCastTo("FloatGrid")],
242242
}
@@ -257,16 +257,18 @@ def _get_best_grid_type(self):
257257
except AttributeError:
258258
continue
259259
else:
260-
if isinstance(gridtype_downcast, DownCastTo):
261-
warnings.warn(
262-
f"Grid type {vdb_gridtypes[0]} not available. Using {gridtype} instead. Data may lose precision.",
263-
UserWarning,
264-
)
265-
return VDB_Grid()
266-
267-
raise TypeError(
268-
f"Could not find any VDB grid type for numpy dtype {self.grid.dtype}"
269-
)
260+
break
261+
else:
262+
raise TypeError(
263+
f"Could not find any VDB grid type for numpy dtype {self.grid.dtype}"
264+
)
265+
266+
if isinstance(gridtype_downcast, DownCastTo):
267+
warnings.warn(
268+
f"Grid type {vdb_gridtypes[0]} not available. Using {gridtype} instead. Data may lose precision.",
269+
RuntimeWarning,
270+
)
271+
return VDB_Grid()
270272

271273
def _create_openvdb_grid(self):
272274
"""Create and populate an OpenVDB grid

gridData/tests/test_vdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def test_write_vdb_float64_conversion_warning(self, tmpdir):
279279
outfile = str(tmpdir / "float64.vdb")
280280

281281
with pytest.warns(
282-
UserWarning, match="Grid type DoubleGrid not available.*FloatGrid"
282+
RuntimeWarning, match="Grid type DoubleGrid not available.*FloatGrid"
283283
):
284284
g.export(outfile)
285285

@@ -293,7 +293,7 @@ def test_write_vdb_int32_conversion_warning(self, tmpdir):
293293
outfile = str(tmpdir / "int32.vdb")
294294

295295
with pytest.warns(
296-
UserWarning, match="Grid type Int32Grid not available.*FloatGrid"
296+
RuntimeWarning, match="Grid type Int32Grid not available.*FloatGrid"
297297
):
298298
g.export(outfile)
299299

0 commit comments

Comments
 (0)