summaryrefslogtreecommitdiffstats
path: root/lab_control
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-06-03 17:47:50 +0200
committerEddy Pedroni <eddy@0xf7.com>2022-06-03 17:47:50 +0200
commit1aec3bacaab2991121e0c00d147fd418cdbfbc17 (patch)
treef347c36ca1191878e87e0a72b25a3d8a4ba51d36 /lab_control
parent8e9563b7b067f549ea539b56eb14e6624b236acb (diff)
Improved CSV dump
Diffstat (limited to 'lab_control')
-rw-r--r--lab_control/frequency_response.py3
-rw-r--r--lab_control/test/frequency_response_test.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/lab_control/frequency_response.py b/lab_control/frequency_response.py
index af78840..6508d80 100644
--- a/lab_control/frequency_response.py
+++ b/lab_control/frequency_response.py
@@ -26,6 +26,9 @@ class FrequencyResponseMeasurement(Measurement):
self.measurementDone = True
def dumpToCSV(self, path: Path) -> None:
+ if self.data is None:
+ return
+
with open(path, "w") as f:
f.write("Frequency (Hz),Amplitude (V)")
diff --git a/lab_control/test/frequency_response_test.py b/lab_control/test/frequency_response_test.py
index ad47d53..2997413 100644
--- a/lab_control/test/frequency_response_test.py
+++ b/lab_control/test/frequency_response_test.py
@@ -58,11 +58,15 @@ def test_dumpToCSV(uut, mockLab, tmp_path):
uut.minFrequency = 10.0
uut.maxFrequency = 30.0
uut.steps = 5
+ csv = tmp_path / "data.csv"
+
+ assert not csv.exists()
+ uut.dumpToCSV(csv)
+ assert not csv.exists()
expectedData = prepareRampResponse(uut, mockLab)
uut.measure(mockLab, mockLab)
- csv = tmp_path / "data.csv"
uut.dumpToCSV(csv)
savedData = csv.read_text().split("\n")