Here is what is happening (certainly a bug).  In the code which picks
a random element from F, F is treated as a sequence and then
subscripted with a random subscript.  But (as you can verify)
evaluating F[0] or F[1] raises an error, since the __getitem__ method
of a field is used to create polynomial rings (as in F['x']).

This does not happen when you just do F.random_element() since that
has an independent implementation.

I think the fault lies in line 125 of /sage/misc/prandom.py in the
function choice() which says

return _pyrand().choice(seq)

but in your example "seq" is the field F.  It would work if that said
list(F), since

_pyrand().choice(F)

fails but

_pyrand().choice(list(F))

works.  But it would be more efficient if that choice function tried
to call a random_element() function on its  argument instead --
imagine if the field was very large, it would be stupid to construct a
list ots elements for each random choice.

I will make a trac ticket for this.

John


On May 28, 9:28 pm, VictorMiller <[email protected]> wrote:
> Here's something a bit odd:
>
> sage: F = GF(2)
> sage: A = CartesianProduct(F,F)
> sage: print A.random_element()
>
> This gets a trace back and the message
>
> TypeError: You must specify the names of the variables
>
> Victor

-- 
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-support
URL: http://www.sagemath.org

Reply via email to