[pypy-commit] pypy default: merge
fijal
noreply at buildbot.pypy.org
Fri Feb 10 10:41:36 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r52347:78f7cb05d2e8
Date: 2012-02-10 11:41 +0200
http://bitbucket.org/pypy/pypy/changeset/78f7cb05d2e8/
Log: merge
diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -1520,7 +1520,7 @@
def utcfromtimestamp(cls, t):
"Construct a UTC datetime from a POSIX timestamp (like time.time())."
t, frac = divmod(t, 1.0)
- us = round(frac * 1e6)
+ us = int(round(frac * 1e6))
# If timestamp is less than one microsecond smaller than a
# full second, us can be rounded up to 1000000. In this case,
diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -134,7 +134,10 @@
assert a == 'a\nbxxxxxxx'
def test_nonblocking_read(self):
- import os, fcntl
+ try:
+ import os, fcntl
+ except ImportError:
+ skip("need fcntl to set nonblocking mode")
r_fd, w_fd = os.pipe()
# set nonblocking
fcntl.fcntl(r_fd, fcntl.F_SETFL, os.O_NONBLOCK)
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -95,6 +95,7 @@
("tan", "tan"),
('bitwise_and', 'bitwise_and'),
('bitwise_or', 'bitwise_or'),
+ ('bitwise_xor', 'bitwise_xor'),
('bitwise_not', 'invert'),
('isnan', 'isnan'),
('isinf', 'isinf'),
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -100,6 +100,7 @@
descr_rsub = _binop_right_impl("subtract")
descr_rmul = _binop_right_impl("multiply")
descr_rdiv = _binop_right_impl("divide")
+ descr_rtruediv = _binop_right_impl("true_divide")
descr_rmod = _binop_right_impl("mod")
descr_rpow = _binop_right_impl("power")
descr_rlshift = _binop_right_impl("left_shift")
@@ -216,6 +217,7 @@
__rsub__ = interp2app(W_GenericBox.descr_rsub),
__rmul__ = interp2app(W_GenericBox.descr_rmul),
__rdiv__ = interp2app(W_GenericBox.descr_rdiv),
+ __rtruediv__ = interp2app(W_GenericBox.descr_rtruediv),
__rmod__ = interp2app(W_GenericBox.descr_rmod),
__rdivmod__ = interp2app(W_GenericBox.descr_rdivmod),
__rpow__ = interp2app(W_GenericBox.descr_rpow),
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
@@ -101,6 +101,7 @@
descr_sub = _binop_impl("subtract")
descr_mul = _binop_impl("multiply")
descr_div = _binop_impl("divide")
+ descr_truediv = _binop_impl("true_divide")
descr_mod = _binop_impl("mod")
descr_pow = _binop_impl("power")
descr_lshift = _binop_impl("left_shift")
@@ -134,6 +135,7 @@
descr_rsub = _binop_right_impl("subtract")
descr_rmul = _binop_right_impl("multiply")
descr_rdiv = _binop_right_impl("divide")
+ descr_rtruediv = _binop_right_impl("true_divide")
descr_rmod = _binop_right_impl("mod")
descr_rpow = _binop_right_impl("power")
descr_rlshift = _binop_right_impl("left_shift")
@@ -1251,6 +1253,7 @@
__sub__ = interp2app(BaseArray.descr_sub),
__mul__ = interp2app(BaseArray.descr_mul),
__div__ = interp2app(BaseArray.descr_div),
+ __truediv__ = interp2app(BaseArray.descr_truediv),
__mod__ = interp2app(BaseArray.descr_mod),
__divmod__ = interp2app(BaseArray.descr_divmod),
__pow__ = interp2app(BaseArray.descr_pow),
@@ -1264,6 +1267,7 @@
__rsub__ = interp2app(BaseArray.descr_rsub),
__rmul__ = interp2app(BaseArray.descr_rmul),
__rdiv__ = interp2app(BaseArray.descr_rdiv),
+ __rtruediv__ = interp2app(BaseArray.descr_rtruediv),
__rmod__ = interp2app(BaseArray.descr_rmod),
__rdivmod__ = interp2app(BaseArray.descr_rdivmod),
__rpow__ = interp2app(BaseArray.descr_rpow),
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -408,6 +408,7 @@
assert 5 / int_(2) == int_(2)
assert truediv(int_(3), int_(2)) == float64(1.5)
+ assert truediv(3, int_(2)) == float64(1.5)
assert int_(8) % int_(3) == int_(2)
assert 8 % int_(3) == int_(2)
assert divmod(int_(8), int_(3)) == (int_(2), int_(2))
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -625,6 +625,13 @@
for i in range(5):
assert b[i] == i / 5.0
+ def test_truediv(self):
+ from operator import truediv
+ from _numpypy import arange
+
+ assert (truediv(arange(5), 2) == [0., .5, 1., 1.5, 2.]).all()
+ assert (truediv(2, arange(3)) == [float("inf"), 2., 1.]).all()
+
def test_divmod(self):
from _numpypy import arange
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
@@ -368,14 +368,14 @@
assert b.shape == (1, 4)
assert (add.reduce(a, 0, keepdims=True) == [12, 15, 18, 21]).all()
-
def test_bitwise(self):
- from _numpypy import bitwise_and, bitwise_or, arange, array
+ from _numpypy import bitwise_and, bitwise_or, bitwise_xor, arange, array
a = arange(6).reshape(2, 3)
assert (a & 1 == [[0, 1, 0], [1, 0, 1]]).all()
assert (a & 1 == bitwise_and(a, 1)).all()
assert (a | 1 == [[1, 1, 3], [3, 5, 5]]).all()
assert (a | 1 == bitwise_or(a, 1)).all()
+ assert (a ^ 3 == bitwise_xor(a, 3)).all()
raises(TypeError, 'array([1.0]) & 1')
def test_unary_bitops(self):
diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -22,3 +22,7 @@
del os.environ["TZ"]
else:
os.environ["TZ"] = prev_tz
+
+def test_utcfromtimestamp_microsecond():
+ dt = datetime.datetime.utcfromtimestamp(0)
+ assert isinstance(dt.microsecond, int)
More information about the pypy-commit
mailing list