#15919: Notation S[i] for i-th element of enumerated set S conflicts with 
notation
R[x] for polynomial ring
-------------------------------------------------+------------------------
       Reporter:  darij                          |        Owner:
           Type:  defect                         |       Status:  new
       Priority:  major                          |    Milestone:  sage-6.2
      Component:  algebra                        |   Resolution:
       Keywords:  notation, algebra, polynomial  |    Merged in:
        Authors:                                 |    Reviewers:
Report Upstream:  N/A                            |  Work issues:
         Branch:                                 |       Commit:
   Dependencies:                                 |     Stopgaps:
-------------------------------------------------+------------------------

Comment (by nbruin):

 I think the bug is in unrank, not in the fact that rings use `__getitem__`
 in a funny way. The problem is that a Cartesian product can easily be
 constructed from iterables, and then should probably be iterable itself,
 but iterables are not necessarily indexable:
 {{{
 sage: V={1,2,3}
 sage: CartesianProduct(V,V).unrank(2)
 TypeError: 'set' object does not support indexing
 sage: [i for i in CartesianProduct(V,V)]
 [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]
 }}}
 The function "unrank" should only be applied to indexable cartesian
 products, i.e., cartesian products of indexables. That's not the same as
 iterables. In particular,

 So the problem is really in `tester.some_elements`. Indeed, the offending
 code:
 {{{
         try:
             n = _len(S)
             if n > self._max_runs:
                 from random import sample
                 S = sample(S, self._max_runs)
         except (TypeError, AttributeError):
 }}}
 tries `sample` on `S`, which apparently leads to calls of the type `S[i]`.
 As you can see, the code is prepared to fail, but doesn't expect that to
 happen with a `ValueError`. I think this just shows that it's a bit
 callous to just try and index a structure and hope for the best.

--
Ticket URL: <http://trac.sagemath.org/ticket/15919#comment:2>
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