Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent slicing with one element. #74

Closed
grst opened this issue Oct 23, 2018 · 2 comments
Closed

inconsistent slicing with one element. #74

grst opened this issue Oct 23, 2018 · 2 comments

Comments

@grst
Copy link
Contributor

grst commented Oct 23, 2018

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.

@falexwolf
Copy link
Member

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

@ivirshup
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants