Skip to content

Commit

Permalink
Merge pull request #114 from neutrinoceros/hotfix_113
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros authored May 5, 2023
2 parents 50ce913 + 322e9e9 commit 506533f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gpgi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from .api import load

__version__ = "0.11.1"
__version__ = "0.11.2"
3 changes: 2 additions & 1 deletion gpgi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
13 changes: 13 additions & 0 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 506533f

Please sign in to comment.