Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Indices and tables
* :ref:`modindex`
* :ref:`search`

These docs pages collect anonymous tracking data using goatcounter, and the
dashboard is available to the public: https://kerchunk.goatcounter.com/ .


.. raw:: html

<script data-goatcounter="https://kerchunk.goatcounter.com/count"
Expand Down
6 changes: 4 additions & 2 deletions kerchunk/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _translator(
for v in val
]
kwargs["data"] = out
kwargs["filters"] = [numcodecs.JSON()]
kwargs["filters"] = [numcodecs.VLenUTF8()]
fill = None
elif self.vlen == "null":
dt = "O"
Expand Down Expand Up @@ -466,7 +466,7 @@ def _translator(
)
dt = "O"
kwargs["data"] = data2
kwargs["filters"] = [numcodecs.JSON()]
kwargs["filters"] = [numcodecs.VLenUTF8()]
fill = None
else:
raise NotImplementedError
Expand All @@ -481,6 +481,8 @@ def _translator(

# Create a Zarr array equivalent to this HDF5 dataset.
data = kwargs.pop("data", None)
if (dt or h5obj.dtype) == object:
dt = "string"
za = self._zroot.require_array(
name=h5obj.name.lstrip("/"),
shape=h5obj.shape,
Expand Down
10 changes: 6 additions & 4 deletions tests/test_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def test_times_str(times_data):

def test_string_embed():
fn = osp.join(here, "vlen.h5")
h = kerchunk.hdf.SingleHdf5ToZarr(fn, fn, vlen_encode="embed", error="pdb")
h = kerchunk.hdf.SingleHdf5ToZarr(fn, fn, vlen_encode="embed")
out = h.translate()

localfs = AsyncFileSystemWrapper(fsspec.filesystem("file"))
fs = refs_as_fs(out, fs=localfs)
# assert txt in fs.references["vlen_str/0"]
store = fs_as_store(fs)
z = zarr.open(store, zarr_format=2)
assert z["vlen_str"].dtype == "O"
assert "String" in str(z["vlen_str"])
assert z["vlen_str"][0] == txt
assert (z["vlen_str"][1:] == "").all()

Expand All @@ -218,14 +218,16 @@ def test_string_pathlib():
fs = fsspec.filesystem("reference", fo=out)
assert txt in fs.references["vlen_str/0"]
z = zarr.open(fs_as_store(fs))
assert z["vlen_str"].dtype == "O"
assert "String" in str(z["vlen_str"])
assert z["vlen_str"][0] == txt
assert (z["vlen_str"][1:] == "").all()


def test_string_null():
fn = osp.join(here, "vlen.h5")
h = kerchunk.hdf.SingleHdf5ToZarr(fn, fn, vlen_encode="null", inline_threshold=0)
h = kerchunk.hdf.SingleHdf5ToZarr(
fn, fn, vlen_encode="null", inline_threshold=0, error="pdb"
)
out = h.translate()
localfs = AsyncFileSystemWrapper(fsspec.filesystem("file"))
store = refs_as_store(out, fs=localfs)
Expand Down
Loading