support python 3.5, fix exceptions
This commit is contained in:
parent
4b564e96ba
commit
05eeb6cbb5
6 changed files with 14 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
6
TODO
6
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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
2
setup.py
2
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',
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue