diff --git a/src/damaris/data/ADC_Result.py b/src/damaris/data/ADC_Result.py index f55d4bc..bf71ba4 100644 --- a/src/damaris/data/ADC_Result.py +++ b/src/damaris/data/ADC_Result.py @@ -447,13 +447,12 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath): raise ValueError(f"ValueError: Cannot power raise \"{other.__class__}\" to ADC-Result!") def __truediv__(self, other): - "Redefining other (scalar) / self" + "Redefining self / other (scalar)" if isinstance(other, int) or isinstance(other, float): self.lock.acquire() tmp_y = [] - for i in range(self.get_number_of_channels()): - tmp_y.append(other / numpy.array(self.y[i], dtype="float32")) + tmp_y.append(numpy.array(self.y[i], dtype="float32") / other) 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() @@ -463,20 +462,27 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath): def __rtruediv__(self, other): "Redefining other (scalar) / self" - return self.__truediv__(other) + if isinstance(other, int) or isinstance(other, float): + self.lock.acquire() + tmp_y = [] + for i in range(self.get_number_of_channels()): + tmp_y.append(other / numpy.array(self.y[i], dtype="float32")) + 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(f"ValueError: Cannot divide \"{other.__class__}\" to ADC-Result!") def __floordiv__(self, other): - "Redefining other (scalar) / self" + "Redefining self // other (scalar)" if isinstance(other, float): - raise ValueError("ValueError: Cannot use floor division (//) on floats! Use \"//\" instead of \"/\"! ") + raise ValueError("ValueError: Cannot use floor division (//) on floats! Use \"/\" instead of \"//\"! ") if isinstance(other, int): self.lock.acquire() tmp_y = [] - for i in range(self.get_number_of_channels()): - tmp_y.append(other / numpy.array(self.y[i], dtype="float32")) - + tmp_y.append(numpy.array(self.y[i], dtype="float32") // other) 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 @@ -484,8 +490,20 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath): raise ValueError(f"ValueError: Cannot divide \"{other.__class__}\" to ADC-Result!") def __rfloordiv__(self, other): - "Redefining other (scalar) / self" - return self.__floordiv__(other) + "Redefining other (scalar) // self" + if isinstance(other, float): + raise ValueError("ValueError: Cannot use floor division (//) on floats! Use \"/\" instead of \"//\"! ") + + if isinstance(other, int): + self.lock.acquire() + tmp_y = [] + for i in range(self.get_number_of_channels()): + tmp_y.append(other // numpy.array(self.y[i], dtype="float32")) + 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(f"ValueError: Cannot divide \"{other.__class__}\" to ADC-Result!") def __neg__(self):