#3847: [with patch, needs review] can't make vector of ints
---------------------+------------------------------------------------------
Reporter: saliola | Owner: tbd
Type: defect | Status: new
Priority: minor | Milestone: sage-3.1.2
Component: algebra | Resolution:
Keywords: |
---------------------+------------------------------------------------------
Changes (by AlexGhitza):
* summary: can't make vector of ints => [with patch, needs review] can't
make vector of ints
Comment:
This issue has also come up in other guises on sage-devel or sage-support
(can't seem to be able to find the threads right now, though).
It all boils down to Sequence(), which takes a list of things and returns
a sequence of things that lie in the same "universe", if canonical
coercions are possible. So if you give it a list containing an RDF, an
Integer, and a Rational, it will give you back a sequence of three RDF's.
The problem is with the builtin Python types (int, long, float, complex),
for which we of course have no coercions. So given a bunch of ints,
Sequence tries to see where in the Sage hierarchy they fit, finds nothing,
and sends them back without a common "universe". This makes vector()
throw an exception, because a vector should be over a ring.
The patch fixes this by giving Sequence() an optional parameter
use_sage_types, defaulting to False. If the parameter is True, Sequence()
catches the builtin Python types and makes them into the appropriate Sage
objects, then carries on. I am making vector() always pass
use_sage_types=True to Sequence(). This fixes the unpleasant behavior
reported in this ticket, and gives vector() a bit more flexibility -- see
the new doctests for more examples.
Sequence() is a fairly fundamental class and I didn't want to change its
default behavior for fear of speed degradation in places other than
vector().
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/3847#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
-~----------~----~----~----~------~----~------~--~---