diff --git a/arraycontext/fake_numpy.py b/arraycontext/fake_numpy.py index 0657ecbbc65e305ad955ad35a2890a1fec9f163b..7e9b189ca1c7fa6491b79d07bb77e6de4e71e840 100644 --- a/arraycontext/fake_numpy.py +++ b/arraycontext/fake_numpy.py @@ -192,6 +192,26 @@ class BaseFakeNumpyLinalgNamespace: if ary.size == 0: return 0 + if ord is None: + ord = 2 + + from arraycontext.impl import _is_meshmode_dofarray + + if _is_meshmode_dofarray(ary): + from warnings import warn + warn("Taking an actx.np.linalg.norm of a DOFArray is deprecated. " + "(DOFArrays use 2D arrays internally, and " + "actx.np.linalg.norm should compute matrix norms of those.) " + "This will stop working in 2022. " + "Use meshmode.dof_array.flat_norm instead.", + DeprecationWarning, stacklevel=2) + + import numpy.linalg as la + return la.norm( + [self.norm(_flatten_array(subary), ord=ord) + for _, subary in serialize_container(ary)], + ord=ord) + if ord == np.inf: return self._array_context.np.max(abs(ary)) elif isinstance(ord, Number) and ord > 0: diff --git a/arraycontext/impl/pyopencl.py b/arraycontext/impl/pyopencl.py index ec75e0fe12a6bda9342ea72df803817c7e82c782..d0777a6c73dd201c1022426be94bc7e2912fe513 100644 --- a/arraycontext/impl/pyopencl.py +++ b/arraycontext/impl/pyopencl.py @@ -164,28 +164,7 @@ def _flatten_array(ary): class _PyOpenCLFakeNumpyLinalgNamespace(BaseFakeNumpyLinalgNamespace): - def norm(self, ary, ord=None): - if ord is None: - ord = 2 - - from arraycontext.impl import _is_meshmode_dofarray - - if _is_meshmode_dofarray(ary): - from warnings import warn - warn("Taking an actx.np.linalg.norm of a DOFArray is deprecated. " - "(DOFArrays use 2D arrays internally, and " - "actx.np.linalg.norm should compute matrix norms of those.) " - "This will stop working in 2022. " - "Use meshmode.dof_array.flat_norm instead.", - DeprecationWarning, stacklevel=2) - - import numpy.linalg as la - return la.norm( - [self.norm(_flatten_array(subary), ord=ord) - for _, subary in serialize_container(ary)], - ord=ord) - - return super().norm(ary, ord) + pass # }}}