Skip to content

[bug] ValueError: could not broadcast input array from shape (1000,1) into shape (1000) #45

Closed

Description

@Hoeze

I'd like to store some design matrix inside adata.obsm.
However, there are cases where this design matrix has only one column, i.e. it has shape (adata.n_obs, 1).

In this case I get the following error message:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-28-86462c4012f3>", line 1, in <module>
    adata.obsm["asdf"] = np.reshape(np.arange(1000), (1000,1))
  File "/usr/lib/python3.6/site-packages/anndata/base.py", line 126, in __setitem__
    new[name] = arr
ValueError: could not broadcast input array from shape (1000,1) into shape (1000)

Example to reproduce:

adata.obsm["asdf"] = np.reshape(np.arange(adata.n_obs), (adata.n_obs,1))```

Activity

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