From 53970859dbca76703182b4031831468f5ec8f3f2 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 5 Jul 2024 16:40:32 -0500
Subject: [PATCH] Drop some long-deprecated functionality

---
 arraycontext/__init__.py               |  9 ---------
 arraycontext/impl/pyopencl/__init__.py | 26 ++----------------------
 arraycontext/metadata.py               | 28 +-------------------------
 test/test_arraycontext.py              | 22 +++++++++++---------
 4 files changed, 15 insertions(+), 70 deletions(-)

diff --git a/arraycontext/__init__.py b/arraycontext/__init__.py
index 27eb532..1d0efb3 100644
--- a/arraycontext/__init__.py
+++ b/arraycontext/__init__.py
@@ -81,9 +81,6 @@ from .impl.jax import EagerJAXArrayContext
 from .impl.pyopencl import PyOpenCLArrayContext
 from .impl.pytato import PytatoJAXArrayContext, PytatoPyOpenCLArrayContext
 from .loopy import make_loopy_program
-
-# deprecated, remove in 2022.
-from .metadata import _FirstAxisIsElementsTag
 from .pytest import (
     PytestArrayContextFactory,
     PytestPyOpenCLArrayContextFactory,
@@ -170,12 +167,6 @@ _depr_name_to_replacement_and_obj = {
         "get_container_context": (
             "get_container_context_opt",
             get_container_context_opt, 2022),
-        "FirstAxisIsElementsTag": (
-            "meshmode.transform_metadata.FirstAxisIsElementsTag",
-            _FirstAxisIsElementsTag, 2022),
-        "_acf": ("<no replacement yet>", _deprecated_acf, 2022),
-        "DeviceArray": ("Array", Array, 2023),
-        "DeviceScalar": ("Scalar", Scalar, 2023),
         }
 
 
diff --git a/arraycontext/impl/pyopencl/__init__.py b/arraycontext/impl/pyopencl/__init__.py
index de9c431..e2deea5 100644
--- a/arraycontext/impl/pyopencl/__init__.py
+++ b/arraycontext/impl/pyopencl/__init__.py
@@ -324,32 +324,10 @@ class PyOpenCLArrayContext(ArrayContext):
                     "to create this kernel?")
 
         all_inames = default_entrypoint.all_inames()
-        # FIXME: This could be much smarter.
-        inner_iname = None
-
-        # import with underscore to avoid DeprecationWarning
-        from arraycontext.metadata import _FirstAxisIsElementsTag
-
-        if (len(default_entrypoint.instructions) == 1
-                and isinstance(default_entrypoint.instructions[0], lp.Assignment)
-                and any(isinstance(tag, _FirstAxisIsElementsTag)
-                    # FIXME: Firedrake branch lacks kernel tags
-                    for tag in getattr(default_entrypoint, "tags", ()))):
-            stmt, = default_entrypoint.instructions
 
-            out_inames = [v.name for v in stmt.assignee.index_tuple]
-            assert out_inames
-            outer_iname = out_inames[0]
-            if len(out_inames) >= 2:
-                inner_iname = out_inames[1]
-
-        elif "iel" in all_inames:
-            outer_iname = "iel"
-
-            if "idof" in all_inames:
-                inner_iname = "idof"
+        inner_iname = None
 
-        elif "i0" in all_inames:
+        if "i0" in all_inames:
             outer_iname = "i0"
 
             if "i1" in all_inames:
diff --git a/arraycontext/metadata.py b/arraycontext/metadata.py
index 3997417..756999f 100644
--- a/arraycontext/metadata.py
+++ b/arraycontext/metadata.py
@@ -28,9 +28,8 @@ THE SOFTWARE.
 """
 
 from dataclasses import dataclass
-from warnings import warn
 
-from pytools.tag import Tag, UniqueTag
+from pytools.tag import UniqueTag
 
 
 @dataclass(frozen=True)
@@ -49,29 +48,4 @@ class NameHint(UniqueTag):
             raise ValueError("'name' must be an identifier")
 
 
-# {{{ deprecation handling
-
-try:
-    from meshmode.transform_metadata import (
-        FirstAxisIsElementsTag as _FirstAxisIsElementsTag,
-    )
-except ImportError:
-    # placeholder in case meshmode is too old to have it.
-    class _FirstAxisIsElementsTag(Tag):  # type: ignore[no-redef]
-        pass
-
-
-def __getattr__(name):
-    if name == "FirstAxisIsElementsTag":
-        warn(f"'arraycontext.{name}' is deprecated. "
-                f"Use 'meshmode.transform_metadata.{name}' instead. "
-                f"'arraycontext.{name}' will continue to work until 2022.",
-                DeprecationWarning, stacklevel=2)
-        return _FirstAxisIsElementsTag
-    else:
-        raise AttributeError(name)
-
-# }}}
-
-
 # vim: foldmethod=marker
diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py
index 02452ec..fb16b87 100644
--- a/test/test_arraycontext.py
+++ b/test/test_arraycontext.py
@@ -28,12 +28,12 @@ import numpy as np
 import pytest
 
 from pytools.obj_array import make_obj_array
+from pytools.tag import Tag
 
 from arraycontext import (
     ArrayContainer,
     ArrayContext,
     EagerJAXArrayContext,
-    FirstAxisIsElementsTag,
     PyOpenCLArrayContext,
     PytatoPyOpenCLArrayContext,
     dataclass_array_container,
@@ -735,8 +735,7 @@ def test_array_context_einsum_array_manipulation(actx_factory, spec):
     rng = np.random.default_rng()
 
     mat = actx.from_numpy(rng.normal(size=(10, 10)))
-    res = actx.to_numpy(actx.einsum(spec, mat,
-                                    tagged=(FirstAxisIsElementsTag())))
+    res = actx.to_numpy(actx.einsum(spec, mat))
     ans = np.einsum(spec, actx.to_numpy(mat))
     assert np.allclose(res, ans)
 
@@ -752,8 +751,7 @@ def test_array_context_einsum_array_matmatprods(actx_factory, spec):
 
     mat_a = actx.from_numpy(rng.normal(size=(5, 5)))
     mat_b = actx.from_numpy(rng.normal(size=(5, 5)))
-    res = actx.to_numpy(actx.einsum(spec, mat_a, mat_b,
-                                    tagged=(FirstAxisIsElementsTag())))
+    res = actx.to_numpy(actx.einsum(spec, mat_a, mat_b))
     ans = np.einsum(spec, actx.to_numpy(mat_a), actx.to_numpy(mat_b))
     assert np.allclose(res, ans)
 
@@ -768,8 +766,7 @@ def test_array_context_einsum_array_tripleprod(actx_factory, spec):
     mat_a = actx.from_numpy(rng.normal(size=(7, 5)))
     mat_b = actx.from_numpy(rng.normal(size=(5, 7)))
     vec = actx.from_numpy(rng.normal(size=(7)))
-    res = actx.to_numpy(actx.einsum(spec, mat_a, mat_b, vec,
-                                    tagged=(FirstAxisIsElementsTag())))
+    res = actx.to_numpy(actx.einsum(spec, mat_a, mat_b, vec))
     ans = np.einsum(spec,
                     actx.to_numpy(mat_a),
                     actx.to_numpy(mat_b),
@@ -1523,6 +1520,11 @@ def test_actx_compile_on_pure_array_return(actx_factory):
 
 # {{{ test_taggable_cl_array_tags
 
+@dataclass(frozen=True)
+class MySampleTag(Tag):
+    pass
+
+
 def test_taggable_cl_array_tags(actx_factory):
     actx = actx_factory()
     if not isinstance(actx, PyOpenCLArrayContext):
@@ -1535,10 +1537,10 @@ def test_taggable_cl_array_tags(actx_factory):
 
     from arraycontext.impl.pyopencl.taggable_cl_array import to_tagged_cl_array
     tagged_ary = to_tagged_cl_array(ary, axes=None,
-                                    tags=frozenset((FirstAxisIsElementsTag(),)))
+                                    tags=frozenset((MySampleTag(),)))
 
     assert tagged_ary.base_data is ary.base_data
-    assert tagged_ary.tags == frozenset((FirstAxisIsElementsTag(),))
+    assert tagged_ary.tags == frozenset((MySampleTag(),))
 
     # }}}
 
@@ -1550,7 +1552,7 @@ def test_taggable_cl_array_tags(actx_factory):
 
     assert tagged_ary.base_data is ary.base_data
     assert tagged_ary.tags == frozenset(
-        (FirstAxisIsElementsTag(), ElementwiseMapKernelTag())
+        (MySampleTag(), ElementwiseMapKernelTag())
     )
 
     # }}}
-- 
GitLab