-
Notifications
You must be signed in to change notification settings - Fork 150
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
(feat): xarray
with experimental backed
reading
#1247
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1247 +/- ##
==========================================
- Coverage 86.87% 84.56% -2.31%
==========================================
Files 39 44 +5
Lines 6033 6303 +270
==========================================
+ Hits 5241 5330 +89
- Misses 792 973 +181
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I think there are tests missing for a bunch of moving parts like Dataset2D, but a lot of the public functionality seems to already be there and working well!
src/anndata/_core/storage.py
Outdated
"""Coerce arrays stored in layers/X, and aligned arrays ({obs,var}{m,p}).""" | ||
# If value is a scalar and we allow that, return it | ||
if allow_array_like and np.isscalar(value): | ||
return value | ||
# If value is one of the allowed types, return it | ||
if isinstance(value, StorageType.classes()): | ||
|
||
if isinstance(value, (*StorageType.classes(), Dataset2D)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that we don’t forget: let’s get rid of the circular import hack
elem_name = get_elem_name(elem) | ||
index_label = f'{elem_name.replace("/", "")}_names' | ||
index_key = elem.attrs["_index"] | ||
index = elem_dict[index_key] # no sense in reading this in multiple times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line can move into the helper
needs_xarray = pytest.mark.skipif( | ||
not find_spec("xarray"), reason="Xarray is not installed" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could just set pytestmark once at the top, then the whole file is skipped and you don’t have to annotate each individual function.
pytestmark = pytest.mark.skipif(
not find_spec("xarray"), reason="Xarray is not installed"
)
assert store.get_access_count("obs/int64") == 1, store.get_subkeys_accessed( | ||
"obs/int64" | ||
) | ||
# one for 0, .zmetadata handles .zarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand either part of this comment, maybe expand a bit
assert store.get_access_count("obs/.zgroup") == 1, store.get_subkeys_accessed( | ||
"obs/.zgroup" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you know, reading this pattern again and again, maybe we should make this a helper.
It could go directly into the AccessTrackingStore
.
That way it’s not possible to ever use two different strings on the left and right side of this statement, which would probably cause hours of debugging.
Co-authored-by: Philipp A. <[email protected]>
Co-authored-by: Philipp A. <[email protected]>
…erator_from_elems`
4947295
to
1540d27
Compare
This PR is a ligther weight version of #947 that involves using the original
AnnData
object as the class to holdobs
andvar
xr.Dataset
..obs
and.var
withbacked="r"
mode #981