Ejemplo n.º 1
0
    def __getitem__(self, key):
        origkey = key

        if isinstance(key, MultiIndex):
            key = key.indices()
        if not isinstance(key, tuple):
            key = (key, )
        k = key[0]
        if isinstance(k, (int, FixedIndex)):
            sub = self.ufl_operands[int(k)]
            return sub if len(key) == 1 else sub[key[1:]]

        return Expr.__getitem__(self, origkey)
Ejemplo n.º 2
0
    def __getitem__(self, key):
        origkey = key

        if isinstance(key, MultiIndex):
            key = key.indices()
        if not isinstance(key, tuple):
            key = (key,)
        k = key[0]
        if isinstance(k, (int, FixedIndex)):
            sub = self.ufl_operands[int(k)]
            return sub if len(key) == 1 else sub[key[1:]]

        return Expr.__getitem__(self, origkey)
Ejemplo n.º 3
0
 def __getitem__(self, key):
     if len(key) != self._dim:
         error("Size mismatch for PermutationSymbol.")
     if all(isinstance(k, (int, FixedIndex)) for k in key):
         return self.__eps(key)
     return Expr.__getitem__(self, key)
Ejemplo n.º 4
0
 def __getitem__(self, key):
     if len(key) != 2:
         error("Size mismatch for Identity.")
     if all(isinstance(k, (int, FixedIndex)) for k in key):
         return IntValue(1) if (int(key[0]) == int(key[1])) else Zero()
     return Expr.__getitem__(self, key)
Ejemplo n.º 5
0
 def __getitem__(self, key):
     if len(key) != self._dim:
         error("Size mismatch for PermutationSymbol.")
     if all(isinstance(k, (int, FixedIndex)) for k in key):
         return self.__eps(key)
     return Expr.__getitem__(self, key)
Ejemplo n.º 6
0
 def __getitem__(self, key):
     if len(key) != 2:
         error("Size mismatch for Identity.")
     if all(isinstance(k, (int, FixedIndex)) for k in key):
         return IntValue(1) if (int(key[0]) == int(key[1])) else Zero()
     return Expr.__getitem__(self, key)