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