diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-07-10 18:06:55 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-07-12 08:56:00 -0600 |
commit | cb2c88790fa9d5afe92a77f920b2bf5232cb8e87 (patch) | |
tree | 036755ede0ae6e82bc199ab619678153e27d5aaa /numpy | |
parent | a053a4372aba0af0bd63ffd5e207baf469cfc7bf (diff) | |
download | numpy-cb2c88790fa9d5afe92a77f920b2bf5232cb8e87.tar.gz |
MAINT: Fix Python version dependent test.
The buffer test in numpy/core/tests/test_api.py was apparently
testing for incorrect behavior that was corrected in Python 2.7.5.
This PR changes the test to check for the correct results and makes
running it depend on Python version.
Closes #3512.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_api.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py index b94f4772e..2bd7eb830 100644 --- a/numpy/core/tests/test_api.py +++ b/numpy/core/tests/test_api.py @@ -68,26 +68,27 @@ def test_array_array(): # test buffer _buffer = builtins.get("buffer") - if _buffer: - assert_equal(np.array(_buffer("1.0"), dtype=np.float64), - np.array(1.0, dtype=np.float64)) - assert_equal(np.array(_buffer("1.0"), dtype=np.float64).dtype, - np.dtype("float64")) - assert_equal(np.array([_buffer("1.0")], dtype=np.float64), - np.array([1.0], dtype=np.float64)) + if _buffer and sys.version_info[:3] >= (2, 7, 5): + # This test fails for earlier versions of Python. + # Evidently a bug got fixed in 2.7.5. + dat = np.array(_buffer('1.0'), dtype=np.float64) + assert_equal(dat, [49.0, 46.0, 48.0]) + assert_(dat.dtype.type is np.float64) + + dat = np.array(_buffer(b'1.0')) + assert_equal(dat, [49, 46, 48]) + assert_(dat.dtype.type is np.uint8) # test memoryview, new version of buffer _memoryview = builtins.get("memoryview") if _memoryview: - assert_equal(np.array(_memoryview(bytearray(b'1.0')), - dtype=np.float64), - np.array([49.0, 46.0, 48.0], - dtype=np.float64)) - assert_equal(np.array(_memoryview(bytearray(b'1.0')), - dtype=np.float64).dtype, - np.dtype("float64")) - assert_equal(np.array(_memoryview(bytearray(b'1.0'))).dtype, - np.dtype('uint8')) + dat = np.array(_memoryview(b'1.0'), dtype=np.float64) + assert_equal(dat, [49.0, 46.0, 48.0]) + assert_(dat.dtype.type is np.float64) + + dat = np.array(_memoryview(b'1.0')) + assert_equal(dat, [49, 46, 48]) + assert_(dat.dtype.type is np.uint8) # test array interface a = np.array(100.0, dtype=np.float64) |