Hi Florent, Florent Hivert wrote:
>> I expected that the __getitem__ method for lazy family would >> >> 1) Check that the value given is (or can be coerced to) a key, and >> 2) If a coercion is necessary, call the function on the coerced item. > When calling Family(keys, functions) keys can be pretty anything: lists, > tuple, parent in the category EnumeratedSets() or probably anythng which is > iterable... We didn't assume that x in keys or keys(x) has any meaning. For > example, I think the following is legal: > > sage: class toto(object): > .....: def __iter__(self): > .....: for i in [1,2,3]: yield i > .....: > sage: bla = toto() > sage: Family(bla, lambda x: x^2) > Lazy family (<lambda>(i))_{i in <__main__.toto object at 0x45f7f10>} > > Maybe this is too much permissive. So you are suggesting we should also > require that keys should also implement __contains__. In what concerns > coercion, please remember that a common usage is to lists as keys... Thanks. I have some reasons why I would like keys to implement __contains__, but I guess it will be easier to talk about this in Toronto. I'd thought about the list case and don't have a really good answer, although possibly the right behavior could somehow be decided during __init__ ... >> On a related note, the following *really* looks like a bug to me: > This is clearly a bug ! Thanks for pointing this out. This is now http://trac.sagemath.org/sage_trac/ticket/8822 Cheers, Jason -- 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.