> > We discussed this with Vincent over the phone: I pointed him to the
> > combinatorial_class_from_iterator decorator implemented in
> > class_from_iterator.patch; he volunteered to refactor it as
> > enumerated_set_from_iterator. Note that, as a decorator over an
> > existing function which produces an iterator, it's picklable.
> >
> > I think it's reasonable to use it in code for implementing little
> > functions that returns a set, the main use of which will be to iterate
> > over.
> >
> 
> This is now #12518.
> 
> Following Florent, I removed ._cardinality attribute and simplify
> everything. I also add an implementation of a cache which allows the
> iterator to be used only once (see  sage.misc.iter_with_cache).
> 
> I get trouble with TestSuite which only works when elements of the set
> have parents. In particular it does not work in the following case
> {{{
> sage: from sage.sets.set_from_iterator import EnumeratedSetFromIterator
> sage: E = EnumeratedSetFromIterator(graphs, category=InfiniteEnumeratedSets())
> sage: TestSuite(E).run()
> }}}
> Actually the above example leads to an infinite loop.

If E is not the parent of the element generated by E, and a fortiori if those
element have no parent, then you should mark your enumerated set as a facade:
 
    sage: E = EnumeratedSetFromIterator(graphs,
    ...             category=InfiniteEnumeratedSets().Facade())

> I wrote an implementation of the decorator for functions (which
> works!) but I'm not sure about what to do for the case of methods. Any
> idea ? As soon as the decorator is ready, the ticket will need review.

I currently don't see the problem. Can you be more specific ?

Florent

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

Reply via email to