Skip to content

Commit c1f5625

Browse files
author
Release Manager
committed
gh-37303: use Parent in Weyl algebra replace the auld-class `Algebra` by `Parent` in Weyl algebras this requires a tweak in the `_first_n_gens` mechanism to handle families ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #37303 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 2416d61 + c817c06 commit c1f5625

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/sage/algebras/weyl_algebra.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from sage.categories.algebras_with_basis import AlgebrasWithBasis
3131
from sage.sets.family import Family
3232
import sage.data_structures.blas_dict as blas
33-
from sage.rings.ring import Algebra
3433
from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
3534
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
3635
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -655,7 +654,7 @@ def diff(self, p):
655654
return self.parent().diff_action(self, p)
656655

657656

658-
class DifferentialWeylAlgebra(Algebra, UniqueRepresentation):
657+
class DifferentialWeylAlgebra(UniqueRepresentation, Parent):
659658
r"""
660659
The differential Weyl algebra of a polynomial ring.
661660
@@ -780,7 +779,7 @@ def _repr_(self) -> str:
780779
sage: DifferentialWeylAlgebra(R)
781780
Differential Weyl algebra of polynomials in x, y, z over Rational Field
782781
"""
783-
poly_gens = ', '.join(repr(x) for x in self.gens()[:self._n])
782+
poly_gens = ', '.join(repr(x) for x in self.variables())
784783
return "Differential Weyl algebra of polynomials in {} over {}".format(
785784
poly_gens, self.base_ring())
786785

@@ -986,6 +985,8 @@ def algebra_generators(self):
986985
d = {x: self.gen(i) for i, x in enumerate(self.variable_names())}
987986
return Family(self.variable_names(), lambda x: d[x])
988987

988+
gens = algebra_generators
989+
989990
@cached_method
990991
def variables(self):
991992
"""

src/sage/structure/category_object.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ cdef class CategoryObject(SageObject):
367367
sage: z.minpoly() # needs sage.rings.number_field
368368
x^2 + 3
369369
"""
370-
return self._defining_names()[:n]
370+
names = self._defining_names()
371+
if isinstance(names, (list, tuple)):
372+
return names[:n]
373+
# case of Family
374+
it = iter(names)
375+
return tuple(next(it) for i in range(n))
371376

372377
@cached_method
373378
def _defining_names(self):

0 commit comments

Comments
 (0)