79365343

Date: 2025-01-17 15:59:16
Score: 1.5
Natty:
Report link

Make a custom IndexedBase which instructs the Latex printer to place the 2nd index in the superscript:

from scipy import Indexed, IndexedBase

class CustomIndexed(Indexed):
    def _latex(self, printer):
        return '%s_{%s}^{(%s)}' % (
            self.base, *self.indices
        )

class CustomIndexedBase(IndexedBase):
    def __getitem__(self, indices, **kwargs):
        return CustomIndexed(self.name, 
                             *indices)

c = CustomIndexedBase('c')
c[i,j]

Output:

c_{i}^{j}

Source: https://medium.com/@mathcube7/indexed-symbols-and-neumann-stability-analysis-with-pythons-sympy-1ab5d5cfc8c5

(Sorry for the messed up output, I don't know how to embed latex in the answer so I just screenshot it :D).

Reasons:
  • Blacklisted phrase (0.5): medium.com
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ccalaza