Hi,

In order to treat tensor fields on a parallelizable domain N of some smooth 
manifold as elements of a free module (cf. 
#15916<http://trac.sagemath.org/ticket/15916>and this 
post <https://groups.google.com/forum/#!topic/sage-devel/1QzUpHLUw_E>), one 
has first to introduce the commutative ring C^oo(N) of smooth functions N 
--> *R*, as a new class, ScalarFieldRing say. Browsing through Sage 
reference manual, a natural guess would be to make it a subclass of 
CommutativeRing:

from sage.rings.ring import CommutativeRing
class ScalarFieldRing(CommutativeRing):
    def __init__(self, domain):
        CommutativeRing.__init__(self, base_ring)
        self.domain = domain



The issue here is that CommutativeRing.__init__ requires the argument 
"base_ring" and in the present context, I don't know what to put here: the 
ring C^oo(N) does not depend upon any other ring. Shall I put self, i.e. 
write CommutativeRing.__init__(self, self) ?

A second solution could be to declare ScalarFieldRing as a subclass of 
Ring, in the category of commutative rings:

from sage.rings.ring import Ring
from sage.categories.commutative_rings import CommutativeRings
class ScalarFieldRing(Ring):
    def __init__(self, domain):
        Ring.__init__(self, None, category=CommutativeRings())
        self.domain = domain



Here the argument "base" of Ring.__init__ is set to None, which was not 
possible for the argument "base_ring" of CommutativeRing.__init__ : this 
triggered the error message "TypeError: base ring None is no commutative 
ring".

A third solution is to declare ScalarFieldRing directly as a subclass of 
Parent, in the category of commutative rings:

from sage.structure.parent import Parent
from sage.categories.commutative_rings import CommutativeRings
class ScalarFieldRing(Parent):
    def __init__(self, domain):
        Parent.__init__(self, category=CommutativeRings())
        self.domain = domain



Which solution is preferable (and why) ? (the three of them seem to work, 
at least in the few tests I've performed). Thank you for your help. 

Eric.  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to