From 5e37c1baa3fe61542b6953817dc7cab43d3d0bb5 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Fri, 20 Mar 2026 16:47:53 +0100 Subject: [PATCH] clean up tests and folders --- src/data/Accumulation.py | 29 ++++++++++---------- src/gui/DamarisGUI.py | 5 +++- src/gui/ResultReader.py | 30 +++++++++++---------- {src/tests => tests}/debugging-gtk.sh | 0 {src/tests => tests}/gtk3test.py | 0 {src/tests => tests}/h5dump1_accu.ascii | 0 {src/tests => tests}/h5dump1_adc_data.ascii | 0 {src/tests => tests}/mpltest.py | 0 {src/tests => tests}/scripts/exp.py | 0 {src/tests => tests}/scripts/res.py | 0 {src/tests => tests}/test_ADC_Result.py | 0 {src/tests => tests}/test_Accumulation.py | 0 12 files changed, 35 insertions(+), 29 deletions(-) rename {src/tests => tests}/debugging-gtk.sh (100%) rename {src/tests => tests}/gtk3test.py (100%) rename {src/tests => tests}/h5dump1_accu.ascii (100%) rename {src/tests => tests}/h5dump1_adc_data.ascii (100%) rename {src/tests => tests}/mpltest.py (100%) rename {src/tests => tests}/scripts/exp.py (100%) rename {src/tests => tests}/scripts/res.py (100%) rename {src/tests => tests}/test_ADC_Result.py (100%) rename {src/tests => tests}/test_Accumulation.py (100%) diff --git a/src/data/Accumulation.py b/src/data/Accumulation.py index 9208a78..65eef09 100644 --- a/src/data/Accumulation.py +++ b/src/data/Accumulation.py @@ -65,7 +65,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): self.common_descriptions=None self.time_period=[] self.job_id = None # this does not make sense for an object accumulated from multiple job_ids - self.job_ids = [] + self.job_ids = {} self.use_error = error if self.uses_statistics(): @@ -498,8 +498,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): expectedrows=len(self.job_ids)) new_row=jobid_table.row for i,job_id in enumerate(self.job_ids): + new_row["job_date"] = self.job_ids[job_id].isoformat(timespec='milliseconds') new_row["job_id"]=job_id - new_row["job_date"]="Not Implemented" new_row.append() jobid_table.flush() # end save job_ids @@ -616,7 +616,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): r = Accumulation(x = numpy.array(self.x, dtype="float32"), y = tmp_y, y_2 = tmp_ysquare, n = self.n, index = self.index, sampl_freq = self.sampling_rate, error = self.use_error) else: r = Accumulation(x = numpy.array(self.x, dtype="float32"), y = tmp_y, n = self.n, index = self.index, sampl_freq = self.sampling_rate, error = self.use_error) - r.job_id = self.job_id # added by Oleg Petrov + r.job_id = self.job_id self.lock.release() return r @@ -626,7 +626,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): # todo: this is seems to be bugy!!!! (Achim) if not other.contains_data(): return - # Self empty (copy) + # Self empty (copy ADC_Result) if not self.contains_data(): tmp_y = [] tmp_ysquare = [] @@ -645,11 +645,11 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): r.time_period=[other.job_date,other.job_date] r.job_id = other.job_id r.common_descriptions=other.description.copy() - r.job_ids.append(other.job_id) + r.job_ids[other.job_id] = other.get_job_date() self.lock.release() return r - # Other and self not empty (self + other) + # Other and self not empty (self + other ADC_Result) else: self.lock.acquire() @@ -679,7 +679,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): max(self.time_period[1],other.job_date)] r.job_id = other.job_id r.job_ids = self.job_ids - r.job_ids.append(other.job_id) + r.job_ids[other.job_id] = other.get_job_date() if self.common_descriptions is not None: r.common_descriptions={} @@ -712,11 +712,11 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): tmp_ysquare.append(other.y_square[i]) r.time_period=other.time_period[:] r.job_id = other.job_id + r.job_ids = other.job_ids if other.common_descriptions is not None: r.common_descriptions=other.common_descriptions.copy() else: r.common_descriptions=None - self.lock.release() return r @@ -750,7 +750,9 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): r.time_period=[min(self.time_period[0],other.time_period[0]), max(self.time_period[1],other.time_period[1])] - r.job_id = other.job_id # added by Oleg Petrov + r.job_id = other.job_id + for i in other.job_ids: + r.job_ids[i] = other.job_ids[i] r.common_descriptions={} if self.common_descriptions is not None and other.common_descriptions is not None: for key in list(self.common_descriptions.keys()): @@ -817,13 +819,13 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): self.time_period=[other.job_date,other.job_date] self.job_id = other.job_id # added by Oleg Petrov - self.job_ids.append(other.job_id) + self.job_ids[other.job_id] = other.get_job_date() self.common_descriptions=other.description.copy() return self - # Other and self not empty (self + other) + # Other and self not empty (self + other/ADC_Result) else: self.lock.acquire() @@ -847,15 +849,14 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath): max(self.time_period[1],other.job_date)] self.job_id = other.job_id - self.job_ids.append(other.job_id) + + self.job_ids[other.job_id] = other.get_job_date() if self.common_descriptions is not None: for key in list(self.common_descriptions.keys()): if not (key in other.description and self.common_descriptions[key]==other.description[key]): del self.common_descriptions[key] - self.set_title(self.__title_pattern % self.n) self.lock.release() - return self # Accumulation diff --git a/src/gui/DamarisGUI.py b/src/gui/DamarisGUI.py index 95ffab1..b35cc71 100644 --- a/src/gui/DamarisGUI.py +++ b/src/gui/DamarisGUI.py @@ -905,9 +905,12 @@ class DamarisGUI: last_end = logtextbuffer.get_mark( "lastdumped" ) if last_end is None: last_end = logtextbuffer.create_mark( "lastdumped", logtextbuffer.get_start_iter( ), left_gravity=True ) - logtext_start = logtextbuffer.get_iter_at_mark( last_end ) + #logtext_start = logtextbuffer.get_iter_at_mark( last_end ) logtext_end = logtextbuffer.get_end_iter( ) logtextbuffer.move_mark( last_end, logtext_end ) + # Create new iterators after the mark move + logtext_start = logtextbuffer.get_iter_at_mark( last_end ) + logtext_end = logtextbuffer.get_end_iter( ) # recode from unicode logtext = logtextbuffer.get_text( logtext_start, logtext_end, True ) # avoid circular references (seems to be necessary with gtk-2.12) diff --git a/src/gui/ResultReader.py b/src/gui/ResultReader.py index 562fbb3..781af34 100644 --- a/src/gui/ResultReader.py +++ b/src/gui/ResultReader.py @@ -56,11 +56,14 @@ class ResultReader: yield self.get_result_object(expected_filename) # purge result file if self.clear_results: - if os.path.isfile(expected_filename): os.remove(expected_filename) + if os.path.isfile(expected_filename): + os.remove(expected_filename) if self.clear_jobs: - if os.path.isfile(expected_filename[:-7]): os.remove(expected_filename[:-7]) + # job_name.result -> job_name + if os.path.isfile(expected_filename[:-7]): + os.remove(expected_filename[:-7]) self.no+=1 - expected_filename=os.path.join(self.spool_dir,self.result_pattern%(self.no)) + expected_filename=os.path.join(self.spool_dir, self.result_pattern % self.no) return def get_result_object(self, in_filename): @@ -80,8 +83,10 @@ class ResultReader: time.sleep(0.05) retries+=1 - # get date of last modification - self.result_job_date = datetime.fromtimestamp(os.stat(in_filename)[8]) + # get date of last modification + stat_result = os.stat(in_filename) + mtime = stat_result.st_mtime + self.result_job_date = datetime.fromtimestamp(mtime) if ELEMENT_TREE: self.__parseFile = self.__parseFile_cETree else: @@ -155,7 +160,7 @@ class ResultReader: self.result.set_nChannels(int(elem.get("channels"))) self.result.set_description_dictionary(self.result_description.copy()) - title = "ADC-Result: job-id=%d"%int(self.result_job_number) + title = "ADC_Result: job-id=%d"%int(self.result_job_number) if len(self.result_description) > 0: for k,v in self.result_description.items(): title += ", %s=%s"%(k,v) @@ -166,22 +171,19 @@ class ResultReader: else: if float(elem.get("rate")) != self.result.get_sampling_rate(): print("sample rate different in ADC_Result, found %f, former value %f"%\ - (float(in_attribute["rate"]),self.result.get_sampling_rate())) + (float(elem.get("rate")),self.result.get_sampling_rate())) new_samples = int(elem.get("samples")) self.adc_result_sample_counter += new_samples - + + # extract adcdata (here base64 encoded) self.adc_result_trailing_chars = "".join(elem.text.splitlines()) tmp_string = base64.standard_b64decode(self.adc_result_trailing_chars) - self.adc_result_trailing_chars = None - tmp = numpy.fromstring(tmp_string,dtype='int16') - tmp_string = None + + tmp = numpy.fromstring(tmp_string, dtype='int16') self.adc_result_parts.append(tmp) - tmp = None # we do not need this adcdata anymore, delete it elem.clear() - - elif elem.tag == 'error': self.__filetype = ResultReader.ERROR_TYPE diff --git a/src/tests/debugging-gtk.sh b/tests/debugging-gtk.sh similarity index 100% rename from src/tests/debugging-gtk.sh rename to tests/debugging-gtk.sh diff --git a/src/tests/gtk3test.py b/tests/gtk3test.py similarity index 100% rename from src/tests/gtk3test.py rename to tests/gtk3test.py diff --git a/src/tests/h5dump1_accu.ascii b/tests/h5dump1_accu.ascii similarity index 100% rename from src/tests/h5dump1_accu.ascii rename to tests/h5dump1_accu.ascii diff --git a/src/tests/h5dump1_adc_data.ascii b/tests/h5dump1_adc_data.ascii similarity index 100% rename from src/tests/h5dump1_adc_data.ascii rename to tests/h5dump1_adc_data.ascii diff --git a/src/tests/mpltest.py b/tests/mpltest.py similarity index 100% rename from src/tests/mpltest.py rename to tests/mpltest.py diff --git a/src/tests/scripts/exp.py b/tests/scripts/exp.py similarity index 100% rename from src/tests/scripts/exp.py rename to tests/scripts/exp.py diff --git a/src/tests/scripts/res.py b/tests/scripts/res.py similarity index 100% rename from src/tests/scripts/res.py rename to tests/scripts/res.py diff --git a/src/tests/test_ADC_Result.py b/tests/test_ADC_Result.py similarity index 100% rename from src/tests/test_ADC_Result.py rename to tests/test_ADC_Result.py diff --git a/src/tests/test_Accumulation.py b/tests/test_Accumulation.py similarity index 100% rename from src/tests/test_Accumulation.py rename to tests/test_Accumulation.py