linnarsson-lab / loompy

Python implementation of the Loom file format - http://loompy.org
BSD 2-Clause "Simplified" License
139 stars 37 forks source link

the mismatch of reutrn type from get_loom_spec_version #165

Open ygidtu opened 2 years ago

ygidtu commented 2 years ago

In current version, the get_loom_spec_version from utils.py will return str or np.ndarray from materialize_attr_values, it should add sort of convertion.

Here is my code:

def get_loom_spec_version(f: HDF5File) -> str:
    version = "0.0.0.0"
    if "attrs" in f and "LOOM_SPEC_VERSION" in f["/attrs"]:
        version = materialize_attr_values(f["/attrs"]["LOOM_SPEC_VERSION"][()])
    if "LOOM_SPEC_VERSION" in f.attrs:
        version = materialize_attr_values(f.attrs["LOOM_SPEC_VERSION"])

    if isinstance(version, np.ndarray):
        version = [str(x) for x in version]
        version = ".".join(version)

    return version