From 1aa6d88c6d16d2e93629e2a5a607a7757fcf7f94 Mon Sep 17 00:00:00 2001 From: Antonio Valentino Date: Wed, 2 Jan 2019 17:11:09 +0000 Subject: [PATCH] Fix future warnings --- tables/array.py | 4 ++-- tables/scripts/ptrepack.py | 9 ++++++--- tables/tests/test_array.py | 2 ++ tables/tests/test_earray.py | 2 +- tables/tests/test_numpy.py | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tables/array.py b/tables/array.py index 85f07b33..d3d1e06e 100644 --- a/tables/array.py +++ b/tables/array.py @@ -801,7 +801,7 @@ def _read_selection(self, selection, reorder, shape): k[idx] = neworder.argsort() # Apparently, a copy is not needed here, but doing it # for symmetry with the `_write_selection()` method. - nparr = nparr[k].copy() + nparr = nparr[tuple(k)].copy() return nparr def _write_slice(self, startl, stopl, stepl, shape, nparr): @@ -833,7 +833,7 @@ def _write_selection(self, selection, reorder, shape, nparr): k[idx] = neworder # For a reason a don't understand well, we need a copy of # the reordered array - nparr = nparr[k].copy() + nparr = nparr[tuple(k)].copy() self._g_write_selection(selection, nparr) def _read(self, start, stop, step, out=None): diff --git a/tables/scripts/ptrepack.py b/tables/scripts/ptrepack.py index 796c4a46..7953197e 100644 --- a/tables/scripts/ptrepack.py +++ b/tables/scripts/ptrepack.py @@ -23,7 +23,10 @@ import os.path import argparse import warnings - +try: + from time import process_time as cputime +except ImportError: + from time import clock as cputime from tables.file import open_file from tables.group import Group @@ -492,7 +495,7 @@ def main(): # Some timing t1 = time.time() - cpu1 = time.clock() + cpu1 = cputime() # Copy the file if verbose: print("+=+" * 20) @@ -541,7 +544,7 @@ def main(): # Gather some statistics t2 = time.time() - cpu2 = time.clock() + cpu2 = cputime () tcopy = round(t2 - t1, 3) cpucopy = round(cpu2 - cpu1, 3) try: diff --git a/tables/tests/test_array.py b/tables/tests/test_array.py index 34f82e32..72c39aa6 100644 --- a/tables/tests/test_array.py +++ b/tables/tests/test_array.py @@ -2084,6 +2084,8 @@ def test01d_read(self): tbarr = self.tbarr for key in self.working_keyset: + if nparr.ndim > 1: + key = tuple(key) if common.verbose: print("Selection to test:", key) a = nparr[key] diff --git a/tables/tests/test_earray.py b/tables/tests/test_earray.py index a9256af1..865c49db 100644 --- a/tables/tests/test_earray.py +++ b/tables/tests/test_earray.py @@ -482,7 +482,7 @@ def test03_readEArray_out_argument(self): slice_obj = [slice(None)] * len(earray.shape) #slice_obj[earray.maindim] = slice(self.start, stop, self.step) slice_obj[earray.maindim] = slice(self.start, self.stop, self.step) - row = row[slice_obj].copy() + row = row[tuple(slice_obj)].copy() earray.read(self.start, self.stop, self.step, out=row) except IndexError: row = numpy.empty(shape=self.shape, dtype=self.dtype) diff --git a/tables/tests/test_numpy.py b/tables/tests/test_numpy.py index 6e453337..ce2d7068 100644 --- a/tables/tests/test_numpy.py +++ b/tables/tests/test_numpy.py @@ -465,7 +465,8 @@ def test01_readTableNum(self): for colname in table.colnames: numcol = table.read(field=colname) typecol = table.coltypes[colname] - nctypecode = np.typeNA[numcol.dtype.char[0]] + #nctypecode = np.typeNA[numcol.dtype.char[0]] + nctypecode = np.sctypeDict[numcol.dtype.char[0]] if typecol != "string": if common.verbose: print("Typecode of NumPy column read:", nctypecode)