Dear Salvatore,

On 2018-11-21, VulK <etn45...@gmail.com> wrote:
> is there any reason why `MPolynomialRing_polydict` 
> hardcodes `MPolynomial_polydict` as its element class?

I believe it shouldn't hard-code it.

> I would have expected something like 
>
> ```
> class MPolynomialRing_polydict( MPolynomialRing_macaulay2_repr, 
> PolynomialRing_singular_repr, MPolynomialRing_base):
>
>     Element = MPolynomial_polydict
> ```
> followed by the use of `Element` whenever this was needed. Instead this class 
> defines a method `_poly_class` which is only used once in `__init__` to 
> define generators (at line 142). Afterwards, every method that needs to build 
> elements imports again MPolynomial_polydict.

It would be fine (and is done in other examples) to assign self.Element
during __init__. In other words, it is not compulsory that Element is a
class attribute; it can very well be an attribute of an instance.

However, I believe it is bad usage to hard-code a certain class as
output of arithmetic errors. If "self" is an element of some algebraic
parent, then the arithmetic methods of self (such as _mul_, _add_)
should create and return instances of self.parent().element_class, which
is a class dynamically created from self.parent().Element and from
information encoded in self.parent().category().

Might be a good idea to create a trac ticket for it.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to