I have a simple array (say length 1000) of objects in zarr. I want to replace it with a slimmed down version, picking only a subset of the items, as specified using a boolean array of size 1000. I want to keep everything else the same (e.g. if this array is a persistent one, I want to change the array on disk as well as in memory).
I can't simply reassign the array:
my_zarr_data = my_zarr_data[:][selected_items]
Because then I get the error ValueError: missing object_codec for object array.
Another option would be to make a copy, delete all the data, then add it back from the original using append(), but I can't see how to clear a zarr array while keeping the object_codec and other params the same (perhaps I could just do resize(0)?).
At the moment I'm resizing to the length of sum(selected_items) and then using my_zarr_data.set_basic_selection(..., my_zarr_data[:][selected_items]).
Is that right? Is there a more efficient way to permanently reassign an array to (say) the return value from get_mask_selection()?