diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index 16e0acf74a1c..2c6d3a704817 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -51,7 +51,7 @@ def callback(env): if env.rank != 0 or (not env.evaluation_result_list) or period is False or period == 0: return i = env.iteration - if (i % period == 0 or i + 1 == env.begin_iteration or i + 1 == env.end_iteration): + if i % period == 0 or i + 1 == env.begin_iteration or i + 1 == env.end_iteration: msg = '\t'.join([_fmt_metric(x, show_stdv) for x in env.evaluation_result_list]) rabit.tracker_print('[%d]\t%s\n' % (i, msg)) return callback diff --git a/python-package/xgboost/core.py b/python-package/xgboost/core.py index 644dcf8f7348..ff147403707f 100644 --- a/python-package/xgboost/core.py +++ b/python-package/xgboost/core.py @@ -241,7 +241,7 @@ def _maybe_pandas_data(data, feature_names, feature_types): if feature_names is None: if isinstance(data.columns, MultiIndex): feature_names = [ - ' '.join(map(str, i)) + ' '.join([str(x) for x in i]) for i in data.columns ] else: @@ -1716,7 +1716,7 @@ def get_split_value_histogram(self, feature, fmap='', bins=None, as_pandas=True) regexp = re.compile(r"\[{0}<([\d.Ee+-]+)\]".format(feature)) for i, _ in enumerate(xgdump): m = re.findall(regexp, xgdump[i]) - values.extend(map(float, m)) + values.extend([float(x) for x in m]) n_unique = len(np.unique(values)) bins = max(min(n_unique, bins) if bins is not None else n_unique, 1) diff --git a/python-package/xgboost/training.py b/python-package/xgboost/training.py index 111fbc019ba2..71c96736a80e 100644 --- a/python-package/xgboost/training.py +++ b/python-package/xgboost/training.py @@ -49,7 +49,7 @@ def _train_internal(params, dtrain, # Distributed code: Load the checkpoint from rabit. version = bst.load_rabit_checkpoint() - assert(rabit.get_world_size() != 1 or version == 0) + assert rabit.get_world_size() != 1 or version == 0 rank = rabit.get_rank() start_iteration = int(version / 2) nboost += start_iteration @@ -75,7 +75,7 @@ def _train_internal(params, dtrain, bst.save_rabit_checkpoint() version += 1 - assert(rabit.get_world_size() == 1 or version == rabit.version_number()) + assert rabit.get_world_size() == 1 or version == rabit.version_number() nboost += 1 evaluation_result_list = [] diff --git a/tests/travis/setup.sh b/tests/travis/setup.sh index f137de76fdfe..7618b84f5997 100755 --- a/tests/travis/setup.sh +++ b/tests/travis/setup.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ ${TASK} == "lint" ]; then - pip3 install --user cpplint 'pylint==1.4.4' 'astroid==1.3.6' + pip3 install --user cpplint 'pylint==1.4.4' 'astroid==1.3.6' numpy scipy fi