#269: Add __mod__ to coercion model
----------------------------------+------------------------
Reporter: dmharvey | Owner: somebody
Type: enhancement | Status: new
Priority: major | Milestone: sage-7.1
Component: coercion | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: #2034 | Stopgaps:
----------------------------------+------------------------
Description changed by jdemeyer:
Old description:
> Add `__mod__` to the coercion model for `Element` and change `__mod__` to
> `_mod_` where applicable.
>
> This does not change any semantics of remaindering, but it does fix
> remaindering in a few cases where coercion is involved.
>
> As proof-of-concept for refactoring more generally the arithmetic methods
> on `Element`, the implementation of `__mod__` is different from the usual
> implementation:
> 1. `_mod_` will be added to `Element` and not `RingElement` or similar.
> 2. The prototype is `cpdef _mod_(self, Element other)` with no typing for
> the return value.
> 3. In order to support better derived classes implementing `__mod__` but
> not `__imod__`, we let `_mod_` return `NotImplemented` and raise the
> `TypeError` in `__mod__` instead of `_mod_`.
>
> My intention is that eventually all arithmetic methods should be
> implemented like `__mod__`.
New description:
Add `__mod__` to the coercion model for `Element` and change `__mod__` to
`_mod_` where applicable.
This does not change any semantics of remaindering, but it does fix
remaindering in a few cases where coercion is involved.
As proof-of-concept for refactoring more generally the arithmetic methods
on `Element`, the implementation of `__mod__` is different from the usual
implementation:
1. `_mod_` will be added to `Element` and not `RingElement` or similar.
2. The prototype is `cpdef _mod_(self, Element other)` with no typing for
the return value.
3. We do not implement the in-place `__imod__` which is useless anyway
with coercion.
My intention is that eventually all arithmetic methods should be
implemented like `__mod__`.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/269#comment:18>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.