def test_isosurface_non_orthogonal(self, setup): pytest.importorskip("skimage", reason="scikit-image not available") # If the grid is non-orthogonal, there should be 20 unique values # (10 for each (HERE), see test_isosurface_orthogonal) grid = Grid(0.1, sc=[[1, 0, 0], [0, 1, 0], [0, 2, 1]]) grid.grid = np.tile([1, 2, 3, 4, 5, 4, 3, 2, 1, 0], 100).reshape(10, 10, 10) verts, *returns = grid.isosurface(2.5) # we have twice as many since the 3rd lattice vector has components in y assert np.unique(verts[:, 1]).shape == (20, ) assert np.unique(verts[:, 2]).shape == (2, )
def test_isosurface_orthogonal(self, setup): pytest.importorskip("skimage", reason="scikit-image not available") # Build an empty grid grid = Grid(0.1, sc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]) # Fill it with some values that have a clear isosurface grid.grid = np.tile([1, 2, 3, 4, 5, 4, 3, 2, 1, 0], 100).reshape(10, 10, 10) # Calculate the isosurface for the value of 2.5 verts, *returns = grid.isosurface(2.5) # The third dimension should contain only two coordinates # [1, 2, (HERE) 3, 4, 5, 4, 3, (HERE) 2, 1, 0] assert np.unique(verts[:, 1]).shape == (10, ) assert np.unique(verts[:, 2]).shape == (2, )