From 8a5ace6ad5fc9a9365826cefe677d84c15b6afd4 Mon Sep 17 00:00:00 2001 From: Vladislav Neverov Date: Wed, 9 Aug 2023 12:43:15 +0300 Subject: [PATCH] Fix NotImplementedError in TestLaserSpectrum. --- cherab/core/laser/tests/test_laserspectrum.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cherab/core/laser/tests/test_laserspectrum.py b/cherab/core/laser/tests/test_laserspectrum.py index 9473e43d..6545f5c7 100644 --- a/cherab/core/laser/tests/test_laserspectrum.py +++ b/cherab/core/laser/tests/test_laserspectrum.py @@ -1,9 +1,11 @@ import unittest import numpy as np -from cherab.core.laser.laserspectrum import LaserSpectrum +# The evaluate() method is not implemented in the base LaserSpectrum, so importing the simplest subclass. +from cherab.core.model.laser.laserspectrum import ConstantSpectrum as LaserSpectrum from raysect.optical.spectrum import Spectrum + class TestLaserSpectrum(unittest.TestCase): def test_laserspectrum_init(self): @@ -24,12 +26,12 @@ def test_laserspectrum_init(self): msg="LaserSpectrum did not raise a ValueError with max_wavelength < min_wavelength."): LaserSpectrum(40, 30, 200) LaserSpectrum(30, 30, 200) - + # test bins > 0 with self.assertRaises(ValueError, - msg="LaserSpectrum did not raise a ValueError with max_wavelength < min_wavelength."): - LaserSpectrum(30, 30, 0) - LaserSpectrum(30, 30, -1) + msg="LaserSpectrum did not raise a ValueError with bins <= 0."): + LaserSpectrum(30, 40, 0) + LaserSpectrum(30, 40, -1) def test_laserspectrum_changes(self): laser_spectrum = LaserSpectrum(100, 200, 100) @@ -59,4 +61,4 @@ def test_laserspectrum_changes(self): # test caching of spectrum data, behaviour should be consistent with raysect.optical.spectrum.Spectrum self.assertTrue(np.array_equal(laser_spectrum.wavelengths, spectrum.wavelengths), "LaserSpectrum.wavelengths values are not equal to Spectrum.wavelengths " - "with same boundaries and number of bins") \ No newline at end of file + "with same boundaries and number of bins")