Public Access
fix return-value/deprecated API bugs, accumulation lock leaks, code cleanup
- raise instead of silent None for unsupported operands and empty negation - validate before acquiring lock in Accumulation operators (no RLock leak) - Accumulation._copy_provenance helper, ADC_Result._copy_metadata for all result paths - shared _sandbox_stdout_redirect contextmanager for sandboxed scripts - TemperatureMonitor dead code removal (gtk helper, traceback, unused properties) - new unit tests incl. lock-freedom regression test - gitignore sphinx generated doc/_autosummary/ and doc/damaris/
This commit is contained in:
1 parent
91ade4376c
commit
f9d8de7697
26 files changed
+590
-236
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from damaris.data.DamarisFFT import DamarisFFT
|
||||
|
||||
|
||||
class TestDamarisFFT(unittest.TestCase):
|
||||
@staticmethod
|
||||
def make_fft():
|
||||
fft = DamarisFFT()
|
||||
fft.sampling_rate = 100.0
|
||||
fft.x = np.arange(10, dtype="float32") / 100.0
|
||||
fft.y = [np.arange(10, dtype="float32")]
|
||||
fft.xlabel = "Time / s"
|
||||
return fft
|
||||
|
||||
def test_clip_without_arguments_is_placeholder(self):
|
||||
"""clip() without arguments returns self unchanged (placeholder use)."""
|
||||
fft = self.make_fft()
|
||||
self.assertIs(fft.clip(), fft)
|
||||
self.assertEqual(len(fft.x), 10)
|
||||
np.testing.assert_array_equal(fft.y[0], np.arange(10, dtype="float32"))
|
||||
|
||||
def test_clip_swaps_reversed_bounds(self):
|
||||
fft = self.make_fft()
|
||||
fft.clip(start=0.05, stop=0.01)
|
||||
expected_x = (np.arange(10, dtype="float32") / 100.0)[1:5]
|
||||
np.testing.assert_array_equal(fft.x, expected_x)
|
||||
np.testing.assert_array_equal(fft.y[0], np.arange(1, 5, dtype="float32"))
|
||||
|
||||
def test_clip_single_bound(self):
|
||||
fft = self.make_fft()
|
||||
fft.clip(start=0.02)
|
||||
self.assertEqual(len(fft.x), 7)
|
||||
self.assertEqual(len(fft.y[0]), 7)
|
||||
|
||||
def test_clip_too_close_raises(self):
|
||||
fft = self.make_fft()
|
||||
self.assertRaises(ValueError, fft.clip, 0.021, 0.029)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user