Beispiel #1
0
 def _check_symbolic_index(self, index):
     # Check if any index is symbolic:
     tuple_index = (index if isinstance(index, tuple) else (index,))
     if any([(isinstance(i, Expr) and (not i.is_number)) for i in tuple_index]):
         for i, nth_dim in zip(tuple_index, self.shape):
             if ((i < 0) == True) or ((i >= nth_dim) == True):
                 raise ValueError("index out of range")
         from sympy.tensor import Indexed
         return Indexed(self, *tuple_index)
     return None
Beispiel #2
0
 def __getitem__(self, indices, **kw_args):
     if is_sequence(indices):
         # Special case needed because M[*my_tuple] is a syntax error.
         return Indexed(self, *indices, **kw_args)
     else:
         return Indexed(self, indices, **kw_args)