Skip to content

[MRG] Replace absolute imports with relative ones #13653

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

Merged
merged 9 commits into from
Apr 17, 2019

Conversation

aditya1702
Copy link
Contributor

Reference Issues/PRs

Fixes #13629

What does this implement/fix? Explain your changes.

Replaces absolute imports with relative imports

Any other comments?

@aditya1702 aditya1702 changed the title [MRG] Replace absolute imports with relative ones [WIP] Replace absolute imports with relative ones Apr 16, 2019
@aditya1702
Copy link
Contributor Author

I will squash commits once this passes

@adrinjalali
Copy link
Member

you don't need to squash commits, and it's nice if you would avoid a force push. We squash the commits before merge anyway.

@jnothman
Copy link
Member

Tests are failing @aditya1702. let us know if you need help.

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

Be careful with the diff. You should not change in docstrings for example

@@ -33,23 +33,23 @@ class NotFittedError(ValueError, AttributeError):
NotFittedError('This LinearSVC instance is not fitted yet'...)

.. versionchanged:: 0.18
Moved from sklearn.utils.validation.
Copy link
Member

Choose a reason for hiding this comment

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

Revert

"""


class ChangedBehaviorWarning(UserWarning):
"""Warning class used to notify the user of any change in the behavior.

.. versionchanged:: 0.18
Moved from sklearn.base.
Moved from .base.
Copy link
Member

Choose a reason for hiding this comment

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

Revert

@aditya1702
Copy link
Contributor Author

you don't need to squash commits, and it's nice if you would avoid a force push. We squash the commits before merge anyway.

@adrinjalali Got it. I dont force push commits :)

@@ -18,7 +18,7 @@ rm -rf $INSTALL_FOLDER
# Needed to rewrite the doctests
# Note: BSD sed -i needs an argument unders OSX
# so first renaming to .bak and then deleting backup files
find joblib -name "*.py" | xargs sed -i.bak "s/from joblib/from sklearn.externals.joblib/"
find joblib -name "*.py" | xargs sed -i.bak "s/from joblib/from .joblib/"
Copy link
Member

Choose a reason for hiding this comment

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

to revert I think

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 should be okay, and despite @NicolasHug's comment, the changes in sklearn/externals/joblib are consistent with this

@@ -2,7 +2,7 @@
from functools import partial

try:
from sklearn.externals.joblib.externals.cloudpickle import dumps, loads
from ..cloudpickle import dumps, loads
Copy link
Member

Choose a reason for hiding this comment

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

unsure about these ones here @ogrisel @tomMoral

Copy link
Member

Choose a reason for hiding this comment

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

anything joblib related can be ignored since we're unvendoring #13531

@@ -1304,7 +1304,7 @@ class LogisticRegression(BaseEstimator, LinearClassifierMixin,

Note that 'sag' and 'saga' fast convergence is only guaranteed on
features with approximately the same scale. You can
preprocess the data with a scaler from sklearn.preprocessing.
.preprocess the data with a scaler from sklearn.preprocessing.
Copy link
Member

Choose a reason for hiding this comment

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

revert

@@ -1758,7 +1758,7 @@ class LogisticRegressionCV(LogisticRegression, BaseEstimator,

Note that 'sag' and 'saga' fast convergence is only guaranteed on
features with approximately the same scale. You can preprocess the data
with a scaler from sklearn.preprocessing.
with a scaler from ..preprocessing.
Copy link
Member

Choose a reason for hiding this comment

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

revert

@@ -2056,7 +2056,7 @@ def check_cv(cv='warn', y=None, classifier=False):
if not hasattr(cv, 'split') or isinstance(cv, str):
if not isinstance(cv, Iterable) or isinstance(cv, str):
raise ValueError("Expected cv as an integer, cross-validation "
"object (from sklearn.model_selection) "
"object (from .) "
Copy link
Member

Choose a reason for hiding this comment

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

revert

sklearn/setup.py Outdated
@@ -1,6 +1,6 @@
import os

from sklearn._build_utils import maybe_cythonize_extensions
from _build_utils import maybe_cythonize_extensions
Copy link
Member

Choose a reason for hiding this comment

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

revert

@@ -274,7 +274,7 @@ def check_estimator(Estimator):
shapes, etc.
Additional tests for classifiers, regressors, clustering or transformers
will be run if the Estimator class inherits from the corresponding mixin
from sklearn.base.
from ..base.
Copy link
Member

Choose a reason for hiding this comment

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

revert

@aditya1702 aditya1702 changed the title [WIP] Replace absolute imports with relative ones [MRG] Replace absolute imports with relative ones Apr 17, 2019
@aditya1702
Copy link
Contributor Author

cc @agramfort @jnothman @NicolasHug

@NicolasHug
Copy link
Member

That looks good for the most part, but please revert the changes related to sklearn.external.joblib. Sorry, I should have pointed that earlier in the issue. You should be able to do this simply with

git checkout master -- sklearn/externals/joblib

(also please merge master to sort out the merge conflict with sklearn/metrics/cluster/bicluster.py)

@@ -18,7 +18,7 @@ rm -rf $INSTALL_FOLDER
# Needed to rewrite the doctests
# Note: BSD sed -i needs an argument unders OSX
# so first renaming to .bak and then deleting backup files
find joblib -name "*.py" | xargs sed -i.bak "s/from joblib/from sklearn.externals.joblib/"
find joblib -name "*.py" | xargs sed -i.bak "s/from joblib/from .joblib/"
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 should be okay, and despite @NicolasHug's comment, the changes in sklearn/externals/joblib are consistent with this

@aditya1702
Copy link
Contributor Author

@NicolasHug Resolved the conflicts

@NicolasHug NicolasHug merged commit 301076e into scikit-learn:master Apr 17, 2019
@NicolasHug
Copy link
Member

Thanks @aditya1702 !

jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Apr 25, 2019
@aditya1702 aditya1702 deleted the fix-absolute-imports branch April 25, 2019 18:03
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove absolute imports
5 participants