Repository: sympy/sympy

Issue:
Cannot lambdify `sp.Idx` symbols in 1.13
The following code worked in 1.12.1:

```python
import sympy as sp

X = sp.IndexedBase('X')
i = sp.Idx('i')
sp.lambdify([X, i], X[i])
```

It now fails with a `PrintMethodNotImplementedError` in 1.13. Full stack trace below the fold:

<details>

<summary>Traceback</summary>

```shelll
PrintMethodNotImplementedError            Traceback (most recent call last)

[<ipython-input-4-ec206ddca58d>](https://localhost:8080/#) in <cell line: 4>()
      2 X = sp.IndexedBase('X')
      3 i = sp.Idx('i')
----> 4 sp.lambdify([X, i], X[i])(np.arange(10), 3)

9 frames

[/usr/local/lib/python3.10/dist-packages/sympy/utilities/lambdify.py](https://localhost:8080/#) in lambdify(args, expr, modules, printer, use_imps, dummify, cse, docstring_limit)
    878     else:
    879         cses, _expr = (), expr
--> 880     funcstr = funcprinter.doprint(funcname, iterable_args, _expr, cses=cses)
    881 
    882     # Collect the module imports from the code printers.

[/usr/local/lib/python3.10/dist-packages/sympy/utilities/lambdify.py](https://localhost:8080/#) in doprint(self, funcname, args, expr, cses)
   1169                 funcbody.append('{} = {}'.format(self._exprrepr(s), self._exprrepr(e)))
   1170 
-> 1171         str_expr = _recursive_to_string(self._exprrepr, expr)
   1172 
   1173         if '\n' in str_expr:

[/usr/local/lib/python3.10/dist-packages/sympy/utilities/lambdify.py](https://localhost:8080/#) in _recursive_to_string(doprint, arg)
    964 
    965     if isinstance(arg, (Basic, MatrixBase)):
--> 966         return doprint(arg)
    967     elif iterable(arg):
    968         if isinstance(arg, list):

[/usr/local/lib/python3.10/dist-packages/sympy/printing/codeprinter.py](https://localhost:8080/#) in doprint(self, expr, assign_to)
    170         self._number_symbols = set()
    171 
--> 172         lines = self._print(expr).splitlines()
    173 
    174         # format the output

[/usr/local/lib/python3.10/dist-packages/sympy/printing/printer.py](https://localhost:8080/#) in _print(self, expr, **kwargs)
    329                 printmethod = getattr(self, printmethodname, None)
    330                 if printmethod is not None:
--> 331                     return printmethod(expr, **kwargs)
    332             # Unknown object, fall back to the emptyPrinter.
    333             return self.emptyPrinter(expr)

[/usr/local/lib/python3.10/dist-packages/sympy/printing/pycode.py](https://localhost:8080/#) in _print_Indexed(self, expr)
    565         base = expr.args[0]
    566         index = expr.args[1:]
--> 567         return "{}[{}]".format(str(base), ", ".join([self._print(ind) for ind in index]))
    568 
    569     def _print_Pow(self, expr, rational=False):

[/usr/local/lib/python3.10/dist-packages/sympy/printing/pycode.py](https://localhost:8080/#) in <listcomp>(.0)
    565         base = expr.args[0]
    566         index = expr.args[1:]
--> 567         return "{}[{}]".format(str(base), ", ".join([self._print(ind) for ind in index]))
    568 
    569     def _print_Pow(self, expr, rational=False):

[/usr/local/lib/python3.10/dist-packages/sympy/printing/printer.py](https://localhost:8080/#) in _print(self, expr, **kwargs)
    329                 printmethod = getattr(self, printmethodname, None)
    330                 if printmethod is not None:
--> 331                     return printmethod(expr, **kwargs)
    332             # Unknown object, fall back to the emptyPrinter.
    333             return self.emptyPrinter(expr)

[/usr/local/lib/python3.10/dist-packages/sympy/printing/codeprinter.py](https://localhost:8080/#) in _print_Function(self, expr)
    459             return '%s(%s)' % (self._print(expr.func), ', '.join(map(self._print, expr.args)))
    460         else:
--> 461             return self._print_not_supported(expr)
    462 
    463     _print_Expr = _print_Function

[/usr/local/lib/python3.10/dist-packages/sympy/printing/codeprinter.py](https://localhost:8080/#) in _print_not_supported(self, expr)
    580     def _print_not_supported(self, expr):
    581         if self._settings.get('strict', False):
--> 582             raise PrintMethodNotImplementedError("Unsupported by %s: %s" % (str(type(self)), str(type(expr))) + \
    583                              "\nSet the printer option 'strict' to False in order to generate partially printed code.")
    584         try:

PrintMethodNotImplementedError: Unsupported by <class 'sympy.printing.numpy.SciPyPrinter'>: <class 'sympy.tensor.indexed.Idx'>
Set the printer option 'strict' to False in order to generate partially printed code.
```

</details>

Tested on a colab under `1.12.1`, `1.13.0`, and `1.13.1`

Discussion:

Patch:
diff --git a/sympy/printing/c.py b/sympy/printing/c.py
index 05549c7fe2..6fcc017776 100644
--- a/sympy/printing/c.py
+++ b/sympy/printing/c.py
@@ -331,9 +331,6 @@ def _print_Indexed(self, expr):
         return "%s[%s]" % (self._print(expr.base.label),
                            self._print(flat_index))
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     @_as_macro_if_defined
     def _print_NumberSymbol(self, expr):
         return super()._print_NumberSymbol(expr)
diff --git a/sympy/printing/codeprinter.py b/sympy/printing/codeprinter.py
index 346a801d30..c036d9c06a 100644
--- a/sympy/printing/codeprinter.py
+++ b/sympy/printing/codeprinter.py
@@ -351,6 +351,9 @@ def _print_Dummy(self, expr):
         else:
             return '%s_%d' % (expr.name, expr.dummy_index)
 
+    def _print_Idx(self, expr):
+        return self._print(expr.label)
+
     def _print_CodeBlock(self, expr):
         return '\n'.join([self._print(i) for i in expr.args])
 
diff --git a/sympy/printing/fortran.py b/sympy/printing/fortran.py
index a647907a91..7cea812d72 100644
--- a/sympy/printing/fortran.py
+++ b/sympy/printing/fortran.py
@@ -376,9 +376,6 @@ def _print_Indexed(self, expr):
         inds = [ self._print(i) for i in expr.indices ]
         return "%s(%s)" % (self._print(expr.base.label), ", ".join(inds))
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     def _print_AugmentedAssignment(self, expr):
         lhs_code = self._print(expr.lhs)
         rhs_code = self._print(expr.rhs)
diff --git a/sympy/printing/glsl.py b/sympy/printing/glsl.py
index 7bcb3bbff9..92c1aa3f53 100644
--- a/sympy/printing/glsl.py
+++ b/sympy/printing/glsl.py
@@ -258,9 +258,6 @@ def _print_Piecewise(self, expr):
             last_line = ": (\n%s\n)" % self._print(expr.args[-1].expr)
             return ": ".join(ecpairs) + last_line + " ".join([")"*len(ecpairs)])
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     def _print_Indexed(self, expr):
         # calculate index for 1d array
         dims = expr.shape
diff --git a/sympy/printing/jscode.py b/sympy/printing/jscode.py
index c0961857e3..753eb3291d 100644
--- a/sympy/printing/jscode.py
+++ b/sympy/printing/jscode.py
@@ -137,9 +137,6 @@ def _print_Indexed(self, expr):
             offset *= dims[i]
         return "%s[%s]" % (self._print(expr.base.label), self._print(elem))
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     def _print_Exp1(self, expr):
         return "Math.E"
 
diff --git a/sympy/printing/julia.py b/sympy/printing/julia.py
index e5912570da..c0585b9357 100644
--- a/sympy/printing/julia.py
+++ b/sympy/printing/julia.py
@@ -384,11 +384,6 @@ def _print_Indexed(self, expr):
         inds = [ self._print(i) for i in expr.indices ]
         return "%s[%s]" % (self._print(expr.base.label), ",".join(inds))
 
-
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
-
     def _print_Identity(self, expr):
         return "eye(%s)" % self._print(expr.shape[0])
 
diff --git a/sympy/printing/maple.py b/sympy/printing/maple.py
index f36a5b5688..2c937cd262 100644
--- a/sympy/printing/maple.py
+++ b/sympy/printing/maple.py
@@ -183,9 +183,6 @@ def _print_NegativeInfinity(self, expr):
     def _print_Infinity(self, expr):
         return 'infinity'
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     def _print_BooleanTrue(self, expr):
         return "true"
 
diff --git a/sympy/printing/octave.py b/sympy/printing/octave.py
index fe36308e12..b7e5993993 100644
--- a/sympy/printing/octave.py
+++ b/sympy/printing/octave.py
@@ -379,10 +379,6 @@ def _print_Indexed(self, expr):
         return "%s(%s)" % (self._print(expr.base.label), ", ".join(inds))
 
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
-
     def _print_KroneckerDelta(self, expr):
         prec = PRECEDENCE["Pow"]
         return "double(%s == %s)" % tuple(self.parenthesize(x, prec)
diff --git a/sympy/printing/rcode.py b/sympy/printing/rcode.py
index c497f1a6ff..3107e6e94d 100644
--- a/sympy/printing/rcode.py
+++ b/sympy/printing/rcode.py
@@ -157,9 +157,6 @@ def _print_Indexed(self, expr):
         inds = [ self._print(i) for i in expr.indices ]
         return "%s[%s]" % (self._print(expr.base.label), ", ".join(inds))
 
-    def _print_Idx(self, expr):
-        return self._print(expr.label)
-
     def _print_Exp1(self, expr):
         return "exp(1)"
 


Test patch:
diff --git a/sympy/utilities/tests/test_lambdify.py b/sympy/utilities/tests/test_lambdify.py
index 96203a3ccb..ee56ab5bcd 100644
--- a/sympy/utilities/tests/test_lambdify.py
+++ b/sympy/utilities/tests/test_lambdify.py
@@ -33,7 +33,7 @@
 from sympy.simplify.cse_main import cse
 from sympy.tensor.array import derive_by_array, Array
 from sympy.tensor.array.expressions import ArraySymbol
-from sympy.tensor.indexed import IndexedBase
+from sympy.tensor.indexed import IndexedBase, Idx
 from sympy.utilities.lambdify import lambdify
 from sympy.utilities.iterables import numbered_symbols
 from sympy.vector import CoordSys3D
@@ -1067,6 +1067,13 @@ def test_Indexed():
     b = numpy.array([[1, 2], [3, 4]])
     assert lambdify(a, Sum(a[x, y], (x, 0, 1), (y, 0, 1)))(b) == 10
 
+def test_Idx():
+    # Issue 26888
+    a = IndexedBase('a')
+    i = Idx('i')
+    b = [1,2,3]
+    assert lambdify([a, i], a[i])(b, 2) == 3
+
 
 def test_issue_12173():
     #test for issue 12173