Skip to content

Remove np.matrix dependency#213

Merged
Yenaled merged 3 commits intopachterlab:developmentfrom
JohnMMa:remove-np.matrix-dependency
Mar 8, 2026
Merged

Remove np.matrix dependency#213
Yenaled merged 3 commits intopachterlab:developmentfrom
JohnMMa:remove-np.matrix-dependency

Conversation

@JohnMMa
Copy link
Contributor

@JohnMMa JohnMMa commented Jul 25, 2023

As most of us may know, numpy is slowly deprecating the np.matrix class. However, the package still has one dependency on this class in report_matrix.ipynb, and scikit-learn is also in the process of doing it (see scikit-learn/scikit-learn#20165). This PR causes the pca.fit_transform's input to switch from np.matrix (the output of csr_matrix.todense()) to np.ndarray (the output of csr_matrix.toarray()`)

However, it must be noted that pca.fit_transform() may have slightly different results depending on its input being np.matrix or np.ndarray, see scikit-learn/scikit-learn#18941. I guess the difference is small enough to matter, but I guess you may think about it a bit.

This is my first PR in the past 5 years, so bear with me.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Yenaled Yenaled changed the base branch from master to development March 8, 2026 07:42
@Yenaled Yenaled merged commit 931f5ad into pachterlab:development Mar 8, 2026
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