Use numpy functions for equality check

This commit is contained in:
Lukas Klass 2020-06-18 09:02:49 +02:00
parent 9367c93743
commit 9376055240
1 changed files with 3 additions and 2 deletions

View File

@ -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":