Skip to content

Commit 0231a44

Browse files
committed
Updated tests
1 parent acff126 commit 0231a44

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

gridData/tests/test_vdb.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,38 @@ def test_write_vdb_int32_conversion_warning(self, tmpdir):
304304
assert acc.getValue((0, 0, 0)) == pytest.approx(float(data[0, 0, 0]))
305305
assert acc.getValue((1, 1, 1)) == pytest.approx(float(data[1, 1, 1]))
306306

307+
def test_write_vdb_unsupported_dtype_raises(self):
308+
data_complex = np.ones((3, 3, 3), dtype=np.complex64)
309+
310+
with pytest.raises(TypeError, match="Data type.*not supported for VDB"):
311+
gridData.OpenVDB.OpenVDBField(
312+
data_complex, origin=[0, 0, 0], delta=[1, 1, 1]
313+
)
314+
315+
def test_openvdb_field_empty_initialization(self, tmpdir):
316+
vdb_field = gridData.OpenVDB.OpenVDBField()
317+
318+
assert vdb_field.grid is None
319+
assert vdb_field.origin is None
320+
assert vdb_field.delta is None
321+
assert vdb_field.vdb_grid is None
322+
assert vdb_field.name == "density"
323+
assert vdb_field.metadata == {}
324+
325+
data = np.ones((3, 3, 3), dtype=np.float32)
326+
vdb_field._populate(data, [0, 0, 0], [1, 1, 1])
327+
vdb_field.vdb_grid = vdb_field._create_openvdb_grid()
328+
329+
assert vdb_field.grid is not None
330+
assert vdb_field.origin is not None
331+
assert vdb_field.delta is not None
332+
assert vdb_field.vdb_grid is not None
333+
334+
outfile = str(tmpdir / "empty_init.vdb")
335+
vdb_field.write(outfile)
336+
337+
assert tmpdir.join("empty_init.vdb").exists()
338+
307339

308340
@pytest.mark.skipif(
309341
not HAS_OPENVDB, reason="Need openvdb to test import error handling"

0 commit comments

Comments
 (0)