@@ -4153,71 +4153,6 @@ def last_position_dict(self):
4153
4153
d .update ((letter , i ) for i , letter in enumerate (self ))
4154
4154
return d
4155
4155
4156
- def _pos_in (self , other , p ):
4157
- r"""
4158
- Return the position of the first occurrence of ``self`` starting at
4159
- position ``p`` in ``other``.
4160
-
4161
- .. WARNING::
4162
-
4163
- This method is deprecated since 2020 and will be removed in a
4164
- later version of SageMath.
4165
- Use :meth:`first_occurrence` instead.
4166
-
4167
- EXAMPLES::
4168
-
4169
- sage: Word('12')._pos_in(Word('131231'), 2)
4170
- doctest:warning
4171
- ...
4172
- DeprecationWarning: f._pos_in(w, start) is deprecated.
4173
- Use w.first_occurrence(f, start) instead.
4174
- See https://github.com/sagemath/sage/issues/30187 for details.
4175
- 2
4176
- sage: Word('12')._pos_in(Word('131231'), 3) is None
4177
- True
4178
- sage: Word('32')._pos_in(Word('131231'), 0) is None
4179
- True
4180
-
4181
- The empty word occurs in a word::
4182
-
4183
- sage: Word('')._pos_in(Word('123'), 0)
4184
- 0
4185
- sage: Word('')._pos_in(Word(''), 0)
4186
- 0
4187
- """
4188
- from sage .misc .superseded import deprecation
4189
- deprecation (30187 , 'f._pos_in(w, start) is deprecated.'
4190
- ' Use w.first_occurrence(f, start) instead.' )
4191
- return other .first_occurrence (self , p )
4192
-
4193
- def first_pos_in (self , other ):
4194
- r"""
4195
- Return the position of the first occurrence of ``self`` in ``other``,
4196
- or ``None`` if ``self`` is not a factor of ``other``.
4197
-
4198
- .. WARNING::
4199
-
4200
- This method is deprecated since 2020 and will be removed in a
4201
- later version of SageMath.
4202
- Use :meth:`first_occurrence` instead.
4203
-
4204
- EXAMPLES::
4205
-
4206
- sage: Word('12').first_pos_in(Word('131231'))
4207
- doctest:warning
4208
- ...
4209
- DeprecationWarning: f.first_pos_in(w) is deprecated.
4210
- Use w.first_occurrence(f) instead.
4211
- See https://github.com/sagemath/sage/issues/30187 for details.
4212
- 2
4213
- sage: Word('32').first_pos_in(Word('131231')) is None
4214
- True
4215
- """
4216
- from sage .misc .superseded import deprecation
4217
- deprecation (30187 , 'f.first_pos_in(w) is deprecated.'
4218
- ' Use w.first_occurrence(f) instead.' )
4219
- return other .first_occurrence (self )
4220
-
4221
4156
def find (self , sub , start = 0 , end = None ):
4222
4157
r"""
4223
4158
Return the index of the first occurrence of ``sub`` in ``self``,
@@ -4411,138 +4346,6 @@ def is_factor(self, other):
4411
4346
"""
4412
4347
return other .first_occurrence (self ) is not None
4413
4348
4414
- def factor_occurrences_in (self , other ):
4415
- r"""
4416
- Return an iterator over all occurrences (including overlapping ones)
4417
- of ``self`` in ``other`` in their order of appearance.
4418
-
4419
- .. WARNING::
4420
-
4421
- This method is deprecated since 2020 and will be removed in a
4422
- later version of SageMath.
4423
- Use :meth:`factor_occurrences_iterator` instead.
4424
-
4425
- EXAMPLES::
4426
-
4427
- sage: u = Word('121')
4428
- sage: w = Word('121213211213')
4429
- sage: list(u.factor_occurrences_in(w))
4430
- doctest:warning
4431
- ...
4432
- DeprecationWarning: f.factor_occurrences_in(w) is deprecated.
4433
- Use w.factor_occurrences_iterator(f) instead.
4434
- See https://github.com/sagemath/sage/issues/30187 for details.
4435
- [0, 2, 8]
4436
- """
4437
- from sage .misc .superseded import deprecation
4438
- deprecation (30187 , 'f.factor_occurrences_in(w) is deprecated.'
4439
- ' Use w.factor_occurrences_iterator(f) instead.' )
4440
- return other .factor_occurrences_iterator (self )
4441
-
4442
- def nb_factor_occurrences_in (self , other ):
4443
- r"""
4444
- Return the number of times ``self`` appears as a factor
4445
- in ``other``.
4446
-
4447
- .. WARNING::
4448
-
4449
- This method is deprecated since 2020 and will be removed in a
4450
- later version of SageMath.
4451
- Use :meth:`number_of_factor_occurrences` instead.
4452
-
4453
- EXAMPLES::
4454
-
4455
- sage: Word('123').nb_factor_occurrences_in(Word('112332312313112332121123'))
4456
- doctest:warning
4457
- ...
4458
- DeprecationWarning: f.nb_factor_occurrences_in(w) is deprecated.
4459
- Use w.number_of_factor_occurrences(f) instead.
4460
- See https://github.com/sagemath/sage/issues/30187 for details.
4461
- 4
4462
- sage: Word('321').nb_factor_occurrences_in(Word('11233231231311233221123'))
4463
- 0
4464
-
4465
- An error is raised for the empty word::
4466
-
4467
- sage: Word().nb_factor_occurrences_in(Word('123'))
4468
- Traceback (most recent call last):
4469
- ...
4470
- NotImplementedError: The factor must be non empty
4471
- """
4472
- from sage .misc .superseded import deprecation
4473
- deprecation (30187 , 'f.nb_factor_occurrences_in(w) is deprecated.'
4474
- ' Use w.number_of_factor_occurrences(f) instead.' )
4475
- return other .number_of_factor_occurrences (self )
4476
-
4477
- def nb_subword_occurrences_in (self , other ):
4478
- r"""
4479
- Return the number of times ``self`` appears in ``other`` as a subword.
4480
-
4481
- This corresponds to the notion of `binomial coefficient` of two
4482
- finite words whose properties are presented in the chapter of
4483
- Lothaire's book written by Sakarovitch and Simon [Lot1997]_.
4484
-
4485
- .. WARNING::
4486
-
4487
- This method is deprecated since 2020 and will be removed in a
4488
- later version of SageMath.
4489
- Use :meth:`number_of_subword_occurrences` instead.
4490
-
4491
- INPUT:
4492
-
4493
- - ``other`` -- finite word
4494
-
4495
- EXAMPLES::
4496
-
4497
- sage: tm = words.ThueMorseWord()
4498
-
4499
- sage: u = Word([0,1,0,1])
4500
- sage: u.nb_subword_occurrences_in(tm[:1000])
4501
- doctest:warning
4502
- ...
4503
- DeprecationWarning: f.nb_subword_occurrences_in(w) is deprecated.
4504
- Use w.number_of_subword_occurrences(f) instead.
4505
- See https://github.com/sagemath/sage/issues/30187 for details.
4506
- 2604124996
4507
-
4508
- sage: u = Word([0,1,0,1,1,0])
4509
- sage: u.nb_subword_occurrences_in(tm[:100])
4510
- 20370432
4511
-
4512
- .. NOTE::
4513
-
4514
- This code, based on [MSSY2001]_, actually compute the number of
4515
- occurrences of all prefixes of ``self`` as subwords in all
4516
- prefixes of ``other``. In particular, its complexity is
4517
- bounded by ``len(self) * len(other)``.
4518
-
4519
- TESTS::
4520
-
4521
- sage: Word('').nb_subword_occurrences_in(Word(''))
4522
- 1
4523
- sage: parent(_)
4524
- Integer Ring
4525
- sage: v,u = Word(), Word('123')
4526
- sage: v.nb_subword_occurrences_in(u)
4527
- 1
4528
- sage: v,u = Word('123'), Word('1133432311132311112')
4529
- sage: v.nb_subword_occurrences_in(u)
4530
- 11
4531
- sage: v,u = Word('4321'), Word('1132231112233212342231112')
4532
- sage: v.nb_subword_occurrences_in(u)
4533
- 0
4534
- sage: v,u = Word('3'), Word('122332112321213')
4535
- sage: v.nb_subword_occurrences_in(u)
4536
- 4
4537
- sage: v,u = Word([]), words.ThueMorseWord()[:1000]
4538
- sage: v.nb_subword_occurrences_in(u)
4539
- 1
4540
- """
4541
- from sage .misc .superseded import deprecation
4542
- deprecation (30187 , 'f.nb_subword_occurrences_in(w) is deprecated.'
4543
- ' Use w.number_of_subword_occurrences(f) instead.' )
4544
- return other .number_of_subword_occurrences (self )
4545
-
4546
4349
def number_of_factor_occurrences (self , other ):
4547
4350
r"""
4548
4351
Return the number of times ``other`` appears as a factor
@@ -5856,7 +5659,7 @@ def sturmian_desubstitute_as_possible(self):
5856
5659
desubstitued_word = desubstitued_word + w_running ** (current_run_length - min_run )
5857
5660
return desubstitued_word .sturmian_desubstitute_as_possible ()
5858
5661
5859
- def is_sturmian_factor (self ):
5662
+ def is_sturmian_factor (self ) -> bool :
5860
5663
r"""
5861
5664
Tell whether ``self`` is a factor of a Sturmian word.
5862
5665
@@ -5914,7 +5717,7 @@ def is_sturmian_factor(self):
5914
5717
"""
5915
5718
return self .sturmian_desubstitute_as_possible ().is_empty ()
5916
5719
5917
- def is_tangent (self ):
5720
+ def is_tangent (self ) -> bool :
5918
5721
r"""
5919
5722
Tell whether ``self`` is a tangent word.
5920
5723
@@ -6493,7 +6296,7 @@ def _phi_inv_tab(self, tab):
6493
6296
res = res .delta_inv (s = tab [i ])
6494
6297
return res
6495
6298
6496
- def is_smooth_prefix (self ):
6299
+ def is_smooth_prefix (self ) -> bool :
6497
6300
r"""
6498
6301
Return ``True`` if ``self`` is the prefix of a smooth word, and ``False``
6499
6302
otherwise.
@@ -6812,7 +6615,7 @@ def colored_vector(self, x=0, y=0, width='default', height=1, cmap='hsv', thickn
6812
6615
rep .axes (False )
6813
6616
return rep
6814
6617
6815
- def is_square (self ):
6618
+ def is_square (self ) -> bool :
6816
6619
r"""
6817
6620
Return ``True`` if ``self`` is a square, and ``False`` otherwise.
6818
6621
@@ -6835,7 +6638,7 @@ def is_square(self):
6835
6638
l = self .length () // 2
6836
6639
return self [:l ] == self [l :]
6837
6640
6838
- def is_square_free (self ):
6641
+ def is_square_free (self ) -> bool :
6839
6642
r"""
6840
6643
Return ``True`` if ``self`` does not contain squares, and ``False``
6841
6644
otherwise.
@@ -6882,7 +6685,7 @@ def squares(self):
6882
6685
T = DecoratedSuffixTree (self )
6883
6686
return set (T .square_vocabulary (output = 'word' ))
6884
6687
6885
- def is_cube (self ):
6688
+ def is_cube (self ) -> bool :
6886
6689
r"""
6887
6690
Return ``True`` if ``self`` is a cube, and ``False`` otherwise.
6888
6691
@@ -6902,7 +6705,7 @@ def is_cube(self):
6902
6705
l = self .length () // 3
6903
6706
return self [:l ] == self [l :2 * l ] == self [2 * l :]
6904
6707
6905
- def is_cube_free (self ):
6708
+ def is_cube_free (self ) -> bool :
6906
6709
r"""
6907
6710
Return ``True`` if ``self`` does not contain cubes, and ``False`` otherwise.
6908
6711
@@ -6965,7 +6768,7 @@ def to_monoid_element(self):
6965
6768
M = FreeMonoid (len (l ), l )
6966
6769
return M (self )
6967
6770
6968
- def is_christoffel (self ):
6771
+ def is_christoffel (self ) -> bool :
6969
6772
r"""
6970
6773
Return ``True`` if ``self`` is a Christoffel word, and ``False`` otherwise.
6971
6774
0 commit comments