Open videlec opened 7 years ago
A simple heuristic to avoid the issue is to limit the expansion of construction functors in pushout()
to cases where it results in a reasonably small number of elementary functors. This is neither super elegant nor super robust, but pushout()
itself is a heuristic in the first place...
New commits:
ed53296 | limit expansion of functors in pushout() |
Branch: u/mmezzarobba/ticket/23906
Commit: ed53296
Author: Marc Mezzarobba
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
434ec4f | limit expansion of functors in pushout() |
Reviewer: Vincent Delecroix
Why this change
- sage: R = PolynomialRing(ZZ, 'x', 500)
- sage: S = PolynomialRing(GF(5), 'x', 200)
+ sage: R = PolynomialRing(ZZ, 'x', 50)
+ sage: S = PolynomialRing(GF(5), 'x', 20)
sage: R.gen(0) + S.gen(0)
2*x0
Since _expand_threshold
is completely static it would better be a class attribute.
Replying to @videlec:
Why this change
- sage: R = PolynomialRing(ZZ, 'x', 500) - sage: S = PolynomialRing(GF(5), 'x', 200) + sage: R = PolynomialRing(ZZ, 'x', 50) + sage: S = PolynomialRing(GF(5), 'x', 20) sage: R.gen(0) + S.gen(0) 2*x0
I don't remember.
Indeed it breaks
TypeError: unsupported operand parent(s) for +:
'Multivariate Polynomial Ring in x0, x1, x2, ... x499 over Integer Ring'
and
'Multivariate Polynomial Ring in x0, x1, x2, ..., x199 over Finite Field of size 5'
I think we discussed the issue verbally in Bordeaux, and that I convinced myself at the time that breaking this example was an acceptable trade-off. But I don't remember the details (and I'm not planning to work on this ticket any further for the moment).
update milestone 8.3 -> 8.4
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
1b96a28 | limit expansion of functors in pushout() |
Works fine with smaller number of variables for the base ring
CC: @simon-king-jena @nthiery @nbruin
Component: coercion
Keywords: bug
Author: Marc Mezzarobba
Branch/Commit: u/mmezzarobba/ticket/23906 @
1b96a28
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/23906