Skip to content

Commit 6648cc5

Browse files
committed
fix febus format issue
1 parent 557343b commit 6648cc5

File tree

4 files changed

+16
-56
lines changed

4 files changed

+16
-56
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

dascore/io/neubrex/core.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import dascore.io.neubrex.utils_rfs as rfs_utils
1212
from dascore.constants import SpoolType
1313
from dascore.io import FiberIO
14-
from dascore.utils.hdf5 import H5Reader, H5Writer
14+
from dascore.utils.hdf5 import H5Reader
1515

1616

1717
class NeubrexRFSPatchAttrs(dc.PatchAttrs):
@@ -84,31 +84,6 @@ def scan(self, resource: H5Reader, snap=True, **kwargs) -> list[dc.PatchAttrs]:
8484
attrs["file_version"] = self.version
8585
return [dc.PatchAttrs(**attrs)]
8686

87-
def write(
88-
self,
89-
spool: SpoolType,
90-
resource: H5Writer,
91-
extra_attrs: dict[str, float | int | str] | None = None,
92-
**kwargs,
93-
) -> None:
94-
"""
95-
Write a Neubrex Rayleigh Frequency Shift file.
96-
97-
Parameters
98-
----------
99-
spool
100-
The spool to write.
101-
resource
102-
The H5file to write to.
103-
extra_attrs
104-
A dict of basic types to write to the Acoustic dataset's
105-
attributes.
106-
**kwargs
107-
Un-used, only here for compat with other write methods.
108-
"""
109-
if len(spool) > 1:
110-
raise ValueError("NeubrexRFS only supports writing a single patch.")
111-
11287

11388
class NeubrexDASV1(FiberIO):
11489
"""

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."""

tests/test_io/test_neubrex/test_neubrex_rfs.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)