mirror of
https://github.com/blackboxprogramming/native-ai-quantum-energy.git
synced 2026-03-17 08:57:22 -05:00
Remove NumPy dependency from quantum simulator and expand tests
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from native_ai_quantum_energy.energy_simulator import (
|
||||
battery_discharge,
|
||||
simulate_particle_collision,
|
||||
solar_panel_output,
|
||||
)
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
from native_ai_quantum_energy.energy_simulator import solar_panel_output
|
||||
|
||||
|
||||
def test_solar_panel_output_valid():
|
||||
@@ -20,3 +20,24 @@ def test_solar_panel_output_negative_power():
|
||||
def test_solar_panel_output_negative_hours():
|
||||
with pytest.raises(ValueError):
|
||||
solar_panel_output(10, -1)
|
||||
|
||||
|
||||
def test_battery_discharge_partial_consumption():
|
||||
remaining = battery_discharge(2000, 500, 2)
|
||||
assert remaining == pytest.approx(2000 - 1000)
|
||||
|
||||
|
||||
def test_battery_discharge_invalid_inputs():
|
||||
with pytest.raises(ValueError):
|
||||
battery_discharge(-1, 100, 1)
|
||||
|
||||
|
||||
def test_particle_collision_conserves_symmetry():
|
||||
v1_final, v2_final = simulate_particle_collision(1.0, 1.0, 1.0, -1.0)
|
||||
assert v1_final == pytest.approx(-1.0)
|
||||
assert v2_final == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_particle_collision_requires_positive_mass():
|
||||
with pytest.raises(ValueError):
|
||||
simulate_particle_collision(0.0, 1.0, 1.0, -1.0)
|
||||
|
||||
Reference in New Issue
Block a user