-
-
Notifications
You must be signed in to change notification settings - Fork 652
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 aSized
Iterable
. - As a replacement for this functionality, revise the method
support
to 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