@@ -4149,71 +4149,6 @@ def last_position_dict(self):
4149
4149
d .update ((letter , i ) for i , letter in enumerate (self ))
4150
4150
return d
4151
4151
4152
- def _pos_in (self , other , p ):
4153
- r"""
4154
- Return the position of the first occurrence of ``self`` starting at
4155
- position ``p`` in ``other``.
4156
-
4157
- .. WARNING::
4158
-
4159
- This method is deprecated since 2020 and will be removed in a
4160
- later version of SageMath.
4161
- Use :meth:`first_occurrence` instead.
4162
-
4163
- EXAMPLES::
4164
-
4165
- sage: Word('12')._pos_in(Word('131231'), 2)
4166
- doctest:warning
4167
- ...
4168
- DeprecationWarning: f._pos_in(w, start) is deprecated.
4169
- Use w.first_occurrence(f, start) instead.
4170
- See https://github.com/sagemath/sage/issues/30187 for details.
4171
- 2
4172
- sage: Word('12')._pos_in(Word('131231'), 3) is None
4173
- True
4174
- sage: Word('32')._pos_in(Word('131231'), 0) is None
4175
- True
4176
-
4177
- The empty word occurs in a word::
4178
-
4179
- sage: Word('')._pos_in(Word('123'), 0)
4180
- 0
4181
- sage: Word('')._pos_in(Word(''), 0)
4182
- 0
4183
- """
4184
- from sage .misc .superseded import deprecation
4185
- deprecation (30187 , 'f._pos_in(w, start) is deprecated.'
4186
- ' Use w.first_occurrence(f, start) instead.' )
4187
- return other .first_occurrence (self , p )
4188
-
4189
- def first_pos_in (self , other ):
4190
- r"""
4191
- Return the position of the first occurrence of ``self`` in ``other``,
4192
- or ``None`` if ``self`` is not a factor of ``other``.
4193
-
4194
- .. WARNING::
4195
-
4196
- This method is deprecated since 2020 and will be removed in a
4197
- later version of SageMath.
4198
- Use :meth:`first_occurrence` instead.
4199
-
4200
- EXAMPLES::
4201
-
4202
- sage: Word('12').first_pos_in(Word('131231'))
4203
- doctest:warning
4204
- ...
4205
- DeprecationWarning: f.first_pos_in(w) is deprecated.
4206
- Use w.first_occurrence(f) instead.
4207
- See https://github.com/sagemath/sage/issues/30187 for details.
4208
- 2
4209
- sage: Word('32').first_pos_in(Word('131231')) is None
4210
- True
4211
- """
4212
- from sage .misc .superseded import deprecation
4213
- deprecation (30187 , 'f.first_pos_in(w) is deprecated.'
4214
- ' Use w.first_occurrence(f) instead.' )
4215
- return other .first_occurrence (self )
4216
-
4217
4152
def find (self , sub , start = 0 , end = None ):
4218
4153
r"""
4219
4154
Return the index of the first occurrence of ``sub`` in ``self``,
@@ -4407,138 +4342,6 @@ def is_factor(self, other):
4407
4342
"""
4408
4343
return other .first_occurrence (self ) is not None
4409
4344
4410
- def factor_occurrences_in (self , other ):
4411
- r"""
4412
- Return an iterator over all occurrences (including overlapping ones)
4413
- of ``self`` in ``other`` in their order of appearance.
4414
-
4415
- .. WARNING::
4416
-
4417
- This method is deprecated since 2020 and will be removed in a
4418
- later version of SageMath.
4419
- Use :meth:`factor_occurrences_iterator` instead.
4420
-
4421
- EXAMPLES::
4422
-
4423
- sage: u = Word('121')
4424
- sage: w = Word('121213211213')
4425
- sage: list(u.factor_occurrences_in(w))
4426
- doctest:warning
4427
- ...
4428
- DeprecationWarning: f.factor_occurrences_in(w) is deprecated.
4429
- Use w.factor_occurrences_iterator(f) instead.
4430
- See https://github.com/sagemath/sage/issues/30187 for details.
4431
- [0, 2, 8]
4432
- """
4433
- from sage .misc .superseded import deprecation
4434
- deprecation (30187 , 'f.factor_occurrences_in(w) is deprecated.'
4435
- ' Use w.factor_occurrences_iterator(f) instead.' )
4436
- return other .factor_occurrences_iterator (self )
4437
-
4438
- def nb_factor_occurrences_in (self , other ):
4439
- r"""
4440
- Return the number of times ``self`` appears as a factor
4441
- in ``other``.
4442
-
4443
- .. WARNING::
4444
-
4445
- This method is deprecated since 2020 and will be removed in a
4446
- later version of SageMath.
4447
- Use :meth:`number_of_factor_occurrences` instead.
4448
-
4449
- EXAMPLES::
4450
-
4451
- sage: Word('123').nb_factor_occurrences_in(Word('112332312313112332121123'))
4452
- doctest:warning
4453
- ...
4454
- DeprecationWarning: f.nb_factor_occurrences_in(w) is deprecated.
4455
- Use w.number_of_factor_occurrences(f) instead.
4456
- See https://github.com/sagemath/sage/issues/30187 for details.
4457
- 4
4458
- sage: Word('321').nb_factor_occurrences_in(Word('11233231231311233221123'))
4459
- 0
4460
-
4461
- An error is raised for the empty word::
4462
-
4463
- sage: Word().nb_factor_occurrences_in(Word('123'))
4464
- Traceback (most recent call last):
4465
- ...
4466
- NotImplementedError: The factor must be non empty
4467
- """
4468
- from sage .misc .superseded import deprecation
4469
- deprecation (30187 , 'f.nb_factor_occurrences_in(w) is deprecated.'
4470
- ' Use w.number_of_factor_occurrences(f) instead.' )
4471
- return other .number_of_factor_occurrences (self )
4472
-
4473
- def nb_subword_occurrences_in (self , other ):
4474
- r"""
4475
- Return the number of times ``self`` appears in ``other`` as a subword.
4476
-
4477
- This corresponds to the notion of `binomial coefficient` of two
4478
- finite words whose properties are presented in the chapter of
4479
- Lothaire's book written by Sakarovitch and Simon [Lot1997]_.
4480
-
4481
- .. WARNING::
4482
-
4483
- This method is deprecated since 2020 and will be removed in a
4484
- later version of SageMath.
4485
- Use :meth:`number_of_subword_occurrences` instead.
4486
-
4487
- INPUT:
4488
-
4489
- - ``other`` -- finite word
4490
-
4491
- EXAMPLES::
4492
-
4493
- sage: tm = words.ThueMorseWord()
4494
-
4495
- sage: u = Word([0,1,0,1])
4496
- sage: u.nb_subword_occurrences_in(tm[:1000])
4497
- doctest:warning
4498
- ...
4499
- DeprecationWarning: f.nb_subword_occurrences_in(w) is deprecated.
4500
- Use w.number_of_subword_occurrences(f) instead.
4501
- See https://github.com/sagemath/sage/issues/30187 for details.
4502
- 2604124996
4503
-
4504
- sage: u = Word([0,1,0,1,1,0])
4505
- sage: u.nb_subword_occurrences_in(tm[:100])
4506
- 20370432
4507
-
4508
- .. NOTE::
4509
-
4510
- This code, based on [MSSY2001]_, actually compute the number of
4511
- occurrences of all prefixes of ``self`` as subwords in all
4512
- prefixes of ``other``. In particular, its complexity is
4513
- bounded by ``len(self) * len(other)``.
4514
-
4515
- TESTS::
4516
-
4517
- sage: Word('').nb_subword_occurrences_in(Word(''))
4518
- 1
4519
- sage: parent(_)
4520
- Integer Ring
4521
- sage: v,u = Word(), Word('123')
4522
- sage: v.nb_subword_occurrences_in(u)
4523
- 1
4524
- sage: v,u = Word('123'), Word('1133432311132311112')
4525
- sage: v.nb_subword_occurrences_in(u)
4526
- 11
4527
- sage: v,u = Word('4321'), Word('1132231112233212342231112')
4528
- sage: v.nb_subword_occurrences_in(u)
4529
- 0
4530
- sage: v,u = Word('3'), Word('122332112321213')
4531
- sage: v.nb_subword_occurrences_in(u)
4532
- 4
4533
- sage: v,u = Word([]), words.ThueMorseWord()[:1000]
4534
- sage: v.nb_subword_occurrences_in(u)
4535
- 1
4536
- """
4537
- from sage .misc .superseded import deprecation
4538
- deprecation (30187 , 'f.nb_subword_occurrences_in(w) is deprecated.'
4539
- ' Use w.number_of_subword_occurrences(f) instead.' )
4540
- return other .number_of_subword_occurrences (self )
4541
-
4542
4345
def number_of_factor_occurrences (self , other ):
4543
4346
r"""
4544
4347
Return the number of times ``other`` appears as a factor
@@ -5852,7 +5655,7 @@ def sturmian_desubstitute_as_possible(self):
5852
5655
desubstitued_word = desubstitued_word + w_running ** (current_run_length - min_run )
5853
5656
return desubstitued_word .sturmian_desubstitute_as_possible ()
5854
5657
5855
- def is_sturmian_factor (self ):
5658
+ def is_sturmian_factor (self ) -> bool :
5856
5659
r"""
5857
5660
Tell whether ``self`` is a factor of a Sturmian word.
5858
5661
@@ -5910,7 +5713,7 @@ def is_sturmian_factor(self):
5910
5713
"""
5911
5714
return self .sturmian_desubstitute_as_possible ().is_empty ()
5912
5715
5913
- def is_tangent (self ):
5716
+ def is_tangent (self ) -> bool :
5914
5717
r"""
5915
5718
Tell whether ``self`` is a tangent word.
5916
5719
@@ -6489,7 +6292,7 @@ def _phi_inv_tab(self, tab):
6489
6292
res = res .delta_inv (s = tab [i ])
6490
6293
return res
6491
6294
6492
- def is_smooth_prefix (self ):
6295
+ def is_smooth_prefix (self ) -> bool :
6493
6296
r"""
6494
6297
Return ``True`` if ``self`` is the prefix of a smooth word, and ``False``
6495
6298
otherwise.
@@ -6808,7 +6611,7 @@ def colored_vector(self, x=0, y=0, width='default', height=1, cmap='hsv', thickn
6808
6611
rep .axes (False )
6809
6612
return rep
6810
6613
6811
- def is_square (self ):
6614
+ def is_square (self ) -> bool :
6812
6615
r"""
6813
6616
Return ``True`` if ``self`` is a square, and ``False`` otherwise.
6814
6617
@@ -6831,7 +6634,7 @@ def is_square(self):
6831
6634
l = self .length () // 2
6832
6635
return self [:l ] == self [l :]
6833
6636
6834
- def is_square_free (self ):
6637
+ def is_square_free (self ) -> bool :
6835
6638
r"""
6836
6639
Return ``True`` if ``self`` does not contain squares, and ``False``
6837
6640
otherwise.
@@ -6878,7 +6681,7 @@ def squares(self):
6878
6681
T = DecoratedSuffixTree (self )
6879
6682
return set (T .square_vocabulary (output = 'word' ))
6880
6683
6881
- def is_cube (self ):
6684
+ def is_cube (self ) -> bool :
6882
6685
r"""
6883
6686
Return ``True`` if ``self`` is a cube, and ``False`` otherwise.
6884
6687
@@ -6898,7 +6701,7 @@ def is_cube(self):
6898
6701
l = self .length () // 3
6899
6702
return self [:l ] == self [l :2 * l ] == self [2 * l :]
6900
6703
6901
- def is_cube_free (self ):
6704
+ def is_cube_free (self ) -> bool :
6902
6705
r"""
6903
6706
Return ``True`` if ``self`` does not contain cubes, and ``False`` otherwise.
6904
6707
@@ -6961,7 +6764,7 @@ def to_monoid_element(self):
6961
6764
M = FreeMonoid (len (l ), l )
6962
6765
return M (self )
6963
6766
6964
- def is_christoffel (self ):
6767
+ def is_christoffel (self ) -> bool :
6965
6768
r"""
6966
6769
Return ``True`` if ``self`` is a Christoffel word, and ``False`` otherwise.
6967
6770
0 commit comments