Hi Tobias!

On Tue, Mar 02, 2010 at 09:10:16AM +0100, Tobias Columbus wrote:
> I am sorry, that we didn't manage to talk more intensely during the
> SAGE days, but I preferred spending my last afternoon at the
> sea. Apologizes for that...

Hmm, given how nice the Calanques are I sure was not standing a chance :-)

> Anyway, I decided to keep on bothering you -- now by mail.

I am glad to hear back from you! Please next time send your e-mail
directly to sage-devel or sage-combinat-devel next time (they are in
CC now): others will be interested in this discussion and you are
likely to get quicker feedback (I was on vacations last week).

> First of all I need some help with my implementation ;-)
> My FreeGroup passes all except two tests in the TestSuite.
> These failing tests are _test_elements and _test_pickling.

> For the latter one I cannot figure out what I have to implement to
> pass this test. I browsed some code of other parents and it seems
> that drops and loads are implemented in SageObject and work out of
> the box for other implementations. What might be the problem is that
> my code does not lie in the sage tree, but in some other folder.

I indeed bet that's the problem. I should have mentioned that I almost
always do this kind of development directly in the Sage source tree.

> But honestly I have no idea about that and I couldn't find any
> documentation in SAGE about cPickle.

        http://docs.python.org/library/pickle.html

> The _test_elements fails again with _test_pickling and with 
> _test_category. The test 
> 
> isinstance( self.an_element(), 
> self.an_element().parent().ElementClass )
> 
> fails. I have absolutely no idea, how to fix this.
> I tried adding methods _element_class, _element_class_ returning 
> my FreeGroupElement class but this did not help.

Just use:

   class FreeGroup(...):
       ...
       Element = FreeGroupElement

and the element_class will be constructed for you (with proper
inheritance from the categories, which is what the test is complaining
about).

Alternatively, you can directly define the FreeGroupElement class
inside your parent:

    class FreeGroup(...):
        ...
        class Element(...):
            ...

> I attached, my not-so-well-documented code. I would be thankful, if
> you find some time to have a look or just point me to some place
> containing the appropriate documentation for my problems...  I think
> my code works with any kind of generators and even so with
> infinitely many generators:
> 
> sage: f = FreeGroup( NonNegativeIntegers() )
> 
> sage: f.an_element()
> 0
> 
> sage: f.one()
> 1
> TODO: This output is ambigous and there needs to be some better
> representation in this case.

Maybe elements should be represented as words (possibly with an option
for the user to choose from).

Some random thoughts:

 - Please use _element_constructor_ rather than __call__. Actually, in
   a first round, you might get away with the default
   _element_constructor_ with the change above.

 - With the above, you don't need anymore to inherit from
   MultiplicativeGroupElement; Element should be enough. The category
   will provide you with the appropriate code. You may want to use
   ElementWrapper by the way, which will e.g. provide an equality test
   for you.

 - some_elements should return an iterable (e.g. a list) rather than
   an iterator. We should add a generic test about this.

 - I am not sure I would want a coerce map from another free group
   with other generators.

 - Define group_generators rather than gens

 - _plain_generators() is equivalent to self.group_generators().keys()

 - for `an_element`, you might want to return a more typical element

 - for `some_elements`, you might want to only return 3-5 typical
   elements (that will make the associativity tests faster)

I'll answer the rest in a separate e-mail.

Thanks for your work on this, and for beta testing all that framework ...

Best,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-de...@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to