Skip to content

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

Open

Description

@moor2562

I'm trying to run the tutorial and am receiving this error while running sdm.spatialdm_local(adata, n_perm=1000, method='both', specified_ind=None, nproc=1).

The full error is pasted below:

Traceback (most recent call last):
File "", line 1, in
sdm.spatialdm_local(adata, n_perm=1000, method='both', specified_ind=None, nproc=1)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/users/2/moor2562/miniconda3/envs/spatialdm/lib/python3.13/site-packages/spatialdm/main.py", line 283, in spatialdm_local
spot_selection_matrix(adata, ligand, receptor, ind, n_perm, method, scale_X)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/users/2/moor2562/miniconda3/envs/spatialdm/lib/python3.13/site-packages/spatialdm/utils.py", line 245, in spot_selection_matrix
raw_norm.X = csr_matrix([norm_max(X) for X in raw_norm.X.T]).T
~~~~~~~~^^^
File "/users/2/moor2562/miniconda3/envs/spatialdm/lib/python3.13/site-packages/spatialdm/utils.py", line 235, in norm_max
X=X.A[0]
^^^
AttributeError: 'csr_matrix' object has no attribute 'A'

Activity

  1. moor2562 commented on May 1, 2025

    @moor2562
    Author

    I'm not an expert by any means, but I think the issue might be stemming from incompatibilities with the updated syntax of the scipy.sparse function in manipulating the csr_matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions