[NumPy-Tickets] [NumPy] #1705: Unicode breaks numpy.correlate (patch attached)
NumPy Trac
numpy-tickets@scipy....
Thu Jan 6 03:56:09 CST 2011
#1705: Unicode breaks numpy.correlate (patch attached)
-------------------------------+--------------------------------------------
Reporter: pyrtsa | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.5.2
Component: numpy.core | Version: 1.5.0
Keywords: correlate unicode |
-------------------------------+--------------------------------------------
'''{{{numpy.correlate}}}''' doesn't play nicely with '''{{{from __future__
import unicode_literals}}}''' (nor generally a {{{unicode}}} string
provided as the {{{mode}}} argument). The following call will result in a
{{{TypeError}}}:
{{{
>>> numpy.correlate([1,2,3],[1,2,3],unicode('full'))
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/Users/me/<ipython console> in <module>()
/path/to/numpy/core/numeric.pyc in correlate(a, v, mode, old_behavior)
692 return multiarray.correlate(a,v,mode)
693 else:
--> 694 return multiarray.correlate2(a,v,mode)
695
696 def convolve(a,v,mode='full'):
TypeError: an integer is required
}}}
'''This patch''' should fix the problem (Python 2.3 and above):
{{{
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index dbad73c..519180b 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -636,7 +636,7 @@ _mode_from_name_dict = {'v': 0,
'f' : 2}
def _mode_from_name(mode):
- if isinstance(mode, type("")):
+ if isinstance(mode, basestring):
return _mode_from_name_dict[mode.lower()[0]]
return mode
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1705>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list