diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-12-24 14:46:01 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-12-24 14:46:01 -0800 |
commit | 61998c22df08e7ec0938bedef931ac824cfb634a (patch) | |
tree | 4ac06c498907f324ab9280776be3e354b1d070eb | |
parent | bc82e93cbc0d8b3294764932339eb78a8a1e6e3c (diff) | |
parent | 9e836c2c5cc0911269ac692a25fc4ec42273354b (diff) | |
download | numpy-61998c22df08e7ec0938bedef931ac824cfb634a.tar.gz |
Merge pull request #4141 from rgommers/py34-fixes
Fix a few issues that show up with python 3.4b1
-rw-r--r-- | numpy/lib/npyio.py | 9 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index dced7fd78..af259cfef 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -726,8 +726,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, elif fname.endswith('.bz2'): import bz2 fh = iter(bz2.BZ2File(fname)) - else: + elif sys.version_info[0] == 2: fh = iter(open(fname, 'U')) + else: + fh = iter(open(fname)) else: fh = iter(fname) except TypeError: @@ -1330,7 +1332,10 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, own_fhd = False try: if isinstance(fname, basestring): - fhd = iter(np.lib._datasource.open(fname, 'rbU')) + if sys.version_info[0] == 2: + fhd = iter(np.lib._datasource.open(fname, 'rbU')) + else: + fhd = iter(np.lib._datasource.open(fname, 'rb')) own_fhd = True else: fhd = iter(fname) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 2255c0b36..494b512f7 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -972,7 +972,7 @@ class TestHistogram(TestCase): # Normalization h, b = histogram(a, range=[1, 9], normed=True) - assert_equal((h * diff(b)).sum(), 1) + assert_almost_equal((h * diff(b)).sum(), 1, decimal=15) # Weights w = np.arange(10) + .5 |