#12867: random_element for Words is broken
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:  sage-combinat
  AlexGhitza             |       Status:  needs_work
           Type:         |    Milestone:  sage-6.2
  defect                 |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:
  combinatorics          |  Work issues:
       Keywords:         |       Commit:
        Authors:         |  035603dd0c523ff054ffdc2d993b1898d827cf3a
Report Upstream:  N/A    |     Stopgaps:
         Branch:         |
  u/ncohen/12867         |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by ncohen):

 YO !

 > 0) Might be rebased for 6.2.rc0

 Done, but there was no conflict with 6.2.rc0....

 > 1) Add doctest for your errors

 Well, this is in the branch
 {{{
 +            sage: W = Words(5)
 +            sage: W.random_element() # random
 }}}

 What else do you expect to find ?

 > 2) The following code
 > {{{
 > self((self.alphabet()[randint(0,n-1)] for x in range(self._length)))
 > }}}
 > does not handle all cases. For example
 > {{{
 > sage: W = Words(GF(5), length=4)
 > sage: W.random_element()
 > KABOOM
 > }}}
 > The problem is that you really do not know what is the `__getitem__`
 there. A possibility is
 > {{{
 > self((self.alphabet().random_element() for _ in range(self._length)))
 > }}}

 Well, a list has no `.random_element()` method. Would that work ?

 Otherwise we could call `list(self.alphabet())`. Or make sure
 self.alphabet() is a list. What do you think ?

 > 3) What is the purpose of the commit
 241a151def174f9cfa93340fd3dd2a9be1d4aa81 that modifies stuff in
 shuffle_algebra.py, algebras_with_basis.py, lyndon_word.py, etc?

 HMmmmmm... Officially, it is to fix a bug because the current status is
 incorrect. I asked around and it turns out that these things are only
 defined on finite words. I don't even know what they are, but doctests
 were broken otherwise. So well. Everybody's happy this way `:-P`

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/12867#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to