mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-07-11 16:22:13 +02:00
more Python 3 compatibility fixes
This commit is contained in:
parent
c3963928f1
commit
4b2299def8
1 changed files with 8 additions and 8 deletions
|
|
@ -73,7 +73,7 @@ def prompt_user(prompt):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print(prompt)
|
print(prompt)
|
||||||
choice = raw_input().lower()
|
choice = input().lower()
|
||||||
# would like to test for exception here, but not sure if we can do that without importing IPython
|
# would like to test for exception here, but not sure if we can do that without importing IPython
|
||||||
except:
|
except:
|
||||||
print('Stdin is not implemented.')
|
print('Stdin is not implemented.')
|
||||||
|
|
@ -96,16 +96,16 @@ def prompt_user(prompt):
|
||||||
def data_available(dataset_name=None):
|
def data_available(dataset_name=None):
|
||||||
"""Check if the data set is available on the local machine already."""
|
"""Check if the data set is available on the local machine already."""
|
||||||
try:
|
try:
|
||||||
from itertools import izip_longest
|
from itertools import zip_longest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from itertools import zip_longest as izip_longest
|
from itertools import zip_longest as zip_longest
|
||||||
dr = data_resources[dataset_name]
|
dr = data_resources[dataset_name]
|
||||||
zip_urls = (dr['files'], )
|
zip_urls = (dr['files'], )
|
||||||
if 'save_names' in dr: zip_urls += (dr['save_names'], )
|
if 'save_names' in dr: zip_urls += (dr['save_names'], )
|
||||||
else: zip_urls += ([],)
|
else: zip_urls += ([],)
|
||||||
|
|
||||||
for file_list, save_list in izip_longest(*zip_urls, fillvalue=[]):
|
for file_list, save_list in zip_longest(*zip_urls, fillvalue=[]):
|
||||||
for f, s in izip_longest(file_list, save_list, fillvalue=None):
|
for f, s in zip_longest(file_list, save_list, fillvalue=None):
|
||||||
if s is not None: f=s # If there is a save_name given, use that one
|
if s is not None: f=s # If there is a save_name given, use that one
|
||||||
if not os.path.exists(os.path.join(data_path, dataset_name, f)):
|
if not os.path.exists(os.path.join(data_path, dataset_name, f)):
|
||||||
return False
|
return False
|
||||||
|
|
@ -138,7 +138,7 @@ def download_url(url, store_directory, save_name=None, messages=True, suffix='')
|
||||||
raise ValueError('Tried url ' + url + suffix + ' and received server error ' + str(response.code))
|
raise ValueError('Tried url ' + url + suffix + ' and received server error ' + str(response.code))
|
||||||
with open(save_name, 'wb') as f:
|
with open(save_name, 'wb') as f:
|
||||||
meta = response.info()
|
meta = response.info()
|
||||||
content_length_str = meta.getheaders("Content-Length")
|
content_length_str = meta.get("Content-Length")
|
||||||
if content_length_str:
|
if content_length_str:
|
||||||
file_size = int(content_length_str[0])
|
file_size = int(content_length_str[0])
|
||||||
else:
|
else:
|
||||||
|
|
@ -220,8 +220,8 @@ def download_data(dataset_name=None):
|
||||||
if 'suffices' in dr: zip_urls += (dr['suffices'], )
|
if 'suffices' in dr: zip_urls += (dr['suffices'], )
|
||||||
else: zip_urls += ([],)
|
else: zip_urls += ([],)
|
||||||
|
|
||||||
for url, files, save_names, suffices in itertools.izip_longest(*zip_urls, fillvalue=[]):
|
for url, files, save_names, suffices in itertools.zip_longest(*zip_urls, fillvalue=[]):
|
||||||
for f, save_name, suffix in itertools.izip_longest(files, save_names, suffices, fillvalue=None):
|
for f, save_name, suffix in itertools.zip_longest(files, save_names, suffices, fillvalue=None):
|
||||||
download_url(os.path.join(url,f), dataset_name, save_name, suffix=suffix)
|
download_url(os.path.join(url,f), dataset_name, save_name, suffix=suffix)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue