Skip to content

Commit

Permalink
Fixes in finite_word.py for pycodestyle and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanni-romanenko committed Jan 31, 2025
1 parent 75afce1 commit a09fd05
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/sage/combinat/words/finite_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,7 @@ def defect(self, f=None):
# Compute g_w
alreadyFoundLetterPairs = set()
for letter in self.letters():
if not((letter, f(letter)[0]) in alreadyFoundLetterPairs):
if (letter, f(letter)[0]) not in alreadyFoundLetterPairs:
alreadyFoundLetterPairs.add((letter, f(letter)[0]))
alreadyFoundLetterPairs.add((f(letter)[0], letter))
if letter != f(letter)[0]:
Expand Down Expand Up @@ -3283,7 +3283,7 @@ def _g_defect_build_g_palindromes_tree(self, morphismsG, inverseMorphismsG, pali
curLeftLetter, curRightLetter = specialLetter, specialLetter
if equivalenceLeftLetter != specialLetter:
curLeftLetter, curRightLetter = morphism(equivalenceLeftLetter)[0], morphism(equivalenceRightLetter)[0]
if not((gNode[2][i], curLeftLetter, curRightLetter) in nextDictsIdentifiers):
if (gNode[2][i], curLeftLetter, curRightLetter) not in nextDictsIdentifiers:
nextDictsIdentifiers[(gNode[2][i], curLeftLetter, curRightLetter)] = curMaxDictIndex
curMaxDictIndex += 1
nextDicts.append(dict())
Expand Down Expand Up @@ -3338,7 +3338,7 @@ def _g_defect_secondary_subtrahend(self, morphismsG, antimorphismsG):
g_G = 0
alreadyFoundLetters = set()
for letter in self.letters():
if not(letter in alreadyFoundLetters):
if letter not in alreadyFoundLetters:
letterContributes = True
alreadyFoundLetters.add(letter)
for antimorphism in antimorphismsG:
Expand Down Expand Up @@ -4092,7 +4092,7 @@ def _build_palindromes_tree(self, diffForest, wordWithSpecialLetter, specialLett
a tree -- tree graph, which contains data about
palindromic factors of ``wordWithSpecialLetter``.
EXAMPLES::
sage: Word()._build_palindromes_tree([[[0, 0, 1, []]], [[1, 0, 1, []]],
Expand Down Expand Up @@ -4120,7 +4120,7 @@ def _build_palindromes_tree(self, diffForest, wordWithSpecialLetter, specialLett
[[{'0': 1}, None, 0, False], [{'a': 2}, 1, 0, True], [{}, 1, 2, False]]
sage: Word()._build_palindromes_tree([[[1, 0, 1, []]]], 'a0a', '0')
[[{'0': 1}, None, 0, False], [{}, 1, 0, True]]
sage: Word()._build_palindromes_tree([[[1, 0, 2, []]],
sage: Word()._build_palindromes_tree([[[1, 0, 2, []]],
....: [[3, 0, 1, [1]], [7, 1, 4, []]], [[5, 0, 3, []]]], 'a0b0b0a0b0a', '0')
[[{'0': 1}, None, 0, False],
[{'a': 2, 'b': 5}, 1, 0, True],
Expand Down Expand Up @@ -4170,8 +4170,7 @@ def _build_palindromes_tree(self, diffForest, wordWithSpecialLetter, specialLett
nextPalindromeIndex = currentPalindrome[0][leftLetter]
currentPalindrome = palindromesTree[nextPalindromeIndex]
palindromeIndexes.append(nextPalindromeIndex)
if centerIndex < currentPalindrome[1]:
currentPalindrome[1] = centerIndex
currentPalindrome[1] = min(currentPalindrome[1], centerIndex)
else:
nextPalindromeIndex = len(palindromesTree)
currentPalindrome[0][leftLetter] = nextPalindromeIndex
Expand Down

0 comments on commit a09fd05

Please sign in to comment.