diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 060295be280..87d2dc0b473 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -3037,10 +3037,6 @@ def _canonicalize_sym_antisym(nb_indices, sym=None, antisym=None, *, antisymmetries among the arguments, with the same convention as for ``sym`` - - ``trivial_symmetries`` -- (default: ``"drop"``) if ``"error"``, raise - an :class:`IndexError` if any trivial symmetries are provided; - otherwise, silently drop them - EXAMPLES:: sage: from sage.tensor.modules.comp import CompWithSym @@ -3063,12 +3059,8 @@ def _canonicalize_sym_antisym(nb_indices, sym=None, antisym=None, *, sym = (tuple(sym),) for isym in sym: if len(isym) < 2: - if trivial_symmetries == 'error': - raise IndexError("at least two index positions must be " + - "provided to define a symmetry") - else: - # Drop trivial symmetry - continue + # Drop trivial symmetry + continue isym = tuple(sorted(isym)) if isym[0] < 0 or isym[-1] > nb_indices - 1: raise IndexError("invalid index position: " + str(i) + @@ -3079,20 +3071,16 @@ def _canonicalize_sym_antisym(nb_indices, sym=None, antisym=None, *, antisym = [] else: # Handle the case that antisym is an iterator - antisym = tuple(antisym) + antisym = list(antisym) if antisym: if isinstance(antisym[0], (int, Integer)): # a single antisymmetry is provided as a tuple or a range # object; it is converted to a 1-item list: - antisym = (tuple(antisym),) + antisym = [tuple(antisym)] for isym in antisym: if len(isym) < 2: - if trivial_symmetries == 'error': - raise IndexError("at least two index positions must be " + - "provided to define an antisymmetry") - else: - # Drop trivial antisymmetry - continue + # Drop trivial antisymmetry + continue isym = tuple(sorted(isym)) if isym[0] < 0 or isym[-1] > nb_indices - 1: raise IndexError("invalid index position: " + str(i) + diff --git a/src/sage/tensor/modules/finite_rank_free_module.py b/src/sage/tensor/modules/finite_rank_free_module.py index 889bc3fb7b0..442b5576b49 100644 --- a/src/sage/tensor/modules/finite_rank_free_module.py +++ b/src/sage/tensor/modules/finite_rank_free_module.py @@ -1669,8 +1669,7 @@ def tensor(self, tensor_type, name=None, latex_name=None, sym=None, """ from .comp import CompWithSym sym, antisym = CompWithSym._canonicalize_sym_antisym( - tensor_type[0] + tensor_type[1], sym, antisym, - trivial_symmetries='error') + tensor_type[0] + tensor_type[1], sym, antisym) # Special cases: if tensor_type == (1,0): return self.element_class(self, name=name, latex_name=latex_name)