Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX make sure we can execute code with python -OO#953

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
glemaitre merged 2 commits intoscikit-learn-contrib:masterfromglemaitre:is/945
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
7 changes: 7 additions & 0 deletionsdoc/whats_new/v0.10.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,13 @@ Version 0.10.0 (ongoing)
Changelog
---------

Bug fixes
.........

- Make sure that :class:`~imblearn.utils._docstring.Substitution` is
working with `python -OO` that replace `__doc__` by `None`.
:pr:`953` bu :user:`Guillaume Lemaitre <glemaitre>`.

Compatibility
.............

Expand Down
3 changes: 2 additions & 1 deletionimblearn/utils/_docstring.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,8 @@ def __init__(self, *args, **kwargs):
self.params = args or kwargs

def __call__(self, obj):
obj.__doc__ = obj.__doc__.format(**self.params)
if obj.__doc__:
obj.__doc__ = obj.__doc__.format(**self.params)
return obj


Expand Down
14 changes: 14 additions & 0 deletionsimblearn/utils/tests/test_docstring.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,3 +66,17 @@ def test_docstring_inject(obj, obj_docstring):
def test_docstring_template():
assert "random_state" in _random_state_docstring
assert "n_jobs" in _n_jobs_docstring


def test_docstring_with_python_OO():
"""Check that we don't raise a warning if the code is executed with -OO.

Non-regression test for:
https://github.com/scikit-learn-contrib/imbalanced-learn/issues/945
"""
instance = cls(param_1="xxx", param_2="yyy")
instance.__doc__ = None # simulate -OO

instance = Substitution(param_1="xxx", param_2="yyy")(instance)

assert instance.__doc__ is None

[8]ページ先頭

©2009-2025 Movatter.jp