New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix call for FiniteEnumeratedSet's of plain Python objects #16280
Comments
This comment has been minimized.
This comment has been minimized.
Author: Nicolas M. Thiéry |
Commit: |
New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:5
Nothing serious, but there is something weird
|
comment:7
Oh, I did not try to pass test in all of src/. My office's computer is off for some reason Nathann |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:9
Running all long tests now. I'll report around noon. |
comment:10
Do you get why this |
comment:11
Replying to @nathanncohen:
It was meant to be a one in the first place: it's the length of 'a'; I had fumbled my copy-paste. Btw: all long tests pass. |
comment:13
Oh sorry, I had not noticed that you had added this doctest with '2' as an answer yourself. I was wondering how your commit could have changed a former "2" into a "1" Good to go as far as I can tell. Seems to do what it should, and if it passes tests... Thanks ! Now #16269 can be reviewed, which means that #16277 can be reviewed which means that #16279 can be reviwed, but also #16235 and so #16241. Damn designs Nathann |
Reviewer: Nathann Cohen |
Changed branch from u/nthiery/fix_call_for_finite_enumeratedset_s_over_plain_python_objects to |
Problem
Before this ticket, a
FiniteEnumeratedSet
could not be called on itsown elements whenever they were not
Element
's:This prevented the use of
F(x)
as generic idiom to convertx
intoF
while checking that it's inF
.And indeed:
Analysis
Parent.__call__
enforces that_element_constructor_
return anElement
(more precisely, it calls_element_constructor_
through aDefaultConvertMap
, and anyMap
requires its results to beinstances of
Element
).Proposed solution
Since
FiniteEnumeratedSets
is often a facade over plain Pythonobjects, this ticket works around this limitation by a custom
FiniteEnumeratedSets.__call__
that calls directly_element_constructor_
wheneverel
is not anElement
. OtherwiseParent.__call__
is called as usual.Limitation
This workaround prevents conversions or coercions from facade parents
over plain Python objects. But it's already much better than before!
CC: @sagetrac-sage-combinat @nathanncohen @videlec
Component: combinatorics
Author: Nicolas M. Thiéry
Branch/Commit:
4e27454
Reviewer: Nathann Cohen
Issue created by migration from https://trac.sagemath.org/ticket/16280
The text was updated successfully, but these errors were encountered: