Skip to content

Commit a1e43ae

Browse files
committed
Fix missing argparse import in backreaction_demo.py
1 parent bc0a534 commit a1e43ae

3 files changed

Lines changed: 89 additions & 32 deletions

File tree

docs/progress_log.md

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
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:40:53 ./scripts/backreaction_demo.py
18+
2025-08-03 22:40:53 ./docs/progress_log.ndjson
19+
2025-08-03 22:37:57 ./docs/progress_log.md
1720
2025-08-03 22:37:40 ./tests/test_simulate_sensor_readout.py
1821
2025-08-03 22:37:40 ./scripts/simulate_sensor_readout.py
1922
2025-08-03 22:37:40 ./.github/workflows/ci.yml
20-
2025-08-03 22:34:27 ./docs/progress_log.md
21-
2025-08-03 22:34:16 ./scripts/backreaction_demo.py
22-
2025-08-03 22:34:16 ./docs/progress_log.ndjson
2323
2025-08-03 22:31:50 ./results/dynamic_evolution_metrics.json
2424
2025-08-03 22:31:49 ./results/dynamic_evolution.h5
2525
2025-08-03 22:31:32 ./tests/test_detection_threshold_uq.py
@@ -129,42 +129,97 @@ collecting ... collected 56 items
129129
130130
tests/test_analytical_solution.py::test_analytical_solution_massless PASSED [ 1%]
131131
tests/test_backreaction.py::test_solve_semiclassical_metric_shapes_and_initial_step PASSED [ 3%]
132-
tests/test_backreaction_export.py::test_backreaction_demo_export FAILED [ 5%]
132+
tests/test_backreaction_export.py::test_backreaction_demo_export PASSED [ 5%]
133+
tests/test_backreaction_stability.py::test_constant_source_growth_matches_theoretical PASSED [ 7%]
134+
tests/test_backreaction_uq.py::test_backreaction_uq_script PASSED [ 8%]
135+
tests/test_backreaction_uq_report.py::test_backreaction_uq_report_script PASSED [ 10%]
136+
tests/test_backreaction_wave.py::test_zero_source_remains_zero PASSED [ 12%]
137+
tests/test_dark_fluid.py::test_generate_negative_mass_fluid_defaults PASSED [ 14%]
138+
tests/test_dark_fluid.py::test_anec_negative_fluid PASSED [ 16%]
139+
tests/test_dark_fluid_demo.py::test_dark_fluid_demo_script PASSED [ 17%]
140+
tests/test_detection_threshold_uq.py::test_detection_threshold_uq PASSED [ 19%]
141+
tests/test_diagnostics.py::TestInterferometricProbe::test_frequency_response PASSED [ 21%]
142+
tests/test_diagnostics.py::TestInterferometricProbe::test_initialization PASSED [ 23%]
143+
tests/test_diagnostics.py::TestInterferometricProbe::test_phase_shift_calculation PASSED [ 25%]
144+
tests/test_diagnostics.py::TestInterferometricProbe::test_phase_shift_scaling PASSED [ 26%]
145+
tests/test_diagnostics.py::TestInterferometricProbe::test_simulate_pulse PASSED [ 28%]
146+
tests/test_diagnostics.py::TestCalorimetricSensor::test_initialization PASSED [ 30%]
147+
tests/test_diagnostics.py::TestCalorimetricSensor::test_simulate_pulse PASSED [ 32%]
148+
tests/test_diagnostics.py::TestCalorimetricSensor::test_temp_rise_calculation PASSED [ 33%]
149+
tests/test_diagnostics.py::TestPhaseShiftInterferometer::test_acquire PASSED [ 35%]
150+
tests/test_diagnostics.py::TestPhaseShiftInterferometer::test_frequency_sweep PASSED [ 37%]
151+
tests/test_diagnostics.py::TestPhaseShiftInterferometer::test_initialization PASSED [ 39%]
152+
tests/test_diagnostics.py::TestRealTimeDAQ::test_add_sample PASSED [ 41%]
153+
tests/test_diagnostics.py::TestRealTimeDAQ::test_circular_buffer PASSED [ 42%]
154+
tests/test_diagnostics.py::TestRealTimeDAQ::test_initialization PASSED [ 44%]
155+
tests/test_diagnostics.py::TestRealTimeDAQ::test_reset PASSED [ 46%]
156+
tests/test_diagnostics.py::TestRealTimeDAQ::test_statistics PASSED [ 48%]
157+
tests/test_diagnostics.py::TestRealTimeDAQ::test_trigger_modes PASSED [ 50%]
158+
tests/test_diagnostics.py::TestUtilityFunctions::test_benchmark_instrumentation_suite PASSED [ 51%]
159+
tests/test_diagnostics.py::TestUtilityFunctions::test_generate_T00_pulse PASSED [ 53%]
160+
tests/test_diagnostics.py::TestIntegration::test_complete_measurement_chain PASSED [ 55%]
161+
tests/test_diagnostics.py::TestIntegration::test_multi_sensor_comparison PASSED [ 57%]
162+
tests/test_dynamic_evolution.py::test_dynamic_energy_conservation PASSED [ 58%]
163+
tests/test_dynamic_evolution_accuracy.py::test_dynamic_evolution_energy_drift PASSED [ 60%]
164+
tests/test_dynamic_evolution_analysis.py::test_dynamic_evolution_analysis PASSED [ 62%]
165+
tests/test_dynamic_evolution_discretization.py::test_dynamic_evolution_discretization_accuracy PASSED [ 64%]
166+
tests/test_dynamic_evolution_export.py::test_dynamic_evolution_demo_export PASSED [ 66%]
167+
tests/test_dynamic_evolution_plot.py::test_dynamic_evolution_plot PASSED [ 67%]
168+
tests/test_dynamic_evolution_report.py::test_dynamic_evolution_report PASSED [ 69%]
169+
tests/test_energy_conservation.py::test_energy_conservation PASSED [ 71%]
170+
tests/test_evolve_qft.py::test_evolve_qft_fallback_identity PASSED [ 73%]
171+
tests/test_lattice_discretization.py::test_laplacian_accuracy_for_sine_wave PASSED [ 75%]
172+
tests/test_lattice_energy.py::test_compute_energy_density_zero_field PASSED [ 76%]
173+
tests/test_lattice_energy.py::test_solve_klein_gordon_basic PASSED [ 78%]
174+
tests/test_lattice_sweep_demo.py::test_lattice_sweep_demo PASSED [ 80%]
175+
tests/test_local_energy_resolution_uq.py::test_local_energy_resolution_uq PASSED [ 82%]
176+
tests/test_parameter_sweep_export.py::test_parameter_sweep_export PASSED [ 83%]
177+
tests/test_qft_backend.py::test_qft_backend_smoke PASSED [ 85%]
178+
tests/test_qft_backend_anec.py::test_compute_anec_and_check_anec_positive PASSED [ 87%]
179+
tests/test_qft_backend_anec.py::test_compute_anec_and_check_anec_negative PASSED [ 89%]
180+
tests/test_qft_backend_vnv.py::test_build_toy_ansatz_shape_and_values PASSED [ 91%]
181+
tests/test_qft_backend_vnv.py::test_local_energy_density_and_find_negative PASSED [ 92%]
182+
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%]
133184
134185
=================================== FAILURES ===================================
135-
________________________ test_backreaction_demo_export _________________________
186+
_________________________ test_simulate_sensor_readout _________________________
136187
137-
tmp_path = PosixPath('/tmp/pytest-of-echo_/pytest-56/test_backreaction_demo_export0')
138-
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7a322694d0f0>
188+
tmp_path = PosixPath('/tmp/pytest-of-echo_/pytest-57/test_simulate_sensor_readout0')
189+
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x74753c8a2b50>
139190
140-
def test_backreaction_demo_export(tmp_path, monkeypatch):
141-
# Ensure scripts are importable
142-
repo_root = pathlib.Path(__file__).parent.parent
143-
# Run backreaction_demo.py with cwd set to tmp_path
144-
result = subprocess.run(
145-
[sys.executable, str(repo_root / 'scripts' / 'backreaction_demo.py')],
146-
cwd=str(tmp_path),
147-
capture_output=True,
148-
text=True
149-
)
150-
> assert result.returncode == 0, f"Script failed: {result.stderr}"
151-
E AssertionError: Script failed: Traceback (most recent call last):
152-
E File "/home/echo_/Code/asciimath/negative-energy-generator/scripts/backreaction_demo.py", line 54, in <module>
153-
E main()
154-
E ~~~~^^
155-
E File "/home/echo_/Code/asciimath/negative-energy-generator/scripts/backreaction_demo.py", line 13, in main
156-
E parser = argparse.ArgumentParser(description="Backreaction demo CLI")
157-
E ^^^^^^^^
158-
E NameError: name 'argparse' is not defined. Did you forget to import 'argparse'?
159-
E
160-
E assert 1 == 0
161-
E + where 1 = CompletedProcess(args=['/home/echo_/Code/asciimath/negative-energy-generator/.venv/bin/python', '/home/echo_/Code/asciimath/negative-energy-generator/scripts/backreaction_demo.py'], returncode=1, stdout='', stderr='Traceback (most recent call last):\n File "/home/echo_/Code/asciimath/negative-energy-generator/scripts/backreaction_demo.py", line 54, in <module>\n main()\n ~~~~^^\n File "/home/echo_/Code/asciimath/negative-energy-generator/scripts/backreaction_demo.py", line 13, in main\n parser = argparse.ArgumentParser(description="Backreaction demo CLI")\n ^^^^^^^^\nNameError: name \'argparse\' is not defined. Did you forget to import \'argparse\'?\n').returncode
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
162214
163-
tests/test_backreaction_export.py:18: AssertionError
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
164219
=========================== short test summary info ============================
165-
FAILED tests/test_backreaction_export.py::test_backreaction_demo_export - Ass...
220+
FAILED tests/test_simulate_sensor_readout.py::test_simulate_sensor_readout - ...
166221
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
167-
========================= 1 failed, 2 passed in 1.68s ==========================
222+
======================== 1 failed, 53 passed in 10.29s =========================
168223
# PYTEST-RESULTS-END
169224
# Never skip a test if an import isn't available. Those tests should fail and the import should be fixed.
170225
~/Code/asciimath$ grep -r "importerskip" --include="*.py" . | wc -l

docs/progress_log.ndjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
{"date":"2025-08-12","event":"Updated CI to run backreaction UQ report script","status":"completed"}
5050
{"date":"2025-08-13","event":"Created dark fluid model module (`dark_fluid.py`) and unit tests","status":"completed"}
5151
{"date":"2025-08-13","event":"Created dark fluid demo script (`dark_fluid_demo.py`) and integration test","status":"completed"}
52+
{"date":"2025-08-03","event":"Fixed missing argparse import in backreaction_demo.py (test_backreaction_demo_export)","status":"completed"}
5253
{"date":"2025-08-01","event":"Identify and import functions (e.g., ANEC checks, vacuum energy models) from external repos into our modules","status":"pending"}
5354
{"date":"2025-08-01","event":"Update documentation with mappings of external modules to our negative-energy-generator framework","status":"pending"}
5455
{"date":"2025-08-01","event":"Analyze numerical stability of metric evolution and adjust solver parameters","status":"pending"}

scripts/backreaction_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Command-line demo for semiclassical backreaction: couples lattice QFT output to metric evolution solver.
44
"""
55
import os
6+
import argparse
67
import numpy as np
78
import h5py
89
from simulation.lattice_qft import solve_klein_gordon, compute_energy_density

0 commit comments

Comments
 (0)