Skip to content

Commit f12a08b

Browse files
committed
rm 'from typing import'
1 parent d740d1f commit f12a08b

36 files changed

Lines changed: 704 additions & 739 deletions

femmt/component.py

Lines changed: 91 additions & 92 deletions
Large diffs are not rendered by default.

femmt/data.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import logging
55
import numpy as np
6-
from typing import List, Optional
76

87
# Local libraries
98
from femmt.enumerations import ConductorType
@@ -17,7 +16,7 @@ class FileData:
1716
def __init__(self, working_directory: str, electro_magnetic_folder_path: str = None, strands_coefficients_folder_path: str = None):
1817
if working_directory is not None:
1918
self.update_paths(working_directory, electro_magnetic_folder_path, strands_coefficients_folder_path)
20-
self.onelab_folder_path: Optional[str] = None
19+
self.onelab_folder_path: str | None = None
2120

2221
@staticmethod
2322
def create_folders(*args: str) -> None:
@@ -122,16 +121,16 @@ class MeshData:
122121
skin_mesh_factor: float
123122
c_core: float
124123
c_window: float
125-
c_conductor = List[float]
126-
c_center_conductor = List[float]
124+
c_conductor = list[float]
125+
c_center_conductor = list[float]
127126
c_air_gaps: float
128127

129128
center_factor: float
130129

131130
mu0: float
132131
core_w: float
133132
window_w: float
134-
windings: List["Conductor"] # This is written as string because it is a forward import
133+
windings: list["Conductor"] # This is written as string because it is a forward import
135134

136135
frequency: float
137136

@@ -152,7 +151,7 @@ def __init__(self, mesh_accuracy_core: float,
152151
# The value 4 has good impact on the runtime and does not affect the simulation results too much.
153152
self.center_factor = 4
154153

155-
def update_spatial_data(self, core_w: float, window_w: float, windings: List["Conductor"]):
154+
def update_spatial_data(self, core_w: float, window_w: float, windings: list["Conductor"]):
156155
"""
157156
Update geometry data of the core of the magnetic component.
158157
@@ -161,7 +160,7 @@ def update_spatial_data(self, core_w: float, window_w: float, windings: List["Co
161160
:param window_w: window width
162161
:type window_w: float
163162
:param windings: list of windings
164-
:type windings: List["Conductor"]
163+
:type windings: list["Conductor"]
165164
"""
166165
self.core_w = core_w
167166
self.window_w = window_w

femmt/drawing.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Python standard libraries
33
import numpy as np
44
import logging
5-
from typing import List
65

76
# Local libraries
87
from femmt.enumerations import *
@@ -19,7 +18,7 @@ class TwoDaxiSymmetric:
1918
"""
2019

2120
core: Core
22-
winding_windows: List[WindingWindow]
21+
winding_windows: list[WindingWindow]
2322
air_gaps: AirGaps
2423
stray_path: StrayPath
2524
insulation: Insulation
@@ -34,11 +33,11 @@ class TwoDaxiSymmetric:
3433
p_region_bound: np.ndarray
3534
p_window: np.ndarray
3635
p_air_gaps: np.ndarray
37-
# p_conductor: List[List[float]]
38-
p_iso_core: List[List[float]]
39-
p_iso_pri_sec: List[List[float]]
36+
# p_conductor: list[list[float]]
37+
p_iso_core: list[list[float]]
38+
p_iso_pri_sec: list[list[float]]
4039

41-
def __init__(self, core: Core, mesh_data: MeshData, air_gaps: AirGaps, winding_windows: List[WindingWindow],
40+
def __init__(self, core: Core, mesh_data: MeshData, air_gaps: AirGaps, winding_windows: list[WindingWindow],
4241
stray_path: StrayPath, insulation: Insulation, component_type: ComponentType, number_of_windings: int, verbosity: Verbosity):
4342
self.core = core
4443
self.mesh_data = mesh_data
@@ -1572,18 +1571,18 @@ def draw_model(self):
15721571
# self.draw_region_stacked()
15731572

15741573
@staticmethod
1575-
def get_center_of_rect(p1: List[float], p2: List[float], p3: List[float], p4: List[float]):
1574+
def get_center_of_rect(p1: list[float], p2: list[float], p3: list[float], p4: list[float]):
15761575
"""
15771576
Get center point of a rectangular conductor.
15781577
15791578
:param p1: Point 1 as a x,y-List
1580-
:type p1: List[float]
1579+
:type p1: list[float]
15811580
:param p2: Point 1 as a x,y-List
1582-
:type p2: List[float]
1581+
:type p2: list[float]
15831582
:param p3: Point 1 as a x,y-List
1584-
:type p3: List[float]
1583+
:type p3: list[float]
15851584
:param p4: Point 1 as a x,y-List
1586-
:type p4: List[float]
1585+
:type p4: list[float]
15871586
"""
15881587
x_list = [p1[0], p2[0], p3[0], p4[0]]
15891588
y_list = [p1[1], p2[1], p3[1], p4[1]]

femmt/dtos.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Data transfer objects (DTOs) used by this toolbox."""
22
from dataclasses import dataclass
33
from femmt.enumerations import WindingTag
4-
from typing import Optional, List
54

65

76
@dataclass
@@ -29,10 +28,10 @@ class ConductorRow:
2928
"""Defines the conductors in one row."""
3029

3130
number_of_conds_per_winding: int
32-
number_of_conds_per_row: Optional[int]
33-
row_height: Optional[float]
31+
number_of_conds_per_row: int | None
32+
row_height: float | None
3433
winding_tag: WindingTag
35-
number_of_rows: Optional[int]
34+
number_of_rows: int | None
3635
additional_bobbin: float
3736

3837

@@ -55,20 +54,20 @@ class ThreeWindingIsolation:
5554
class CenterTappedGroup:
5655
"""Definitions for the center tapped group. A group is made of several primary and secondary rows."""
5756

58-
primary_number_of_rows: Optional[int]
59-
secondary_number_of_rows: Optional[int]
60-
primary_rest: Optional[int]
61-
secondary_rest: Optional[int]
62-
stack: List[WindingTag]
57+
primary_number_of_rows: int | None
58+
secondary_number_of_rows: int | None
59+
primary_rest: int | None
60+
secondary_rest: int | None
61+
stack: list[WindingTag]
6362

6463

6564
@dataclass
6665
class ConductorStack:
6766
"""Definitions for the conductor stack."""
6867

6968
number_of_groups: int
70-
number_of_single_rows: Optional[int]
71-
order: List[int]
69+
number_of_single_rows: int | None
70+
order: list[int]
7271

7372

7473
@dataclass
@@ -106,16 +105,16 @@ class TransformerInductance:
106105
class ThreeWindingTransformerInductance:
107106
"""Inductance definitions for a three-winding transformer."""
108107

109-
M_12: Optional[float]
110-
M_13: Optional[float]
111-
M_23: Optional[float]
112-
L_s1: Optional[float]
113-
L_s2: Optional[float]
114-
L_s3: Optional[float]
115-
L_h: Optional[float]
116-
n_12: Optional[float]
117-
n_13: Optional[float]
118-
n_23: Optional[float]
119-
L_s12: Optional[float]
120-
L_s13: Optional[float]
121-
L_s23: Optional[float]
108+
M_12: float | None
109+
M_13: float | None
110+
M_23: float | None
111+
L_s1: float | None
112+
L_s2: float | None
113+
L_s3: float | None
114+
L_h: float | None
115+
n_12: float | None
116+
n_13: float | None
117+
n_23: float | None
118+
L_s12: float | None
119+
L_s13: float | None
120+
L_s23: float | None

femmt/examples/advanced_inductor_air_gap_sweep.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import matplotlib.pyplot as plt
33
import femmt as fmt
44
import os
5-
from typing import Optional
65

7-
def basic_example_sweep(onelab_folder: Optional[str] = None, show_visual_outputs: bool = True, is_test: bool = False):
6+
def basic_example_sweep(onelab_folder: str | None = None, show_visual_outputs: bool = True, is_test: bool = False):
87
"""
98
Advanced example to demonstrate an air gap sweep for an inductor.
109

femmt/examples/basic_inductor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in
181181

182182

183183
if __name__ == "__main__":
184-
basic_example_inductor(show_visual_outputs=False)
184+
basic_example_inductor(show_visual_outputs=True)

femmt/examples/basic_transformer_three_winding.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
"""
1111
import femmt as fmt
1212
import os
13-
from typing import Optional
1413
import logging
1514

1615
# configure logging to show femmt terminal output
1716
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
1817

19-
def basic_example_transformer_three_winding(onelab_folder: Optional[str] = None, show_visual_outputs: bool = True,
18+
def basic_example_transformer_three_winding(onelab_folder: str | None = None, show_visual_outputs: bool = True,
2019
is_test: bool = False):
2120
"""
2221
Run the example code for the three-winding transformer.

femmt/examples/component_study/transformer_component_study.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import femmt as fmt
33
import os
44
import numpy as np
5-
from typing import Optional
65

7-
def transformer_component_study(onelab_folder: Optional[str] = None, show_visual_outputs: bool = True, is_test: bool = False):
6+
def transformer_component_study(onelab_folder: str | None = None, show_visual_outputs: bool = True, is_test: bool = False):
87
"""
98
Perform a component study.
109

femmt/examples/femmt_benchmark.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
# Python standard libraries
7-
from typing import List, Optional
87
from dataclasses import dataclass
98
import os
109
import json
@@ -41,7 +40,7 @@ class SingleBenchmark:
4140

4241
execution_time_: float # all measurements summed up
4342

44-
flux_over_current: List[float]
43+
flux_over_current: list[float]
4544
total_losses: float
4645
total_winding_losses: float
4746

@@ -141,7 +140,7 @@ def to_json(self, file_path: str):
141140
# ------ Generic Functions ------
142141

143142

144-
def create_model(working_directory: str, mesh_accuracies=Optional[MeshAccuracies], aspect_ratio: float = 10,
143+
def create_model(working_directory: str, mesh_accuracies=MeshAccuracies, aspect_ratio: float = 10,
145144
wwr_enabled: bool = True, number_of_conductors: int = 9):
146145
"""
147146
Create the model for benchmark.
@@ -299,14 +298,14 @@ def create_rectangular_conductor_model(working_directory: str, mesh_accuracies:
299298

300299
return geo
301300

302-
def plot_mesh_over_precision(benchmarks, x_list: List, x_label: str, title: str):
301+
def plot_mesh_over_precision(benchmarks, x_list: list, x_label: str, title: str):
303302
"""
304303
Plot the mesh over precision.
305304
306305
:param benchmarks:
307306
:type benchmarks:
308307
:param x_list: list with simulation numbers
309-
:type x_list: List
308+
:type x_list: list
310309
:param x_label: x-label for the plot
311310
:type x_label: str
312311
:param title: title for the plot

femmt/examples/hpc_examples.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Examples for the parallel simulation."""
22
# Python standard libraries
3-
from typing import Dict
43
from itertools import product
54
import os
65
import time
@@ -94,7 +93,7 @@ def create_parallel_example_inductor(inductor_frequency: int, air_gap_height: fl
9493

9594
return geo
9695

97-
def custom_hpc(parameters: Dict):
96+
def custom_hpc(parameters: dict):
9897
"""Very simple example for a custom hpc_function which can be given to the hpc.run() function.
9998
10099
:param parameters: Dictionary containing the model and the given simulation_parameters.

0 commit comments

Comments
 (0)