diff --git a/benchmark_accuracy.py b/benchmark_accuracy.py index d7c752f..36f07b0 100644 --- a/benchmark_accuracy.py +++ b/benchmark_accuracy.py @@ -13,11 +13,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, diff --git a/benchmark_adaptive_twophase.py b/benchmark_adaptive_twophase.py index 3e8ff4b..975719e 100644 --- a/benchmark_adaptive_twophase.py +++ b/benchmark_adaptive_twophase.py @@ -18,11 +18,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 adaptive_control_parameters, compute_ds2, compute_gradient, @@ -288,11 +288,11 @@ def main(): ) * 100 print("IMPROVEMENTS:") - print(f" vs Fixed Fast:") + print(" vs Fixed Fast:") print(f" • {vs_fast_precision:+.1f}% better precision") print(f" • Similar speed (both reach 10cm in ~{adaptive_ticks_to_10cm} ticks)") print() - print(f" vs Fixed Ultra-Slow:") + print(" vs Fixed Ultra-Slow:") print(f" • {vs_ultraslow_speed:+.1f}% faster to 10cm") print( f" • Similar precision ({adaptive_final_error:.1f}mm vs {ultraslow_final_error:.1f}mm)" @@ -315,7 +315,7 @@ def main(): print( f" Adaptive control spent only {terminal_phase_ticks/len(df_adaptive)*100:.1f}% of time in slow mode," ) - print(f" but achieved precision comparable to 100% ultra-slow!") + print(" but achieved precision comparable to 100% ultra-slow!") print() print("=" * 80) diff --git a/benchmark_dynamic.py b/benchmark_dynamic.py index 8aef420..095eeda 100644 --- a/benchmark_dynamic.py +++ b/benchmark_dynamic.py @@ -17,11 +17,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -216,7 +216,7 @@ def analyze_tracking(df, scenario_name): return metrics -def main(): +def main(): # noqa: C901 print("=" * 80) print("DYNAMIC SCENARIOS: Moving Targets and Obstacles".center(80)) print("=" * 80) diff --git a/benchmark_dynamic_adaptation.py b/benchmark_dynamic_adaptation.py index dbfbd6e..0090da8 100644 --- a/benchmark_dynamic_adaptation.py +++ b/benchmark_dynamic_adaptation.py @@ -48,17 +48,14 @@ def simulate_robot_control( # Heavy robot: slow movements, needs small eta velocity_scale = 0.1 noise_level = 0.05 - optimal_eta = 0.05 elif robot_type == "fast": # Agile robot: fast movements, can handle large eta velocity_scale = 2.0 noise_level = 0.2 - optimal_eta = 0.3 else: # medium # Baseline robot velocity_scale = 0.5 noise_level = 0.1 - optimal_eta = 0.1 state = initial_state.copy() trajectory = [state.copy()] @@ -240,17 +237,17 @@ def run_benchmark(): all_results[robot_type] = results - print(f" Convergence Time:") + print(" Convergence Time:") print(f" Adaptive: {avg_conv_adaptive:.1f} steps") print(f" Fixed: {avg_conv_fixed:.1f} steps") print(f" Improvement: {conv_improvement:+.1f}%") print() - print(f" Final Error:") + print(" Final Error:") print(f" Adaptive: {avg_err_adaptive:.4f}") print(f" Fixed: {avg_err_fixed:.4f}") print(f" Improvement: {error_improvement:+.1f}%") print() - print(f" Auto-Detected Parameters:") + print(" Auto-Detected Parameters:") print(f" c (characteristic velocity): {avg_c:.3f}") print(f" eta (recommended): {avg_eta:.3f}") print(f" confidence: {avg_confidence:.3f}") diff --git a/benchmark_geodesic_planning.py b/benchmark_geodesic_planning.py index 240e828..8e2c04c 100644 --- a/benchmark_geodesic_planning.py +++ b/benchmark_geodesic_planning.py @@ -227,17 +227,17 @@ def run_benchmark(): all_results[scenario_name] = results - print(f" Success Rate:") + print(" Success Rate:") print(f" Naive: {naive_success_rate:.1f}%") print(f" Geodesic: {geo_success_rate:.1f}%") print(f" Improvement: {success_improvement:+.1f}%") print() - print(f" Collisions:") + print(" Collisions:") print(f" Naive: {naive_avg_collisions:.2f}") print(f" Geodesic: {geo_avg_collisions:.2f}") print(f" Reduction: {collision_reduction:+.1f}%") print() - print(f" Path Length:") + print(" Path Length:") print(f" Naive: {naive_avg_length:.2f}") print(f" Geodesic: {geo_avg_length:.2f}") print() diff --git a/benchmark_landing.py b/benchmark_landing.py index 19e2d7f..5686309 100644 --- a/benchmark_landing.py +++ b/benchmark_landing.py @@ -25,11 +25,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -236,7 +236,7 @@ def analyze_landing(df, scenario_name): return metrics -def main(): +def main(): # noqa: C901 print("=" * 80) print("AUTONOMOUS LANDING: Moving Platform Scenarios".center(80)) print("=" * 80) diff --git a/benchmark_mars_landing.py b/benchmark_mars_landing.py index 89701bf..ffccfa6 100644 --- a/benchmark_mars_landing.py +++ b/benchmark_mars_landing.py @@ -27,11 +27,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -229,7 +229,7 @@ def analyze_mars_landing(df, scenario_name, safe_zone_radius=0.015): return metrics -def main(): +def main(): # noqa: C901 print("=" * 80) print("MARS LANDING: Mission-Critical Precision Landing".center(80)) print("=" * 80) @@ -466,7 +466,7 @@ def sample_return_site(t): baseline_successes = sum(1 for r in results if r["baseline"]["mission_success"]) lightlike_successes = sum(1 for r in results if r["lightlike"]["mission_success"]) - print(f"MISSION SUCCESS RATE:") + print("MISSION SUCCESS RATE:") print( f" Baseline: {baseline_successes}/{len(results)} missions successful ({baseline_successes/len(results)*100:.0f}%)" ) @@ -503,7 +503,7 @@ def sample_return_site(t): if lightlike_successes > baseline_successes or total_oscillation_reduction > 5: print("★★★ MISSION-CRITICAL IMPROVEMENT ★★★") print() - print(f"The lightlike observer SAVES MISSIONS:") + print("The lightlike observer SAVES MISSIONS:") print(f" • {lightlike_successes - baseline_successes} additional successful landing(s)") print(f" • {total_oscillation_reduction} fewer descent oscillations") print(f" • {avg_precision_improvement:.1f}% better landing precision") diff --git a/benchmark_moving_targets.py b/benchmark_moving_targets.py index 5578bad..dd2c308 100644 --- a/benchmark_moving_targets.py +++ b/benchmark_moving_targets.py @@ -12,10 +12,7 @@ import matplotlib.pyplot as plt import numpy as np -from src.eigen_lorentz import ( - estimate_target_velocity, - moving_target_control_step, -) +from src.eigen_lorentz import moving_target_control_step def simulate_moving_target_tracking( diff --git a/benchmark_qec.py b/benchmark_qec.py index 0c34bb3..0a4f947 100644 --- a/benchmark_qec.py +++ b/benchmark_qec.py @@ -18,7 +18,6 @@ import numpy as np from src.eigen_qec import ( - correct_measurement_errors, qec_control_step, simulate_sensor_array, ) @@ -191,7 +190,7 @@ def run_benchmark(): all_results[failure_rate] = results - print(f" Final Error:") + print(" Final Error:") print(f" Naive: {avg_error_naive:.3f}") print(f" QEC: {avg_error_qec:.3f}") print(f" Improvement: {error_improvement:+.1f}%") diff --git a/benchmark_scaling.py b/benchmark_scaling.py index da154f3..e414601 100644 --- a/benchmark_scaling.py +++ b/benchmark_scaling.py @@ -17,11 +17,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -188,7 +188,7 @@ def analyze_precision(df_baseline, df_lightlike, target, scenario_name): } -def main(): +def main(): # noqa: C901 print("=" * 80) print("SCALING ANALYSIS: Lightlike Observer Benefits vs Complexity".center(80)) print("=" * 80) @@ -306,7 +306,7 @@ def main(): ) print() print("For 3D robot control (6-DOF or 7-DOF):") - print(f" • Configuration space: 2D → 6D or 7D (3-3.5x more dimensions)") + print(" • Configuration space: 2D → 6D or 7D (3-3.5x more dimensions)") print( f" • Expected improvement: ~{avg_improvement * 3:.1f}% to {avg_improvement * 3.5:.1f}%" ) diff --git a/benchmark_self_tuning.py b/benchmark_self_tuning.py index 501658e..d8b25a8 100644 --- a/benchmark_self_tuning.py +++ b/benchmark_self_tuning.py @@ -11,7 +11,6 @@ import numpy as np from src.eigen_meta_control import self_tuning_control_step -from src.eigen_similarity import lightlike_damping_factor def gradient_step_with_damping( @@ -192,9 +191,9 @@ def main(): print("=" * 70) print() print("Key Results:") - print(f" 1. No infinite loops despite self-reference (TC+ property ✓)") + print(" 1. No infinite loops despite self-reference (TC+ property ✓)") print(f" 2. Parameters self-adjusted in {len(params2)-1} iterations") - print(f" 3. Recovered from bad initial params automatically") + print(" 3. Recovered from bad initial params automatically") print() print("Computational Implications:") print(" • System observes itself: a = current_params") diff --git a/benchmark_stereo_lorentz.py b/benchmark_stereo_lorentz.py index 842300a..fa13965 100644 --- a/benchmark_stereo_lorentz.py +++ b/benchmark_stereo_lorentz.py @@ -22,11 +22,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -34,8 +34,7 @@ forward_kinematics, lightlike_damping_factor, ) -from src.eigen_lorentz import ( - lorentz_to_stereo, +from src.eigen_lorentz import ( # noqa: E402 regime_classification, stereo_to_lorentz, ) diff --git a/benchmark_terminal_descent.py b/benchmark_terminal_descent.py index a1a4ea8..eb5109d 100644 --- a/benchmark_terminal_descent.py +++ b/benchmark_terminal_descent.py @@ -20,11 +20,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -228,7 +228,6 @@ def main(): # Find best precision best = min(results, key=lambda r: r["light_final_mm"]) - worst = max(results, key=lambda r: r["base_final_mm"]) print("KEY FINDINGS:") print() @@ -238,7 +237,7 @@ def main(): print(f" - Configuration: eta={best['eta']}, {best['ticks']} iterations") print() - print(f"2. PRECISION SCALING:") + print("2. PRECISION SCALING:") fast_precision = results[0]["base_final_mm"] slow_precision = results[-1]["base_final_mm"] precision_gain = (fast_precision - slow_precision) / fast_precision * 100 @@ -247,7 +246,7 @@ def main(): print(f" - Improvement from slowing down: {precision_gain:.1f}%") print() - print(f"3. LIGHTLIKE OBSERVER BENEFIT:") + print("3. LIGHTLIKE OBSERVER BENEFIT:") avg_improvement = sum(r["improvement_pct"] for r in results) / len(results) print(f" - Average improvement across all speeds: {avg_improvement:+.1f}%") @@ -260,7 +259,7 @@ def main(): # Oscillation analysis total_osc_reduction = sum(r["base_oscillations"] - r["light_oscillations"] for r in results) - print(f"4. STABILITY:") + print("4. STABILITY:") print(f" - Total oscillation reduction: {total_osc_reduction:+d} events") print() diff --git a/benchmark_visual_servoing.py b/benchmark_visual_servoing.py index 2e0b494..b7c8984 100644 --- a/benchmark_visual_servoing.py +++ b/benchmark_visual_servoing.py @@ -22,11 +22,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -262,7 +262,7 @@ def analyze_visual_servoing(df, scenario_name): return metrics -def main(): +def main(): # noqa: C901 print("=" * 80) print("VISUAL SERVOING: Stereo Vision + Lightlike Observer".center(80)) print("=" * 80) diff --git a/benchmark_weak_stereo_noisy.py b/benchmark_weak_stereo_noisy.py index 668b3ee..e0a485b 100644 --- a/benchmark_weak_stereo_noisy.py +++ b/benchmark_weak_stereo_noisy.py @@ -158,7 +158,6 @@ def run_noisy_benchmark(): print() weakest = results["Weak (0.05)"] - weak = results["Weak (0.1)"] strong = results["Strong (0.9)"] # Compare weakest vs strong @@ -170,7 +169,7 @@ def run_noisy_benchmark(): ) error_improvement = (strong["error_mean"] - weakest["error_mean"]) / strong["error_mean"] * 100 - print(f"WEAK (0.05) vs STRONG (0.9):") + print("WEAK (0.05) vs STRONG (0.9):") print("-" * 40) print(f"Coherence: {coherence_improvement:+.1f}% (higher is smoother)") print(f" Weak: {weakest['coherence_mean']:.4f}") diff --git a/benchmark_xor.py b/benchmark_xor.py index ec4784b..dc96af8 100644 --- a/benchmark_xor.py +++ b/benchmark_xor.py @@ -10,11 +10,11 @@ import numpy as np -sys.path.insert(0, "/home/user/Eigen-Geometric-Control") +sys.path.insert(0, "/home/user/Eigen-Geometric-Control") # noqa: E402 -import pandas as pd +import pandas as pd # noqa: E402 -from src import ( +from src import ( # noqa: E402 compute_change_stability, compute_ds2, compute_gradient, @@ -151,6 +151,10 @@ def main(): print("1. Running baseline XOR (v1.0.0 algorithm)...") df_baseline = run_xor_simulation(n_ticks=40) + # Run with lightlike observer + print("2. Running with lightlike observer...") + df_lightlike = run_xor_with_lightlike_damping(n_ticks=40) + # Note: XOR rotation is a bit-level operation, not robot arm control # The lightlike observer is not applicable to this discrete bit-flip problem print() diff --git a/src/eigen_geodesic.py b/src/eigen_geodesic.py index 687adb9..989e7e1 100644 --- a/src/eigen_geodesic.py +++ b/src/eigen_geodesic.py @@ -16,7 +16,7 @@ - Integration with lightlike damping framework """ -from typing import List, Optional, Tuple +from typing import List, Tuple import numpy as np diff --git a/src/eigen_meta_control.py b/src/eigen_meta_control.py index 9fd935e..d5a8d74 100644 --- a/src/eigen_meta_control.py +++ b/src/eigen_meta_control.py @@ -17,7 +17,7 @@ import numpy as np -from .eigen_similarity import detect_oscillation, standard_cosine_similarity +from .eigen_similarity import detect_oscillation def observe_parameter_performance( diff --git a/src/eigen_multi_agent.py b/src/eigen_multi_agent.py index cdf7777..58b1852 100644 --- a/src/eigen_multi_agent.py +++ b/src/eigen_multi_agent.py @@ -18,7 +18,7 @@ import numpy as np -from .eigen_similarity import detect_oscillation, lorentz_similarity +from .eigen_similarity import detect_oscillation def collective_lightlike_observer( @@ -272,7 +272,6 @@ def simulate_multi_agent( - info_history: Diagnostic info at each step - converged: Did all agents reach their targets? """ - n_agents = len(initial_states) # Initialize current_states = [s.copy() for s in initial_states] diff --git a/src/eigen_qec.py b/src/eigen_qec.py index 17da8a2..420b822 100644 --- a/src/eigen_qec.py +++ b/src/eigen_qec.py @@ -176,7 +176,7 @@ def compute_parity_checks( return np.array(syndromes) -def detect_error_location( +def detect_error_location( # noqa: C901 syndromes: np.ndarray, threshold: float = 0.5, ) -> Optional[int]: diff --git a/tests/test_adaptive_control.py b/tests/test_adaptive_control.py index 8ce0914..6aade74 100644 --- a/tests/test_adaptive_control.py +++ b/tests/test_adaptive_control.py @@ -1,10 +1,10 @@ +import pytest # -*- coding: utf-8 -*- """ Tests for adaptive two-phase control parameters """ import numpy as np -import pytest from src import adaptive_control_parameters diff --git a/tests/test_coherent_decomposition.py b/tests/test_coherent_decomposition.py index 2458e1e..bce04ab 100644 --- a/tests/test_coherent_decomposition.py +++ b/tests/test_coherent_decomposition.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_decomposition import ( coherence_score, @@ -194,7 +193,7 @@ def test_coherent_signal_minimal_filtering(self): filtered, info = filtered_observation(observation, history, noise_suppression=0.8) # Should be classified as coherent - assert info["is_coherent"] == True + assert info["is_coherent"] is True # Should be close to original (little noise to suppress) assert np.linalg.norm(filtered - observation) < 0.5 @@ -226,7 +225,7 @@ def test_incoherent_signal_high_suppression(self): filtered, info = filtered_observation(observation, history, noise_suppression=0.9) # Should be classified as incoherent - assert info["is_coherent"] == False + assert info["is_coherent"] is False # Filtered should be heavily suppressed (near zero) assert np.linalg.norm(filtered) < np.linalg.norm(observation) @@ -301,7 +300,7 @@ def test_coherent_trajectory_uses_observation(self): ) # Should be classified as coherent - assert info["is_coherent"] == True + assert info["is_coherent"] is True # Should trust and use the observation assert info["noise_reduction"] < 0.5 # Little filtering needed @@ -327,22 +326,7 @@ def test_filtering_reduces_noise_sensitivity(self): current, target, noisy_obs, history, eta=0.2, noise_suppression=0.9 ) - # Control WITHOUT filtering (naive) - # Simulate by using observation directly - blend = 0.5 - naive_state = blend * noisy_obs + (1 - blend) * current - direction = target - naive_state - new_naive = naive_state + 0.2 * direction - - # Filtered should be closer to smooth trajectory - expected_next = current + (target - current) * 0.2 - - dist_filter = np.linalg.norm(new_with_filter - expected_next) - dist_naive = np.linalg.norm(new_naive - expected_next) - - # Filtered should deviate less from expected smooth trajectory - # (This test may be probabilistic due to random noise) - # We just check that filtering was applied + # We just check that filtering was applied and reduced noise assert info_filter["noise_reduction"] > 0.1 diff --git a/tests/test_dynamic_invariant.py b/tests/test_dynamic_invariant.py index ef59fcb..15338ea 100644 --- a/tests/test_dynamic_invariant.py +++ b/tests/test_dynamic_invariant.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_adaptive import ( adaptive_control_step, @@ -270,7 +269,7 @@ def test_auto_tuning_detects_parameters(self): ) # Should have detected parameters - assert info["parameters_detected"] == True + assert info["parameters_detected"] is True assert info["c"] > 0 assert info["confidence"] > 0 @@ -283,7 +282,7 @@ def test_insufficient_samples_uses_defaults(self): new_state, info = adaptive_control_step(current, target, history, auto_tune=True) # Should use defaults - assert info["parameters_detected"] == False + assert info["parameters_detected"] is False assert info["c"] == 1.0 assert info["confidence"] == 0.0 @@ -306,7 +305,7 @@ def test_auto_tune_disabled_uses_defaults(self): new_state, info = adaptive_control_step(current, target, history, auto_tune=False) - assert info["parameters_detected"] == False + assert info["parameters_detected"] is False class TestRenormalizeLorentzState: diff --git a/tests/test_eigen_core.py b/tests/test_eigen_core.py index a013c33..ad7884f 100644 --- a/tests/test_eigen_core.py +++ b/tests/test_eigen_core.py @@ -6,7 +6,7 @@ import sys -sys.path.insert(0, ".") +sys.path.insert(0, ".") # noqa: E402 import numpy as np import pytest diff --git a/tests/test_eigen_noperthedron.py b/tests/test_eigen_noperthedron.py index 0cb7e5d..14ef4b9 100644 --- a/tests/test_eigen_noperthedron.py +++ b/tests/test_eigen_noperthedron.py @@ -1,3 +1,4 @@ +import pytest # -*- coding: utf-8 -*- """ Tests for Noperthedron analysis module @@ -7,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_noperthedron import ( PassageAttempt, diff --git a/tests/test_frequency_selective_damping.py b/tests/test_frequency_selective_damping.py index 0a9cd88..6382679 100644 --- a/tests/test_frequency_selective_damping.py +++ b/tests/test_frequency_selective_damping.py @@ -1,10 +1,10 @@ +import pytest # -*- coding: utf-8 -*- """ Tests for frequency-selective damping """ import numpy as np -import pytest from src import detect_oscillation_frequency, frequency_selective_damping diff --git a/tests/test_geodesic_planning.py b/tests/test_geodesic_planning.py index 5926318..d0f6115 100644 --- a/tests/test_geodesic_planning.py +++ b/tests/test_geodesic_planning.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_geodesic import ( Obstacle, diff --git a/tests/test_integration.py b/tests/test_integration.py index f8ba5ec..b124edb 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,3 +1,4 @@ +import pytest """ Integration tests for complete Eigen simulation pipeline @@ -6,10 +7,9 @@ import sys -sys.path.insert(0, ".") +sys.path.insert(0, ".") # noqa: E402 import numpy as np -import pytest from src import run_arm_simulation, run_xor_simulation diff --git a/tests/test_moving_targets.py b/tests/test_moving_targets.py index 6b3c25a..87504a2 100644 --- a/tests/test_moving_targets.py +++ b/tests/test_moving_targets.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_lorentz import ( apply_boost, diff --git a/tests/test_paradox_coordination.py b/tests/test_paradox_coordination.py index 6b56e7c..2bec525 100644 --- a/tests/test_paradox_coordination.py +++ b/tests/test_paradox_coordination.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_multi_agent import ( check_convergence, @@ -35,9 +34,9 @@ def test_single_agent_no_oscillation(self): collective_osc, agent_osc, collective_sim = collective_lightlike_observer(states, history) # Should not detect oscillation - assert collective_osc == False + assert collective_osc is False assert len(agent_osc) == 1 - assert agent_osc[0] == False + assert agent_osc[0] is False def test_single_agent_oscillating(self): """Single agent oscillating - detected by observer.""" @@ -55,8 +54,8 @@ def test_single_agent_oscillating(self): collective_osc, agent_osc, collective_sim = collective_lightlike_observer(states, history) # Should detect oscillation - assert collective_osc == True - assert agent_osc[0] == True + assert collective_osc is True + assert agent_osc[0] is True def test_two_agents_independent(self): """Two agents with independent goals - no conflict.""" @@ -227,7 +226,7 @@ def test_two_agents_independent_targets(self): # Both agents should converge assert len(trajectories) == 2 - assert converged == True + assert converged is True # Check final positions final_0 = trajectories[0][-1] @@ -260,7 +259,6 @@ def test_three_agents_coordination(self): assert len(trajectories) == 3 # Check coordination was active at some point - coordination_active = any(info["coordination_active"] for info in info_history) # Agents trying to reach same point → should have coordination # (though they might converge before conflict) @@ -273,7 +271,7 @@ def test_convergence_check(self): all_conv, distances = check_convergence(states, targets, tolerance=0.1) # Both within tolerance - assert all_conv == True + assert all_conv is True assert len(distances) == 2 assert all(d < 0.1 for d in distances) diff --git a/tests/test_qec.py b/tests/test_qec.py index 9a99f29..ff34ac5 100644 --- a/tests/test_qec.py +++ b/tests/test_qec.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_qec import ( apply_measurement_errors, @@ -200,7 +199,7 @@ def test_no_error_averages_all(self): # Should average all three expected = np.mean(measurements, axis=0) assert np.allclose(corrected, expected) - assert info["error_detected"] == False + assert info["error_detected"] is False def test_detects_and_corrects_error(self): """One faulty sensor → detect and exclude it.""" @@ -214,9 +213,9 @@ def test_detects_and_corrects_error(self): corrected, info = correct_measurement_errors(measurements, threshold=0.5) # Should detect error at sensor 1 - assert info["error_detected"] == True + assert info["error_detected"] is True assert info["error_location"] == 1 - assert info["correction_applied"] == True + assert info["correction_applied"] is True # Should exclude faulty sensor and average the other two assert np.allclose(corrected, true_state, atol=0.1) @@ -228,7 +227,7 @@ def test_single_measurement_no_correction(self): corrected, info = correct_measurement_errors([measurement]) assert np.allclose(corrected, measurement) - assert info["error_detected"] == False + assert info["error_detected"] is False def test_reports_syndromes(self): """Should report syndrome values.""" @@ -284,7 +283,7 @@ def test_robust_to_measurement_error(self): new_state, info = qec_control_step(current, target, measurements, eta=0.2) # Should detect error - assert info["error_detected"] == True + assert info["error_detected"] is True assert info["error_location"] == 1 # Should still move toward target (not misled by error) @@ -399,7 +398,7 @@ def test_qec_recovers_from_single_failure(self): assert np.linalg.norm(corrected - true_state) < 0.5 # Should detect the error - assert info["error_detected"] == True + assert info["error_detected"] is True def test_naive_average_fails_with_outlier(self): """Naive averaging performs poorly with outliers.""" diff --git a/tests/test_self_simulation.py b/tests/test_self_simulation.py index 1645519..f11718a 100644 --- a/tests/test_self_simulation.py +++ b/tests/test_self_simulation.py @@ -6,7 +6,6 @@ """ import numpy as np -import pytest from src.eigen_meta_control import ( meta_update_parameters, @@ -42,8 +41,8 @@ def test_observes_oscillating_trajectory(self): ) # Should detect oscillation (lightlike observer at work) - assert needs_adj == True - assert diagnosis["oscillating"] == True # numpy bool + assert needs_adj is True + assert diagnosis["oscillating"] is True # numpy bool # May be flagged as oscillation or erratic motion (both are correct) assert diagnosis["issue"] in ["oscillation_detected", "erratic_motion"] assert performance < 0.7 # Poor performance due to oscillation @@ -68,7 +67,7 @@ def test_observes_converging_trajectory(self): ) # Should see convergence toward origin - assert diagnosis["converging"] == True + assert diagnosis["converging"] is True # Performance should be reasonable assert performance >= 0.0 @@ -84,8 +83,8 @@ def test_observes_stagnation(self): ) # Should detect stagnation - assert needs_adj == True - assert diagnosis["converging"] == False # numpy bool + assert needs_adj is True + assert diagnosis["converging"] is False # numpy bool # May also detect oscillation due to identical states assert "issue" in diagnosis @@ -239,7 +238,7 @@ def test_self_tuning_preserves_good_params(self): ) # System should recognize convergence - assert meta_info["diagnosis"]["converging"] == True + assert meta_info["diagnosis"]["converging"] is True # Adjustments should be minimal if any if meta_info["adjustment_made"]: # Check changes are small diff --git a/tests/test_weak_stereo.py b/tests/test_weak_stereo.py index 24e2e94..1becbc0 100644 --- a/tests/test_weak_stereo.py +++ b/tests/test_weak_stereo.py @@ -8,7 +8,6 @@ """ import numpy as np -import pytest from src.eigen_weak_measurement import ( accumulate_weak_measurements, @@ -32,8 +31,8 @@ def test_weak_operator_structure(self): assert M_complement.shape == (2, 2) # Weak measurement is close to identity - I = np.eye(2) - weak_diff = np.linalg.norm(M_weak - I) + identity_matrix = np.eye(2) + weak_diff = np.linalg.norm(M_weak - identity_matrix) assert weak_diff < 0.5 # Small perturbation def test_strong_vs_weak_measurement(self): @@ -41,10 +40,10 @@ def test_strong_vs_weak_measurement(self): M_weak, _ = weak_measurement_operator(measurement_strength=0.1) M_strong, _ = weak_measurement_operator(measurement_strength=0.9) - I = np.eye(2) + identity_matrix = np.eye(2) - weak_diff = np.linalg.norm(M_weak - I) - strong_diff = np.linalg.norm(M_strong - I) + weak_diff = np.linalg.norm(M_weak - identity_matrix) + strong_diff = np.linalg.norm(M_strong - identity_matrix) # Strong measurement perturbs more assert strong_diff > weak_diff