Skip to content

Commit

Permalink
fix: add __array_ufunc__ to containers in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Feb 8, 2025
1 parent 685ab38 commit 204e4af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/parallel-vtkhdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def main(*, ambient_dim: int) -> None:
logger.info("[%4d] fields: finished", comm.rank)

from meshmode.discretization.visualization import make_visualizer
vis = make_visualizer(actx, discr, vis_order=order, force_equidistant=False)
vis = make_visualizer(actx, discr, force_equidistant=False)
logger.info("[%4d] make_visualizer: finished", comm.rank)

filename = f"parallel-vtkhdf-example-{ambient_dim}d.hdf"
Expand Down
6 changes: 6 additions & 0 deletions examples/simple-dg.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ class TracePair:
interior: ArrayContainer
exterior: ArrayContainer

# NOTE: let the container do the broadcasting + arithmetic
__array_ufunc__ = None

def __getattr__(self, name):
return map_array_container(
lambda ary: getattr(ary, name),
Expand Down Expand Up @@ -450,6 +453,9 @@ class WaveState:
u: DOFArray
v: np.ndarray # [object]

# NOTE: let the container do the broadcasting + arithmetic
__array_ufunc__ = None

def __post_init__(self):
assert isinstance(self.v, np.ndarray) and self.v.dtype.char == "O"

Expand Down

0 comments on commit 204e4af

Please sign in to comment.