Hi Christian,

On Tue, Jun 08, 2010 at 03:57:57PM -0700, Christian Stump wrote:
> is it on purpose that the method LazyFamily does not check membership
> when calling __getitem__?
> 
> sage: a = Family( range(10), lambda i:i+2)
> sage: a[4]
> 6
> sage: a[100]
> KeyError: 100
> 
> sage: b = Family( range(10), lambda i:i+2, lazy=True)
> sage: b[4]
> 6
> sage: b[100]
> 102
> 
> Do you also think that the b[100] should return a KeyError as well? Or
> having an additional parameter check_key_membership=True as standard
> input for LazyFamily? If you agree I would open a ticket and fix that.

Yes, it has been a bother for a while. There might actually be a
ticket already for it, at least in the case where the family is the
basis of a free module.

The reason why it was not implemented is that, in general, membership
testing in the index set can be any of expensive, hard, if not
undecidable. So we decided with Florent not to do anything before
having a deep discussion about the various use cases of membership
testing. But we never got to actually run that discussion :-(

Adding check_key_membership=True could be a good temporary
workaround. And it could be enabled by default when the indexing set
is something simple and cheap (say a Python list/tuple/set, or a Sage
Set).

Cheers,
                                Nicolas
--
Nicolas M. ThiĆ©ry "Isil" <[email protected]>
http://Nicolas.Thiery.name/

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to