Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
check for nonzero constant in multivariate Taylor series
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Aug 5, 2021
1 parent 2d5285b commit 117022d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/sage/rings/lazy_laurent_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No
1
sage: L = LazyTaylorSeriesRing(ZZ, 'z')
sage: L(lambda i: i, 5, 1, 10)
5*z^5 + 6*z^6 + 7*z^7 + 8*z^8 + 9*z^9 + z^10 + z^11 + z^12 + O(z^13)
sage: L(lambda i: i, 5, (1, 10))
Expand Down Expand Up @@ -773,17 +772,26 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No
.. TODO::
Add a method to change the sparse/dense implementation.
TESTS::
sage: L.<x,y> = LazyTaylorSeriesRing(QQ)
sage: L(constant=1)
Traceback (most recent call last):
...
ValueError: constant must be zero for multivariate Taylor series
"""
if valuation is None:
valuation = 0
assert valuation >= 0, "the valuation of a Taylor series must be positive"
if valuation < 0:
raise ValueError("the valuation of a Taylor series must be positive")

R = self._laurent_poly_ring
if x is None:
assert degree is None
coeff_stream = CoefficientStream_uninitialized(self._sparse, valuation)
return self.element_class(self, coeff_stream)

try:
# Try to build stuff using the polynomial ring constructor
x = R(x)
Expand All @@ -793,6 +801,8 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No
constant, degree = constant
if constant is not None:
constant = R(constant)
if len(self.variable_names()) > 1 and constant:
raise ValueError(f"constant must be zero for multivariate Taylor series")
if x in R:
if not x and not constant:
coeff_stream = CoefficientStream_zero(self._sparse)
Expand Down

0 comments on commit 117022d

Please sign in to comment.