Skip to content

inconsistent slicing with one element.  #74

Closed

Description

@grst

When slicing AnnData with a List of one (adata[:, [0]]) element, I expect it to return a 2d array.
When slicing AnnData with one element (adata[:, 0]), I expect it to return a 1d array.
AnnData always returns a 1d array.

See the following example

a = np.ones((3, 3))
adata = AnnData(a)

Expected behaviour (like in numpy)

> a[:, [0]]
array([1., 1., 1.])
> a[:, 0]
array([[1.],
       [1.],
       [1.]])
> adata.X[:, [0]]
array([[1.],
       [1.],
       [1.]], dtype=float32)

Actual behaviour:

> adata[:, 0].X
ArrayView([1., 1., 1.], dtype=float32)
> adata[:, [0]].X

This is somewhat related to #60. I still opened a separate issue as in my case the behavious is actually inconsistent with numpy.

Activity

  1. falexwolf commented on Oct 23, 2018

    @falexwolf
    Member

    Right! This should be fixed! Thank you for pointing this out! I'll do that soon!

  2. ivirshup commented on Sep 10, 2019

    @ivirshup
    Member

    We've gone with behavior more like an ExpressionSet than a numpy array, but we decided on a consistent solution. Closed by #164.

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