Author: Armin Rigo <[email protected]>
Branch:
Changeset: r71100:984c2d21a9f5
Date: 2014-04-30 20:54 +0200
http://bitbucket.org/pypy/pypy/changeset/984c2d21a9f5/
Log: merge heads
diff --git a/lib-python/2.7/cProfile.py b/lib-python/2.7/cProfile.py
--- a/lib-python/2.7/cProfile.py
+++ b/lib-python/2.7/cProfile.py
@@ -161,7 +161,7 @@
# ____________________________________________________________
def main():
- import os, sys
+ import os, sys, new
from optparse import OptionParser
usage = "cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
parser = OptionParser(usage=usage)
@@ -184,12 +184,10 @@
sys.path.insert(0, os.path.dirname(progname))
with open(progname, 'rb') as fp:
code = compile(fp.read(), progname, 'exec')
- globs = {
- '__file__': progname,
- '__name__': '__main__',
- '__package__': None,
- }
- runctx(code, globs, None, options.outfile, options.sort)
+ mainmod = new.module('__main__')
+ mainmod.__file__ = progname
+ mainmod.__package__ = None
+ runctx(code, mainmod.__dict__, None, options.outfile, options.sort)
else:
parser.print_usage()
return parser
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
@@ -310,7 +310,7 @@
assert math.isnan(fmod(v, 2))
def test_minimum(self):
- from numpypy import array, minimum
+ from numpypy import array, minimum, nan, isnan
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -318,8 +318,12 @@
for i in range(3):
assert c[i] == min(a[i], b[i])
+ arg1 = array([0, nan, nan])
+ arg2 = array([nan, 0, nan])
+ assert isnan(minimum(arg1, arg2)).all()
+
def test_maximum(self):
- from numpypy import array, maximum
+ from numpypy import array, maximum, nan, isnan
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -327,6 +331,10 @@
for i in range(3):
assert c[i] == max(a[i], b[i])
+ arg1 = array([0, nan, nan])
+ arg2 = array([nan, 0, nan])
+ assert isnan(maximum(arg1, arg2)).all()
+
x = maximum(2, 3)
assert x == 3
assert isinstance(x, (int, long))
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -705,20 +705,20 @@
return math.fabs(v)
@simple_binary_op
+ def max(self, v1, v2):
+ return v1 if v1 >= v2 or rfloat.isnan(v1) else v2
+
+ @simple_binary_op
+ def min(self, v1, v2):
+ return v1 if v1 <= v2 or rfloat.isnan(v1) else v2
+
+ @simple_binary_op
def fmax(self, v1, v2):
- if rfloat.isnan(v2):
- return v1
- elif rfloat.isnan(v1):
- return v2
- return max(v1, v2)
+ return v1 if v1 >= v2 or rfloat.isnan(v2) else v2
@simple_binary_op
def fmin(self, v1, v2):
- if rfloat.isnan(v2):
- return v1
- elif rfloat.isnan(v1):
- return v2
- return min(v1, v2)
+ return v1 if v1 <= v2 or rfloat.isnan(v2) else v2
@simple_binary_op
def fmod(self, v1, v2):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit