Skip to content

Commit

Permalink
Merge pull request #91 from neutrinoceros/hotfix_dtype_validation
Browse files Browse the repository at this point in the history
BUG: fix a bug where float32 coordinates were incorrectly invalidated against double precision limits
  • Loading branch information
neutrinoceros authored Feb 8, 2023
2 parents 4deeb93 + 20513c0 commit d3ebf96
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 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.dev0"
__version__ = "0.10.1"
5 changes: 3 additions & 2 deletions gpgi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ def _validate_coordinates(self) -> None:
coord = self.coordinates[axis]
if len(coord) == 0:
continue
dtype = self._get_safe_datatype().type
xmin, xmax = _AXES_LIMITS[axis]
if (cmin := np.min(coord)) < xmin:
if (cmin := np.min(coord)) < dtype(xmin):
raise ValueError(
f"Invalid coordinate data for axis {axis!r} {cmin} "
f"(minimal allowed value is {xmin})"
)
if (cmax := np.max(coord)) > xmax:
if (cmax := np.max(coord)) > dtype(xmax):
raise ValueError(
f"Invalid coordinate data for axis {axis!r} {cmax} "
f"(maximal allowed value is {xmax})"
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.dev0"
version = "0.10.1"
description = "A Generic Particle+Grid Interface"
authors = [
{ name = "C.M.T. Robert" },
Expand Down

0 comments on commit d3ebf96

Please sign in to comment.