From 91478d11469914bbc35e1f353a5a01a6d269e0b8 Mon Sep 17 00:00:00 2001 From: pieths Date: Sun, 2 Jun 2019 15:51:44 -0700 Subject: [PATCH] Fix signature import error when using latest version of scikit-learn. (#116) * Fix signature import error when using latest version of scikit-learn. Fixes #111 * Move the conditional import of the signature method in to the utils package. --- .../nimbusml/internal/core/base_pipeline_item.py | 2 +- src/python/nimbusml/internal/utils/entrypoints.py | 2 +- src/python/nimbusml/utils/__init__.py | 10 ++++++++-- src/python/setup.py | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/python/nimbusml/internal/core/base_pipeline_item.py b/src/python/nimbusml/internal/core/base_pipeline_item.py index b2daf9a..e45b3d0 100644 --- a/src/python/nimbusml/internal/core/base_pipeline_item.py +++ b/src/python/nimbusml/internal/core/base_pipeline_item.py @@ -18,7 +18,7 @@ from itertools import chain from textwrap import wrap import six -from sklearn.utils.fixes import signature +from nimbusml.utils import signature from ..utils.data_roles import DataRoles, Role from ..utils.data_stream import ViewBasePipelineItem, DataStream, \ diff --git a/src/python/nimbusml/internal/utils/entrypoints.py b/src/python/nimbusml/internal/utils/entrypoints.py index 94510eb..8d9ef08 100644 --- a/src/python/nimbusml/internal/utils/entrypoints.py +++ b/src/python/nimbusml/internal/utils/entrypoints.py @@ -16,7 +16,7 @@ import pandas as pd import six from pandas import DataFrame from scipy.sparse import csr_matrix -from sklearn.utils.fixes import signature +from nimbusml.utils import signature from .data_stream import BinaryDataStream from .data_stream import FileDataStream diff --git a/src/python/nimbusml/utils/__init__.py b/src/python/nimbusml/utils/__init__.py index ef1288e..3243711 100644 --- a/src/python/nimbusml/utils/__init__.py +++ b/src/python/nimbusml/utils/__init__.py @@ -1,11 +1,17 @@ from .utils import get_X_y, evaluate_binary_classifier, check_accuracy, \ check_accuracy_scikit, load_img, ColumnSelector -all = [ +try: + from inspect import signature +except ImportError: + from funcsigs import signature + +__all__ = [ 'get_X_y', 'evaluate_binary_classifier', 'check_accuracy', 'check_accuracy_scikit', 'load_img', - 'ColumnSelector' + 'ColumnSelector', + 'signature' ] diff --git a/src/python/setup.py b/src/python/setup.py index e1059ce..ee6dc3b 100644 --- a/src/python/setup.py +++ b/src/python/setup.py @@ -37,6 +37,7 @@ if sys.version_info.major == 3: if sys.version_info[0:2] == (2,7): _install_requires.append('decorator') _install_requires.append('enum') + _install_requires.append('funcsigs>=1.0.2') setup( name='nimbusml',