Skip to content

Commit 045cbbb

Browse files
authored
Fix febus format empty file (#492)
* work on adding neubrex * fix febus format issue
1 parent f9f8289 commit 045cbbb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

dascore/io/febus/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _get_febus_version_str(hdf_fi) -> str:
7575
# Hopefully this is the file version...
7676
version = unbyte(source.attrs.get("Version", version)).split(".")[0]
7777
is_febus = is_febus and expected_source_attrs.issubset(set(source.attrs))
78-
if is_febus:
78+
if inst_keys and is_febus:
7979
return version
8080
return ""
8181

tests/test_io/test_io_core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88
from typing import TypeVar
99

10+
import h5py
1011
import numpy as np
1112
import pandas as pd
1213
import pytest
@@ -260,6 +261,14 @@ def test_implements(self):
260261
class TestGetFormat:
261262
"""Tests to ensure formats can be retrieved."""
262263

264+
@pytest.fixture(scope="class")
265+
def empty_h5_path(self, tmpdir_factory):
266+
"""Create an empty HDF5 file."""
267+
path = tmpdir_factory.mktemp("empty") / "empty.h5"
268+
with h5py.File(path, "w"):
269+
pass
270+
return path
271+
263272
def test_not_known(self, dummy_text_file):
264273
"""Ensure a non-path/str object raises."""
265274
with pytest.raises(UnknownFiberFormatError):
@@ -279,6 +288,11 @@ def test_fiberio_directory(self, tmp_path_factory):
279288
assert fiber_io.name == name
280289
assert fiber_io.version == version
281290

291+
def test_empty_hdf5_no_format(self, empty_h5_path):
292+
"""Ensure the empty hdf5 dorsen't have a format."""
293+
with pytest.raises(UnknownFiberFormatError):
294+
dc.get_format(empty_h5_path)
295+
282296

283297
class TestScan:
284298
"""Tests for scanning fiber files."""

0 commit comments

Comments
 (0)