Skip to content

Commit 81cba18

Browse files
committed
Fix NameError in sensor readout test by adding missing pytest import
1 parent a1e43ae commit 81cba18

2 files changed

Lines changed: 9 additions & 43 deletions

File tree

docs/progress_log.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
```file-history
1515
~/Code/asciimath/negative-energy-generator$ find . -path "./.venv" -prune -o -type f -regex '.*\.\(ps1\|py\|sh\|ndjson\|json\|md\|yml\|toml\|h5\|ini\)$' -print | while read file; do stat -c '%Y %n' "$file"; done | sort -nr | while read timestamp file; do echo "$(date -d @$timestamp '+%Y-%m-%d %H:%M:%S') $file"; done | head -n 40
1616
# LATEST-FILES-LIST-BEGIN
17+
2025-08-03 22:43:58 ./tests/test_simulate_sensor_readout.py
18+
2025-08-03 22:43:46 ./results/dynamic_evolution_metrics.json
19+
2025-08-03 22:43:45 ./results/dynamic_evolution.h5
20+
2025-08-03 22:41:08 ./docs/progress_log.md
1721
2025-08-03 22:40:53 ./scripts/backreaction_demo.py
1822
2025-08-03 22:40:53 ./docs/progress_log.ndjson
19-
2025-08-03 22:37:57 ./docs/progress_log.md
20-
2025-08-03 22:37:40 ./tests/test_simulate_sensor_readout.py
2123
2025-08-03 22:37:40 ./scripts/simulate_sensor_readout.py
2224
2025-08-03 22:37:40 ./.github/workflows/ci.yml
23-
2025-08-03 22:31:50 ./results/dynamic_evolution_metrics.json
24-
2025-08-03 22:31:49 ./results/dynamic_evolution.h5
2525
2025-08-03 22:31:32 ./tests/test_detection_threshold_uq.py
2626
2025-08-03 22:30:00 ./scripts/detection_threshold_uq.py
2727
2025-08-03 22:26:19 ./tests/test_local_energy_resolution_uq.py
@@ -180,46 +180,11 @@ tests/test_qft_backend_anec.py::test_compute_anec_and_check_anec_negative PASSED
180180
tests/test_qft_backend_vnv.py::test_build_toy_ansatz_shape_and_values PASSED [ 91%]
181181
tests/test_qft_backend_vnv.py::test_local_energy_density_and_find_negative PASSED [ 92%]
182182
tests/test_qft_toy_ansatz_uq.py::test_qft_toy_ansatz_uq_script PASSED [ 94%]
183-
tests/test_simulate_sensor_readout.py::test_simulate_sensor_readout FAILED [ 96%]
183+
tests/test_simulate_sensor_readout.py::test_simulate_sensor_readout PASSED [ 96%]
184+
tests/test_time_integration_basic.py::test_solve_klein_gordon_shapes_and_values PASSED [ 98%]
185+
tests/test_zero_initial_condition.py::test_zero_initial_condition PASSED [100%]
184186
185-
=================================== FAILURES ===================================
186-
_________________________ test_simulate_sensor_readout _________________________
187-
188-
tmp_path = PosixPath('/tmp/pytest-of-echo_/pytest-57/test_simulate_sensor_readout0')
189-
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x74753c8a2b50>
190-
191-
def test_simulate_sensor_readout(tmp_path, monkeypatch):
192-
# Create dummy HDF5 with energies dataset
193-
import h5py
194-
import numpy as np
195-
data_file = tmp_path / 'energies.h5'
196-
with h5py.File(data_file, 'w') as f:
197-
f.create_dataset('energies', data=np.linspace(0,1,10))
198-
# Run CLI tool
199-
output_file = tmp_path / 'sensor_readout.json'
200-
script = pathlib.Path(__file__).parent.parent / 'scripts' / 'simulate_sensor_readout.py'
201-
cmd = [sys.executable, str(script),
202-
'--data', str(data_file),
203-
'--noise-std', '0.0',
204-
'--gain', '2.0',
205-
'--seed', '0',
206-
'--output', str(output_file)]
207-
subprocess.check_call(cmd)
208-
data = json.loads(output_file.read_text())
209-
assert data['gain'] == 2.0
210-
assert data['noise_std'] == 0.0
211-
> assert data['mean_reading'] == pytest.approx(np.mean(np.linspace(0,1,10))*2.0)
212-
^^^^^^
213-
E NameError: name 'pytest' is not defined
214-
215-
tests/test_simulate_sensor_readout.py:26: NameError
216-
----------------------------- Captured stdout call -----------------------------
217-
Sensor readout simulation saved to /tmp/pytest-of-echo_/pytest-57/test_simulate_sensor_readout0/sensor_readout.json
218-
Mean reading: 1.000000, Std: 0.638285
219-
=========================== short test summary info ============================
220-
FAILED tests/test_simulate_sensor_readout.py::test_simulate_sensor_readout - ...
221-
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
222-
======================== 1 failed, 53 passed in 10.29s =========================
187+
============================= 56 passed in 10.50s ==============================
223188
# PYTEST-RESULTS-END
224189
# Never skip a test if an import isn't available. Those tests should fail and the import should be fixed.
225190
~/Code/asciimath$ grep -r "importerskip" --include="*.py" . | wc -l

tests/test_simulate_sensor_readout.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import pytest
23
import subprocess
34
import sys
45
import pathlib

0 commit comments

Comments
 (0)