Skip to content

Commit 02fe335

Browse files
author
Release Manager
committed
gh-40347: remove deprecated methods in combinat/words from #30187 ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40347 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 238a9a0 + 42696db commit 02fe335

File tree

1 file changed

+8
-205
lines changed

1 file changed

+8
-205
lines changed

src/sage/combinat/words/finite_word.py

Lines changed: 8 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -4149,71 +4149,6 @@ def last_position_dict(self):
41494149
d.update((letter, i) for i, letter in enumerate(self))
41504150
return d
41514151

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-
42174152
def find(self, sub, start=0, end=None):
42184153
r"""
42194154
Return the index of the first occurrence of ``sub`` in ``self``,
@@ -4407,138 +4342,6 @@ def is_factor(self, other):
44074342
"""
44084343
return other.first_occurrence(self) is not None
44094344

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-
45424345
def number_of_factor_occurrences(self, other):
45434346
r"""
45444347
Return the number of times ``other`` appears as a factor
@@ -5852,7 +5655,7 @@ def sturmian_desubstitute_as_possible(self):
58525655
desubstitued_word = desubstitued_word + w_running ** (current_run_length - min_run)
58535656
return desubstitued_word.sturmian_desubstitute_as_possible()
58545657

5855-
def is_sturmian_factor(self):
5658+
def is_sturmian_factor(self) -> bool:
58565659
r"""
58575660
Tell whether ``self`` is a factor of a Sturmian word.
58585661
@@ -5910,7 +5713,7 @@ def is_sturmian_factor(self):
59105713
"""
59115714
return self.sturmian_desubstitute_as_possible().is_empty()
59125715

5913-
def is_tangent(self):
5716+
def is_tangent(self) -> bool:
59145717
r"""
59155718
Tell whether ``self`` is a tangent word.
59165719
@@ -6489,7 +6292,7 @@ def _phi_inv_tab(self, tab):
64896292
res = res.delta_inv(s=tab[i])
64906293
return res
64916294

6492-
def is_smooth_prefix(self):
6295+
def is_smooth_prefix(self) -> bool:
64936296
r"""
64946297
Return ``True`` if ``self`` is the prefix of a smooth word, and ``False``
64956298
otherwise.
@@ -6808,7 +6611,7 @@ def colored_vector(self, x=0, y=0, width='default', height=1, cmap='hsv', thickn
68086611
rep.axes(False)
68096612
return rep
68106613

6811-
def is_square(self):
6614+
def is_square(self) -> bool:
68126615
r"""
68136616
Return ``True`` if ``self`` is a square, and ``False`` otherwise.
68146617
@@ -6831,7 +6634,7 @@ def is_square(self):
68316634
l = self.length() // 2
68326635
return self[:l] == self[l:]
68336636

6834-
def is_square_free(self):
6637+
def is_square_free(self) -> bool:
68356638
r"""
68366639
Return ``True`` if ``self`` does not contain squares, and ``False``
68376640
otherwise.
@@ -6878,7 +6681,7 @@ def squares(self):
68786681
T = DecoratedSuffixTree(self)
68796682
return set(T.square_vocabulary(output='word'))
68806683

6881-
def is_cube(self):
6684+
def is_cube(self) -> bool:
68826685
r"""
68836686
Return ``True`` if ``self`` is a cube, and ``False`` otherwise.
68846687
@@ -6898,7 +6701,7 @@ def is_cube(self):
68986701
l = self.length() // 3
68996702
return self[:l] == self[l:2*l] == self[2*l:]
69006703

6901-
def is_cube_free(self):
6704+
def is_cube_free(self) -> bool:
69026705
r"""
69036706
Return ``True`` if ``self`` does not contain cubes, and ``False`` otherwise.
69046707
@@ -6961,7 +6764,7 @@ def to_monoid_element(self):
69616764
M = FreeMonoid(len(l), l)
69626765
return M(self)
69636766

6964-
def is_christoffel(self):
6767+
def is_christoffel(self) -> bool:
69656768
r"""
69666769
Return ``True`` if ``self`` is a Christoffel word, and ``False`` otherwise.
69676770

0 commit comments

Comments
 (0)