Opened 13 months ago
Closed 12 months ago
#28274 closed defect (fixed)
EnumeratedFamily should use integers as keys
Reported by: | gh-mwageringel | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-8.9 |
Component: | combinatorics | Keywords: | |
Cc: | tscrim, nthiery | Merged in: | |
Authors: | Markus Wageringel | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | 4ba13d8 (Commits) | Commit: | 4ba13d872900eba7e2f556afd77bfc0f94852521 |
Dependencies: | Stopgaps: |
Description (last modified by )
This ticket solves the following problems involing EnumeratedFamily
:
- The keys of an enumerated family should be integers. Currently, the elements of the family itself are returned.
sage: f = Family(Permutations(4)) sage: f.keys() Standard permutations of 4 sage: list(f.keys()) == list(f) # should not be True here True
Because of this, looking up elements by key as inf[next(iter(f.keys()))]
raises a type error. For example, this is used inDisjointUnionEnumeratedSets
.
- Finite enumerated families should be in the category of
FiniteEnumeratedSets()
, while currently it is only inEnumeratedSets()
:sage: Family(Permutations(4)) in FiniteEnumeratedSets() # should be True False
- Infinite enumerated families are currently indexed by
NonNegativeIntegers()
fromsage.categories.example.infinite_enumerated_sets
. This ticket replaces the usage of these example numbers by those insage.sets.non_negative_integers
. This also includes one instance inbaxter_permutations
.
Change History (7)
comment:1 Changed 13 months ago by
- Branch set to u/gh-mwageringel/28274
- Commit set to 4ba13d872900eba7e2f556afd77bfc0f94852521
- Status changed from new to needs_review
comment:3 follow-up: ↓ 4 Changed 12 months ago by
- Cc nthiery added
- Reviewers set to Travis Scrimshaw
This is clearly a bug as it contradicts the documentation of EnumeratedFamily
:
:class:`EnumeratedFamily` turns an enumerated set ``c`` into a family indexed by the set `\{0,\dots, |c|-1\}`.
I don't understand this:
The category of finite enumerated families should be in
FiniteEnumeratedSets()
, while currently it is only inEnumeratedSets()
.
in both what is supposed to mean and what was changed.
comment:4 in reply to: ↑ 3 Changed 12 months ago by
Replying to tscrim:
I don't understand this:
The category of finite enumerated families should be in
FiniteEnumeratedSets()
, while currently it is only inEnumeratedSets()
.in both what is supposed to mean and what was changed.
What I meant is that the category should be a subcategory of FiniteEnumeratedSets()
so that the following can be used to check whether the family is finite.
sage: Family(Permutations(4)) in FiniteEnumeratedSets() # should be True False
The category is set based on whether the type of the keys is known to be finite, such as for lists and tuples. I added range
to this detection, which is the type of keys of EnumeratedFamily
. This bug was probably introduced when six.moves.range
was imported into the module, as ordinarily in Python 2 range
returns a list.
comment:5 Changed 12 months ago by
- Description modified (diff)
- Status changed from needs_review to positive_review
Okay, that helps quite a lot. Thanks.
comment:6 Changed 12 months ago by
Thank you.
comment:7 Changed 12 months ago by
- Branch changed from u/gh-mwageringel/28274 to 4ba13d872900eba7e2f556afd77bfc0f94852521
- Resolution set to fixed
- Status changed from positive_review to closed
Note that this ticket is independent from, but compatible with #28273.
New commits:
28274: fix keys and category of EnumeratedFamily