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

Commit

Permalink
Bug correction and updated documentation and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LBrunswic committed Jan 29, 2020
1 parent cd96494 commit 93ec3e7
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/sage/tensor/modules/tensor_with_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ class TensorWithIndices(SageObject):
Traceback (most recent call last):
...
ValueError: index conventions not satisfied: repeated indices of same type
sage: (a*a)['^(ij)^(kl)'] # multiple indices group of the same type
Traceback (most recent call last):
...
ValueError: index conventions not satisfied
sage: a["^éa"] # accentuated index name
Traceback (most recent call last):
...
Expand Down Expand Up @@ -282,18 +278,20 @@ def _parse_indices(indices, tensor_type=None, allow_contraction=True,
Traceback (most recent call last):
...
ValueError: index conventions not satisfied: repeated indices of same type
sage: TensorWithIndices._parse_indices('^(ij)^(kl)') # multiple indices group of the same type
Traceback (most recent call last):
...
ValueError: index conventions not satisfied
sage: TensorWithIndices._parse_indices("^éa") # accentuated index name
Traceback (most recent call last):
...
ValueError: index conventions not satisfied
sage: TensorWithIndices._parse_indices('^ij_kl')
('ij', 'kl')
sage: TensorWithIndices._parse_indices('^i_j^k_l')
('ik', 'jl')
sage: TensorWithIndices._parse_indices('^i_k^j_l')
('ij', 'kl')
sage: TensorWithIndices._parse_indices('_kl^ij')
('ij', 'kl')
sage: TensorWithIndices._parse_indices('^(ij)^(kl)') # multiple indices group of the same type
('(ij)(kl)', '')
sage: TensorWithIndices._parse_indices("(ij)_ik",tensor_type=(2,2))
('(ij)', 'ik')
sage: TensorWithIndices._parse_indices("(ij)_ik",tensor_type=(2,0))
Expand Down Expand Up @@ -331,13 +329,11 @@ def _parse_indices(indices, tensor_type=None, allow_contraction=True,
elif re.match(mixed,indices) is not None:
con = ""
cov = ""
r"^(?P<type>(\_[\^))(?P<indices>" + allowed_pattern +")"
for indices_match in re.finditer(mixed,indices):
indices_match = re.match(mixed,indices[i:])
if indices_match.groupdict["type"] == "^":
con += indices_match.groupdict[indices]
for indices_match in re.finditer(r"(?P<T>(\_|\^))(?P<indices>" + allowed_pattern +")",indices):
if indices_match.groupdict()["T"] == "^":
con += indices_match.groupdict()["indices"]
else:
cov += indices_match.groupdict[indices]
cov += indices_match.groupdict()["indices"]
else:
try:
cov,con = indices.replace("_","").split("^")
Expand Down

0 comments on commit 93ec3e7

Please sign in to comment.