summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-05-28 11:56:02 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-05-28 11:56:02 +0200
commit7afe53c6511c521f942e706051240e8e319d1c29 (patch)
tree3b3fcb4a5863930315d27ceec27f1e35948b994d
parent4c93c93dbe131359fca93b7543e65c48f5ae0dc1 (diff)
downloadnumpy-7afe53c6511c521f942e706051240e8e319d1c29.tar.gz
BUG: Fixed an issue wherein `poly1d.__getitem__` could return scalars of the wrong dtype
-rw-r--r--numpy/lib/polynomial.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index e9df783b4..56fcce621 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -494,11 +494,11 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
cov : bool or str, optional
If given and not `False`, return not just the estimate but also its
covariance matrix. By default, the covariance are scaled by
- chi2/dof, where dof = M - (deg + 1), i.e., the weights are presumed
- to be unreliable except in a relative sense and everything is scaled
- such that the reduced chi2 is unity. This scaling is omitted if
- ``cov='unscaled'``, as is relevant for the case that the weights are
- 1/sigma**2, with sigma known to be a reliable estimate of the
+ chi2/dof, where dof = M - (deg + 1), i.e., the weights are presumed
+ to be unreliable except in a relative sense and everything is scaled
+ such that the reduced chi2 is unity. This scaling is omitted if
+ ``cov='unscaled'``, as is relevant for the case that the weights are
+ 1/sigma**2, with sigma known to be a reliable estimate of the
uncertainty.
Returns
@@ -1394,9 +1394,9 @@ class poly1d:
def __getitem__(self, val):
ind = self.order - val
if val > self.order:
- return 0
+ return self.coeffs.dtype.type(0)
if val < 0:
- return 0
+ return self.coeffs.dtype.type(0)
return self.coeffs[ind]
def __setitem__(self, key, val):