Skip to content

Commit 42696db

Browse files
committed
remove deprecated methods in combinat/words
1 parent 665a3fa commit 42696db

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
@@ -4153,71 +4153,6 @@ def last_position_dict(self):
41534153
d.update((letter, i) for i, letter in enumerate(self))
41544154
return d
41554155

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-
42214156
def find(self, sub, start=0, end=None):
42224157
r"""
42234158
Return the index of the first occurrence of ``sub`` in ``self``,
@@ -4411,138 +4346,6 @@ def is_factor(self, other):
44114346
"""
44124347
return other.first_occurrence(self) is not None
44134348

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-
45464349
def number_of_factor_occurrences(self, other):
45474350
r"""
45484351
Return the number of times ``other`` appears as a factor
@@ -5856,7 +5659,7 @@ def sturmian_desubstitute_as_possible(self):
58565659
desubstitued_word = desubstitued_word + w_running ** (current_run_length - min_run)
58575660
return desubstitued_word.sturmian_desubstitute_as_possible()
58585661

5859-
def is_sturmian_factor(self):
5662+
def is_sturmian_factor(self) -> bool:
58605663
r"""
58615664
Tell whether ``self`` is a factor of a Sturmian word.
58625665
@@ -5914,7 +5717,7 @@ def is_sturmian_factor(self):
59145717
"""
59155718
return self.sturmian_desubstitute_as_possible().is_empty()
59165719

5917-
def is_tangent(self):
5720+
def is_tangent(self) -> bool:
59185721
r"""
59195722
Tell whether ``self`` is a tangent word.
59205723
@@ -6493,7 +6296,7 @@ def _phi_inv_tab(self, tab):
64936296
res = res.delta_inv(s=tab[i])
64946297
return res
64956298

6496-
def is_smooth_prefix(self):
6299+
def is_smooth_prefix(self) -> bool:
64976300
r"""
64986301
Return ``True`` if ``self`` is the prefix of a smooth word, and ``False``
64996302
otherwise.
@@ -6812,7 +6615,7 @@ def colored_vector(self, x=0, y=0, width='default', height=1, cmap='hsv', thickn
68126615
rep.axes(False)
68136616
return rep
68146617

6815-
def is_square(self):
6618+
def is_square(self) -> bool:
68166619
r"""
68176620
Return ``True`` if ``self`` is a square, and ``False`` otherwise.
68186621
@@ -6835,7 +6638,7 @@ def is_square(self):
68356638
l = self.length() // 2
68366639
return self[:l] == self[l:]
68376640

6838-
def is_square_free(self):
6641+
def is_square_free(self) -> bool:
68396642
r"""
68406643
Return ``True`` if ``self`` does not contain squares, and ``False``
68416644
otherwise.
@@ -6882,7 +6685,7 @@ def squares(self):
68826685
T = DecoratedSuffixTree(self)
68836686
return set(T.square_vocabulary(output='word'))
68846687

6885-
def is_cube(self):
6688+
def is_cube(self) -> bool:
68866689
r"""
68876690
Return ``True`` if ``self`` is a cube, and ``False`` otherwise.
68886691
@@ -6902,7 +6705,7 @@ def is_cube(self):
69026705
l = self.length() // 3
69036706
return self[:l] == self[l:2*l] == self[2*l:]
69046707

6905-
def is_cube_free(self):
6708+
def is_cube_free(self) -> bool:
69066709
r"""
69076710
Return ``True`` if ``self`` does not contain cubes, and ``False`` otherwise.
69086711
@@ -6965,7 +6768,7 @@ def to_monoid_element(self):
69656768
M = FreeMonoid(len(l), l)
69666769
return M(self)
69676770

6968-
def is_christoffel(self):
6771+
def is_christoffel(self) -> bool:
69696772
r"""
69706773
Return ``True`` if ``self`` is a Christoffel word, and ``False`` otherwise.
69716774

0 commit comments

Comments
 (0)