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 int for shortcut #3461

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix int for shortcut #3461

wants to merge 3 commits into from

Conversation

Intron7
Copy link
Member

@Intron7 Intron7 commented Feb 11, 2025

Fixes a bug where the regress_out short cut would error for integer dyte

@Intron7 Intron7 modified the milestones: 1.12.0, 1.11.0 Feb 11, 2025
@Intron7 Intron7 requested a review from ilan-gold February 11, 2025 12:37
@@ -752,6 +752,9 @@ def regress_out(
# if the regressors are not categorical and the matrix is not singular
# use the shortcut numpy_regress_out
if not variable_is_categorical and np.linalg.det(regressors.T @ regressors) != 0:
if np.issubdtype(X.dtype, np.integer):
target_dtype = np.float32 if X.dtype.itemsize <= 4 else np.float64
X = X.astype(target_dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

For dense you can also do the ordering here, since you're copying anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.43%. Comparing base (cce4bd6) to head (1abe26c).

Files with missing lines Patch % Lines
src/scanpy/preprocessing/_simple.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3461      +/-   ##
==========================================
- Coverage   75.44%   75.43%   -0.01%     
==========================================
  Files         113      113              
  Lines       13250    13253       +3     
==========================================
+ Hits         9997     9998       +1     
- Misses       3253     3255       +2     
Files with missing lines Coverage Δ
src/scanpy/preprocessing/_simple.py 89.72% <33.33%> (-0.43%) ⬇️

@@ -754,7 +754,7 @@ def regress_out(
if not variable_is_categorical and np.linalg.det(regressors.T @ regressors) != 0:
if np.issubdtype(X.dtype, np.integer):
target_dtype = np.float32 if X.dtype.itemsize <= 4 else np.float64
X = X.astype(target_dtype)
X = X.astype(target_dtype, order="C")
Copy link
Contributor

Choose a reason for hiding this comment

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

But this could also apply to sparse? And we don't want the argument then, no? https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.astype.html nothing here about order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants