Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix print statements for python3 compatability in base and MNIST and remove whitespace #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions skdata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(self, new_model):
def best_model_vector_classification(self, train, valid):
# TODO: use validation set if not-None
model = self.new_model()
print 'SklearnClassifier training on data set of shape', train.x.shape
print('SklearnClassifier training on data set of shape', train.x.shape)
model.fit(train.x, train.y)
model.trained_on = train.name
self.results['best_model'].append(
Expand Down Expand Up @@ -288,5 +288,3 @@ def best_model_indexed_image_classification(self, train, valid):
def loss_indexed_image_classification(self, model, task):
return self.loss_vector_classification(model,
self._fallback_indexed_image_task(task))


2 changes: 1 addition & 1 deletion skdata/mnist/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
test_labels='4.5K',
)


def _read_int32(f):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this also in fetch function.
downloader = urllib.urlopen(url)
downloader = urllib.request.urlopen(url)

"""unpack a 4-byte integer from the current position in file f"""
s = f.read(4)
Expand Down Expand Up @@ -207,4 +208,3 @@ def build_meta(self):
for j, l in enumerate(arrays['test_labels'])])
assert len(meta) == 70000, (i, len(meta))
return meta

8 changes: 3 additions & 5 deletions skdata/mnist/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ def main_clean_up():
MNIST().clean_up()



def main():
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
if len(sys.argv) <= 1:
print usage
print(usage)
return 1
else:
try:
fn = globals()['main_' + sys.argv[1]]
except:
print 'command %s not recognized' % sys.argv[1]
print usage
print('command %s not recognized' % sys.argv[1])
print(usage)
return 1
return fn()


if __name__ == '__main__':
sys.exit(main())

1 change: 0 additions & 1 deletion skdata/mnist/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ def test_MNIST():
assert M.meta[69999] == dict(id=69999, split='test', label=6), M.meta[69999]
assert len(M.meta) == 70000