From 039ddba12188e2c6bc147e87b40645dc69af14bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 22:55:08 +0000 Subject: [PATCH 1/3] Initial plan From 2f6b9d825e05b454b93ae24e48e0267dc8cd17ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 23:10:55 +0000 Subject: [PATCH 2/3] Remove unused imports and variables, add explanatory comments to except clauses Co-authored-by: tinix84 <16301528+tinix84@users.noreply.github.com> --- api/architect/analyzer.py | 5 ++++- api/design.py | 5 +++-- api/optimization.py | 3 +-- api/report.py | 5 ++--- examples/common.py | 1 - tas/models/components.py | 2 +- tas/models/outputs.py | 4 ++-- tas/models/waveforms.py | 1 - tests/test_bobbin_extended.py | 1 - tests/test_design_builder.py | 4 +++- tests/test_losses.py | 1 - tests/test_mas_dataclasses.py | 6 ------ tests/test_settings_extended.py | 1 - tests/test_tas_basic.py | 2 -- tests/test_utils.py | 2 -- 15 files changed, 16 insertions(+), 27 deletions(-) diff --git a/api/architect/analyzer.py b/api/architect/analyzer.py index dd68ab5..84a307e 100644 --- a/api/architect/analyzer.py +++ b/api/architect/analyzer.py @@ -5,7 +5,6 @@ """ import ast -import os from dataclasses import dataclass, field from typing import Optional from pathlib import Path @@ -194,6 +193,8 @@ def analyze_module(module_path: str) -> ModuleMetrics: if isinstance(tree.body[0].value, ast.Constant): has_docstring = True except SyntaxError: + # Ignore syntax errors here; docstring detection is best-effort. + # Full syntax error handling is performed when analyzing the module below. pass analyzer = CodeAnalyzer(source) @@ -243,6 +244,8 @@ def analyze_package(package_path: str) -> list[ModuleMetrics]: try: results.append(analyze_module(str(py_file))) except Exception: + # Intentionally ignore errors for individual modules so that analysis + # can continue for the rest of the package. pass return results diff --git a/api/design.py b/api/design.py index 5788c7f..e905e1f 100644 --- a/api/design.py +++ b/api/design.py @@ -263,8 +263,9 @@ def _save_results(self, results: list, output_dir: str, verbose: bool = False): if len(results) >= 2: try: self._generate_pareto_plot(results_data, output_dir, verbose) - except ImportError: - pass + except ImportError as e: + if verbose: + print(f"[Pareto plot skipped - plotting dependency not installed: {e}]") def _get_report_specs(self) -> dict: """Get specifications dict for report generation.""" diff --git a/api/optimization.py b/api/optimization.py index 86a82e8..39105b9 100644 --- a/api/optimization.py +++ b/api/optimization.py @@ -15,9 +15,8 @@ pareto_front = optimizer.run(generations=50) """ -import math from dataclasses import dataclass, field -from typing import Optional, Callable, Any +from typing import Optional, Callable from abc import ABC, abstractmethod diff --git a/api/report.py b/api/report.py index b21a1c5..823d4ff 100644 --- a/api/report.py +++ b/api/report.py @@ -13,7 +13,6 @@ import os import json from typing import List, Optional, Dict, Any -from dataclasses import dataclass def _ensure_matplotlib(): @@ -144,8 +143,8 @@ def _plot_pareto_front(ax, data: list, plt, np): # Color by rank colors = plt.cm.RdYlGn_r(np.linspace(0, 1, len(data))) - scatter = ax.scatter(core_losses, copper_losses, s=sizes, c=colors, - edgecolors='black', linewidths=1, alpha=0.8) + ax.scatter(core_losses, copper_losses, s=sizes, c=colors, + edgecolors='black', linewidths=1, alpha=0.8) # Mark Pareto-optimal points pareto_mask = _find_pareto_front(core_losses, copper_losses) diff --git a/examples/common.py b/examples/common.py index e9f9c12..b2e53c2 100644 --- a/examples/common.py +++ b/examples/common.py @@ -4,7 +4,6 @@ Provides standardized output generation for all examples. """ -import os from pathlib import Path from typing import List, Any, Optional, Dict diff --git a/tas/models/components.py b/tas/models/components.py index 7e7710b..f39f372 100644 --- a/tas/models/components.py +++ b/tas/models/components.py @@ -3,7 +3,7 @@ """ from dataclasses import dataclass, field -from typing import Optional, List, Dict, Any +from typing import Optional, List from enum import Enum diff --git a/tas/models/outputs.py b/tas/models/outputs.py index a500471..cc95303 100644 --- a/tas/models/outputs.py +++ b/tas/models/outputs.py @@ -2,8 +2,8 @@ TAS Output models - Simplified results for basic DC-DC converters. """ -from dataclasses import dataclass, field -from typing import Optional, Dict +from dataclasses import dataclass +from typing import Optional @dataclass diff --git a/tas/models/waveforms.py b/tas/models/waveforms.py index 6b2173f..26f9ee8 100644 --- a/tas/models/waveforms.py +++ b/tas/models/waveforms.py @@ -7,7 +7,6 @@ from dataclasses import dataclass from typing import List from enum import Enum -import math class WaveformShape(Enum): diff --git a/tests/test_bobbin_extended.py b/tests/test_bobbin_extended.py index 5489604..9558035 100644 --- a/tests/test_bobbin_extended.py +++ b/tests/test_bobbin_extended.py @@ -3,7 +3,6 @@ Covers create_basic_bobbin(), bobbin data access, and bobbin fitting checks. """ -import pytest import PyOpenMagnetics diff --git a/tests/test_design_builder.py b/tests/test_design_builder.py index 704eccc..323928e 100644 --- a/tests/test_design_builder.py +++ b/tests/test_design_builder.py @@ -1,7 +1,9 @@ """Tests for PyOpenMagnetics Design Builder API.""" import pytest -import math + +# Test configuration +MAX_RESULTS = 5 class TestDesignImports: diff --git a/tests/test_losses.py b/tests/test_losses.py index db09e42..27001bb 100644 --- a/tests/test_losses.py +++ b/tests/test_losses.py @@ -4,7 +4,6 @@ Covers core losses (multiple models), winding losses (ohmic, skin, proximity), wire-level per-meter loss functions, and Steinmetz coefficients. """ -import pytest import PyOpenMagnetics diff --git a/tests/test_mas_dataclasses.py b/tests/test_mas_dataclasses.py index a6417dd..2844435 100644 --- a/tests/test_mas_dataclasses.py +++ b/tests/test_mas_dataclasses.py @@ -15,8 +15,6 @@ DimensionWithTolerance, CTI, InsulationType, - OvervoltageCategory, - PollutionDegree, InsulationStandards, InsulationRequirements, IsolationSide, @@ -25,19 +23,15 @@ DesignRequirements, Topology, OperatingConditions, - Cooling, Harmonics, WaveformLabel, Processed, Waveform, SignalDescriptor, - OperatingPointExcitation, OperatingPoint, Inputs, ManufacturerInfo, Status, - Outputs, - Mas, Masfromdict, Mastodict, from_float, diff --git a/tests/test_settings_extended.py b/tests/test_settings_extended.py index bb6bce4..afe50c8 100644 --- a/tests/test_settings_extended.py +++ b/tests/test_settings_extended.py @@ -4,7 +4,6 @@ Covers get_settings(), set_settings(), reset_settings(), get_constants(), and get_default_models(). """ -import pytest import PyOpenMagnetics diff --git a/tests/test_tas_basic.py b/tests/test_tas_basic.py index e7d8d0b..077e866 100644 --- a/tests/test_tas_basic.py +++ b/tests/test_tas_basic.py @@ -4,7 +4,6 @@ import pytest import json -import os from pathlib import Path from tas import ( @@ -25,7 +24,6 @@ ModulationType, ControlMode, OperatingMode, - TASOutputs, TASLossBreakdown, TASKPIs, create_buck_tas, diff --git a/tests/test_utils.py b/tests/test_utils.py index 219c256..4ba7e25 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -4,8 +4,6 @@ Covers waveform processing, harmonics, sampled waveform generation, power calculations, and reflected waveform transformations. """ -import pytest -import math import PyOpenMagnetics From 27408ce0439421aba0a365252fdef205cd5ecc2f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 23:13:18 +0000 Subject: [PATCH 3/3] Fix exception variable shadowing in api/design.py Co-authored-by: tinix84 <16301528+tinix84@users.noreply.github.com> --- api/design.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/design.py b/api/design.py index e905e1f..52bf5c3 100644 --- a/api/design.py +++ b/api/design.py @@ -263,9 +263,9 @@ def _save_results(self, results: list, output_dir: str, verbose: bool = False): if len(results) >= 2: try: self._generate_pareto_plot(results_data, output_dir, verbose) - except ImportError as e: + except ImportError as e2: if verbose: - print(f"[Pareto plot skipped - plotting dependency not installed: {e}]") + print(f"[Pareto plot skipped - plotting dependency not installed: {e2}]") def _get_report_specs(self) -> dict: """Get specifications dict for report generation."""