Skip to content

AttributeError: 'csr_matrix' object has no attribute 'A' when running clf.fit(adata.X).predict() #28

@victorsanchezarevalo

Description

@victorsanchezarevalo

Description:

I encountered an issue while trying to use clf.fit() and predict() on a csr_matrix input (from adata.X) when running the following code:

doublets = clf.fit(adata.X).predict(p_thresh=1e-3, voter_thresh=0.5)

This throws the error:

AttributeError: 'csr_matrix' object has no attribute 'A'

Steps to Reproduce:

  1. Load a dataset into adata where adata.X is in a sparse csr_matrix format.
  2. Call clf.fit(adata.X).predict(p_thresh=1e-3, voter_thresh=0.5).

Expected Behavior:

The method should handle sparse matrices properly or convert them internally to dense arrays if required.

Actual Behavior:

The error is raised because the sparse matrix (csr_matrix) does not have an .A attribute, which seems to be expected by the function.

Environment:

  • Python version: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions