fix: enforce strict ruff lint (17 rule sets) across entire repo
- Expand ruff config from E/F to 17 rule sets (B, RUF, SIM, PIE, T20, ARG, ERA, A, BLE, RET, ISC, TCH, UP, C4, PERF) - Fix 907 lint errors across all Python files (GUI, FPGA cosim, schematics scripts, simulations, utilities, tools) - Replace all blind except-Exception with specific exception types - Remove commented-out dead code (ERA001) from cosim/simulation files - Modernize typing: deprecated typing.List/Dict/Tuple to builtins - Fix unused args/loop vars, ambiguous unicode, perf anti-patterns - Delete legacy GUI files V1-V4 - Add V7 test suite, requirements files - All CI jobs pass: ruff (0 errors), py_compile, pytest (92/92), MCU tests (20/20), FPGA regression (25/25)
This commit is contained in:
@@ -38,7 +38,6 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
chirp_number = 0
|
||||
|
||||
# Generate Long Chirps (30µs duration equivalent)
|
||||
print("Generating Long Chirps...")
|
||||
for chirp in range(num_long_chirps):
|
||||
for sample in range(samples_per_chirp):
|
||||
# Base noise
|
||||
@@ -90,7 +89,6 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
timestamp_ns += 175400 # 175.4µs guard time
|
||||
|
||||
# Generate Short Chirps (0.5µs duration equivalent)
|
||||
print("Generating Short Chirps...")
|
||||
for chirp in range(num_short_chirps):
|
||||
for sample in range(samples_per_chirp):
|
||||
# Base noise
|
||||
@@ -142,11 +140,6 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
|
||||
# Save to CSV
|
||||
df.to_csv(filename, index=False)
|
||||
print(f"Generated CSV file: {filename}")
|
||||
print(f"Total samples: {len(df)}")
|
||||
print(f"Long chirps: {num_long_chirps}, Short chirps: {num_short_chirps}")
|
||||
print(f"Samples per chirp: {samples_per_chirp}")
|
||||
print(f"File size: {len(df) // 1000}K samples")
|
||||
|
||||
return df
|
||||
|
||||
@@ -154,15 +147,11 @@ def analyze_generated_data(df):
|
||||
"""
|
||||
Analyze the generated data to verify target detection
|
||||
"""
|
||||
print("\n=== Data Analysis ===")
|
||||
|
||||
# Basic statistics
|
||||
long_chirps = df[df['chirp_type'] == 'LONG']
|
||||
short_chirps = df[df['chirp_type'] == 'SHORT']
|
||||
df[df['chirp_type'] == 'LONG']
|
||||
df[df['chirp_type'] == 'SHORT']
|
||||
|
||||
print(f"Long chirp samples: {len(long_chirps)}")
|
||||
print(f"Short chirp samples: {len(short_chirps)}")
|
||||
print(f"Unique chirp numbers: {df['chirp_number'].nunique()}")
|
||||
|
||||
# Calculate actual magnitude and phase for analysis
|
||||
df['magnitude'] = np.sqrt(df['I_value']**2 + df['Q_value']**2)
|
||||
@@ -172,15 +161,11 @@ def analyze_generated_data(df):
|
||||
high_mag_threshold = df['magnitude'].quantile(0.95) # Top 5%
|
||||
targets_detected = df[df['magnitude'] > high_mag_threshold]
|
||||
|
||||
print(f"\nTarget detection threshold: {high_mag_threshold:.2f}")
|
||||
print(f"High magnitude samples: {len(targets_detected)}")
|
||||
|
||||
# Group by chirp type
|
||||
long_targets = targets_detected[targets_detected['chirp_type'] == 'LONG']
|
||||
short_targets = targets_detected[targets_detected['chirp_type'] == 'SHORT']
|
||||
targets_detected[targets_detected['chirp_type'] == 'LONG']
|
||||
targets_detected[targets_detected['chirp_type'] == 'SHORT']
|
||||
|
||||
print(f"Targets in long chirps: {len(long_targets)}")
|
||||
print(f"Targets in short chirps: {len(short_targets)}")
|
||||
|
||||
return df
|
||||
|
||||
@@ -191,10 +176,3 @@ if __name__ == "__main__":
|
||||
# Analyze the generated data
|
||||
analyze_generated_data(df)
|
||||
|
||||
print("\n=== CSV File Ready ===")
|
||||
print("You can now test the Python GUI with this CSV file!")
|
||||
print("The file contains:")
|
||||
print("- 16 Long chirps + 16 Short chirps")
|
||||
print("- 4 simulated targets at different ranges and velocities")
|
||||
print("- Realistic noise and clutter")
|
||||
print("- Proper I/Q data for Doppler processing")
|
||||
|
||||
@@ -90,8 +90,6 @@ def generate_small_radar_csv(filename="small_test_radar_data.csv"):
|
||||
|
||||
df = pd.DataFrame(data)
|
||||
df.to_csv(filename, index=False)
|
||||
print(f"Generated small CSV: {filename}")
|
||||
print(f"Total samples: {len(df)}")
|
||||
return df
|
||||
|
||||
generate_small_radar_csv()
|
||||
|
||||
@@ -31,7 +31,6 @@ freq_indices = np.arange(L)
|
||||
T = L*Ts
|
||||
freq = freq_indices/T
|
||||
|
||||
print("The Array is: ", x) #printing the array
|
||||
|
||||
plt.figure(figsize = (12, 6))
|
||||
plt.subplot(121)
|
||||
|
||||
@@ -20,5 +20,5 @@ y = 1 + np.sin(theta_n) # Normalize from 0 to 2
|
||||
y_scaled = np.round(y * 127.5).astype(int) # Scale to 8-bit range (0-255)
|
||||
|
||||
# Print values in Verilog-friendly format
|
||||
for i in range(n):
|
||||
print(f"waveform_LUT[{i}] = 8'h{y_scaled[i]:02X};")
|
||||
for _i in range(n):
|
||||
pass
|
||||
|
||||
+18
-18
@@ -58,10 +58,10 @@ class RadarCalculatorGUI:
|
||||
scrollbar = ttk.Scrollbar(self.input_frame, orient="vertical", command=canvas.yview)
|
||||
scrollable_frame = ttk.Frame(canvas)
|
||||
|
||||
scrollable_frame.bind(
|
||||
"<Configure>",
|
||||
lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
|
||||
)
|
||||
scrollable_frame.bind(
|
||||
"<Configure>",
|
||||
lambda _e: canvas.configure(scrollregion=canvas.bbox("all"))
|
||||
)
|
||||
|
||||
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
|
||||
canvas.configure(yscrollcommand=scrollbar.set)
|
||||
@@ -83,7 +83,7 @@ class RadarCalculatorGUI:
|
||||
|
||||
self.entries = {}
|
||||
|
||||
for i, (label, default) in enumerate(inputs):
|
||||
for _i, (label, default) in enumerate(inputs):
|
||||
# Create a frame for each input row
|
||||
row_frame = ttk.Frame(scrollable_frame)
|
||||
row_frame.pack(fill=tk.X, pady=5)
|
||||
@@ -119,8 +119,8 @@ class RadarCalculatorGUI:
|
||||
calculate_btn.pack()
|
||||
|
||||
# Bind hover effect
|
||||
calculate_btn.bind("<Enter>", lambda e: calculate_btn.config(bg='#45a049'))
|
||||
calculate_btn.bind("<Leave>", lambda e: calculate_btn.config(bg='#4CAF50'))
|
||||
calculate_btn.bind("<Enter>", lambda _e: calculate_btn.config(bg='#45a049'))
|
||||
calculate_btn.bind("<Leave>", lambda _e: calculate_btn.config(bg='#4CAF50'))
|
||||
|
||||
def create_results_display(self):
|
||||
"""Create the results display area"""
|
||||
@@ -135,10 +135,10 @@ class RadarCalculatorGUI:
|
||||
scrollbar = ttk.Scrollbar(self.results_frame, orient="vertical", command=canvas.yview)
|
||||
scrollable_frame = ttk.Frame(canvas)
|
||||
|
||||
scrollable_frame.bind(
|
||||
"<Configure>",
|
||||
lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
|
||||
)
|
||||
scrollable_frame.bind(
|
||||
"<Configure>",
|
||||
lambda _e: canvas.configure(scrollregion=canvas.bbox("all"))
|
||||
)
|
||||
|
||||
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
|
||||
canvas.configure(yscrollcommand=scrollbar.set)
|
||||
@@ -158,7 +158,7 @@ class RadarCalculatorGUI:
|
||||
|
||||
self.results_labels = {}
|
||||
|
||||
for i, (label, key) in enumerate(results):
|
||||
for _i, (label, key) in enumerate(results):
|
||||
# Create a frame for each result row
|
||||
row_frame = ttk.Frame(scrollable_frame)
|
||||
row_frame.pack(fill=tk.X, pady=10, padx=20)
|
||||
@@ -180,10 +180,10 @@ class RadarCalculatorGUI:
|
||||
note_text = """
|
||||
NOTES:
|
||||
• Maximum detectable range is calculated using the radar equation
|
||||
• Range resolution = c × τ / 2, where τ is pulse duration
|
||||
• Maximum unambiguous range = c / (2 × PRF)
|
||||
• Maximum detectable speed = λ × PRF / 4
|
||||
• Speed resolution = λ × PRF / (2 × N) where N is number of pulses (assumed 1)
|
||||
• Range resolution = c x τ / 2, where τ is pulse duration
|
||||
• Maximum unambiguous range = c / (2 x PRF)
|
||||
• Maximum detectable speed = λ x PRF / 4
|
||||
• Speed resolution = λ x PRF / (2 x N) where N is number of pulses (assumed 1)
|
||||
• λ (wavelength) = c / f
|
||||
"""
|
||||
|
||||
@@ -300,10 +300,10 @@ class RadarCalculatorGUI:
|
||||
# Show success message
|
||||
messagebox.showinfo("Success", "Calculation completed successfully!")
|
||||
|
||||
except Exception as e:
|
||||
except (ValueError, ZeroDivisionError) as e:
|
||||
messagebox.showerror(
|
||||
"Calculation Error",
|
||||
f"An error occurred during calculation:\n{str(e)}",
|
||||
f"An error occurred during calculation:\n{e!s}",
|
||||
)
|
||||
|
||||
def main():
|
||||
|
||||
@@ -66,8 +66,3 @@ W_mm, L_mm, dx_mm, dy_mm, W_feed_mm = calculate_patch_antenna_parameters(
|
||||
frequency, epsilon_r, h_sub, h_cu, array
|
||||
)
|
||||
|
||||
print(f"Width of the patch: {W_mm:.4f} mm")
|
||||
print(f"Length of the patch: {L_mm:.4f} mm")
|
||||
print(f"Separation distance in horizontal axis: {dx_mm:.4f} mm")
|
||||
print(f"Separation distance in vertical axis: {dy_mm:.4f} mm")
|
||||
print(f"Feeding line width: {W_feed_mm:.2f} mm")
|
||||
|
||||
Reference in New Issue
Block a user