From 9376055240a0f01598e35fbf66c168084d647bf3 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Thu, 18 Jun 2020 09:02:49 +0200 Subject: [PATCH] Use numpy functions for equality check --- esbo_etc/classes/SpectralQty.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esbo_etc/classes/SpectralQty.py b/esbo_etc/classes/SpectralQty.py index 19e378e..e61c99a 100644 --- a/esbo_etc/classes/SpectralQty.py +++ b/esbo_etc/classes/SpectralQty.py @@ -6,6 +6,7 @@ import math from typing import Union, Callable import os from scipy.integrate import trapz +import numpy as np # noinspection PyUnresolvedReferences @@ -118,8 +119,8 @@ class SpectralQty: """ return self.wl.unit.is_equivalent(other.wl.unit) and self.qty.unit.is_equivalent(other.qty.unit) and \ len(self.wl) == len(other.wl) and len(self.qty) == len(other.qty) and \ - all([math.isclose(x, y, rel_tol=1e-5) for x, y in zip(self.wl.value, other.wl.to(self.wl.unit).value)]) and\ - all([math.isclose(x, y, rel_tol=1e-5) for x, y in zip(self.qty.value, other.qty.to(self.qty.unit).value)]) + np.allclose(self.wl.value, other.wl.to(self.wl.unit).value) and \ + np.allclose(self.qty.value, other.qty.to(self.qty.unit).value) def __add__(self, other: Union[int, float, u.Quantity, "SpectralQty", Callable[[u.Quantity], u.Quantity]]) ->\ "SpectralQty":