-
Notifications
You must be signed in to change notification settings - Fork 614
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
Create cat regressor #3353
Open
Intron7
wants to merge
28
commits into
main
Choose a base branch
from
create_cat_regressor
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.
+38
−11
Open
Create cat regressor #3353
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
086f70d
add function and test
Intron7 37244a9
add test
Intron7 b4ecb0a
add test for regressor
Intron7 36858d9
add release note
Intron7 be1bccc
Merge branch 'main' into create_cat_regressor
Intron7 a1a59ae
update typing
Intron7 7b41bc8
update test
Intron7 119a142
update test
Intron7 d77fa9c
update dtype
Intron7 236e356
rename cats
Intron7 bb9cde4
Update tests/test_preprocessing.py
Intron7 bbb5035
Update tests/test_preprocessing.py
Intron7 2a92193
Update tests/test_preprocessing.py
Intron7 c7b78c0
Update tests/test_preprocessing.py
ilan-gold b001c0e
remove test
Intron7 c3ce03e
update kernel
Intron7 c50226a
remove test
Intron7 c6665f4
make test together
Intron7 858e247
cleanup
Intron7 2421bd5
add comment
Intron7 2e16c45
Merge branch 'main' into create_cat_regressor
Intron7 1b7d7e1
Merge branch 'main' into create_cat_regressor
Intron7 3b7fe6e
Merge branch 'main' into create_cat_regressor
Intron7 726a625
update doc strings and clean up names
Intron7 104a0f3
Update src/scanpy/preprocessing/_simple.py
Intron7 f9b13be
update dtypes
Intron7 6eafd04
update atol for test
Intron7 1dae8f4
remove int fix
Intron7 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 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 @@ | ||
* Speed up for a categorical regressor in {func}`~scanpy.pp.regress_out` {smaller}`S Dicks` |
This file contains 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
Binary file not shown.
This file contains 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 |
---|---|---|
|
@@ -464,14 +464,21 @@ def test_regress_out_constants(): | |
assert_equal(adata, adata_copy) | ||
|
||
|
||
def test_regress_out_reproducible(): | ||
adata = pbmc68k_reduced() | ||
@pytest.mark.parametrize( | ||
("keys", "test_file", "atol"), | ||
[ | ||
(["n_counts", "percent_mito"], "regress_test_small.npy", 0.0), | ||
(["bulk_labels"], "regress_test_small_cat.npy", 1e-6), | ||
], | ||
) | ||
def test_regress_out_reproducible(keys, test_file, atol): | ||
adata = sc.datasets.pbmc68k_reduced() | ||
adata = adata.raw.to_adata()[:200, :200].copy() | ||
sc.pp.regress_out(adata, keys=["n_counts", "percent_mito"]) | ||
sc.pp.regress_out(adata, keys=keys) | ||
# This file was generated from the original implementation in version 1.10.3 | ||
# Now we compare new implementation with the old one | ||
tester = np.load(DATA_PATH / "regress_test_small.npy") | ||
np.testing.assert_allclose(adata.X, tester) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change in testing function? There's a pretty big note (see https://numpy.org/doc/stable/reference/generated/numpy.testing.assert_array_almost_equal.html) about why we should use |
||
tester = np.load(DATA_PATH / test_file) | ||
np.testing.assert_allclose(adata.X, tester, atol=atol) | ||
|
||
|
||
def test_regress_out_constants_equivalent(): | ||
|
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.
check dtype for behavior with integer dtype i.e., need to ensure this is a floating point matrix