Merge pull request #683 from terrytangyuan/pylint

Pylint Fixes
This commit is contained in:
Yuan (Terry) Tang 2015-12-11 19:04:38 -06:00
commit 7a74c9523a
7 changed files with 18 additions and 9 deletions

View File

@ -9,7 +9,7 @@ os:
env:
matrix:
- TASK=lint LINT_LANG=cpp
#- TASK=lint LINT_LANG=python
- TASK=lint LINT_LANG=python
- TASK=R-package CXX=g++
- TASK=python-package CXX=g++
- TASK=python-package3 CXX=g++

9
python-package/.pylintrc Normal file
View File

@ -0,0 +1,9 @@
[MASTER]
ignore=tests
unexpected-special-method-signature,too-many-nested-blocks
dummy-variables-rgx=(unused|)_.*
reports=no

View File

@ -11,7 +11,7 @@ sys.path.insert(0, '.')
#it builds xgboost code on the fly and packs for pip
#please don't use this file for installing from github
if not os.name == 'nt': #if not windows, compile and install
if os.name != 'nt': #if not windows, compile and install
os.system('sh ./xgboost/build-python.sh')
else:
print('Windows users please use github installation.')

View File

@ -1,5 +1,5 @@
# coding: utf-8
# pylint: disable=unused-import, invalid-name
# pylint: disable=unused-import, invalid-name, wrong-import-position
"""For compatibility"""
from __future__ import absolute_import

View File

@ -523,7 +523,7 @@ class DMatrix(object):
feature_names : list or None
Labels for features. None will reset existing feature names
"""
if not feature_names is None:
if feature_names is not None:
# validate feature name
if not isinstance(feature_names, list):
feature_names = list(feature_names)
@ -554,7 +554,7 @@ class DMatrix(object):
feature_types : list or None
Labels for features. None will reset existing feature names
"""
if not feature_types is None:
if feature_types is not None:
if self.feature_names is None:
msg = 'Unable to set feature types before setting names'
@ -890,6 +890,7 @@ class Booster(object):
_check_call(_LIB.XGBoosterLoadModelFromBuffer(self.handle, ptr, length))
def dump_model(self, fout, fmap='', with_stats=False):
# pylint: disable=consider-using-enumerate
"""
Dump model into a text file.

View File

@ -5,12 +5,11 @@
from __future__ import absolute_import
import re
from io import BytesIO
import numpy as np
from .core import Booster
from .sklearn import XGBModel
from io import BytesIO
def plot_importance(booster, ax=None, height=0.2,
xlim=None, ylim=None, title='Feature importance',
xlabel='F score', ylabel='Features',

View File

@ -130,7 +130,7 @@ class XGBModel(XGBModelBase):
def fit(self, X, y, eval_set=None, eval_metric=None,
early_stopping_rounds=None, verbose=True):
# pylint: disable=missing-docstring,invalid-name,attribute-defined-outside-init
# pylint: disable=missing-docstring,invalid-name,attribute-defined-outside-init, redefined-variable-type
"""
Fit the gradient boosting model
@ -265,7 +265,7 @@ class XGBClassifier(XGBModel, XGBClassifierBase):
def fit(self, X, y, sample_weight=None, eval_set=None, eval_metric=None,
early_stopping_rounds=None, verbose=True):
# pylint: disable = attribute-defined-outside-init,arguments-differ
# pylint: disable = attribute-defined-outside-init,arguments-differ, redefined-variable-type
"""
Fit gradient boosting classifier