Skip to content

Commit 7fc2c2d

Browse files
dbochkov-flexcomputemomchil-flex
authored andcommitted
on-the-fly vtk import
1 parent 99e0aaf commit 7fc2c2d

File tree

4 files changed

+110
-108
lines changed

4 files changed

+110
-108
lines changed

tests/test_data/_test_datasets_no_vtk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_triangular_dataset_no_vtk(tmp_path):
2424
# double check that vtk was not imported
2525
from tidy3d.components.types import vtk
2626

27-
assert vtk is None
27+
assert vtk["mod"] is None
2828

2929

3030
@pytest.mark.usefixtures("hide_vtk")
@@ -34,4 +34,4 @@ def test_tetrahedral_dataset_no_vtk(tmp_path):
3434
# double check that vtk was not imported
3535
from tidy3d.components.types import vtk
3636

37-
assert vtk is None
37+
assert vtk["mod"] is None

tests/test_data/test_datasets.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_triangular_dataset(tmp_path, ds_name):
124124
assert tri_grid.bounds == ((0.0, 0.0, 0.0), (1.0, 0.0, 1.0))
125125
assert np.all(tri_grid._vtk_offsets == np.array([0, 3, 6]))
126126

127-
if vtk is None:
127+
if vtk["mod"] is None:
128128
with pytest.raises(Tidy3dImportError):
129129
_ = tri_grid._vtk_cells
130130
with pytest.raises(Tidy3dImportError):
@@ -137,7 +137,7 @@ def test_triangular_dataset(tmp_path, ds_name):
137137
_ = tri_grid._vtk_obj
138138

139139
# plane slicing
140-
if vtk is None:
140+
if vtk["mod"] is None:
141141
with pytest.raises(Tidy3dImportError):
142142
_ = tri_grid.plane_slice(axis=2, pos=0.5)
143143
else:
@@ -154,7 +154,7 @@ def test_triangular_dataset(tmp_path, ds_name):
154154
_ = tri_grid.plane_slice(axis=0, pos=2)
155155

156156
# clipping by a box
157-
if vtk is None:
157+
if vtk["mod"] is None:
158158
with pytest.raises(Tidy3dImportError):
159159
_ = tri_grid.box_clip([[0.1, -0.2, 0.1], [0.2, 0.2, 0.9]])
160160
else:
@@ -166,7 +166,7 @@ def test_triangular_dataset(tmp_path, ds_name):
166166
_ = tri_grid.box_clip([[0.1, 0.1, 0.3], [0.2, 0.2, 0.9]])
167167

168168
# interpolation
169-
if vtk is None:
169+
if vtk["mod"] is None:
170170
with pytest.raises(Tidy3dImportError):
171171
invariant = tri_grid.interp(
172172
x=0.4, y=[0, 1], z=np.linspace(0.2, 0.6, 10), fill_value=-333
@@ -224,7 +224,7 @@ def test_triangular_dataset(tmp_path, ds_name):
224224
_ = tri_grid.plot(field=False, grid=False)
225225

226226
# generalized selection method
227-
if vtk is None:
227+
if vtk["mod"] is None:
228228
with pytest.raises(Tidy3dImportError):
229229
_ = tri_grid.sel(x=0.2)
230230
else:
@@ -238,7 +238,7 @@ def test_triangular_dataset(tmp_path, ds_name):
238238
_ = tri_grid.sel(x=np.linspace(0, 1, 3), y=1.2, z=[0.3, 0.4, 0.5])
239239

240240
# writting/reading .vtu
241-
if vtk is None:
241+
if vtk["mod"] is None:
242242
with pytest.raises(Tidy3dImportError):
243243
tri_grid.to_vtu(tmp_path / "tri_grid_test.vtu")
244244
with pytest.raises(Tidy3dImportError):
@@ -362,7 +362,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
362362
assert np.all(tet_grid._vtk_offsets == np.array([0, 4, 8]))
363363
assert tet_grid.name == ds_name
364364

365-
if vtk is None:
365+
if vtk["mod"] is None:
366366
with pytest.raises(Tidy3dImportError):
367367
_ = tet_grid._vtk_cells
368368
with pytest.raises(Tidy3dImportError):
@@ -375,7 +375,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
375375
_ = tet_grid._vtk_obj
376376

377377
# plane slicing
378-
if vtk is None:
378+
if vtk["mod"] is None:
379379
with pytest.raises(Tidy3dImportError):
380380
_ = tet_grid.plane_slice(axis=2, pos=0.5)
381381
else:
@@ -387,7 +387,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
387387
_ = tet_grid.plane_slice(axis=1, pos=2)
388388

389389
# clipping by a box
390-
if vtk is None:
390+
if vtk["mod"] is None:
391391
with pytest.raises(Tidy3dImportError):
392392
_ = tet_grid.box_clip([[0.1, -0.2, 0.1], [0.2, 0.2, 0.9]])
393393
else:
@@ -399,7 +399,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
399399
_ = tet_grid.box_clip([[0.1, 1.1, 0.3], [0.2, 1.2, 0.9]])
400400

401401
# interpolation
402-
if vtk is None:
402+
if vtk["mod"] is None:
403403
with pytest.raises(Tidy3dImportError):
404404
_ = tet_grid.interp(x=0.4, y=[0, 1], z=np.linspace(0.2, 0.6, 10), fill_value=-333)
405405
else:
@@ -415,7 +415,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
415415
assert no_intersection.name == ds_name
416416

417417
# generalized selection method
418-
if vtk is None:
418+
if vtk["mod"] is None:
419419
with pytest.raises(Tidy3dImportError):
420420
_ = tet_grid.sel(x=0.2)
421421
else:
@@ -429,7 +429,7 @@ def test_tetrahedral_dataset(tmp_path, ds_name):
429429
_ = tet_grid.sel(x=0.2, z=[0.3, 0.4, 0.5])
430430

431431
# writting/reading .vtu
432-
if vtk is None:
432+
if vtk["mod"] is None:
433433
with pytest.raises(Tidy3dImportError):
434434
tet_grid.to_vtu(tmp_path / "tet_grid_test.vtu")
435435
with pytest.raises(Tidy3dImportError):

0 commit comments

Comments
 (0)