diff --git a/README.md b/README.md index 01b9e93..15a6507 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ and checked for integrity by SHA-256 hashes. ### dependencies -python 3.6 (or later), numpy. +python 3.5 (or later), numpy. ### install diff --git a/TODO b/TODO index 1caefc8..6467f43 100644 --- a/TODO +++ b/TODO @@ -4,8 +4,6 @@ * document prepare() function - * support python 3.5 - * adjust dates created/modified on server-hosted files to something sensible * host files on a more reliable service @@ -14,6 +12,10 @@ * basic tests (including running pycodestyle) + * --fix (delete corrupt files) and --debug (logging.DEBUG) __main__ arguments + + * try python 3.2 with an old version of numpy (don't care if it doesn't work) + ### release version 1.0 * submit to pypi diff --git a/mnists/__init__.py b/mnists/__init__.py index cfc9e21..a8a10ef 100644 --- a/mnists/__init__.py +++ b/mnists/__init__.py @@ -90,14 +90,15 @@ def validate(name): if name not in hashes.keys(): raise UnknownDatasetError(name) - with open(construct_path(name), "rb") as f: + path = construct_path(name) + with open(path, "rb") as f: data = f.read() known_hash = hashes[name] hash = hashlib.sha256(data).hexdigest() if hash != known_hash: - raise IntegrityError(file, known_hash, hash) + raise IntegrityError(path, known_hash, hash) def onehot(ind): diff --git a/mnists/__main__.py b/mnists/__main__.py index a504d4a..df5d379 100644 --- a/mnists/__main__.py +++ b/mnists/__main__.py @@ -31,7 +31,7 @@ for name in metadata.keys(): # print out the shape table for use in the README. data = prepare(name) prefix = metadata[name][0] - row_data = [f"[{prefix}][]"] + row_data = ["[{}][]".format(prefix)] row_data += [name.replace("_", "\\_")] row_data += [str(array.shape) for array in data] print(row.format(*row_data)) @@ -39,4 +39,4 @@ for name in metadata.keys(): print() for anchor, url in urls.items(): - print(f"[{anchor}]: {url}") + print("[{}]: {}".format(anchor, url)) diff --git a/mnists/exceptions.py b/mnists/exceptions.py index c5b2b57..5d022be 100644 --- a/mnists/exceptions.py +++ b/mnists/exceptions.py @@ -5,9 +5,9 @@ class IntegrityError(Exception): self.computed_hash = computed_hash def __str__(self): - return f"""Failed to validate dataset: {name} + return """Failed to validate dataset: {self.file} Hash mismatch: {self.computed_hash} should be {self.expected_hash} -Please check your local file for tampering or corruption.""" +Please check your local file for tampering or corruption.""".format(self=self) class UnknownDatasetError(Exception): @@ -15,4 +15,4 @@ class UnknownDatasetError(Exception): self.dataset = dataset def __str__(self): - return f"Unknown mnist-like dataset: {dataset}" + return "Unknown mnist-like dataset: {self.dataset}".format(self=self) diff --git a/setup.py b/setup.py index 12b9d5f..393fe26 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( 'Natural Language :: English', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.5', 'Topic :: Scientific/Engineering', ] )