On Tue, Mar 31, 2009 at 12:55 AM, Robert Bradshaw
<rober...@math.washington.edu> wrote:
>
> On Mar 30, 2009, at 6:36 AM, Henryk Trappmann wrote:
>
>>
>> Ok, here is a first shot that has 100% coverage (except dumps):
>> http://github.com/bo198214/hyperops/raw/
>> 09e1da3372d7b431cdf557ffe164df9f91c08e68/formal_powerseries.py
>>
>> I finally decided to name it FPSRing, for Formal Power Series Ring. It
>> resides in sage.rings.formal_powerseries
>
> I'd rather it were named the more verbose, but significantly more
> explicit, FormalPowerSeriesRing. This fits better with the naming of
> all the other rings, and we do have tab completion after all. (As an
> aside, when I see FPS, I think of "frames per second" and I'm not
> even a gammer.)
>
>> I hope Nicolas M. Thiery can throw a look onto it, and give me some
>> suggestions (public or private), while trying out what he wanted to do
>> with it, being my reviewer.
>>
>> For me there are several open questions yet:
>> 1. I dont know anything about coercing
>
> Please see http://wiki.sagemath.org/coercion . If you this is
> insufficiently clear please ask.
>
>> 2. I have no idea how to approach pickling, how to get dumps to work.
>> I think that the attribute functions are the problem like William
>> said.
>
> The basic idea is to implement a __reduce__ method, which returns a
> tuple
>
>     callable, (args,to,pass,to,callable)
>
> and then on unpickling (loads) it will return callable
> (args,to,pass,to,callable) as the re-constructed object.

(1) You can't pickle objects with attributes that are functions.  If
your code currently only works with attributes that are functions, it
will need to be rewritten.  Note that callable objects are fine as
attributes (e.g., objects with a __call__ method defined).

(2) In many cases pickling is supposed to just work automatically
without having to define __reduce__.   With the new coercion model
there was a 1-line bug that I found which meant pickling would never
"just work".   The bug is fixed in the large patch again 3.4.1.alpha
at #5520.   The fix is:
wst...@mod:~/sage/devel/sage/sage/structure$ hg diff parent_gens.pyx

diff -r e8e97f260027 sage/structure/parent_gens.pyx
--- a/sage/structure/parent_gens.pyx    Thu Mar 26 12:34:13 2009 -0700
+++ b/sage/structure/parent_gens.pyx    Fri Mar 27 10:08:23 2009 -0700
@@ -350,7 +350,7 @@
        return d

    def __setstate__(self, d):
-        if self._element_constructor is not None:
+        if d.has_key('_element_constructor'):
            return parent.Parent.__setstate__(self, d)
        try:
            self.__dict__ = d

>
>> 3. I dont know what "sum_generator" and "product_generator" in Mike's
>> implementation do.
>> 4. I dont know about formatting docstrings.
>
> I would just open up integer.pyx, or some other file, for lots of
> examples here.

+1  Also there is a very good wiki page at wiki.sagemath.org I think
on the new format.

>
>> 5. If I define _pow_ it cant be used with non-integer exponents, this
>> comes somehow from RingElement. So I instead defined __pow__. I dont
>> know exactly about the benefits or drawbacks of defining _operator_
>> instead of __operator__. I also dont know for which operators such
>> distinction exists, e.g. is there also a _lshift_ and _rshift_ and so
>> on?
>
> For powering, it is simplest to override __pow__. As for the others,
> see the link above, but the basic idea is that when _add_, _sub_,
> _mul_, and _div_ are called, both inputs are guaranteed to have the
> same parent (i.e. they both will be formal power series over the same
> basering) so you don't, for example, have to worry about manually
> handling if someone is trying to add an integer, or rational, etc. to
> your power series. The default (Element) x.__add__(y) will coerce x
> and y into the same parent if necissary, and then call x._add_(y).
> There is also _rmul_ and _lmul_ which are used to implement
> multiplication by a scalar.
>
> - Robert
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to