#18264: make map_coefficients in modules_with_basis safer or more general
-------------------------------------+-------------------------------------
Reporter: mantepse | Owner:
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-6.7
Component: algebra | Resolution:
Keywords: map_coefficients, | Merged in:
modules_with_basis, base_ring, | Reviewers:
check arguments | Work issues:
Authors: Martin Rubey | Commit:
Report Upstream: N/A | 3a7761e95b8ca8b83e08635828a3754d751fe918
Branch: | Stopgaps:
u/mantepse/make_map_coefficients_in_modules_with_basis_safer_or_more_general|
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by nthiery):
Hi Martin!
Thanks for taking action; this is looking good!
Now that I am reading actual code: a usual idiom to check that a
coefficient is indeed in the base ring is to coerce it back there with
`R(c)`. I guess that would be a fine behavior: it's faster, and it
takes care of all cases where someone passes an int, or something that
requires some small coercion to be put back in the base ring.
Maybe the option shall be named `coerce` after all. Comments anyone?
Note by the way that coercing would fail in Mike's original use case,
so whether we go for `coerce` or `check` don't make a difference
there:
{{{
sage: ZZ(factor(4))
TypeError: unable to coerce <class
'sage.structure.factorization_integer.IntegerFactorization'> to an integer
}}}
If we go for the coerce way, then the simplest would be to pass this
option down to `sum_of_terms`. This requires updating
`CombinatorialFreeModule.sum_of_terms` to implement that option, by
passing it down to respectively `CombinatorialFreeModule._from_dict`
where it's already implemented and `CombinatorialFreeModule.term`
where it would need to be implemented by passing the option down to
`_from_dict`.
It's getting a bit bigger of a change than what was planned for
originaly; do you feel like handling it?
Cheers,
Nicolas
--
Ticket URL: <http://trac.sagemath.org/ticket/18264#comment:7>
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.