[get_slice] use shifted bounds
This commit is contained in:
parent
ddce4fa491
commit
e345d1dcf8
2 changed files with 13 additions and 1 deletions
|
|
@ -83,7 +83,7 @@ class GridReadMixin(GridPosMixin):
|
|||
else:
|
||||
w = [1]
|
||||
|
||||
c_min, c_max = (self.xyz[plane.axis][i] for i in [0, -1])
|
||||
c_min, c_max = (self.shifted_xyz(which_shifts)[plane.axis][i] for i in [0, -1])
|
||||
if plane.pos < c_min or plane.pos > c_max:
|
||||
raise GridError('Coordinate of selected plane must be within simulation domain')
|
||||
|
||||
|
|
|
|||
|
|
@ -226,6 +226,18 @@ def test_extent_accepts_scalar_like_inputs() -> None:
|
|||
assert_allclose([extent.center, extent.span, extent.min, extent.max], [3.0, 4.0, 1.0, 5.0])
|
||||
|
||||
|
||||
def test_get_slice_uses_shifted_grid_bounds() -> None:
|
||||
grid = Grid([[0, 1, 2], [0, 1, 2], [0, 1, 2]], shifts=[[0.5, 0, 0]])
|
||||
cell_data = numpy.arange(numpy.prod(grid.cell_data_shape), dtype=float).reshape(grid.cell_data_shape)
|
||||
|
||||
grid_slice = grid.get_slice(cell_data, Plane(x=2.0), which_shifts=0)
|
||||
|
||||
assert_allclose(grid_slice, cell_data[0, 1, :, :])
|
||||
|
||||
with pytest.raises(GridError):
|
||||
grid.get_slice(cell_data, Plane(x=2.1), which_shifts=0)
|
||||
|
||||
|
||||
|
||||
|
||||
def test_visualize_isosurface_sampling_uses_preview_lattice(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue