You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow storing heterogeneous lists in .uns (as JSON or so) #1979
When I use write_h5ad to save the .h5ad file, some contents in uns are automatically converted to np.array objects. Is there any way to prevent this from happening? Thanks a lot!
This is expected behavior since we do not store lists as such on disk, treating them as arrays. Technically we could override the behavior of the uns dictionary to understand setting with a list implies array. So I can understand better, is there a use case here for knowing something was a list when it was set before being written out?
In the future, please use the issue template, bug or enhancement would have been fine.
I don't think we would store lists on disks marked as such, but we could override the behvaior of uns to not store lists in memory, instead using numpy object arrays (or similarly appropriate object).
@jmzhang1911 Without users like you, I would not be paid to have time for you to take up so, thanks for opening the issue. That is indeed actually an interesting use-case, especially for browsers where JSON is expected potentially. I am going to reopen this. What you have is nice for python but it might make sense to distinguish between lists actually for exactly this purpose. I am going to post a question on zulip and see what some people say: https://scverse.zulipchat.com/. If you're not there, check it out!
Writing this out, now that I think about, does not exactly fit the zarr spec at least. So this might require some thought. We have not stepped outside zarr for anything, but maybe there is a way to achieve this sort of thing
changed the title [-]write_h5ad automatically converts data type in uns[/-][+]Allow storing heterogeneous lists in .uns (as JSON or so)[/+]on Jul 23, 2025
Activity
ilan-gold commentedon May 8, 2025
This is expected behavior since we do not store lists as such on disk, treating them as arrays. Technically we could override the behavior of the
unsdictionary to understand setting with a list implies array. So I can understand better, is there a use case here for knowing something was a list when it was set before being written out?In the future, please use the issue template, bug or enhancement would have been fine.
ilan-gold commentedon May 8, 2025
I don't think we would store lists on disks marked as such, but we could override the behvaior of uns to not store lists in memory, instead using numpy object arrays (or similarly appropriate object).
jmzhang1911 commentedon May 12, 2025
Thank you for your reply! My intention was to directly export the uns values as a JSON file. I achieved this goal using the following approach:
Apologies for taking up your time, and thank you once again for your help!
ilan-gold commentedon May 12, 2025
@jmzhang1911 Without users like you, I would not be paid to have time for you to take up so, thanks for opening the issue. That is indeed actually an interesting use-case, especially for browsers where JSON is expected potentially. I am going to reopen this. What you have is nice for python but it might make sense to distinguish between lists actually for exactly this purpose. I am going to post a question on zulip and see what some people say: https://scverse.zulipchat.com/. If you're not there, check it out!
ilan-gold commentedon May 12, 2025
Writing this out, now that I think about, does not exactly fit the zarr spec at least. So this might require some thought. We have not stepped outside zarr for anything, but maybe there is a way to achieve this sort of thing
ilan-gold commentedon May 12, 2025
See: https://scverse.zulipchat.com/#narrow/channel/315789-data-structures/topic/JSON.20in.20.60uns.60/with/517500234
[-]write_h5ad automatically converts data type in uns[/-][+]Allow storing heterogeneous lists in .uns (as JSON or so)[/+]flying-sheep commentedon Aug 21, 2026
Currently getting bitten by this not existing 😢