From 6f108ae44904026d7da2a1b71abb116284b04960 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Thu, 9 Mar 2017 03:21:23 +0000 Subject: DEP: Deprecate copying random properties in __init__ --- numpy/lib/polynomial.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'numpy/lib/polynomial.py') diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 9803ce6fb..50e6d8db2 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -1066,8 +1066,15 @@ class poly1d(object): def __init__(self, c_or_r, r=False, variable=None): if isinstance(c_or_r, poly1d): - for key in c_or_r.__dict__.keys(): - self.__dict__[key] = c_or_r.__dict__[key] + self._variable = c_or_r._variable + self._coeffs = c_or_r._coeffs + + if set(c_or_r.__dict__) - set(self.__dict__): + msg = ("In the future extra properties will not be copied " + "across when constructing one poly1d from another") + warnings.warn(msg, FutureWarning, stacklevel=2) + self.__dict__.update(c_or_r.__dict__) + if variable is not None: self._variable = variable return -- cgit v1.2.1