diff --git a/gpgi/__init__.py b/gpgi/__init__.py index fecb430..b6d7655 100644 --- a/gpgi/__init__.py +++ b/gpgi/__init__.py @@ -2,4 +2,4 @@ from .api import load -__version__ = "0.11.1" +__version__ = "0.11.2" diff --git a/gpgi/types.py b/gpgi/types.py index dc4afbf..d449056 100644 --- a/gpgi/types.py +++ b/gpgi/types.py @@ -293,7 +293,8 @@ def cell_volumes(self) -> RealArray: """ widths = list(self.cell_widths.values()) if self.geometry is Geometry.CARTESIAN: - return cast("RealArray", np.prod(np.meshgrid(*widths), axis=0)) + raw = np.prod(np.meshgrid(*widths), axis=0) + return cast("RealArray", np.swapaxes(raw, 0, 1)) else: raise NotImplementedError( f"cell_volumes property is not implemented for {self.geometry} geometry" diff --git a/pyproject.toml b/pyproject.toml index 00a7f2f..2b0e655 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "gpgi" -version = "0.11.1" +version = "0.11.2" description = "A Generic Particle+Grid Interface" authors = [ { name = "C.M.T. Robert" }, diff --git a/tests/test_grid.py b/tests/test_grid.py index 326424c..5e2a03e 100644 --- a/tests/test_grid.py +++ b/tests/test_grid.py @@ -35,3 +35,16 @@ def test_cell_volumes_curvilinear(): match=r"cell_volumes property is not implemented for cylindrical geometry", ): ds.grid.cell_volumes # noqa: B018 + + +def test_cell_volumes_shape(): + ds = load( + grid={ + "cell_edges": { + "x": np.linspace(0, 1, 3), + "y": np.linspace(0, 1, 4), + "z": np.linspace(0, 1, 5), + } + } + ) + assert ds.grid.cell_volumes.shape == ds.grid.shape