Repository navigation
feat: write support for keys that aren’t file names - #2662
flying-sheep wants to merge 5 commits into
Conversation
eb84892 to
6a98023
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/json-io #2662 +/- ##
================================================
+ Coverage 85.94% 86.05% +0.11%
================================================
Files 50 50
Lines 8329 8400 +71
================================================
+ Hits 7158 7229 +71
Misses 1171 1171
|
6a98023 to
2d67fe1
Compare
ilan-gold
left a comment
There was a problem hiding this comment.
Discussion is a bit mangled now, but scverse/zarr-convention-dataframe#1 is quite a strong suggestion that seems simpler to implement. Maybe let's discuss there and then I will implement there (and you here) whatever mechanism we settle on (your implementation here of other data frame things does not have to match mine otherwise)
622fd5a to
20b6199
Compare
0428361 to
ed0ed9c
Compare
Documentation build overview
156 files changed ·
|
4aee430 to
4c77cfe
Compare
4c77cfe to
8fd7652
Compare
8fd7652 to
b0850ab
Compare
|
Otherwise these fail: @pytest.mark.parametrize(
"existing", ["x", "x/y"], ids=["unescaped-group", "escaped-group"]
)
@pytest.mark.parametrize("key", ["a/b", "100%"])
@pytest.mark.parametrize(
"use", [lambda k: A.obsm[k], lambda _: A.obsm], ids=["single-key", "mapping"]
)
def test_use_escapes_keys(
diskfmt_store: Path | MemoryStore,
diskfmt: Literal["h5ad", "zarr"],
existing: str,
key: str,
use: Callable[[str], object],
) -> None:
"""`use=` escapes keys like a full write with the same `compat` does.
`100%` into an already escaped group is the silent case:
written literally, it would be read back as an escape sequence.
"""
adata = ad.AnnData(np.zeros((2, 3)), obsm={existing: np.zeros((2, 2))})
getattr(adata, f"write_{diskfmt}")(diskfmt_store, compat="0.14")
adata.obsm[key] = np.ones((2, 2))
getattr(adata, f"write_{diskfmt}")(diskfmt_store, use=use(key), compat="0.14")
back = getattr(ad, f"read_{diskfmt}")(diskfmt_store)
assert set(back.obsm) == {existing, key}
np.testing.assert_array_equal(back.obsm[key], np.ones((2, 2))) |
cb4214d to
4a53beb
Compare
ilan-gold
left a comment
There was a problem hiding this comment.
anndata/src/anndata/_settings.py
Line 25 in c8bbe5a
Unrelated, going to suggest taking a page out of Davis' Bennet's book, and having Claude do an adversarial test of this. Can Claude come up with use-cases where this breaks?
| * The group's metadata MUST contain the encoding metadata `"encoding-type": "dict"`, `"encoding-version": "0.1.0"` | ||
|
|
||
| (mapping-escaped)= | ||
| ### Mapping specifications (v0.2.0) |
There was a problem hiding this comment.
Why only mapping? #2039 seems to be for data frames
There was a problem hiding this comment.
I removed the data frame part because you asked for alignment with the data frame convention, which no longer uses escaping (while I think that potentially nested mappings might benefit from escaping)
I originally had the data frame part in here but removed it in order to not impose two new specs on other implementers in possibly quick succession. I thought that’s what you wanted.
Please tell me if you want working slashes in data frame keys now (at the cost of two spec changes for data frames) or hamstrung data frames until the convention is done.
23fdb6e to
a382197
Compare
|
OK, did the adversarial review, it found the following issues with this PR:
It also found these, which I’d say we ignore:
It also flagged these issues that aren’t ours:
|
This and the two PRs below it are I need in 0.14 (for scanpy 2.0 preview), except for
.unsaccessors.See also zarr-developers/zarr-specs#128
/and\inobsmkeys,obscolumns,unskeys, … #2450