On Mon, Jul 12, 2010 at 11:28:41AM +0200, Viviane Pons wrote:
> Ok I understand what you're saying but this is not obvious from the
> documentation which says : Return True if there is a natural map from
> S to self. Otherwise, return False.
> 
> There is nothing in this sentence that says that the function is
> actually changing something and stopping you from registering
> coertions !

Note that the name of the function is not
"has_registered_coerce_map_from". So it is clear that the coercion
still has to do something non trivial.

But yes, the documentation could be improved. Patch welcome!

> Also, there is still a problem. This beahviour may not be a bug but
> it's causing me issues. Look at the example I attached, The behavious
> is as follows :
> 
> - I create the morphism
> - I register the morphism (ok, no error)
> - I use the morphism (this is actually moving the coercion to stage 2)
> - I register again the morphims : I got an error (still normal from
> what you say)
> 
> Only, this may look silly on the example but this is exactly what I
> was doing on my program which is creating morphism dynamically : and
> that is why I tried to use has_coerce_map because I needed to know if
> the morphism was already there. So, if has_coerce_map is not the
> method I need, what should I do ? Should I launch the coercion anyway
> and catch the error ? It seems a bit heavy and a method only checking
> would seem usefull.
> 
> Also, the name of has_coerce_map_from is also wrong, If it's actually
> doing something, it should be called "look_for_coercion" or something
> like that. This name (and the doc) says it's a checking method not an
> active method.

If this feature is really useful, then you could add an accessor
self.has_registered_coerce_map_from(domain) in parent.pyx to lookup if
domain is already in self._coerce_from_hash. Though even that would
not work perfectly, since self._coerce_from_hash contains both
registered and discovered coercion maps.

Now do you really need this feature? We never had a need for it.
Isn't it possible to setup the initialization of your parents so that
it is guaranteed that the coercion is registered exactly once?

Cheers,
                                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