fix test errors
Build Debian Packages / build (bookworm, debian12) (push) Successful in 7m26s
Build Debian Packages / build (bullseye, debian11) (push) Successful in 6m51s
Build Debian Packages / build (trixie, debian13) (push) Successful in 8m27s

This commit is contained in:
2026-03-20 14:52:56 +01:00
parent 69e23bdb12
commit c8192ecbb0
3 changed files with 45 additions and 14 deletions
+38 -10
View File
@@ -15,8 +15,7 @@ from .Errorable import Errorable
from .Drawable import Drawable from .Drawable import Drawable
from .DamarisFFT import DamarisFFT from .DamarisFFT import DamarisFFT
from .Signalpath import Signalpath from .Signalpath import Signalpath
from .ADC_Result import ADC_Result
from data.ADC_Result import ADC_Result
import sys import sys
import threading import threading
@@ -65,7 +64,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
self.common_descriptions=None self.common_descriptions=None
self.time_period=[] self.time_period=[]
self.job_id = None self.job_id = None # this does not make sense for an object accumulated from multiple job_ids
self.job_ids = []
self.use_error = error self.use_error = error
if self.uses_statistics(): if self.uses_statistics():
@@ -452,13 +452,16 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
for (key,value) in self.common_descriptions.items(): for (key,value) in self.common_descriptions.items():
accu_group._v_attrs.__setattr__("description_"+key,str(value)) accu_group._v_attrs.__setattr__("description_"+key,str(value))
accu_group._v_attrs.__setattr__("sampling_rate",self.sampling_rate) accu_group._v_attrs.__setattr__("sampling_rate",self.sampling_rate)
# save interval information
filter=None filter=None
if complib is not None: if complib is not None:
if complevel is None: if complevel is None:
complevel=9 complevel=3
filter=tables.Filters(complevel=complevel,complib=complib,shuffle=1) filter=tables.Filters(complevel=complevel,complib=complib,shuffle=1)
# save interval information
# start save index_table
# tried compression filter, but no effect... # tried compression filter, but no effect...
index_table=hdffile.create_table(where=accu_group, index_table=hdffile.create_table(where=accu_group,
name="indices", name="indices",
@@ -468,7 +471,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
"dwelltime": tables.Float64Col(), "dwelltime": tables.Float64Col(),
"number": tables.UInt64Col()}, "number": tables.UInt64Col()},
title="indices of adc data intervals", title="indices of adc data intervals",
filters=filter, filters=tables.Filters(complib="zlib"),
expectedrows=len(self.index)) expectedrows=len(self.index))
index_table.flavor="numpy" index_table.flavor="numpy"
# save interval data # save interval data
@@ -482,8 +485,24 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
new_row.append() new_row.append()
index_table.flush() index_table.flush()
new_row=None # end save index_table
index_table=None
# start save job_ids
jobid_table=hdffile.create_table(where=accu_group,
name="job_ids",
description={"job_id": tables.UInt64Col(),
"job_date": tables.StringCol(128),
},
title="job_ids used for accumulation",
filters=filter,
expectedrows=len(self.job_ids))
new_row=jobid_table.row
for i,job_id in enumerate(self.job_ids):
new_row["job_id"]=job_id
new_row["job_date"]="Not Implemented"
new_row.append()
jobid_table.flush()
# end save job_ids
# prepare saving data # prepare saving data
channel_no=len(self.y) channel_no=len(self.y)
@@ -563,7 +582,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
tmp_string += "Samples per Channel: " + str(len(self.y[0])) + "\n" tmp_string += "Samples per Channel: " + str(len(self.y[0])) + "\n"
tmp_string += "Samplingfrequency: " + str(self.sampling_rate) + "\n" tmp_string += "Samplingfrequency: " + str(self.sampling_rate) + "\n"
tmp_string += "n: " + str(self.n) tmp_string += "n: " + str(self.n) + "\n"
tmp_string += "jobids: " + str(self.job_ids) + "\n"
return tmp_string return tmp_string
@@ -625,6 +645,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
r.time_period=[other.job_date,other.job_date] r.time_period=[other.job_date,other.job_date]
r.job_id = other.job_id r.job_id = other.job_id
r.common_descriptions=other.description.copy() r.common_descriptions=other.description.copy()
r.job_ids.append(other.job_id)
self.lock.release() self.lock.release()
return r return r
@@ -657,6 +678,9 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
r.time_period=[min(self.time_period[0],other.job_date), r.time_period=[min(self.time_period[0],other.job_date),
max(self.time_period[1],other.job_date)] max(self.time_period[1],other.job_date)]
r.job_id = other.job_id r.job_id = other.job_id
r.job_ids = self.job_ids
r.job_ids.append(other.job_id)
if self.common_descriptions is not None: if self.common_descriptions is not None:
r.common_descriptions={} r.common_descriptions={}
for key in list(self.common_descriptions.keys()): for key in list(self.common_descriptions.keys()):
@@ -793,6 +817,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
self.time_period=[other.job_date,other.job_date] self.time_period=[other.job_date,other.job_date]
self.job_id = other.job_id # added by Oleg Petrov self.job_id = other.job_id # added by Oleg Petrov
self.job_ids.append(other.job_id)
self.common_descriptions=other.description.copy() self.common_descriptions=other.description.copy()
return self return self
@@ -820,7 +845,9 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
self.n += 1 self.n += 1
self.time_period=[min(self.time_period[0],other.job_date), self.time_period=[min(self.time_period[0],other.job_date),
max(self.time_period[1],other.job_date)] max(self.time_period[1],other.job_date)]
self.job_id = other.job_id # added by Oleg Petrov
self.job_id = other.job_id
self.job_ids.append(other.job_id)
if self.common_descriptions is not None: if self.common_descriptions is not None:
for key in list(self.common_descriptions.keys()): for key in list(self.common_descriptions.keys()):
if not (key in other.description and self.common_descriptions[key]==other.description[key]): if not (key in other.description and self.common_descriptions[key]==other.description[key]):
@@ -858,6 +885,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
self.common_descriptions=other.common_desriptions.copy() self.common_descriptions=other.common_desriptions.copy()
self.time_period=other.time_period[:] self.time_period=other.time_period[:]
self.job_id = other.job_id # added by Oleg Petrov self.job_id = other.job_id # added by Oleg Petrov
self.job_ids += other.job_ids
self.lock.release() self.lock.release()
return self return self
+2 -1
View File
@@ -145,7 +145,8 @@ class TestADCResult(unittest.TestCase):
# read back data with h5dump utility (apt-get -y install hdf5-tools) # read back data with h5dump utility (apt-get -y install hdf5-tools)
h5dump = subprocess.run(["h5dump", "-d", "/name/adc_data", "test.hdf5"], capture_output=True) h5dump = subprocess.run(["h5dump", "-d", "/name/adc_data", "test.hdf5"], capture_output=True)
content = h5dump.stdout.decode("utf-8") content = h5dump.stdout.decode("utf-8")
with open("tests/h5dump1_adc_data.ascii", "r") as f: test_dir = os.path.dirname(__file__)
with open(os.path.join(test_dir, "h5dump1_adc_data.ascii"), "r") as f:
expected = f.read() expected = f.read()
self.assertEqual(content, expected) self.assertEqual(content, expected)
os.unlink("test.hdf5") os.unlink("test.hdf5")
+5 -3
View File
@@ -5,7 +5,7 @@ from datetime import datetime
import numpy as np import numpy as np
from data.ADC_Result import ADC_Result from src.data.ADC_Result import ADC_Result
from src.data.Accumulation import Accumulation from src.data.Accumulation import Accumulation
@@ -54,7 +54,7 @@ class TestAccumulation(unittest.TestCase):
# TODO make testing strict with array types! # TODO make testing strict with array types!
np.testing.assert_array_equal(accu.x, np.array(x, dtype="float32"), strict=False) np.testing.assert_array_equal(accu.x, np.array(x, dtype="float32"), strict=False)
np.testing.assert_array_equal(accu.y[0], np.array(y[0], dtype="int16"), strict=False) np.testing.assert_array_equal(accu.y[0], np.array(y[0], dtype="int16"), strict=False)
np.testing.assert_equal(accu.y[1], np.array(y[1], dtype="int16"), strict=False) np.testing.assert_array_equal(accu.y[1], np.array(y[1], dtype="int16"), strict=False)
def test_add_adc_result(self): def test_add_adc_result(self):
"""Test adding sample space.""" """Test adding sample space."""
@@ -180,7 +180,9 @@ class TestAccumulation(unittest.TestCase):
# read back data with h5dump utility (apt-get -y install hdf5-tools) # read back data with h5dump utility (apt-get -y install hdf5-tools)
h5dump = subprocess.run(["h5dump", "-d", "/name/accu_data", "testaccu.hdf5"], capture_output=True) h5dump = subprocess.run(["h5dump", "-d", "/name/accu_data", "testaccu.hdf5"], capture_output=True)
content = h5dump.stdout.decode("utf-8") content = h5dump.stdout.decode("utf-8")
with open("tests/h5dump1_accu.ascii", "r") as f: # Use path relative to project root
test_dir = os.path.dirname(__file__)
with open(os.path.join(test_dir, "h5dump1_accu.ascii"), "r") as f:
expected = f.read() expected = f.read()
self.assertEqual(content, expected) self.assertEqual(content, expected)
os.unlink("testaccu.hdf5") os.unlink("testaccu.hdf5")