Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Revert "FiniteRankFreeModule.tensor: Restore error when trivial symme…
Browse files Browse the repository at this point in the history
…tries are passed"

This reverts commit 564be35.
  • Loading branch information
mkoeppe committed Sep 1, 2022
1 parent 8a2c71a commit e34306b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
24 changes: 6 additions & 18 deletions src/sage/tensor/modules/comp.py
Expand Up @@ -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
Expand All @@ -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) +
Expand All @@ -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) +
Expand Down
3 changes: 1 addition & 2 deletions src/sage/tensor/modules/finite_rank_free_module.py
Expand Up @@ -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)
Expand Down

0 comments on commit e34306b

Please sign in to comment.