Skip to content

Commit

Permalink
Fix NotImplementedError in TestLaserSpectrum.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsnever committed Aug 9, 2023
1 parent 26452e9 commit 8a5ace6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cherab/core/laser/tests/test_laserspectrum.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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")
"with same boundaries and number of bins")

0 comments on commit 8a5ace6

Please sign in to comment.