#13853: Correct FreeModule.coordinates() to match specification
----------------------------------+-----------------------------------------
Reporter: Bouillaguet | Owner: jason, was
Type: defect | Status: needs_review
Priority: minor | Milestone: sage-5.6
Component: linear algebra | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
----------------------------------+-----------------------------------------
Description changed by Bouillaguet:
Old description:
> The docstring of the {{{FreeModule.coordinates}}} method advertizes a
> {{{check}}} parameters, which defaults to {{{True}}}, and whose effect is
> in principle to check that the arguments belongs to the module. If not,
> an {{{ArithmeticError}}} is said to be raised.
>
> The actual implementation deviates in several ways.
>
> * The {{{check}}} parameter does not check that the argument belongs to
> the module. It checks that the argument belongs to the ambient vector
> space of the module. The coordinates returned are coordinates in the
> ambient vector space.
> {{{
> sage: M = ZZ^3
> sage: v = vector(ZZ, [1/2,0,1])
> sage: v in M
> False
> sage: M.coordinates(v)
> [1/2, 0, 1]
> }}}
> According to the docstring, the call to {{{M.coordinates(v)}}} should
> have failed with an {{{ArithmeticError}}} exception
>
> * When the method fails, it does not fail with the right exception.
> {{{
> sage: M = ZZ^3
> sage: M.coordinates( [sqrt(2), 1, 1] )
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call
> last)
> ...
> TypeError: unable to convert sqrt(2) to a rational
> }}}
> According to the spec, it should have failed with an
> {{{ArithmeticError}}} exception.
>
> **Proposed Solution** : modify the function so that its behavior match
> the specification, by rejecting things that are not in the module itself
> with an {{{ArithmeticError}}} exception
>
> Arguments AGAINST modifying the specification to match the present
> behavior are:
> * The ambient vector space does not always exist (e.g. when the ring is
> not a PID)
> * When it does, the present functionnality is still available through
> {{{M.ambient_vector_space().coordinates()}}}
New description:
The docstring of the {{{FreeModule.coordinates}}} method advertizes a
{{{check}}} parameters, which defaults to {{{True}}}, and whose effect is
in principle to check that the arguments belongs to the module. If not, an
{{{ArithmeticError}}} is said to be raised.
The actual implementation deviates in several ways.
* The {{{check}}} parameter does not check that the argument belongs to
the module. It checks that the argument belongs to the ambient vector
space of the module. The coordinates returned are coordinates in the
ambient vector space.
{{{
sage: M = ZZ^3
sage: v = vector(ZZ, [1/2,0,1])
sage: v in M
False
sage: M.coordinates(v)
[1/2, 0, 1]
}}}
According to the docstring, the call to {{{M.coordinates(v)}}} should have
failed with an {{{ArithmeticError}}} exception
* When the method fails, it does not fail with the right exception.
{{{
sage: M = ZZ^3
sage: M.coordinates( [sqrt(2), 1, 1] )
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
...
TypeError: unable to convert sqrt(2) to a rational
}}}
According to the spec, it should have failed with an {{{ArithmeticError}}}
exception.
**Proposed Solution** : modify the function so that its behavior match the
specification, by rejecting things that are not in the module itself with
an {{{ArithmeticError}}} exception
Arguments AGAINST modifying the specification to match the present
behavior are:
* The ambient vector space does not always exist (e.g. when the ring is
not a PID)
* When it does, the present functionnality is still available through
{{{M.vector_space().coordinates()}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13853#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 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.