#5534: [with patch, needs review] sage.combinat.subword.smallest_positions
modifying its input (use #5200)
---------------------------+------------------------------------------------
Reporter: nthiery | Owner: hivert
Type: defect | Status: new
Priority: minor | Milestone: sage-combinat
Component: combinatorics | Keywords:
---------------------------+------------------------------------------------
Changes (by hivert):
* owner: mhansen => hivert
Old description:
> I came across this function in Sage-Combinat,
>
> sage.combinat.subword.smallest_positions(word, subword, pos=0)
>
> Running this function not only returns the positions in "word" where
> "subword" occurs, but it modifies "subword" to be this sequence of
> positions. Is there a reason for this? It seems to me that it should
> leave "subword" unchanged, but maybe I'm not thinking of something.
>
> sage: w = ["a", "b", "c", "d"]
> sage: ww = ["b", "d"]
> sage: sage.combinat.subword.smallest_positions?
> sage: sage.combinat.subword.smallest_positions(w, ww)
> [1, 3]
> sage: w
> ['a', 'b', 'c', 'd']
> sage: ww
> [1, 3]
>
> Thanks,
> Steve
New description:
I came across this function in Sage-Combinat,
sage.combinat.subword.smallest_positions(word, subword, pos=0)
Running this function not only returns the positions in "word" where
"subword" occurs, but it modifies "subword" to be this sequence of
positions. Is there a reason for this? It seems to me that it should
leave "subword" unchanged, but maybe I'm not thinking of something.
{{{
sage: w = ["a", "b", "c", "d"]
sage: ww = ["b", "d"]
sage: sage.combinat.subword.smallest_positions(w, ww)
[1, 3]
sage: w
['a', 'b', 'c', 'd']
sage: ww
[1, 3]
}}}
Thanks,
Steve
--
Comment:
Fixed (see the attached patch):
Now:
{{{
sage: w = ["a", "b", "c", "d"]
sage: ww = ["b", "d"]
sage: sage.combinat.subword.smallest_positions(w, ww)
[1, 3]
sage: w
['a', 'b', 'c', 'd']
sage: ww
['b', 'd']
}}}
Note the patch only applies on top of #5200
Author : Florent Hivert
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5534#comment:1>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---