diff options
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 50e6d8db2..e18bbc8bc 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -1041,7 +1041,7 @@ class poly1d(object): @property def coeffs(self): """ The polynomial coefficients """ - return self._coeffs + return self._coeffs.copy() @property def variable(self): @@ -1059,6 +1059,16 @@ class poly1d(object): """ The roots of the polynomial, where self(x) == 0 """ return roots(self._coeffs) + # our internal _coeffs property need to be backed by __dict__['coeffs'] for + # scipy to work correctly. Note that as a result, the getter for .coeffs + # does not run unless accessed through one of its aliases. + @property + def _coeffs(self): + return self.__dict__['coeffs'] + @_coeffs.setter + def _coeffs(self, coeffs): + self.__dict__['coeffs'] = coeffs + # alias attributes r = roots c = coef = coefficients = coeffs |