Skip to content

Commit

Permalink
Fix febus format empty file (#492)
Browse files Browse the repository at this point in the history
* work on adding neubrex

* fix febus format issue
  • Loading branch information
d-chambers authored Feb 28, 2025
1 parent f9f8289 commit 045cbbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dascore/io/febus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _get_febus_version_str(hdf_fi) -> str:
# Hopefully this is the file version...
version = unbyte(source.attrs.get("Version", version)).split(".")[0]
is_febus = is_febus and expected_source_attrs.issubset(set(source.attrs))
if is_febus:
if inst_keys and is_febus:
return version
return ""

Expand Down
14 changes: 14 additions & 0 deletions tests/test_io/test_io_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from typing import TypeVar

import h5py
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -260,6 +261,14 @@ def test_implements(self):
class TestGetFormat:
"""Tests to ensure formats can be retrieved."""

@pytest.fixture(scope="class")
def empty_h5_path(self, tmpdir_factory):
"""Create an empty HDF5 file."""
path = tmpdir_factory.mktemp("empty") / "empty.h5"
with h5py.File(path, "w"):
pass
return path

def test_not_known(self, dummy_text_file):
"""Ensure a non-path/str object raises."""
with pytest.raises(UnknownFiberFormatError):
Expand All @@ -279,6 +288,11 @@ def test_fiberio_directory(self, tmp_path_factory):
assert fiber_io.name == name
assert fiber_io.version == version

def test_empty_hdf5_no_format(self, empty_h5_path):
"""Ensure the empty hdf5 dorsen't have a format."""
with pytest.raises(UnknownFiberFormatError):
dc.get_format(empty_h5_path)


class TestScan:
"""Tests for scanning fiber files."""
Expand Down

0 comments on commit 045cbbb

Please sign in to comment.