fixed a lot of Ruff errors and incorrect Accumulation returns in the overloaded operators
Build Debian Packages / build (bookworm, debian12) (push) Successful in 8m0s
Build Debian Packages / build (bullseye, debian11) (push) Successful in 7m14s
Build Debian Packages / build (trixie, debian13) (push) Has been cancelled

This commit is contained in:
2026-03-19 13:03:25 +01:00
parent df34447ef2
commit a591dfc161
9 changed files with 45 additions and 38 deletions
+1
View File
@@ -5,3 +5,4 @@ spool
__pycache__
*.egg-info
*.whl
.idea
+7 -3
View File
@@ -7,7 +7,6 @@ from .DamarisFFT import DamarisFFT
import threading
import numpy
import sys
import types
import datetime
import tables
#############################################################################
@@ -69,8 +68,10 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
print("Warning ADC-Result: Tried to run \"create_data_space()\" more than once.")
return
if channels <= 0: raise ValueError("ValueError: You cant create an ADC-Result with less than 1 channel!")
if samples <= 0: raise ValueError("ValueError: You cant create an ADC-Result with less than 1 sample!")
if channels <= 0:
raise ValueError("ValueError: You cant create an ADC-Result with less than 1 channel!")
if samples <= 0:
raise ValueError("ValueError: You cant create an ADC-Result with less than 1 sample!")
for i in range(channels):
self.y.append(numpy.zeros((samples,), dtype="int16"))
@@ -398,6 +399,8 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
return r
else:
raise ValueError("ValueError: Cannot multiply \"%s\" to ADC-Result!") % str(other.__class__)
@@ -450,6 +453,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
return r
else:
raise ValueError("ValueError: Cannot multiply \"%s\" to ADC-Result!") % str(other.__class__)
+4 -5
View File
@@ -41,7 +41,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
self.common_descriptions=None
self.time_period=[]
self.job_id = None # added by Oleg Petrov
self.job_id = None
self.use_error = error
@@ -513,9 +513,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
accu_group=None
self.lock.release()
# / Schnittstellen nach Außen ------------------------------------------------------------------
# Überladen von Operatoren ---------------------------------------------------------------------
# External interfaces ------------------------------------------------------------------
# Overloaded operators -----------------------------------------------------------------
def __len__(self):
"""
@@ -658,7 +657,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
r.time_period=other.time_period[:]
r.job_id = other.job_id # added by Oleg Petrov
if other.common_descriptions is not None:
r.common_descriptions=othter.common_descriptions.copy()
r.common_descriptions=other.common_descriptions.copy()
else:
r.common_descriptions=None
+9 -6
View File
@@ -15,8 +15,10 @@ class Config_Result(Resultable):
def __init__(self, config = None, desc = None, job_id = None, job_date = None):
Resultable.__init__(self)
if config is None: self.config = { }
if desc is None: self.description = { }
if config is None:
self.config = { }
if desc is None:
self.description = { }
self.job_id = job_id
self.job_date = job_date
@@ -31,8 +33,10 @@ class Config_Result(Resultable):
def get_config(self, key):
if key in self.config: return self.config[key]
else: return None
if key in self.config:
return self.config[key]
else:
return None
def set_config(self, key, value):
@@ -41,8 +45,7 @@ class Config_Result(Resultable):
self.config[key] = value
# Überladen von Operatoren und Built-Ins -------------------------------------------------------
# Ueberladen von Operatoren und Built-Ins -------------------------------------------------------
def __repr__(self):
return str(self.config)
+13 -11
View File
@@ -9,6 +9,9 @@
#############################################################################
class Errorable:
"""
Base class for data objects that can have data with errors.
"""
def __init__(self):
# Will be determined in one of the subclasses
@@ -22,12 +25,12 @@ class Errorable:
def get_xerr(self):
"Returns a reference to x-Error (array)"
"""Returns a reference to x-Error (array)"""
return self.xerr
def set_xerr(self, pos, value):
"Sets a point in x-Error"
"""Sets a point in x-Error"""
try:
self.xerr[pos] = value
except:
@@ -35,7 +38,7 @@ class Errorable:
def get_yerr(self, channel):
"Returns a list of y-Errors (list of arrays, corresponding channels)"
"""Returns a list of y-Errors (list of arrays, corresponding channels)"""
try:
return self.yerr[channel]
except:
@@ -43,7 +46,7 @@ class Errorable:
def set_yerr(self, channel, pos, value):
"Sets a point in y-Error"
"""Sets a point in y-Error"""
try:
self.yerr[channel][pos] = value
except:
@@ -51,26 +54,25 @@ class Errorable:
def get_error_color(self):
"Returns the error-bar color"
"""Returns the error-bar color"""
return self.error_color
def set_error_color(self, color):
"Sets the error-bar color"
"""Sets the error-bar color"""
self.error_color = color
def get_bars_above(self):
"Gets bars-above property of errorplot"
"""Gets bars-above property of errorplot"""
return self.bars_above
def set_bars_above(self, bars_above):
"Sets bars-above property of errorplot"
"""Sets bars-above property of errorplot"""
self.bars_above = bool(bars_above)
def ready_for_drawing_error(self):
"Returns true if more than one result have been accumulated"
if self.n >= 2: return True
else: return False
"""Returns true if more than one result have been accumulated"""
return self.n >= 2
@@ -3,8 +3,6 @@
from .Resultable import Resultable
from .Drawable import Drawable
from types import *
#############################################################################
# #
# Name: Class Temp_Result #
@@ -14,7 +12,11 @@ from types import *
# #
#############################################################################
class Temp_Result(Resultable, Drawable):
class TemperatureResult(Resultable, Drawable):
"""
Specialised class of Resultable and Drawable
Contains recorded temperature data
"""
def __init__(self, x = None, y = None, desc = None, job_id = None, job_date = None):
Resultable.__init__(self)
Drawable.__init__(self)
@@ -27,8 +29,3 @@ class Temp_Result(Resultable, Drawable):
else:
raise ValueError("Wrong usage of __init__!")
# Überladen von Operatoren und Built-Ins -------------------------------------------------------
# / Überladen von Operatoren und Built-Ins -----------------------------------------------------
+2 -1
View File
@@ -4,6 +4,7 @@ from damaris.data.MeasurementResult import MeasurementResult, AccumulatedValue
from damaris.data.DataPool import DataPool
from damaris.data.Error_Result import Error_Result
from damaris.data.Config_Result import Config_Result
from damaris.data.Temperature import TemperatureResult
__all__=["ADC_Result", "Accumulation", "MeasurementResult", "AccumulatedValue", "DataPool", "FFT", "Error_Result", "Config_Result" ]
__all__=["ADC_Result", "Accumulation", "MeasurementResult", "AccumulatedValue", "DataPool", "FFT", "Error_Result", "Config_Result", "TemperatureResult" ]
+1 -1
View File
@@ -1,4 +1,4 @@
from scipy.optimize import fmin_powell, bisect, ridder, brentq
from scipy.optimize import fmin_powell
import numpy as N
def calculate_entropy(phi, real, imag, gamma, dwell):
+1 -1
View File
@@ -26,7 +26,7 @@ from datetime import datetime
from damaris.data import ADC_Result
from damaris.data import Error_Result
from damaris.data import Temp_Result
from damaris.data import TemperatureResult
from damaris.data import Config_Result
class ResultReader: