summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-04-30 15:25:03 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-05-03 16:42:30 -0600
commit8c72a78f56d1f87ca801495bec0c0d676d2ef6a5 (patch)
tree388fb3a4399198ef4db87e954cef82a0c48ebdb4 /numpy
parentbe3f0b1e1332b2a153b11f5027835a054a511427 (diff)
downloadnumpy-8c72a78f56d1f87ca801495bec0c0d676d2ef6a5.tar.gz
BUG: Fix __truediv__ bug in polytemplate.py file.
The use of polytemplate is deprecated, this fix is only for a backport if needed.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/polynomial/polytemplate.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/numpy/polynomial/polytemplate.py b/numpy/polynomial/polytemplate.py
index eeacf24fb..6c60ab3b2 100644
--- a/numpy/polynomial/polytemplate.py
+++ b/numpy/polynomial/polytemplate.py
@@ -14,6 +14,7 @@ from __future__ import division, absolute_import, print_function
import string
import sys
import warnings
+from number import Number
from numpy import ModuleDeprecationWarning
@@ -287,15 +288,13 @@ class $name(pu.PolyBase) :
return self.__floordiv__(other)
def __truediv__(self, other) :
- # there is no true divide if the rhs is not a scalar, although it
+ # there is no true divide if the rhs is not a Number, although it
# could return the first n elements of an infinite series.
# It is hard to see where n would come from, though.
- if np.isscalar(other) :
- # this might be overly restrictive
- coef = self.coef/other
- return self.__class__(coef, self.domain, self.window)
- else :
- return NotImplemented
+ if not isinstance(other, Number) or isinstance(other, bool):
+ form = "unsupported types for true division: '%s', '%s'"
+ raise TypeError(form % (type(self), type(other)))
+ return self.__floordiv__(other)
def __floordiv__(self, other) :
"""Returns the quotient."""
@@ -384,20 +383,14 @@ class $name(pu.PolyBase) :
return self.__rfloordiv__(other)
def __rtruediv__(self, other) :
- # there is no true divide if the rhs is not a scalar, although it
- # could return the first n elements of an infinite series.
- # It is hard to see where n would come from, though.
- if len(self.coef) == 1 :
- try :
- quo, rem = ${nick}div(other, self.coef[0])
- except :
- return NotImplemented
- return self.__class__(quo, self.domain, self.window)
+ # An instance of PolyBase is not considered a
+ # Number.
+ return NotImplemented
def __rfloordiv__(self, other) :
try :
quo, rem = ${nick}div(other, self.coef)
- except :
+ except:
return NotImplemented
return self.__class__(quo, self.domain, self.window)