Public Access
normalize list/array handling in data classes
Establish one invariant across the Drawable hierarchy: x is always a numpy ndarray, y is always a list of per-channel ndarrays, and empty data is the same types with zero length. - Drawable: x starts as empty ndarray; min/max helpers return 0 on empty data instead of raising; drop contradictory isinstance(self.y, list) branches - ADC_Result/Accumulation: empty constructors build ndarray x; full constructors coerce x/y/y_square with numpy.asarray; Accumulation get_ydata/get_yerr return empty ndarrays and no longer crash on empty statistics-less accumulations - MeasurementResult: fix get_lineplotdata to return the accumulated means (previously the never-populated self.y, so the GUI line plot could never draw); remove dead float/int branches in CSV and HDF writers - Error_Result: get_xdata/get_ydata return ndarrays Add unittest coverage for the invariant, empty-state accessors, constructor coercion, line plot data, CSV output and HDF round-trip. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
35d040426b
commit
947c4c7f8d
10 files changed
+245
-58
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from damaris.data.Error_Result import Error_Result
|
||||
|
||||
|
||||
class TestErrorResult(unittest.TestCase):
|
||||
def test_plotdata_are_ndarrays(self):
|
||||
"""get_xdata/get_ydata must return numpy arrays like every Drawable."""
|
||||
er = Error_Result("core failed")
|
||||
self.assertIsInstance(er.get_xdata(), np.ndarray)
|
||||
self.assertIsInstance(er.get_ydata(), np.ndarray)
|
||||
np.testing.assert_array_equal(er.get_xdata(), [0.0])
|
||||
np.testing.assert_array_equal(er.get_ydata(), [0.0])
|
||||
|
||||
def test_add_returns_self(self):
|
||||
er = Error_Result("msg")
|
||||
self.assertIs(er + 1, er)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user