Skip to content

Commit

Permalink
Merge pull request #261 from neutrinoceros/hotfix_flaky_runtime_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed May 23, 2023
2 parents 23895d5 + ec26eef commit 49fb3b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "yt_idefix"
version = "2.0.0"
version = "2.0.1"
description = "An extension module for yt, adding a frontend for Idefix"
authors = [
{ name = "C.M.T. Robert" },
Expand Down
2 changes: 1 addition & 1 deletion yt_idefix/__init__.py
Expand Up @@ -2,4 +2,4 @@
# immediately after `import yt.extensions.idefix`
from yt_idefix.api import *

__version__ = "2.0.0"
__version__ = "2.0.1"
33 changes: 21 additions & 12 deletions yt_idefix/data_structures.py
Expand Up @@ -12,6 +12,7 @@

import inifix
import numpy as np
import numpy.testing as npt

from yt.data_objects.index_subobjects.stretched_grid import StretchedGrid
from yt.data_objects.static_output import Dataset
Expand Down Expand Up @@ -185,16 +186,18 @@ def _cell_widths(self) -> tuple[XSpans, YSpans, ZSpans]:

cell_widths: tuple[XSpans, YSpans, ZSpans]
cell_widths = (
np.empty(max(dims[0], 2), dtype="float64") * length_unit,
np.empty(max(dims[1], 2), dtype="float64") * length_unit,
np.empty(max(dims[2], 2), dtype="float64") * length_unit,
np.full(max(dims[0], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[1], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[2], 2), -1, dtype="float64") * length_unit,
)

for idir, edges in enumerate(cell_edges[:3]):
if dims[idir] > 1:
cell_widths[idir][:] = np.ediff1d(edges)
else:
cell_widths[idir][:] = self.ds.domain_width[idir]
npt.assert_array_less(0, cell_widths[idir])

return cell_widths

@cached_property
Expand All @@ -207,16 +210,18 @@ def _cell_centers(self) -> tuple[XCoords, YCoords, ZCoords]:

cell_centers: tuple[XCoords, YCoords, ZCoords]
cell_centers = (
np.empty(max(dims[0], 2), dtype="float64") * length_unit,
np.empty(max(dims[1], 2), dtype="float64") * length_unit,
np.empty(max(dims[2], 2), dtype="float64") * length_unit,
np.full(max(dims[0], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[1], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[2], 2), -1, dtype="float64") * length_unit,
)

for idir, edges in enumerate(cell_edges[:3]):
if dims[idir] > 1:
cell_centers[idir][:] = 0.5 * (edges[1:] + edges[:-1])
else:
cell_centers[idir][:] = edges[0]
npt.assert_array_less(0, cell_centers[idir])

return cell_centers


Expand Down Expand Up @@ -258,16 +263,18 @@ def _cell_widths(self) -> tuple[XSpans, YSpans, ZSpans]:

cell_widths: tuple[XSpans, YSpans, ZSpans]
cell_widths = (
np.empty(max(dims[0], 2), dtype="float64") * length_unit,
np.empty(max(dims[1], 2), dtype="float64") * length_unit,
np.empty(max(dims[2], 2), dtype="float64") * length_unit,
np.full(max(dims[0], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[1], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[2], 2), -1, dtype="float64") * length_unit,
)

for idir, edges in enumerate(cell_edges[:3]):
if dims[idir] > 1:
cell_widths[idir][:] = np.ediff1d(edges)
else:
cell_widths[idir][:] = self.ds.domain_width[idir]
npt.assert_array_less(0, cell_widths[idir])

return cell_widths

@cached_property
Expand All @@ -281,16 +288,18 @@ def _cell_centers(self) -> tuple[XCoords, YCoords, ZCoords]:

cell_centers: tuple[XCoords, YCoords, ZCoords]
cell_centers = (
np.empty(max(dims[0], 2), dtype="float64") * length_unit,
np.empty(max(dims[1], 2), dtype="float64") * length_unit,
np.empty(max(dims[2], 2), dtype="float64") * length_unit,
np.full(max(dims[0], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[1], 2), -1, dtype="float64") * length_unit,
np.full(max(dims[2], 2), -1, dtype="float64") * length_unit,
)

for idir, edges in enumerate(cell_edges[:3]):
if dims[idir] > 1:
cell_centers[idir][:] = 0.5 * (edges[1:] + edges[:-1])
else:
cell_centers[idir][:] = edges[0]
npt.assert_array_less(0, cell_centers)

return cell_centers


Expand Down

0 comments on commit 49fb3b3

Please sign in to comment.