Skip to content
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

Fix hvg warnings #2810

Merged
merged 4 commits into from
Jan 15, 2024
Merged

Fix hvg warnings #2810

merged 4 commits into from
Jan 15, 2024

Conversation

flying-sheep
Copy link
Member

  • Closes N/A
  • Tests included or not required because:
  • Release notes not necessary because: only minor changes

some small changes before #2809

sum_total = np.sum(sums_genes).ravel()
sum_total = np.sum(sums_genes)
Copy link
Member Author

Choose a reason for hiding this comment

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

this makes a 0D array into a 1D array. Later a 0D array is expected, so let’s just not do that.

batch_info = adata.obs[batch_key].values
batch_info = adata.obs[batch_key].to_numpy()
Copy link
Member Author

Choose a reason for hiding this comment

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

.values is deprecated in favor of .to_numpy()

Comment on lines -566 to +570
df.means > min_mean,
df.means < max_mean,
df.dispersions_norm > min_disp,
df.dispersions_norm < max_disp,
df["means"] > min_mean,
df["means"] < max_mean,
df["dispersions_norm"] > min_disp,
df["dispersions_norm"] < max_disp,
Copy link
Member Author

Choose a reason for hiding this comment

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

using item access instead of attribute access is good style, especially for library code

Comment on lines -69 to 70
adata = adata[:1000, :500]
adata = adata[:1000, :500].copy()
sc.pp.filter_cells(adata, min_genes=1)
Copy link
Member Author

Choose a reason for hiding this comment

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

avoids a warning

Comment on lines -24 to +30
np.random.seed(0)
adata.obs["batch"] = np.random.binomial(3, 0.5, size=(adata.n_obs))
adata.obs["batch"] = adata.obs["batch"].astype("category")
gen = np.random.default_rng(0)
adata.obs["batch"] = pd.array(
gen.binomial(3, 0.5, size=adata.n_obs), dtype="category"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

np.random.* functions are deprecated in favor of np.random.Generator.* methods.

@@ -50,15 +58,23 @@ def test_highly_variable_genes_basic():
assert adata.var["highly_variable"].sum() == 3
assert (highly_var_first_layer != adata.var["highly_variable"]).any()


def test_highly_variable_genes_no_batch_matches_batch():
Copy link
Member Author

Choose a reason for hiding this comment

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

splitting this long sequential test of many features up into individual ones

Copy link

codecov bot commented Jan 15, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c410cd1) 72.84% compared to head (4d51759) 72.70%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2810      +/-   ##
==========================================
- Coverage   72.84%   72.70%   -0.14%     
==========================================
  Files         111      111              
  Lines       12368    12368              
==========================================
- Hits         9009     8992      -17     
- Misses       3359     3376      +17     
Files Coverage Δ
scanpy/experimental/pp/_highly_variable_genes.py 63.46% <100.00%> (ø)
scanpy/testing/_pytest/fixtures/data.py 100.00% <100.00%> (ø)
scanpy/preprocessing/_highly_variable_genes.py 96.17% <90.47%> (ø)

... and 1 file with indirect coverage changes

@flying-sheep flying-sheep changed the title Fix-hvg-warnings Fix hvg warnings Jan 15, 2024
@flying-sheep flying-sheep merged commit b01072e into master Jan 15, 2024
15 of 16 checks passed
@flying-sheep flying-sheep deleted the fix-hvg-warnings branch January 15, 2024 15:05
@flying-sheep flying-sheep modified the milestones: 1.9.7, 1.10.0 Jan 16, 2024
@scverse scverse deleted a comment from lumberbot-app bot Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant