-
-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-36933: More conversion to parent a few more conversions from `Ring` (old coercion framework) to `Parent` (new coercion framework), ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. URL: #36933 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
- Loading branch information
Showing
5 changed files
with
37 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,22 +185,23 @@ | |
Classes and Methods | ||
=================== | ||
""" | ||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2008 Alexander Raichev <[email protected]> | ||
# Copyright (C) 2014, 2016 Daniel Krenn <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
from functools import total_ordering | ||
from itertools import combinations_with_replacement | ||
|
||
from sage.structure.element import RingElement | ||
from sage.structure.unique_representation import UniqueRepresentation | ||
from sage.rings.ring import Ring | ||
from sage.structure.parent import Parent | ||
from sage.calculus.var import var | ||
from sage.calculus.functional import diff | ||
from sage.symbolic.ring import SR | ||
|
@@ -1507,7 +1508,7 @@ def asymptotic_decomposition(self, alpha, asy_var=None): | |
for f in decomp2: | ||
ff = self.parent()((f.numerator() / | ||
cauchy_stuff).simplify_full().collect(asy_var), | ||
f.denominator_factored()) | ||
f.denominator_factored()) | ||
decomp3.append(ff) | ||
|
||
return decomp3 | ||
|
@@ -2248,9 +2249,9 @@ def asymptotics_multiple(self, p, alpha, N, asy_var, coordinate=None, | |
if verbose: | ||
print("Computing derivatives of auxiliary functions...") | ||
m = min(n, N) | ||
end = [X[d-1] for j in range(n)] | ||
end = [X[d - 1] for j in range(n)] | ||
Hprodderivs = diff_all(Hprod, X, 2 * N - 2 + n, ending=end, sub_final=P) | ||
atP.update({U.subs(P): diff(Hprod, X[d - 1], n).subs(P)/factorial(n)}) | ||
atP.update({U.subs(P): diff(Hprod, X[d - 1], n).subs(P) / factorial(n)}) | ||
Uderivs = {} | ||
k = Hprod.polynomial(CC).degree() - n | ||
if k == 0: | ||
|
@@ -2327,7 +2328,7 @@ def asymptotics_multiple(self, p, alpha, N, asy_var, coordinate=None, | |
(-1) ** (q - j - k) | ||
for (j, k) in product(range(min(n - 1, q) + 1), | ||
range(max(0, q - n), | ||
q + 1)) | ||
q + 1)) | ||
if j + k <= q]) | ||
for q in range(N)]) | ||
chunk = chunk.subs(P).simplify() | ||
|
@@ -2936,7 +2937,7 @@ def relative_error(self, approx, alpha, interval, exp_scale=Integer(1), | |
alpha = vector(alpha) | ||
multi_indices = [r * alpha for r in interval] | ||
mac = self.maclaurin_coefficients(multi_indices, numerical=digits) | ||
#mac = self.old_maclaurin_coefficients(alpha, max(interval)) | ||
# mac = self.old_maclaurin_coefficients(alpha, max(interval)) | ||
mac_approx = {} | ||
stats = [] | ||
for r in interval: | ||
|
@@ -3010,7 +3011,7 @@ def _mul_(left, right): | |
return left.parent()(numer, df) | ||
|
||
|
||
class FractionWithFactoredDenominatorRing(UniqueRepresentation, Ring): | ||
class FractionWithFactoredDenominatorRing(UniqueRepresentation, Parent): | ||
r""" | ||
This is the ring of fractions with factored denominator. | ||
|
@@ -3053,7 +3054,8 @@ def __classcall_private__(cls, denominator_ring, numerator_ring=None, category=N | |
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_functions import FractionWithFactoredDenominatorRing | ||
sage: R.<x,y> = PolynomialRing(QQ) | ||
sage: FFPD1 = FractionWithFactoredDenominatorRing(R) | ||
sage: FFPD2 = FractionWithFactoredDenominatorRing(R, R, Rings()) | ||
sage: cat = Rings().Commutative() | ||
sage: FFPD2 = FractionWithFactoredDenominatorRing(R, R, cat) | ||
sage: FFPD1 is FFPD2 | ||
True | ||
""" | ||
|
@@ -3063,7 +3065,7 @@ def __classcall_private__(cls, denominator_ring, numerator_ring=None, category=N | |
raise ValueError('numerator ring {} has no coercion map from the ' | ||
'denominator ring {}'.format( | ||
numerator_ring, denominator_ring)) | ||
category = Rings().or_subcategory(category) | ||
category = Rings().Commutative().or_subcategory(category) | ||
return super().__classcall__(cls, denominator_ring, | ||
numerator_ring, category) | ||
|
||
|
@@ -3081,11 +3083,11 @@ def __init__(self, denominator_ring, numerator_ring=None, category=None): | |
""" | ||
self._numerator_ring = numerator_ring | ||
self._denominator_ring = denominator_ring | ||
Ring.__init__(self, denominator_ring, category=category) | ||
Parent.__init__(self, denominator_ring, category=category) | ||
|
||
def _repr_(self): | ||
r""" | ||
Returns a representation. | ||
Return a representation. | ||
OUTPUT: | ||
|
@@ -3614,7 +3616,7 @@ def sum(self): | |
|
||
|
||
##################################################################### | ||
## Helper functions | ||
# Helper functions | ||
|
||
|
||
def diff_prod(f_derivs, u, g, X, interval, end, uderivs, atc): | ||
|
@@ -3829,7 +3831,7 @@ def subs_all(f, sub, simplify=False): | |
|
||
|
||
def diff_all(f, V, n, ending=[], sub=None, sub_final=None, | ||
zero_order=0, rekey=None): | ||
zero_order=0, rekey=None): | ||
r""" | ||
Return a dictionary of representative mixed partial | ||
derivatives of `f` from order 1 up to order `n` with respect to the | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters