-
Notifications
You must be signed in to change notification settings - Fork 21
deprecate MuData methods whose AnnData analogs will be deprecated in 0.13 #131
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
Open
ilia-kats
wants to merge
3
commits into
scverse:main
Choose a base branch
from
ilia-kats:deprecations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import pytest | ||
|
|
||
| from mudata._core.utils import deprecated | ||
|
|
||
|
|
||
| @pytest.fixture(params=[None, "Test message."]) | ||
| def msg(request: pytest.FixtureRequest): | ||
| return request.param | ||
|
|
||
|
|
||
| @pytest.fixture( | ||
| params=[ | ||
| None, | ||
| "Test function", | ||
| """Test function | ||
|
|
||
| This is a test. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| foo | ||
| bar | ||
| bar | ||
| baz | ||
| """, | ||
| ] | ||
| ) | ||
| def docstring(request): | ||
| return request.param | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def deprecated_func(msg, docstring): | ||
| def func(foo, bar): | ||
| return 42 | ||
|
|
||
| func.__doc__ = docstring | ||
| return deprecated(version="foo", msg=msg)(func) | ||
|
|
||
|
|
||
| def test_deprecation_decorator(deprecated_func, docstring, msg): | ||
| with pytest.warns(FutureWarning, match="deprecated"): | ||
| assert deprecated_func(1, 2) == 42 | ||
|
|
||
| lines = deprecated_func.__doc__.expandtabs().splitlines() | ||
| if docstring is None: | ||
| assert lines[0].startswith(".. version-deprecated::") | ||
| else: | ||
| lines_orig = docstring.expandtabs().splitlines() | ||
| assert lines[0] == lines_orig[0] | ||
| assert len(lines[1].strip()) == 0 | ||
| if len(lines_orig) == 1: | ||
| assert lines[2].startswith(".. version-deprecated") | ||
| if msg is not None: | ||
| assert lines[3] == f" {msg}" | ||
| else: | ||
| assert lines[2].startswith(" .. version-deprecated") | ||
| if msg is not None: | ||
| assert lines[3] == f" {msg}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good candidate for
scverse-miscright?We don't seem to have this in
AnnData: https://anndata.readthedocs.io/en/stable/generated/anndata.AnnData.var_vector.html#anndata.AnnData.var_vector i.e., the deprecation does not appear in the docsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @flying-sheep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you guys have this mixin class that explicitly hides deprecated methods from the docs. But I'm happy to move this to scverse-misc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true, I guess we will deprecate in
0.13but maybe this is a nice alternative? I'd like to hear from @flying-sheep what his take is. My feeling is that this is a cleaner solution than deleting from the docs.