-
-
Notifications
You must be signed in to change notification settings - Fork 719
Description
This is the element class of a CombinatorialFreeModule.
Its implementation of __iter__, __contains__, __len__ are not compatible with anything in the collections.abc protocols. Specifically,
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
sage: import collections.abc
sage: isinstance(f, collections.abc.Collection)
True
but __iter__ating over this collection gives objects that are not __contain__ed in it.
To improve interoperability, we propose to make the following changes:
- Deprecate the
__contains__method (currently testing whether a given index is in the support). After its removal, the class would no longer be considered by Python to be a subclass ofcollections.abc.Collection, but merely aSizedIterable. - As a replacement for this functionality, revise the method
supportto return an instance of a new classSupportView, which provides a fast__contains__method, instead of a list.
(Similarly, in #24815, it was proposed to make the elements of free modules from sage.modules a collections.abc.Sequence.)
Part of Meta-ticket #30309: Unify free module elements API: methods dict, monomial_coefficients, etc.
Depends on #34505
CC: @fchapoton @tscrim @mwageringel @nthiery @anneschilling
Component: linear algebra
Author: Matthias Koeppe
Branch/Commit: 2fe3b98
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/34509