Skip to content

Commit

Permalink
fix febus format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
d-chambers committed Feb 28, 2025
1 parent 557343b commit 6648cc5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 56 deletions.
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
27 changes: 1 addition & 26 deletions dascore/io/neubrex/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import dascore.io.neubrex.utils_rfs as rfs_utils
from dascore.constants import SpoolType
from dascore.io import FiberIO
from dascore.utils.hdf5 import H5Reader, H5Writer
from dascore.utils.hdf5 import H5Reader


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

def write(
self,
spool: SpoolType,
resource: H5Writer,
extra_attrs: dict[str, float | int | str] | None = None,
**kwargs,
) -> None:
"""
Write a Neubrex Rayleigh Frequency Shift file.
Parameters
----------
spool
The spool to write.
resource
The H5file to write to.
extra_attrs
A dict of basic types to write to the Acoustic dataset's
attributes.
**kwargs
Un-used, only here for compat with other write methods.
"""
if len(spool) > 1:
raise ValueError("NeubrexRFS only supports writing a single patch.")


class NeubrexDASV1(FiberIO):
"""
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
29 changes: 0 additions & 29 deletions tests/test_io/test_neubrex/test_neubrex_rfs.py

This file was deleted.

0 comments on commit 6648cc5

Please sign in to comment.