Skip to content
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

wrong inverse action when using ConstructionFunctor.coercion_reversed #19521

Closed
dkrenn opened this issue Nov 4, 2015 · 14 comments
Closed

wrong inverse action when using ConstructionFunctor.coercion_reversed #19521

dkrenn opened this issue Nov 4, 2015 · 14 comments

Comments

@dkrenn
Copy link
Contributor

dkrenn commented Nov 4, 2015

sage: Q.<y> = SR.subring(no_variables=True)[[]]
sage: (y / 1).parent()
Univariate Polynomial Ring in x over Symbolic Ring

but the result should be

Univariate Polynomial Ring in x over Symbolic Constants Subring

since there is a coercion from the integer ring to the symbolc constants subring.

This is because the attrirute coercion_reversed of ConstructionFunctor is not taken into account.

Depends on #19259

Component: coercion

Author: Daniel Krenn

Branch/Commit: 867d6d3

Reviewer: Benjamin Hackl

Issue created by migration from https://trac.sagemath.org/ticket/19521

@dkrenn dkrenn added this to the sage-6.10 milestone Nov 4, 2015
@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

comment:1

BTW: For some reason it works (partially) for polynomial rings:

     sage: R.<x> = SR.subring(no_variables=True)[]
     sage: (x / 1).parent()
     Univariate Polynomial Ring in x over Symbolic Constants Subring

but

     sage: cm = sage.structure.element.get_coercion_model()
     sage: cm.explain(x, 1, operator.div)
     Action discovered.
        Right inverse action by Symbolic Ring on Univariate Polynomial Ring in x over Symbolic Constants Subring
        with precomposition on right by Conversion map:
          From: Integer Ring
          To:   Symbolic Ring
    Result lives in Univariate Polynomial Ring in x over Symbolic Ring
    Univariate Polynomial Ring in x over Symbolic Ring

At one point this should be investigated, but probably on a different ticket.

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

Author: Daniel Krenn

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

Dependencies: #19259

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

Branch: u/dkrenn/coerce/inverse-action

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

Commit: 5638459

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 4, 2015

comment:4

Branch should fix this; still need to run a make ptestlong; will do this soon...


Last 10 new commits:

fb2885csubring in index.rst
eab9513simplify a doctest
23352b2change ValueError to TypeError to make everything work with SR as it should
2d8b7c4typo in docstring
15ec40edocstring of SR.subring
7938d95module description of subring
852959arename only_constants --> no_variables
e4837e9correct parent of result of an_element
6e5a098Merge branch 'u/dkrenn/symbolic-subring' of trac.sagemath.org:sage into coerce/inverse-action
5638459#19521: use coercion_reversed in InverseAction

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 5, 2015

comment:5

Replying to @dkrenn:

Branch should fix this; still need to run a make ptestlong; will do this soon...

Passed. So I set it to needs review.

@behackl
Copy link
Member

behackl commented Jan 24, 2016

Reviewer: Benjamin Hackl

@behackl
Copy link
Member

behackl commented Jan 24, 2016

Changed commit from 5638459 to 867d6d3

@behackl
Copy link
Member

behackl commented Jan 24, 2016

@behackl
Copy link
Member

behackl commented Jan 24, 2016

comment:6

Hi! I've merged the (positively reviewed) dependency into this branch and reviewed the code in this ticket.

I think I understand your fix as well as the strategy behind it, and I am willing to give this a positive_review (i.e. everything LGTM). However, I'd rather be sure:

In principle, all that happens is that you order the functors and parents from smallest to largest (in the sense of coercion) and iterate over this reordered tower such that actually the smallest parent with the required property is found?

For example, (using your notation from the comment), if we had a tower A -> B <- C <- D -> E, then the old code would iterate over [A, B, C, D, E, F], and in your fixed version we iterate over [A, D, C, B, E]?

Also, I'd like to give the patchbots a chance to test this---or, at least, run make ptestlong myself.


New commits:

ff99c7fTrac #19259: change to has_valid_variable
581f315Trac #19259: check validity of variables
c9b2428improve language
05dc834misc. changes, indentation, line breaks
8cc884afix merge of functors
aeae8f3Merge tag '7.0' into symbolics/symbolic-subring
c4a0e22merge accepting and rejecting functors in all cases
d376b10revert changes to merge of functors
867d6d3Merge branch 'u/behackl/symbolics/symbolic-subring' of git://trac.sagemath.org/sage into coercion/inverse-action

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 24, 2016

comment:7

Replying to @behackl:

Hi! I've merged the (positively reviewed) dependency into this branch and reviewed the code in this ticket.

Thanks.

In principle, all that happens is that you order the functors and parents from smallest to largest (in the sense of coercion) and iterate over this reordered tower such that actually the smallest parent with the required property is found?

For example, (using your notation from the comment), if we had a tower A -> B <- C <- D -> E, then the old code would iterate over [A, B, C, D, E, F], and in your fixed version we iterate over [A, D, C, B, E]?

Correct.

Also, I'd like to give the patchbots a chance to test this---or, at least, run make ptestlong myself.

Ok.

@behackl
Copy link
Member

behackl commented Jan 24, 2016

comment:8

... alright. Passes ptestlong and does what it should -> positive_review.

@vbraun
Copy link
Member

vbraun commented Jan 24, 2016

Changed branch from u/behackl/coercion/inverse-action to 867d6d3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants