Skip to content

[MRG] Use logging.info instead of print (#6929) #6930

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion sklearn/datasets/california_housing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from os.path import exists
from os import makedirs
import tarfile
import logging

try:
# Python 2
Expand Down Expand Up @@ -90,7 +91,7 @@ def fetch_california_housing(data_home=None, download_if_missing=True):
makedirs(data_home)
filepath = _pkl_filepath(data_home, TARGET_FILENAME)
if not exists(filepath):
print('downloading Cal. housing from %s to %s' % (DATA_URL, data_home))
logging.info('downloading Cal. housing from %s to %s' % (DATA_URL, data_home))
archive_fileobj = BytesIO(urlopen(DATA_URL).read())
fileobj = tarfile.open(
mode="r:gz",
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/kddcup99.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _fetch_brute_kddcup99(subset=None, data_home=None,
line = line.decode()
Xy.append(line.replace('\n', '').split(','))
file_.close()
print('extraction done')
logging.info('extraction done')
Xy = np.asarray(Xy, dtype=object)
for j in range(42):
Xy[:, j] = Xy[:, j].astype(DT[j])
Expand Down
3 changes: 2 additions & 1 deletion sklearn/datasets/olivetti_faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from io import BytesIO
from os.path import exists
from os import makedirs
import logging
try:
# Python 2
import urllib2
Expand Down Expand Up @@ -111,7 +112,7 @@ def fetch_olivetti_faces(data_home=None, shuffle=False, random_state=0,
makedirs(data_home)
filepath = _pkl_filepath(data_home, TARGET_FILENAME)
if not exists(filepath):
print('downloading Olivetti faces from %s to %s'
logging.info('downloading Olivetti faces from %s to %s'
% (DATA_URL, data_home))
fhandle = urlopen(DATA_URL)
buf = BytesIO(fhandle.read())
Expand Down
7 changes: 4 additions & 3 deletions sklearn/datasets/species_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from io import BytesIO
from os import makedirs
from os.path import exists
import logging

try:
# Python 2
Expand Down Expand Up @@ -222,7 +223,7 @@ def fetch_species_distributions(data_home=None,
archive_path = _pkl_filepath(data_home, DATA_ARCHIVE_NAME)

if not exists(archive_path):
print('Downloading species data from %s to %s' % (SAMPLES_URL,
logging.info('Downloading species data from %s to %s' % (SAMPLES_URL,
data_home))
X = np.load(BytesIO(urlopen(SAMPLES_URL).read()))

Expand All @@ -233,15 +234,15 @@ def fetch_species_distributions(data_home=None,
if 'test' in f:
test = _load_csv(fhandle)

print('Downloading coverage data from %s to %s' % (COVERAGES_URL,
logging.info('Downloading coverage data from %s to %s' % (COVERAGES_URL,
data_home))

X = np.load(BytesIO(urlopen(COVERAGES_URL).read()))

coverages = []
for f in X.files:
fhandle = BytesIO(X[f])
print(' - converting', f)
logging.info(' - converting', f)
coverages.append(_load_coverage(fhandle))
coverages = np.asarray(coverages, dtype=dtype)

Expand Down
8 changes: 4 additions & 4 deletions sklearn/datasets/twenty_newsgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ def fetch_20newsgroups(data_home=None, subset='train', categories=None,
compressed_content, 'zlib_codec')
cache = pickle.loads(uncompressed_content)
except Exception as e:
print(80 * '_')
print('Cache loading failed')
print(80 * '_')
print(e)
logging.info(80 * '_')
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be better composed as a single multiline string.

logging.info('Cache loading failed')
logging.info(80 * '_')
logging.info(e)

if cache is None:
if download_if_missing:
Expand Down