-
Notifications
You must be signed in to change notification settings - Fork 154
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
Error slicing when there is only one observation #60
Comments
This is intentional and the same behavior as of numpy arrays, see
as mentioned in the docs: https://anndata.readthedocs.io/en/latest/anndata.AnnData.html Just recently we had a discussion of whether this helpful or not. I personally think it's helpful. What do you think. |
I can see why in your example this behaviour is good, but in the two errors in the original post it is very confusing. Without knowing more, my intuition was:
Generally, I've come across scenarios in numpy and pandas where applying the same function on an array will return different 'shape' results based on the input. With pandas, there are times when it remains as a DataFrame or can switch to a Series. These are pretty annoying to deal with as a library author, but it probably indicates that these edge cases are hard... With numpy, the |
Yes, very happy to add a Also happy to change the output of That's an interesting point that you make about pandas. I know that
returns a Why is it bothersome to you the other way round? |
Here is the anti-pattern we are trying to avoid for our users:
If we can deal with the Thinking about the |
Makes sense! If it's only about retaining indexing with But I see that an I'd tend to call it |
This would be useful in the constructor, yes -- would you try and persist that when creating a view/copy of the object? I'm ambivalent as to how that should work.
No worries, not bad English at all |
Of course, this would persist throughout copies and views. Wouldn't be a problem. Just yesterday, another question came up regarding efficient extraction of a slice of
@flying-sheep: You don't need to go through the whole issue, just consider the two bullets above. What do you think? I guess you would be happier with this |
Another option: Instead of letting The big advantage is that this is backwards compatible. But I fear it's super confusing to have access to the data matrix twice in the object... |
Not withstanding backwards compatibility, I would take a different approach with something akin to the following:
That way, you have better encapsulation and if you need to change implementation details like the shape of |
Worth mentioning that this definitely makes users' code more verbose and is not as simple as the pandas I'm on the fence, and you guys have better knowledge about how AnnData is currently being used. |
OK, so now we at least have One other solution: go away completely from Calling
What do you think, @flying-sheep (also @bretttully if you want to comment). |
This issue has been automatically marked as stale because it has not had recent activity. |
Fixed by #171 |
This may be intentional, but there seems to be an issue when the raw data only has one row. We have come across this in our unit tests when creating a small example data set with only one observation.
The text was updated successfully, but these errors were encountered: