perf: optimization of stats code for rank_genes_groups#4204
Conversation
|
@ilan-gold regarding these points, perhaps I open separate PR(s):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4204 +/- ##
==========================================
+ Coverage 79.93% 79.95% +0.01%
==========================================
Files 121 121
Lines 12958 12985 +27
==========================================
+ Hits 10358 10382 +24
- Misses 2600 2603 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Benchmark changes
Comparison: https://github.com/scverse/scanpy/compare/c52da398956c8de9a5bc1945a7966ad86b8431be..30621045a30c46a6e2227ea1ac2a60604086b3ce More details: https://github.com/scverse/scanpy/pull/4204/checks?check_run_id=87113112149 |
| return expm1_func(x) | ||
|
|
||
|
|
||
| @numba.njit # noqa: TID251 (inner kernel called from _vars_rest's nopython loop) |
There was a problem hiding this comment.
I don't fully understand this - could you explain more? Why do we need to use numba.njit here?
| n_r, m2_r = stats_after_g[0], stats_after_g[2] | ||
| denom = n_r - 1.0 if n_r >= 2.0 else 1.0 | ||
| v = m2_r / denom | ||
| vars_rest[g, j] = v if v > 0.0 else 0.0 |
There was a problem hiding this comment.
| vars_rest[g, j] = v if v > 0.0 else 0.0 | |
| vars_rest[g, j] = v |
| else: | ||
| # g == 0 has no groups before it, so its rest is just the groups after | ||
| n_r, m2_r = stats_after_g[0], stats_after_g[2] | ||
| denom = n_r - 1.0 if n_r >= 2.0 else 1.0 |
There was a problem hiding this comment.
| denom = n_r - 1.0 if n_r >= 2.0 else 1.0 | |
| denom = n_r - 1.0 |
why not?
| self.stats[group_name, "names"] = self.var_names[global_indices] | ||
|
|
||
| self.stats[group_name, "scores"] = scores[global_indices] | ||
| def _build_stats_dataframe( |
There was a problem hiding this comment.
Is this function just copy-pasted?
|
P.S Any thought why the |
@ilan-gold replayed changes of #4118 onto main