passagemath-combinat 10.6.1__cp312-cp312-musllinux_1_2_aarch64.whl → 10.8.1a1__cp312-cp312-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. passagemath_combinat/__init__.py +3 -0
  2. {passagemath_combinat-10.6.1.dist-info → passagemath_combinat-10.8.1a1.dist-info}/METADATA +17 -20
  3. {passagemath_combinat-10.6.1.dist-info → passagemath_combinat-10.8.1a1.dist-info}/RECORD +220 -218
  4. {passagemath_combinat-10.6.1.dist-info → passagemath_combinat-10.8.1a1.dist-info}/WHEEL +1 -1
  5. passagemath_combinat-10.8.1a1.dist-info/top_level.txt +3 -0
  6. sage/algebras/affine_nil_temperley_lieb.py +3 -3
  7. sage/algebras/all.py +0 -1
  8. sage/algebras/askey_wilson.py +1 -1
  9. sage/algebras/associated_graded.py +2 -2
  10. sage/algebras/cellular_basis.py +3 -6
  11. sage/algebras/cluster_algebra.py +2 -3
  12. sage/algebras/down_up_algebra.py +6 -6
  13. sage/algebras/free_algebra.py +3 -32
  14. sage/algebras/free_algebra_element.py +21 -25
  15. sage/algebras/free_algebra_quotient_element.py +9 -38
  16. sage/algebras/free_zinbiel_algebra.py +4 -3
  17. sage/algebras/hall_algebra.py +2 -2
  18. sage/algebras/hecke_algebras/ariki_koike_algebra.py +8 -8
  19. sage/algebras/hecke_algebras/ariki_koike_specht_modules.py +2 -2
  20. sage/algebras/hecke_algebras/cubic_hecke_algebra.py +11 -14
  21. sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +1 -1
  22. sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +5 -5
  23. sage/algebras/iwahori_hecke_algebra.py +59 -57
  24. sage/algebras/jordan_algebra.py +97 -89
  25. sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py +6 -6
  26. sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +14 -12
  27. sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py +6 -6
  28. sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py +4 -4
  29. sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py +13 -13
  30. sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +8 -6
  31. sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +7 -5
  32. sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py +7 -7
  33. sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py +6 -5
  34. sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +12 -11
  35. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +3 -3
  36. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py +3 -3
  37. sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +11 -11
  38. sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py +3 -3
  39. sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py +8 -7
  40. sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py +9 -8
  41. sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py +6 -5
  42. sage/algebras/nil_coxeter_algebra.py +4 -4
  43. sage/algebras/q_commuting_polynomials.py +6 -6
  44. sage/algebras/q_system.py +3 -3
  45. sage/algebras/quantum_clifford.py +8 -8
  46. sage/algebras/quantum_groups/fock_space.py +48 -8
  47. sage/algebras/quantum_groups/quantum_group_gap.py +5 -7
  48. sage/algebras/quantum_matrix_coordinate_algebra.py +7 -7
  49. sage/algebras/quantum_oscillator.py +3 -3
  50. sage/algebras/quaternion_algebra_element.py +5 -3
  51. sage/algebras/schur_algebra.py +3 -3
  52. sage/algebras/shuffle_algebra.py +5 -8
  53. sage/algebras/splitting_algebra.py +129 -85
  54. sage/algebras/tensor_algebra.py +7 -7
  55. sage/algebras/yangian.py +16 -15
  56. sage/algebras/yokonuma_hecke_algebra.py +13 -11
  57. sage/combinat/all.py +9 -0
  58. sage/combinat/all__sagemath_combinat.py +1 -0
  59. sage/combinat/alternating_sign_matrix.py +36 -29
  60. sage/combinat/baxter_permutations.py +32 -12
  61. sage/combinat/bijectionist.py +13 -17
  62. sage/combinat/chas/fsym.py +6 -6
  63. sage/combinat/chas/wqsym.py +23 -29
  64. sage/combinat/colored_permutations.py +9 -11
  65. sage/combinat/colored_permutations_representations.py +13 -12
  66. sage/combinat/composition_tableau.py +2 -2
  67. sage/combinat/constellation.py +57 -30
  68. sage/combinat/crystals/affine_factorization.py +5 -4
  69. sage/combinat/crystals/alcove_path.py +2 -2
  70. sage/combinat/crystals/fully_commutative_stable_grothendieck.py +3 -2
  71. sage/combinat/crystals/infinity_crystals.py +18 -18
  72. sage/combinat/crystals/kac_modules.py +1 -1
  73. sage/combinat/crystals/kirillov_reshetikhin.py +2 -2
  74. sage/combinat/crystals/letters.cpython-312-aarch64-linux-musl.so +0 -0
  75. sage/combinat/crystals/littelmann_path.py +1 -1
  76. sage/combinat/crystals/pbw_datum.cpython-312-aarch64-linux-musl.so +0 -0
  77. sage/combinat/crystals/pbw_datum.pyx +3 -2
  78. sage/combinat/crystals/spins.cpython-312-aarch64-linux-musl.so +0 -0
  79. sage/combinat/crystals/tensor_product.py +7 -5
  80. sage/combinat/crystals/tensor_product_element.cpython-312-aarch64-linux-musl.so +0 -0
  81. sage/combinat/debruijn_sequence.cpython-312-aarch64-linux-musl.so +0 -0
  82. sage/combinat/debruijn_sequence.pyx +1 -2
  83. sage/combinat/degree_sequences.cpython-312-aarch64-linux-musl.so +0 -0
  84. sage/combinat/degree_sequences.pyx +241 -188
  85. sage/combinat/derangements.py +28 -22
  86. sage/combinat/diagram_algebras.py +12 -14
  87. sage/combinat/dyck_word.py +15 -14
  88. sage/combinat/e_one_star.py +1 -1
  89. sage/combinat/expnums.cpython-312-aarch64-linux-musl.so +0 -0
  90. sage/combinat/fast_vector_partitions.cpython-312-aarch64-linux-musl.so +0 -0
  91. sage/combinat/fqsym.py +13 -19
  92. sage/combinat/free_dendriform_algebra.py +2 -2
  93. sage/combinat/free_prelie_algebra.py +2 -2
  94. sage/combinat/fully_commutative_elements.py +8 -8
  95. sage/combinat/fully_packed_loop.py +9 -9
  96. sage/combinat/gelfand_tsetlin_patterns.py +4 -5
  97. sage/combinat/gray_codes.py +3 -4
  98. sage/combinat/grossman_larson_algebras.py +2 -2
  99. sage/combinat/growth.py +13 -13
  100. sage/combinat/hall_polynomial.py +1 -1
  101. sage/combinat/hillman_grassl.py +1 -1
  102. sage/combinat/integer_matrices.py +5 -7
  103. sage/combinat/k_tableau.py +8 -7
  104. sage/combinat/kazhdan_lusztig.py +3 -3
  105. sage/combinat/key_polynomial.py +845 -298
  106. sage/combinat/knutson_tao_puzzles.py +11 -13
  107. sage/combinat/matrices/hadamard_matrix.py +1 -1
  108. sage/combinat/matrices/latin.py +75 -92
  109. sage/combinat/misc.py +3 -3
  110. sage/combinat/multiset_partition_into_sets_ordered.py +27 -10
  111. sage/combinat/ncsf_qsym/generic_basis_code.py +5 -5
  112. sage/combinat/ncsf_qsym/ncsf.py +6 -5
  113. sage/combinat/ncsf_qsym/qsym.py +9 -17
  114. sage/combinat/ncsym/ncsym.py +8 -12
  115. sage/combinat/nu_dyck_word.py +1 -1
  116. sage/combinat/parallelogram_polyomino.py +3 -5
  117. sage/combinat/parking_functions.py +6 -5
  118. sage/combinat/partition_algebra.py +22 -57
  119. sage/combinat/partition_kleshchev.py +4 -4
  120. sage/combinat/partition_tuple.py +12 -10
  121. sage/combinat/plane_partition.py +10 -13
  122. sage/combinat/positive_integer_semigroup_test.py +17 -0
  123. sage/combinat/q_bernoulli.cpython-312-aarch64-linux-musl.so +0 -0
  124. sage/combinat/quickref.py +2 -2
  125. sage/combinat/recognizable_series.py +2 -2
  126. sage/combinat/regular_sequence.py +7 -7
  127. sage/combinat/regular_sequence_bounded.py +15 -21
  128. sage/combinat/restricted_growth.py +3 -3
  129. sage/combinat/ribbon.py +3 -3
  130. sage/combinat/rigged_configurations/bijection.py +3 -3
  131. sage/combinat/rigged_configurations/rigged_partition.cpython-312-aarch64-linux-musl.so +0 -0
  132. sage/combinat/rsk.py +2 -0
  133. sage/combinat/schubert_polynomial.py +11 -2
  134. sage/combinat/set_partition.py +3 -7
  135. sage/combinat/set_partition_iterator.cpython-312-aarch64-linux-musl.so +0 -0
  136. sage/combinat/set_partition_iterator.pyx +0 -1
  137. sage/combinat/set_partition_ordered.py +2 -2
  138. sage/combinat/sf/classical.py +1 -1
  139. sage/combinat/sf/dual.py +4 -8
  140. sage/combinat/sf/elementary.py +13 -7
  141. sage/combinat/sf/hall_littlewood.py +10 -8
  142. sage/combinat/sf/homogeneous.py +6 -3
  143. sage/combinat/sf/jack.py +11 -9
  144. sage/combinat/sf/llt.py +4 -5
  145. sage/combinat/sf/macdonald.py +10 -11
  146. sage/combinat/sf/monomial.py +6 -0
  147. sage/combinat/sf/ns_macdonald.py +92 -51
  148. sage/combinat/sf/powersum.py +9 -14
  149. sage/combinat/sf/schur.py +6 -0
  150. sage/combinat/sf/sf.py +21 -19
  151. sage/combinat/sf/sfa.py +13 -64
  152. sage/combinat/shifted_primed_tableau.py +5 -7
  153. sage/combinat/shuffle.py +1 -1
  154. sage/combinat/sine_gordon.py +18 -38
  155. sage/combinat/skew_partition.py +9 -12
  156. sage/combinat/skew_tableau.py +2 -7
  157. sage/combinat/sloane_functions.py +1 -1
  158. sage/combinat/species/all.py +67 -2
  159. sage/combinat/species/characteristic_species.py +3 -0
  160. sage/combinat/species/composition_species.py +3 -0
  161. sage/combinat/species/cycle_species.py +4 -0
  162. sage/combinat/species/empty_species.py +3 -0
  163. sage/combinat/species/functorial_composition_species.py +3 -0
  164. sage/combinat/species/generating_series.py +3 -0
  165. sage/combinat/species/library.py +3 -0
  166. sage/combinat/species/linear_order_species.py +3 -0
  167. sage/combinat/species/partition_species.py +3 -0
  168. sage/combinat/species/permutation_species.py +4 -0
  169. sage/combinat/species/product_species.py +3 -0
  170. sage/combinat/species/recursive_species.py +3 -0
  171. sage/combinat/species/set_species.py +3 -0
  172. sage/combinat/species/species.py +13 -7
  173. sage/combinat/species/structure.py +8 -9
  174. sage/combinat/species/subset_species.py +3 -0
  175. sage/combinat/species/sum_species.py +3 -0
  176. sage/combinat/subword.py +4 -1
  177. sage/combinat/subword_complex.py +7 -7
  178. sage/combinat/subword_complex_c.cpython-312-aarch64-linux-musl.so +0 -0
  179. sage/combinat/superpartition.py +1 -1
  180. sage/combinat/symmetric_group_algebra.py +9 -9
  181. sage/combinat/symmetric_group_representations.py +5 -5
  182. sage/combinat/t_sequences.py +4 -4
  183. sage/combinat/tableau.py +3 -4
  184. sage/combinat/tableau_tuple.py +2 -2
  185. sage/combinat/tiling.py +39 -42
  186. sage/combinat/triangles_FHM.py +38 -15
  187. sage/combinat/tutorial.py +2 -2
  188. sage/combinat/vector_partition.py +43 -31
  189. sage/combinat/words/abstract_word.py +4 -4
  190. sage/combinat/words/alphabet.py +12 -12
  191. sage/combinat/words/finite_word.py +25 -229
  192. sage/combinat/words/infinite_word.py +1 -1
  193. sage/combinat/words/morphic.py +13 -13
  194. sage/combinat/words/morphism.py +3 -12
  195. sage/combinat/words/paths.py +16 -17
  196. sage/combinat/words/word.py +60 -35
  197. sage/combinat/words/word_char.cpython-312-aarch64-linux-musl.so +0 -0
  198. sage/combinat/words/word_char.pyx +46 -7
  199. sage/combinat/words/word_datatypes.cpython-312-aarch64-linux-musl.so +0 -0
  200. sage/combinat/words/word_generators.py +39 -38
  201. sage/databases/findstat.py +72 -31
  202. sage/databases/oeis.py +125 -25
  203. sage/databases/sloane.py +14 -8
  204. sage/games/sudoku_backtrack.cpython-312-aarch64-linux-musl.so +0 -0
  205. sage/groups/indexed_free_group.py +3 -4
  206. sage/libs/symmetrica/symmetrica.cpython-312-aarch64-linux-musl.so +0 -0
  207. sage/libs/symmetrica/symmetrica.pxi +1 -0
  208. sage/monoids/automatic_semigroup.py +1 -3
  209. sage/monoids/free_abelian_monoid.py +7 -33
  210. sage/monoids/free_abelian_monoid_element.cpython-312-aarch64-linux-musl.so +0 -0
  211. sage/monoids/free_monoid.py +8 -40
  212. sage/monoids/free_monoid_element.py +1 -9
  213. sage/monoids/string_monoid.py +5 -2
  214. sage/monoids/string_monoid_element.py +12 -66
  215. sage/rings/all__sagemath_combinat.py +7 -0
  216. sage/sat/solvers/__init__.py +3 -4
  217. sage/sat/solvers/cryptominisat.py +2 -3
  218. sage/sat/solvers/picosat.py +2 -3
  219. sage/sat/solvers/sat_lp.py +2 -2
  220. sage/sat/solvers/satsolver.cpython-312-aarch64-linux-musl.so +0 -0
  221. passagemath_combinat-10.6.1.dist-info/top_level.txt +0 -2
@@ -1248,7 +1248,7 @@ class FiniteWord_class(Word_class):
1248
1248
  elif algorithm == 'naive':
1249
1249
  return ZZ(len(self.factor_set(n, algorithm='naive')))
1250
1250
  else:
1251
- raise ValueError(f'Unknown algorithm (={algorithm})')
1251
+ raise ValueError(f'unknown algorithm (={algorithm})')
1252
1252
 
1253
1253
  def factor_iterator(self, n=None):
1254
1254
  r"""
@@ -1424,7 +1424,7 @@ class FiniteWord_class(Word_class):
1424
1424
  S.add(self[i:i+n])
1425
1425
  return Set(S)
1426
1426
  else:
1427
- raise ValueError(f'Unknown algorithm (={algorithm})')
1427
+ raise ValueError(f'unknown algorithm (={algorithm})')
1428
1428
 
1429
1429
  def topological_entropy(self, n):
1430
1430
  r"""
@@ -1475,7 +1475,7 @@ class FiniteWord_class(Word_class):
1475
1475
  sage: w.topological_entropy(3)
1476
1476
  Traceback (most recent call last):
1477
1477
  ...
1478
- TypeError: The word must be defined over a finite alphabet
1478
+ TypeError: the word must be defined over a finite alphabet
1479
1479
 
1480
1480
  The following is ok::
1481
1481
 
@@ -1486,7 +1486,7 @@ class FiniteWord_class(Word_class):
1486
1486
  """
1487
1487
  d = self.parent().alphabet().cardinality()
1488
1488
  if d is Infinity:
1489
- raise TypeError("The word must be defined over a finite alphabet")
1489
+ raise TypeError("the word must be defined over a finite alphabet")
1490
1490
  if n == 0:
1491
1491
  return 1
1492
1492
  pn = self.number_of_factors(n)
@@ -1676,7 +1676,7 @@ class FiniteWord_class(Word_class):
1676
1676
  g = copy(self.rauzy_graph(n))
1677
1677
  # Otherwise it changes the rauzy_graph function.
1678
1678
  l = [v for v in g if g.in_degree(v) == 1 == g.out_degree(v)]
1679
- if g.num_verts() != 0 and len(l) == g.num_verts():
1679
+ if len(l) == g.n_vertices() != 0:
1680
1680
  # In this case, the Rauzy graph is simply a cycle.
1681
1681
  g = DiGraph()
1682
1682
  g.allow_loops(True)
@@ -3583,13 +3583,9 @@ class FiniteWord_class(Word_class):
3583
3583
  """
3584
3584
  if p < 0:
3585
3585
  return False
3586
- elif p >= len(self):
3587
- return True
3588
- else:
3589
- for i in range(len(self) - p):
3590
- if self[i] != self[i + p]:
3591
- return False
3586
+ if p >= len(self):
3592
3587
  return True
3588
+ return all(self[i] == self[i + p] for i in range(len(self) - p))
3593
3589
 
3594
3590
  def periods(self, divide_length=False):
3595
3591
  r"""
@@ -4155,71 +4151,6 @@ class FiniteWord_class(Word_class):
4155
4151
  d.update((letter, i) for i, letter in enumerate(self))
4156
4152
  return d
4157
4153
 
4158
- def _pos_in(self, other, p):
4159
- r"""
4160
- Return the position of the first occurrence of ``self`` starting at
4161
- position ``p`` in ``other``.
4162
-
4163
- .. WARNING::
4164
-
4165
- This method is deprecated since 2020 and will be removed in a
4166
- later version of SageMath.
4167
- Use :meth:`first_occurrence` instead.
4168
-
4169
- EXAMPLES::
4170
-
4171
- sage: Word('12')._pos_in(Word('131231'), 2)
4172
- doctest:warning
4173
- ...
4174
- DeprecationWarning: f._pos_in(w, start) is deprecated.
4175
- Use w.first_occurrence(f, start) instead.
4176
- See https://github.com/sagemath/sage/issues/30187 for details.
4177
- 2
4178
- sage: Word('12')._pos_in(Word('131231'), 3) is None
4179
- True
4180
- sage: Word('32')._pos_in(Word('131231'), 0) is None
4181
- True
4182
-
4183
- The empty word occurs in a word::
4184
-
4185
- sage: Word('')._pos_in(Word('123'), 0)
4186
- 0
4187
- sage: Word('')._pos_in(Word(''), 0)
4188
- 0
4189
- """
4190
- from sage.misc.superseded import deprecation
4191
- deprecation(30187, 'f._pos_in(w, start) is deprecated.'
4192
- ' Use w.first_occurrence(f, start) instead.')
4193
- return other.first_occurrence(self, p)
4194
-
4195
- def first_pos_in(self, other):
4196
- r"""
4197
- Return the position of the first occurrence of ``self`` in ``other``,
4198
- or ``None`` if ``self`` is not a factor of ``other``.
4199
-
4200
- .. WARNING::
4201
-
4202
- This method is deprecated since 2020 and will be removed in a
4203
- later version of SageMath.
4204
- Use :meth:`first_occurrence` instead.
4205
-
4206
- EXAMPLES::
4207
-
4208
- sage: Word('12').first_pos_in(Word('131231'))
4209
- doctest:warning
4210
- ...
4211
- DeprecationWarning: f.first_pos_in(w) is deprecated.
4212
- Use w.first_occurrence(f) instead.
4213
- See https://github.com/sagemath/sage/issues/30187 for details.
4214
- 2
4215
- sage: Word('32').first_pos_in(Word('131231')) is None
4216
- True
4217
- """
4218
- from sage.misc.superseded import deprecation
4219
- deprecation(30187, 'f.first_pos_in(w) is deprecated.'
4220
- ' Use w.first_occurrence(f) instead.')
4221
- return other.first_occurrence(self)
4222
-
4223
4154
  def find(self, sub, start=0, end=None):
4224
4155
  r"""
4225
4156
  Return the index of the first occurrence of ``sub`` in ``self``,
@@ -4413,138 +4344,6 @@ class FiniteWord_class(Word_class):
4413
4344
  """
4414
4345
  return other.first_occurrence(self) is not None
4415
4346
 
4416
- def factor_occurrences_in(self, other):
4417
- r"""
4418
- Return an iterator over all occurrences (including overlapping ones)
4419
- of ``self`` in ``other`` in their order of appearance.
4420
-
4421
- .. WARNING::
4422
-
4423
- This method is deprecated since 2020 and will be removed in a
4424
- later version of SageMath.
4425
- Use :meth:`factor_occurrences_iterator` instead.
4426
-
4427
- EXAMPLES::
4428
-
4429
- sage: u = Word('121')
4430
- sage: w = Word('121213211213')
4431
- sage: list(u.factor_occurrences_in(w))
4432
- doctest:warning
4433
- ...
4434
- DeprecationWarning: f.factor_occurrences_in(w) is deprecated.
4435
- Use w.factor_occurrences_iterator(f) instead.
4436
- See https://github.com/sagemath/sage/issues/30187 for details.
4437
- [0, 2, 8]
4438
- """
4439
- from sage.misc.superseded import deprecation
4440
- deprecation(30187, 'f.factor_occurrences_in(w) is deprecated.'
4441
- ' Use w.factor_occurrences_iterator(f) instead.')
4442
- return other.factor_occurrences_iterator(self)
4443
-
4444
- def nb_factor_occurrences_in(self, other):
4445
- r"""
4446
- Return the number of times ``self`` appears as a factor
4447
- in ``other``.
4448
-
4449
- .. WARNING::
4450
-
4451
- This method is deprecated since 2020 and will be removed in a
4452
- later version of SageMath.
4453
- Use :meth:`number_of_factor_occurrences` instead.
4454
-
4455
- EXAMPLES::
4456
-
4457
- sage: Word('123').nb_factor_occurrences_in(Word('112332312313112332121123'))
4458
- doctest:warning
4459
- ...
4460
- DeprecationWarning: f.nb_factor_occurrences_in(w) is deprecated.
4461
- Use w.number_of_factor_occurrences(f) instead.
4462
- See https://github.com/sagemath/sage/issues/30187 for details.
4463
- 4
4464
- sage: Word('321').nb_factor_occurrences_in(Word('11233231231311233221123'))
4465
- 0
4466
-
4467
- An error is raised for the empty word::
4468
-
4469
- sage: Word().nb_factor_occurrences_in(Word('123'))
4470
- Traceback (most recent call last):
4471
- ...
4472
- NotImplementedError: The factor must be non empty
4473
- """
4474
- from sage.misc.superseded import deprecation
4475
- deprecation(30187, 'f.nb_factor_occurrences_in(w) is deprecated.'
4476
- ' Use w.number_of_factor_occurrences(f) instead.')
4477
- return other.number_of_factor_occurrences(self)
4478
-
4479
- def nb_subword_occurrences_in(self, other):
4480
- r"""
4481
- Return the number of times ``self`` appears in ``other`` as a subword.
4482
-
4483
- This corresponds to the notion of `binomial coefficient` of two
4484
- finite words whose properties are presented in the chapter of
4485
- Lothaire's book written by Sakarovitch and Simon [Lot1997]_.
4486
-
4487
- .. WARNING::
4488
-
4489
- This method is deprecated since 2020 and will be removed in a
4490
- later version of SageMath.
4491
- Use :meth:`number_of_subword_occurrences` instead.
4492
-
4493
- INPUT:
4494
-
4495
- - ``other`` -- finite word
4496
-
4497
- EXAMPLES::
4498
-
4499
- sage: tm = words.ThueMorseWord()
4500
-
4501
- sage: u = Word([0,1,0,1])
4502
- sage: u.nb_subword_occurrences_in(tm[:1000])
4503
- doctest:warning
4504
- ...
4505
- DeprecationWarning: f.nb_subword_occurrences_in(w) is deprecated.
4506
- Use w.number_of_subword_occurrences(f) instead.
4507
- See https://github.com/sagemath/sage/issues/30187 for details.
4508
- 2604124996
4509
-
4510
- sage: u = Word([0,1,0,1,1,0])
4511
- sage: u.nb_subword_occurrences_in(tm[:100])
4512
- 20370432
4513
-
4514
- .. NOTE::
4515
-
4516
- This code, based on [MSSY2001]_, actually compute the number of
4517
- occurrences of all prefixes of ``self`` as subwords in all
4518
- prefixes of ``other``. In particular, its complexity is
4519
- bounded by ``len(self) * len(other)``.
4520
-
4521
- TESTS::
4522
-
4523
- sage: Word('').nb_subword_occurrences_in(Word(''))
4524
- 1
4525
- sage: parent(_)
4526
- Integer Ring
4527
- sage: v,u = Word(), Word('123')
4528
- sage: v.nb_subword_occurrences_in(u)
4529
- 1
4530
- sage: v,u = Word('123'), Word('1133432311132311112')
4531
- sage: v.nb_subword_occurrences_in(u)
4532
- 11
4533
- sage: v,u = Word('4321'), Word('1132231112233212342231112')
4534
- sage: v.nb_subword_occurrences_in(u)
4535
- 0
4536
- sage: v,u = Word('3'), Word('122332112321213')
4537
- sage: v.nb_subword_occurrences_in(u)
4538
- 4
4539
- sage: v,u = Word([]), words.ThueMorseWord()[:1000]
4540
- sage: v.nb_subword_occurrences_in(u)
4541
- 1
4542
- """
4543
- from sage.misc.superseded import deprecation
4544
- deprecation(30187, 'f.nb_subword_occurrences_in(w) is deprecated.'
4545
- ' Use w.number_of_subword_occurrences(f) instead.')
4546
- return other.number_of_subword_occurrences(self)
4547
-
4548
4347
  def number_of_factor_occurrences(self, other):
4549
4348
  r"""
4550
4349
  Return the number of times ``other`` appears as a factor
@@ -4573,7 +4372,7 @@ class FiniteWord_class(Word_class):
4573
4372
  sage: Word('123').number_of_factor_occurrences(Word())
4574
4373
  Traceback (most recent call last):
4575
4374
  ...
4576
- NotImplementedError: The factor must be non empty
4375
+ NotImplementedError: the factor must be non empty
4577
4376
  """
4578
4377
  return sum(1 for _ in self.factor_occurrences_iterator(other))
4579
4378
 
@@ -5102,14 +4901,14 @@ class FiniteWord_class(Word_class):
5102
4901
  {{-4, -2, 0, 2, 4}, {-5, -3, -1, 1, 3, 5}}
5103
4902
  """
5104
4903
  if not isinstance(delay, (int, Integer)):
5105
- raise TypeError("delay (=%s) must be an integer" % delay)
4904
+ raise TypeError(f"delay (={delay}) must be an integer")
5106
4905
  elif delay < 0:
5107
4906
  return other.overlap_partition(self, -delay, p)
5108
4907
 
5109
4908
  from sage.sets.disjoint_set import DisjointSet_class
5110
4909
  if p is None:
5111
4910
  if self.parent().alphabet().cardinality() is Infinity:
5112
- raise ValueError("The alphabet of the parent must be finite")
4911
+ raise ValueError("the alphabet of the parent must be finite")
5113
4912
  from sage.sets.disjoint_set import DisjointSet
5114
4913
  p = DisjointSet(self.parent().alphabet())
5115
4914
  elif not isinstance(p, DisjointSet_class):
@@ -5858,7 +5657,7 @@ class FiniteWord_class(Word_class):
5858
5657
  desubstitued_word = desubstitued_word + w_running ** (current_run_length - min_run)
5859
5658
  return desubstitued_word.sturmian_desubstitute_as_possible()
5860
5659
 
5861
- def is_sturmian_factor(self):
5660
+ def is_sturmian_factor(self) -> bool:
5862
5661
  r"""
5863
5662
  Tell whether ``self`` is a factor of a Sturmian word.
5864
5663
 
@@ -5916,7 +5715,7 @@ class FiniteWord_class(Word_class):
5916
5715
  """
5917
5716
  return self.sturmian_desubstitute_as_possible().is_empty()
5918
5717
 
5919
- def is_tangent(self):
5718
+ def is_tangent(self) -> bool:
5920
5719
  r"""
5921
5720
  Tell whether ``self`` is a tangent word.
5922
5721
 
@@ -6495,7 +6294,7 @@ class FiniteWord_class(Word_class):
6495
6294
  res = res.delta_inv(s=tab[i])
6496
6295
  return res
6497
6296
 
6498
- def is_smooth_prefix(self):
6297
+ def is_smooth_prefix(self) -> bool:
6499
6298
  r"""
6500
6299
  Return ``True`` if ``self`` is the prefix of a smooth word, and ``False``
6501
6300
  otherwise.
@@ -6601,18 +6400,18 @@ class FiniteWord_class(Word_class):
6601
6400
  sage: w.standard_factorization()
6602
6401
  Traceback (most recent call last):
6603
6402
  ...
6604
- ValueError: Standard factorization not defined on words of
6403
+ ValueError: standard factorization not defined on words of
6605
6404
  length less than 2
6606
6405
  sage: w = Word('a')
6607
6406
  sage: w.standard_factorization()
6608
6407
  Traceback (most recent call last):
6609
6408
  ...
6610
- ValueError: Standard factorization not defined on words of
6409
+ ValueError: standard factorization not defined on words of
6611
6410
  length less than 2
6612
6411
  """
6613
6412
  selflen = self.length()
6614
6413
  if selflen < 2:
6615
- raise ValueError("Standard factorization not defined on"
6414
+ raise ValueError("standard factorization not defined on"
6616
6415
  " words of length less than 2")
6617
6416
  for l in range(1, selflen):
6618
6417
  suff = self[l:]
@@ -6745,11 +6544,11 @@ class FiniteWord_class(Word_class):
6745
6544
  sage: Word(range(100)).colored_vector(cmap='jolies') # needs sage.plot
6746
6545
  Traceback (most recent call last):
6747
6546
  ...
6748
- RuntimeError: Color map jolies not known
6547
+ RuntimeError: color map jolies not known
6749
6548
  sage: Word(range(100)).colored_vector(cmap='__doc__') # needs sage.plot
6750
6549
  Traceback (most recent call last):
6751
6550
  ...
6752
- RuntimeError: Color map __doc__ not known
6551
+ RuntimeError: color map __doc__ not known
6753
6552
  """
6754
6553
  # Recognize the color map
6755
6554
  import matplotlib.cm as cm
@@ -6765,7 +6564,7 @@ class FiniteWord_class(Word_class):
6765
6564
  if isinstance(val, C))
6766
6565
  import sage.misc.verbose
6767
6566
  sage.misc.verbose.verbose("The possible color maps include: %s" % possibilities, level=0)
6768
- raise RuntimeError("Color map %s not known" % cmap)
6567
+ raise RuntimeError(f"color map {cmap} not known")
6769
6568
 
6770
6569
  # Drawing the colored vector...
6771
6570
  from sage.plot.line import line
@@ -6814,7 +6613,7 @@ class FiniteWord_class(Word_class):
6814
6613
  rep.axes(False)
6815
6614
  return rep
6816
6615
 
6817
- def is_square(self):
6616
+ def is_square(self) -> bool:
6818
6617
  r"""
6819
6618
  Return ``True`` if ``self`` is a square, and ``False`` otherwise.
6820
6619
 
@@ -6837,7 +6636,7 @@ class FiniteWord_class(Word_class):
6837
6636
  l = self.length() // 2
6838
6637
  return self[:l] == self[l:]
6839
6638
 
6840
- def is_square_free(self):
6639
+ def is_square_free(self) -> bool:
6841
6640
  r"""
6842
6641
  Return ``True`` if ``self`` does not contain squares, and ``False``
6843
6642
  otherwise.
@@ -6884,7 +6683,7 @@ class FiniteWord_class(Word_class):
6884
6683
  T = DecoratedSuffixTree(self)
6885
6684
  return set(T.square_vocabulary(output='word'))
6886
6685
 
6887
- def is_cube(self):
6686
+ def is_cube(self) -> bool:
6888
6687
  r"""
6889
6688
  Return ``True`` if ``self`` is a cube, and ``False`` otherwise.
6890
6689
 
@@ -6904,7 +6703,7 @@ class FiniteWord_class(Word_class):
6904
6703
  l = self.length() // 3
6905
6704
  return self[:l] == self[l:2*l] == self[2*l:]
6906
6705
 
6907
- def is_cube_free(self):
6706
+ def is_cube_free(self) -> bool:
6908
6707
  r"""
6909
6708
  Return ``True`` if ``self`` does not contain cubes, and ``False`` otherwise.
6910
6709
 
@@ -6967,7 +6766,7 @@ class FiniteWord_class(Word_class):
6967
6766
  M = FreeMonoid(len(l), l)
6968
6767
  return M(self)
6969
6768
 
6970
- def is_christoffel(self):
6769
+ def is_christoffel(self) -> bool:
6971
6770
  r"""
6972
6771
  Return ``True`` if ``self`` is a Christoffel word, and ``False`` otherwise.
6973
6772
 
@@ -7017,10 +6816,7 @@ class FiniteWord_class(Word_class):
7017
6816
  """
7018
6817
  if len(self) == 0 or len(self.letters()) > 2 or (self.is_palindrome() and len(self) > 1):
7019
6818
  return False
7020
- elif self.is_symmetric() and self[1:len(self) - 1].is_palindrome():
7021
- return True
7022
- else:
7023
- return False
6819
+ return self.is_symmetric() and self[1:len(self) - 1].is_palindrome()
7024
6820
 
7025
6821
  def minimal_conjugate(self):
7026
6822
  r"""
@@ -80,7 +80,7 @@ from sage.rings.infinity import Infinity
80
80
 
81
81
 
82
82
  class InfiniteWord_class(Word_class):
83
- def _repr_(self):
83
+ def _repr_(self) -> str:
84
84
  r"""
85
85
  Return a string representation of ``self``.
86
86
 
@@ -26,6 +26,8 @@ letter, see chapter 3 of the book [BR2010b]_::
26
26
  sage: w[10000000] # needs sage.modules
27
27
  'b'
28
28
  """
29
+ from collections.abc import Iterator
30
+ from itertools import chain
29
31
 
30
32
  from sage.combinat.words.word_infinite_datatypes import WordDatatype_callable
31
33
  from sage.misc.lazy_import import lazy_import
@@ -39,7 +41,8 @@ class WordDatatype_morphic(WordDatatype_callable):
39
41
  Datatype for a morphic word defined by a morphism, a starting letter
40
42
  and a coding.
41
43
  """
42
- def __init__(self, parent, morphism, letter, coding=None, length=Infinity):
44
+ def __init__(self, parent, morphism, letter,
45
+ coding=None, length=Infinity) -> None:
43
46
  r"""
44
47
  INPUT:
45
48
 
@@ -128,7 +131,7 @@ class WordDatatype_morphic(WordDatatype_callable):
128
131
  else:
129
132
  self._coding = coding
130
133
 
131
- def __reduce__(self):
134
+ def __reduce__(self) -> tuple:
132
135
  r"""
133
136
  EXAMPLES::
134
137
 
@@ -157,7 +160,7 @@ class WordDatatype_morphic(WordDatatype_callable):
157
160
  return self.__class__, (self._parent, self._morphism, self._letter,
158
161
  self._coding, self._len)
159
162
 
160
- def representation(self, n):
163
+ def representation(self, n) -> list:
161
164
  r"""
162
165
  Return the representation of the integer n in the numeration system
163
166
  associated to the morphism.
@@ -202,16 +205,16 @@ class WordDatatype_morphic(WordDatatype_callable):
202
205
  sage: w.representation(5) # needs sage.modules
203
206
  [1, 0, 0, 0]
204
207
  """
205
- letters_to_int = {a:i for (i,a) in enumerate(self._alphabet)}
208
+ letters_to_int = {a: i for i, a in enumerate(self._alphabet)}
206
209
  position = letters_to_int[self._letter]
207
210
  M = self._morphism.incidence_matrix()
208
- vMk = vector([1]*len(self._alphabet))
211
+ vMk = vector([1] * len(self._alphabet))
209
212
  length_of_images = []
210
213
  while vMk[position] <= n:
211
214
  length_of_images.append(vMk)
212
- vMk_next = vMk*M
215
+ vMk_next = vMk * M
213
216
  if vMk[position] == vMk_next[position]:
214
- raise IndexError('index (={}) out of range, the fixed point is finite and has length {}'.format(n,vMk[position]))
217
+ raise IndexError(f'index (={n}) out of range, the fixed point is finite and has length {vMk[position]}')
215
218
  vMk = vMk_next
216
219
  k = len(length_of_images)
217
220
  letter_k = self._letter
@@ -224,10 +227,10 @@ class WordDatatype_morphic(WordDatatype_callable):
224
227
  while S <= n_k:
225
228
  a = m_letter_k[j]
226
229
  i = letters_to_int[a]
227
- pile_length = length_of_images[k-1][i]
230
+ pile_length = length_of_images[k - 1][i]
228
231
  S += pile_length
229
232
  j += 1
230
- path.append(j-1)
233
+ path.append(j - 1)
231
234
  n_k -= S - pile_length
232
235
  letter_k = a
233
236
  k -= 1
@@ -270,11 +273,9 @@ class WordDatatype_morphic(WordDatatype_callable):
270
273
  letter = self._letter
271
274
  for a in self.representation(key):
272
275
  letter = (self._morphism(letter))[a]
273
- if key == 0:
274
- return self._coding[letter]
275
276
  return self._coding[letter]
276
277
 
277
- def __iter__(self):
278
+ def __iter__(self) -> Iterator:
278
279
  r"""
279
280
  Return an iterator of the letters of the fixed point of ``self``
280
281
  starting with ``letter``.
@@ -339,7 +340,6 @@ class WordDatatype_morphic(WordDatatype_callable):
339
340
  sage: (s^7).reversal().fixed_points()
340
341
  []
341
342
  """
342
- from itertools import chain
343
343
  w = iter(self._morphism.image(self._letter))
344
344
  while True:
345
345
  try:
@@ -1325,10 +1325,7 @@ class WordMorphism(SageObject):
1325
1325
  sage: WordMorphism('').is_erasing()
1326
1326
  False
1327
1327
  """
1328
- for image in self.images():
1329
- if image.is_empty():
1330
- return True
1331
- return False
1328
+ return any(image.is_empty() for image in self.images())
1332
1329
 
1333
1330
  def is_identity(self):
1334
1331
  r"""
@@ -1548,10 +1545,7 @@ class WordMorphism(SageObject):
1548
1545
  """
1549
1546
  dom_alphabet = set(self.domain().alphabet())
1550
1547
 
1551
- for image in self.images():
1552
- if not dom_alphabet <= set(image):
1553
- return False
1554
- return True
1548
+ return all(dom_alphabet <= set(image) for image in self.images())
1555
1549
 
1556
1550
  def is_primitive(self):
1557
1551
  r"""
@@ -2423,10 +2417,7 @@ class WordMorphism(SageObject):
2423
2417
  sage: (fibo^2).has_conjugate_in_classP()
2424
2418
  True
2425
2419
  """
2426
- for k in self.list_of_conjugates():
2427
- if k.is_in_classP(f=f):
2428
- return True
2429
- return False
2420
+ return any(k.is_in_classP(f=f) for k in self.list_of_conjugates())
2430
2421
 
2431
2422
  def dual_map(self, k=1):
2432
2423
  r"""
@@ -314,11 +314,11 @@ def WordPaths(alphabet, steps=None):
314
314
  sage: WordPaths(range(5))
315
315
  Traceback (most recent call last):
316
316
  ...
317
- TypeError: Unable to make a class WordPaths from {0, 1, 2, 3, 4}
317
+ TypeError: unable to make a class WordPaths from {0, 1, 2, 3, 4}
318
318
  sage: WordPaths('abAB', steps='square_gridd')
319
319
  Traceback (most recent call last):
320
320
  ...
321
- TypeError: Unknown type of steps : square_gridd
321
+ TypeError: unknown type of steps : square_gridd
322
322
  """
323
323
  # Construction of the alphabet
324
324
  alphabet = build_alphabet(alphabet)
@@ -332,26 +332,25 @@ def WordPaths(alphabet, steps=None):
332
332
  elif alphabet.cardinality() == 6:
333
333
  steps = 'hexagonal_grid'
334
334
  else:
335
- raise TypeError("Unable to make a class WordPaths from %s" % alphabet)
335
+ raise TypeError("unable to make a class WordPaths from %s" % alphabet)
336
336
 
337
337
  # Return the class of WordPaths according to the given type of paths
338
338
  if isinstance(steps, str):
339
339
  if steps in ('square_grid', 'square'):
340
340
  return WordPaths_square_grid(alphabet=alphabet)
341
- elif steps in ('triangle_grid', 'triangle'):
341
+ if steps in ('triangle_grid', 'triangle'):
342
342
  return WordPaths_triangle_grid(alphabet=alphabet)
343
- elif steps in ('hexagonal_grid', 'hexagon'):
343
+ if steps in ('hexagonal_grid', 'hexagon'):
344
344
  return WordPaths_hexagonal_grid(alphabet=alphabet)
345
- elif steps in ('cube_grid', 'cube'):
345
+ if steps in ('cube_grid', 'cube'):
346
346
  return WordPaths_cube_grid(alphabet=alphabet)
347
- elif steps in ('north_east', 'ne', 'NE'):
347
+ if steps in ('north_east', 'ne', 'NE'):
348
348
  return WordPaths_north_east(alphabet=alphabet)
349
- elif steps == 'dyck':
349
+ if steps == 'dyck':
350
350
  return WordPaths_dyck(alphabet=alphabet)
351
- else:
352
- raise TypeError("Unknown type of steps : %s" % steps)
353
- else:
354
- return WordPaths_all(alphabet=alphabet, steps=steps)
351
+ raise TypeError(f"unknown type of steps : {steps}")
352
+
353
+ return WordPaths_all(alphabet=alphabet, steps=steps)
355
354
 
356
355
 
357
356
  #######################################################################
@@ -1205,16 +1204,14 @@ class FiniteWordPath_all(SageObject):
1205
1204
  sage: P('aabdee').is_simple()
1206
1205
  False
1207
1206
  """
1208
- n = 0
1209
1207
  s = set()
1210
1208
  include_last = not self.is_closed()
1211
- for p in self.points(include_last=include_last):
1209
+ for n, p in enumerate(self.points(include_last=include_last), start=1):
1212
1210
  # We need the elements to have a common parent,
1213
1211
  # so we convert the points to immutable vectors.
1214
1212
  v = vector(p)
1215
1213
  v.set_immutable()
1216
1214
  s.add(v)
1217
- n += 1
1218
1215
  if len(s) != n:
1219
1216
  return False
1220
1217
  return True
@@ -1408,7 +1405,7 @@ class FiniteWordPath_all(SageObject):
1408
1405
  if letters is None:
1409
1406
  letters = self.parent().alphabet()
1410
1407
  if color is None:
1411
- from sage.plot.all import hue
1408
+ from sage.plot.colors import hue
1412
1409
  A = self.parent().alphabet()
1413
1410
  color = {a: hue(A.rank(a) / float(A.cardinality())) for a in A}
1414
1411
  it = self.projected_point_iterator(v, ring=ring)
@@ -1674,7 +1671,9 @@ class FiniteWordPath_2d(FiniteWordPath_all):
1674
1671
 
1675
1672
  See www.imagemagick.org, for example.
1676
1673
  """
1677
- from sage.plot.all import line, polygon, animate
1674
+ from sage.plot.line import line
1675
+ from sage.plot.polygon import polygon
1676
+ from sage.plot.animate import animate
1678
1677
 
1679
1678
  pts = list(self.points())
1680
1679