Skip to content

Commit ed72e73

Browse files
committed
use Parent in Weyl algebra
1 parent 0c390a0 commit ed72e73

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(Parent, UniqueRepresentation):
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
@@ -365,7 +365,12 @@ cdef class CategoryObject(SageObject):
365365
sage: z.minpoly() # needs sage.rings.number_field
366366
x^2 + 3
367367
"""
368-
return self._defining_names()[:n]
368+
names = self._defining_names()
369+
if isinstance(names, (list, tuple)):
370+
return names[:n]
371+
# case of Family
372+
it = iter(names)
373+
return tuple(next(it) for i in range(n))
369374

370375
@cached_method
371376
def _defining_names(self):

0 commit comments

Comments
 (0)