diff --git a/arraycontext/fake_numpy.py b/arraycontext/fake_numpy.py index 97ee9ef85030713062c4bdfd3e127a52e6ed9e9c..04f66e0e52ccd0a383a51abe3da90282b538f82e 100644 --- a/arraycontext/fake_numpy.py +++ b/arraycontext/fake_numpy.py @@ -182,24 +182,6 @@ class BaseFakeNumpyLinalgNamespace: if ord is None: ord = 2 - from arraycontext.impl import _is_meshmode_dofarray - from arraycontext.impl.pyopencl import _flatten_array - - 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 is_array_container(ary): import numpy.linalg as la return la.norm( diff --git a/arraycontext/impl/pyopencl.py b/arraycontext/impl/pyopencl.py index d11abd10c9d6e084625c088b28a9186903f5e4e8..3cbf9856dfe0c3a20d513487460e099208752eed 100644 --- a/arraycontext/impl/pyopencl.py +++ b/arraycontext/impl/pyopencl.py @@ -186,7 +186,31 @@ def _flatten_array(ary): class _PyOpenCLFakeNumpyLinalgNamespace(BaseFakeNumpyLinalgNamespace): - pass + def norm(self, ary, ord=None): + try: + from meshmode.dof_array import DOFArray + except ImportError: + pass + else: + if isinstance(ary, DOFArray): + if ord is None: + ord = 2 + + 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) # }}}