Code tuning

This commit is contained in:
Lukas Klass 2020-04-24 11:46:16 +02:00
parent 33a6fd65c7
commit 1477072c2c

View File

@ -164,7 +164,7 @@ class SpectralQty:
raise TypeError("Units are not matching for addition.") raise TypeError("Units are not matching for addition.")
# Summand is of type lambda # Summand is of type lambda
elif isLambda(other): elif isLambda(other):
return SpectralQty(self.wl, self.qty + [other(wl).value for wl in self.wl] * other(self.wl[0]).unit) return SpectralQty(self.wl, self.qty + other(self.wl).value * other(self.wl[0]).unit)
# Summand is of type SpectralQty # Summand is of type SpectralQty
else: else:
if other.wl.unit.is_equivalent(self.wl.unit) and other.qty.unit.is_equivalent(self.qty.unit): if other.wl.unit.is_equivalent(self.wl.unit) and other.qty.unit.is_equivalent(self.qty.unit):
@ -211,7 +211,7 @@ class SpectralQty:
raise TypeError('Units are not matching for subtraction.') raise TypeError('Units are not matching for subtraction.')
# Subtrahend is of type lambda # Subtrahend is of type lambda
elif isLambda(other): elif isLambda(other):
return SpectralQty(self.wl, self.qty - [other(wl).value for wl in self.wl] * other(self.wl[0]).unit) return SpectralQty(self.wl, self.qty - other(self.wl).value * other(self.wl[0]).unit)
# Subtrahend is of type SpectralQty # Subtrahend is of type SpectralQty
else: else:
if other.wl.unit.is_equivalent(self.wl.unit) and other.qty.unit.is_equivalent(self.qty.unit): if other.wl.unit.is_equivalent(self.wl.unit) and other.qty.unit.is_equivalent(self.qty.unit):
@ -251,7 +251,7 @@ class SpectralQty:
return SpectralQty(self.wl, self.qty * other) return SpectralQty(self.wl, self.qty * other)
# Factor is of type lambda # Factor is of type lambda
elif isLambda(other): elif isLambda(other):
return SpectralQty(self.wl, self.qty * [other(wl).value for wl in self.wl] * other(self.wl[0]).unit) return SpectralQty(self.wl, self.qty * other(self.wl).value * other(self.wl[0]).unit)
# Factor is of type SpectralQty # Factor is of type SpectralQty
else: else:
if other.wl.unit.is_equivalent(self.wl.unit): if other.wl.unit.is_equivalent(self.wl.unit):
@ -293,7 +293,7 @@ class SpectralQty:
return SpectralQty(self.wl, self.qty / other) return SpectralQty(self.wl, self.qty / other)
# Factor is of type lambda # Factor is of type lambda
elif isLambda(other): elif isLambda(other):
return SpectralQty(self.wl, self.qty / [other(wl).value for wl in self.wl] * other(self.wl[0]).unit) return SpectralQty(self.wl, self.qty / other(self.wl).value * other(self.wl[0]).unit)
# Factor is of type SpectralQty # Factor is of type SpectralQty
else: else:
if other.wl.unit.is_equivalent(self.wl.unit): if other.wl.unit.is_equivalent(self.wl.unit):