Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for change to lh5.read #89

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
style: pre-commit fixes
  • Loading branch information
pre-commit-ci[bot] committed Oct 15, 2024
commit c4224c7937ae9b0c8014ffb3c6c1b4297858c5f7
4 changes: 3 additions & 1 deletion src/dspeed/processing_chain.py
Original file line number Diff line number Diff line change
@@ -1859,7 +1859,9 @@ def write(self, start: int, end: int) -> None:
np.copyto(self.raw_buf[start:end, ...], self.raw_var, "unsafe")
else:
np.copyto(
self.raw_buf[start:end, ...], self.raw_var[0 : end - start, ...], "unsafe"
self.raw_buf[start:end, ...],
self.raw_var[0 : end - start, ...],
"unsafe",
)

def __str__(self) -> str:
4 changes: 3 additions & 1 deletion tests/processors/test_histogram.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,9 @@ def test_histogram_fixed_width(lgnd_test_data, tmptestdir):
)
assert os.path.exists(dsp_file)

df = lh5.read_as("geds/dsp/", dsp_file, 'pd', field_mask=["hist_weights", "hist_borders"])
df = lh5.read_as(
"geds/dsp/", dsp_file, "pd", field_mask=["hist_weights", "hist_borders"]
)

assert len(df["hist_weights"][0]) + 1 == len(df["hist_borders"][0])
for i in range(2, len(df["hist_borders"][0])):
2 changes: 1 addition & 1 deletion tests/test_build_dsp.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

import lgdo
import pytest
from lgdo.lh5 import read, ls
from lgdo.lh5 import ls, read

from dspeed import build_dsp

2 changes: 1 addition & 1 deletion tests/test_list_parsing.py
Original file line number Diff line number Diff line change
@@ -32,6 +32,6 @@ def test_list_parsing(lgnd_test_data, tmptestdir):
)
assert os.path.exists(dsp_file)

df = lh5.read_as("geds/dsp/", dsp_file, 'pd', n_rows=5, field_mask=["wf_out"])
df = lh5.read_as("geds/dsp/", dsp_file, "pd", n_rows=5, field_mask=["wf_out"])

assert np.all(df["wf_out"][:] == np.array([7, 9, 11, 13, 15]))
8 changes: 5 additions & 3 deletions tests/test_numpy_constants_parsing.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ def test_build_dsp(lgnd_test_data, tmptestdir):
def test_numpy_math_constants_dsp(tmptestdir):
dsp_file = f"{tmptestdir}/LDQTA_r117_20200110T105115Z_cal_geds__numpy_test_dsp.lh5"
df = lh5.read_as(
"geds/dsp/", dsp_file, 'pd', field_mask=["timestamp", "calc1", "calc2", "calc3"]
"geds/dsp/", dsp_file, "pd", field_mask=["timestamp", "calc1", "calc2", "calc3"]
)

a1 = df["timestamp"] - df["timestamp"] - np.pi * df["timestamp"]
@@ -43,8 +43,10 @@ def test_numpy_math_constants_dsp(tmptestdir):

def test_numpy_infinity_and_nan_dsp(tmptestdir):
dsp_file = f"{tmptestdir}/LDQTA_r117_20200110T105115Z_cal_geds__numpy_test_dsp.lh5"
df = lh5.read_as("geds/dsp/", dsp_file, 'pd', field_mask=["calc4", "calc5", "calc6"])

df = lh5.read_as(
"geds/dsp/", dsp_file, "pd", field_mask=["calc4", "calc5", "calc6"]
)

assert (np.isnan(df["calc4"])).all()
assert (np.isneginf(df["calc5"])).all()
assert (np.isnan(df["calc6"])).all()
Loading
Oops, something went wrong.