Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r67355:d57e7620cc8b
Date: 2013-10-14 13:15 +0200
http://bitbucket.org/pypy/pypy/changeset/d57e7620cc8b/
Log: merged upstream
diff --git a/pypy/module/cpyext/include/numpy/arrayobject.h
b/pypy/module/cpyext/include/numpy/arrayobject.h
--- a/pypy/module/cpyext/include/numpy/arrayobject.h
+++ b/pypy/module/cpyext/include/numpy/arrayobject.h
@@ -1,5 +1,8 @@
-/* NDArray object interface - S. H. Muller, 2013/07/26 */
+/* NDArray object interface - S. H. Muller, 2013/07/26
+ * It will be copied by numpy/core/setup.py by install_data to
+ * site-packages/numpy/core/includes/numpy
+*/
#ifndef Py_NDARRAYOBJECT_H
#define Py_NDARRAYOBJECT_H
@@ -9,7 +12,6 @@
#include "old_defines.h"
-#define NPY_INLINE
#define NPY_UNUSED(x) x
#define PyArray_MAX(a,b) (((a)>(b))?(a):(b))
#define PyArray_MIN(a,b) (((a)<(b))?(a):(b))
@@ -22,11 +24,12 @@
typedef unsigned char npy_bool;
typedef unsigned char npy_uint8;
+typedef unsigned short npy_uint16;
+typedef signed short npy_int16;
+typedef signed char npy_int8;
typedef int npy_int;
-#ifndef npy_intp
-#define npy_intp long
-#endif
+typedef long npy_intp;
#ifndef NPY_INTP_FMT
#define NPY_INTP_FMT "ld"
#endif
diff --git a/pypy/module/cpyext/include/numpy/npy_3kcompat.h
b/pypy/module/cpyext/include/numpy/npy_3kcompat.h
--- a/pypy/module/cpyext/include/numpy/npy_3kcompat.h
+++ b/pypy/module/cpyext/include/numpy/npy_3kcompat.h
@@ -3,7 +3,9 @@
* for supporting Python 2 and Python 3 in the same code base.
*
* PyPy uses it as a convenient place to add compatability declarations
- */
+ * It will be copied by numpy/core/setup.py by install_data to
+ * site-packages/numpy/core/includes/numpy
+*/
#ifndef _NPY_3KCOMPAT_H_
#define _NPY_3KCOMPAT_H_
@@ -36,4 +38,4 @@
Py_DECREF(ret);
return 0;
}
-
+#endif
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -954,6 +954,13 @@
def descr___array_finalize__(self, space, w_obj):
pass
+ def descr___array_wrap__(self, space, w_obj, w_context=None):
+ return w_obj
+
+ def descr___array_prepare__(self, space, w_obj, w_context=None):
+ return w_obj
+ pass
+
@unwrap_spec(offset=int, order=str)
def descr_new_array(space, w_subtype, w_shape, w_dtype=None, w_buffer=None,
offset=0, w_strides=None, order='C'):
@@ -1144,7 +1151,8 @@
__reduce__ = interp2app(W_NDimArray.descr_reduce),
__setstate__ = interp2app(W_NDimArray.descr_setstate),
__array_finalize__ = interp2app(W_NDimArray.descr___array_finalize__),
-
+ __array_prepare__ = interp2app(W_NDimArray.descr___array_prepare__),
+ __array_wrap__ = interp2app(W_NDimArray.descr___array_wrap__),
__array__ = interp2app(W_NDimArray.descr___array__),
)
diff --git a/pypy/module/micronumpy/interp_ufuncs.py
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -342,6 +342,9 @@
if w_ldtype.is_str_type() and w_rdtype.is_str_type() and \
self.comparison_func:
pass
+ elif (w_ldtype.is_str_type() or w_rdtype.is_str_type()) and \
+ self.comparison_func and w_out is None:
+ return space.wrap(False)
elif (w_ldtype.is_flexible_type() or \
w_rdtype.is_flexible_type()):
raise OperationError(space.w_TypeError, space.wrap(
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -712,7 +712,8 @@
def test_comparisons(self):
import operator
- from numpypy import equal, not_equal, less, less_equal, greater,
greater_equal
+ from numpypy import (equal, not_equal, less, less_equal, greater,
+ greater_equal, arange)
for ufunc, func in [
(equal, operator.eq),
@@ -735,7 +736,9 @@
(3, 3.5),
]:
assert ufunc(a, b) == func(a, b)
-
+ c = arange(10)
+ val = c == 'abcdefg'
+ assert val == False
def test_count_nonzero(self):
from numpypy import count_nonzero
diff --git a/rpython/tool/gcanalyze.py b/rpython/tool/gcanalyze.py
new file mode 100755
--- /dev/null
+++ b/rpython/tool/gcanalyze.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+""" Parse gcdumps. Use by saying PYPYLOG=gc-collect:log pypy <program>
+and run it by:
+
+gcanalyze.py logfile [--plot]
+"""
+
+import sys
+from rpython.tool.logparser import parse_log
+
+NO_BUCKETS = 8
+
+def main(arg):
+ log = parse_log(open(arg).readlines())
+ all = []
+ for entry in log:
+ if entry[0].startswith('gc-collect'):
+ start = entry[1]
+ end = entry[2]
+ all.append(float(end - start) / 1000000)
+ avg = sum(all) / len(all)
+ max_t = max(all)
+ print "AVG:", "%.1fms" % avg, "MAX:", "%.1fms" % max_t
+ buckets = [0] * (NO_BUCKETS + 1)
+ for item in all:
+ bucket = int(item / max_t * NO_BUCKETS)
+ buckets[bucket] += 1
+ l1 = ["%.1fms" % ((i + 1) * max_t / NO_BUCKETS) for i in range(NO_BUCKETS)]
+ l2 = [str(i) for i in buckets[1:]]
+ for i, elem in enumerate(l1):
+ l2[i] += " " * (len(elem) - len(l2[i]))
+ print " ".join(l1)
+ print " ".join(l2)
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2 or len(sys.argv) > 3:
+ print __doc__
+ sys.exit(1)
+ plot = False
+ if len(sys.argv) == 3:
+ if sys.argv[1] == '--plot':
+ plot = True
+ arg = sys.argv[2]
+ elif sys.argv[2] == '--plot':
+ plot = True
+ arg = sys.argv[1]
+ else:
+ print "Wrong command line options:", sys.argv
+ sys.exit(1)
+ else:
+ arg = sys.argv[1]
+ main(arg)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit