From e4d82cd9341f0de423610a77c028f99ccdec2d33 Mon Sep 17 00:00:00 2001 From: VEZINET Didier Date: Thu, 27 Feb 2020 16:33:42 +0100 Subject: [PATCH 1/3] [Issue357] Made allow_pickle available to user --- tofu/utils.py | 13 ++++++++----- tofu/version.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tofu/utils.py b/tofu/utils.py index 2e2d50ce8..e76d46fd1 100644 --- a/tofu/utils.py +++ b/tofu/utils.py @@ -454,7 +454,7 @@ def _filefind(name, path=None, lmodes=['.npz','.mat']): -def load(name, path=None, strip=None, verb=True): +def load(name, path=None, strip=None, verb=True, allow_pickle=None): """ Load a tofu object file Can load from .npz or .txt files @@ -483,7 +483,7 @@ def load(name, path=None, strip=None, verb=True): obj = _load_from_txt(name, pfe) else: if mode == 'npz': - dd = _load_npz(pfe) + dd = _load_npz(pfe, allow_pîckle=allow_pickle) elif mode == 'mat': dd = _load_mat(pfe) @@ -581,12 +581,15 @@ def _get_load_npzmat_dict(out, pfe, mode='npz', exclude_keys=[]): -def _load_npz(pfe): +def _load_npz(pfe, allow_pickle=None): + if allow_pickle is None: + allow_pickle = True try: - out = np.load(pfe, mmap_mode=None) + out = np.load(pfe, mmap_mode=None, allow_pickle=allow_pickle) except UnicodeError: - out = np.load(pfe, mmap_mode=None, encoding='latin1') + out = np.load(pfe, mmap_mode=None, allow_pickle=allow_pickle, + encoding='latin1') except Exception as err: raise err diff --git a/tofu/version.py b/tofu/version.py index 2ee9c73d6..6fd52b9fe 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2b4-56-g4622b310' +__version__ = '1.4.2b4-61-g1a5ca76a' From f16dd82ef45c2234f4feedf6b0e0c0499a1781d6 Mon Sep 17 00:00:00 2001 From: VEZINET Didier Date: Thu, 27 Feb 2020 18:12:50 +0100 Subject: [PATCH 2/3] [Issue357] Corrected Typo --- tofu/utils.py | 2 +- tofu/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tofu/utils.py b/tofu/utils.py index e76d46fd1..e37782210 100644 --- a/tofu/utils.py +++ b/tofu/utils.py @@ -483,7 +483,7 @@ def load(name, path=None, strip=None, verb=True, allow_pickle=None): obj = _load_from_txt(name, pfe) else: if mode == 'npz': - dd = _load_npz(pfe, allow_pîckle=allow_pickle) + dd = _load_npz(pfe, allow_pickle=allow_pickle) elif mode == 'mat': dd = _load_mat(pfe) diff --git a/tofu/version.py b/tofu/version.py index 6fd52b9fe..798a06e56 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2b4-61-g1a5ca76a' +__version__ = '1.4.2b4-62-ge4d82cd9' From 90cefa74aac6f6dbd1110631d25a68bde4e5b765 Mon Sep 17 00:00:00 2001 From: VEZINET Didier Date: Thu, 27 Feb 2020 18:13:50 +0100 Subject: [PATCH 3/3] [Issue357] PEP8 compliance --- tofu/utils.py | 2 -- tofu/version.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tofu/utils.py b/tofu/utils.py index e37782210..7d722b41d 100644 --- a/tofu/utils.py +++ b/tofu/utils.py @@ -453,7 +453,6 @@ def _filefind(name, path=None, lmodes=['.npz','.mat']): return name, mode, pfe - def load(name, path=None, strip=None, verb=True, allow_pickle=None): """ Load a tofu object file @@ -580,7 +579,6 @@ def _get_load_npzmat_dict(out, pfe, mode='npz', exclude_keys=[]): return dout - def _load_npz(pfe, allow_pickle=None): if allow_pickle is None: allow_pickle = True diff --git a/tofu/version.py b/tofu/version.py index 798a06e56..3c36d1b56 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2b4-62-ge4d82cd9' +__version__ = '1.4.2b4-63-gf16dd82e'