Skip to content

Commit 4e78784

Browse files
committed
verified type check changes
1 parent dd8275a commit 4e78784

File tree

10 files changed

+53
-58
lines changed

10 files changed

+53
-58
lines changed

aerosandbox/aerodynamics/aero_3D/aero_buildup.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from aerosandbox.performance import OperatingPoint
44
import aerosandbox.library.aerodynamics as aero
55
import aerosandbox.numpy as np
6+
from aerosandbox.numpy.typing import Vectorizable
67
from aerosandbox.aerodynamics.aero_3D.aero_buildup_submodels.fuselage_aerodynamics_utilities import *
78
from aerosandbox.library.aerodynamics import transonic
89
import aerosandbox.library.aerodynamics as aerolib
@@ -137,78 +138,78 @@ def __repr__(self):
137138
)
138139

139140
@property
140-
def F_b(self) -> list[float | np.ndarray]:
141+
def F_b(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
141142
"""
142-
An [x, y, z] list of forces in body axes [N]
143+
An (x, y, z) tuple of forces in body axes [N]
143144
"""
144145
return self.op_point.convert_axes(
145146
*self.F_g, from_axes="geometry", to_axes="body"
146147
)
147148

148149
@property
149-
def F_w(self) -> list[float | np.ndarray]:
150+
def F_w(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
150151
"""
151-
An [x, y, z] list of forces in wind axes [N]
152+
An (x, y, z) tuple of forces in wind axes [N]
152153
"""
153154
return self.op_point.convert_axes(
154155
*self.F_g, from_axes="geometry", to_axes="wind"
155156
)
156157

157158
@property
158-
def M_b(self) -> list[float | np.ndarray]:
159+
def M_b(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
159160
"""
160-
An [x, y, z] list of moments about body axes [Nm]
161+
An (x, y, z) tuple of moments about body axes [Nm]
161162
"""
162163
return self.op_point.convert_axes(
163164
*self.M_g, from_axes="geometry", to_axes="body"
164165
)
165166

166167
@property
167-
def M_w(self) -> list[float | np.ndarray]:
168+
def M_w(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
168169
"""
169-
An [x, y, z] list of moments about wind axes [Nm]
170+
An (x, y, z) tuple of moments about wind axes [Nm]
170171
"""
171172
return self.op_point.convert_axes(
172173
*self.M_g, from_axes="geometry", to_axes="wind"
173174
)
174175

175176
@property
176-
def L(self) -> float | np.ndarray:
177+
def L(self) -> Vectorizable:
177178
"""
178179
The lift force [N]. Definitionally, this is in wind axes.
179180
"""
180181
return -self.F_w[2]
181182

182183
@property
183-
def Y(self) -> float | np.ndarray:
184+
def Y(self) -> Vectorizable:
184185
"""
185186
The side force [N]. Definitionally, this is in wind axes.
186187
"""
187188
return self.F_w[1]
188189

189190
@property
190-
def D(self) -> float | np.ndarray:
191+
def D(self) -> Vectorizable:
191192
"""
192193
The drag force [N]. Definitionally, this is in wind axes.
193194
"""
194195
return -self.F_w[0]
195196

196197
@property
197-
def l_b(self) -> float | np.ndarray:
198+
def l_b(self) -> Vectorizable:
198199
"""
199200
The rolling moment [Nm] in body axes. Positive is roll-right.
200201
"""
201202
return self.M_b[0]
202203

203204
@property
204-
def m_b(self) -> float | np.ndarray:
205+
def m_b(self) -> Vectorizable:
205206
"""
206207
The pitching moment [Nm] in body axes. Positive is nose-up.
207208
"""
208209
return self.M_b[1]
209210

210211
@property
211-
def n_b(self) -> float | np.ndarray:
212+
def n_b(self) -> Vectorizable:
212213
"""
213214
The yawing moment [Nm] in body axes. Positive is nose-right.
214215
"""

aerosandbox/aerodynamics/aero_3D/lifting_line.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
from typing import Callable
1111
from aerosandbox.aerodynamics.aero_3D.aero_buildup import AeroBuildup
12+
from aerosandbox.numpy.typing import Vectorizable
1213
from dataclasses import dataclass
1314

1415

@@ -157,78 +158,78 @@ def __repr__(self):
157158
)
158159

159160
@property
160-
def F_b(self) -> list[float | np.ndarray]:
161+
def F_b(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
161162
"""
162-
An [x, y, z] list of forces in body axes [N]
163+
An (x, y, z) tuple of forces in body axes [N]
163164
"""
164165
return self.op_point.convert_axes(
165166
*self.F_g, from_axes="geometry", to_axes="body"
166167
)
167168

168169
@property
169-
def F_w(self) -> list[float | np.ndarray]:
170+
def F_w(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
170171
"""
171-
An [x, y, z] list of forces in wind axes [N]
172+
An (x, y, z) tuple of forces in wind axes [N]
172173
"""
173174
return self.op_point.convert_axes(
174175
*self.F_g, from_axes="geometry", to_axes="wind"
175176
)
176177

177178
@property
178-
def M_b(self) -> list[float | np.ndarray]:
179+
def M_b(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
179180
"""
180-
An [x, y, z] list of moments about body axes [Nm]
181+
An (x, y, z) tuple of moments about body axes [Nm]
181182
"""
182183
return self.op_point.convert_axes(
183184
*self.M_g, from_axes="geometry", to_axes="body"
184185
)
185186

186187
@property
187-
def M_w(self) -> list[float | np.ndarray]:
188+
def M_w(self) -> tuple[Vectorizable, Vectorizable, Vectorizable]:
188189
"""
189-
An [x, y, z] list of moments about wind axes [Nm]
190+
An (x, y, z) tuple of moments about wind axes [Nm]
190191
"""
191192
return self.op_point.convert_axes(
192193
*self.M_g, from_axes="geometry", to_axes="wind"
193194
)
194195

195196
@property
196-
def L(self) -> float | np.ndarray:
197+
def L(self) -> Vectorizable:
197198
"""
198199
The lift force [N]. Definitionally, this is in wind axes.
199200
"""
200201
return -self.F_w[2]
201202

202203
@property
203-
def Y(self) -> float | np.ndarray:
204+
def Y(self) -> Vectorizable:
204205
"""
205206
The side force [N]. Definitionally, this is in wind axes.
206207
"""
207208
return self.F_w[1]
208209

209210
@property
210-
def D(self) -> float | np.ndarray:
211+
def D(self) -> Vectorizable:
211212
"""
212213
The drag force [N]. Definitionally, this is in wind axes.
213214
"""
214215
return -self.F_w[0]
215216

216217
@property
217-
def l_b(self) -> float | np.ndarray:
218+
def l_b(self) -> Vectorizable:
218219
"""
219220
The rolling moment [Nm] in body axes. Positive is roll-right.
220221
"""
221222
return self.M_b[0]
222223

223224
@property
224-
def m_b(self) -> float | np.ndarray:
225+
def m_b(self) -> Vectorizable:
225226
"""
226227
The pitching moment [Nm] in body axes. Positive is nose-up.
227228
"""
228229
return self.M_b[1]
229230

230231
@property
231-
def n_b(self) -> float | np.ndarray:
232+
def n_b(self) -> Vectorizable:
232233
"""
233234
The yawing moment [Nm] in body axes. Positive is nose-right.
234235
"""

aerosandbox/aerodynamics/aero_3D/linear_potential_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def get_induced_velocity_at_points(
283283
points: np.ndarray,
284284
vortex_strengths: np.ndarray,
285285
sum_across_elements: bool = True,
286-
) -> tuple[np.ndarray]:
286+
) -> tuple[float | np.ndarray, float | np.ndarray, float | np.ndarray]:
287287
u_induced, v_induced, w_induced = calculate_induced_velocity_horseshoe(
288288
x_field=tall(points[:, 0]),
289289
y_field=tall(points[:, 1]),

aerosandbox/atmosphere/thermodynamics/gas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def process(
326326
if inplace:
327327
self.pressure = new_pressure
328328
self.temperature = new_temperature
329+
return self
329330

330331
else:
331332
return PerfectGas(

aerosandbox/dynamics/point_mass/common_point_mass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def _set_state(
111111
) # Pack the iterable into a dict-like, then do the same thing as above.
112112

113113
def unpack_state(
114-
self, dict_like_state: dict[str, float | np.ndarray] | None = None
115-
) -> tuple[float | np.ndarray]:
114+
self, dict_like_state: dict[str, Vectorizable] | None = None
115+
) -> tuple[Vectorizable, ...]:
116116
"""
117117
'Unpacks' a Dict-like state into an array-like that represents the state of the dynamical system.
118118

aerosandbox/geometry/airfoil/airfoil_families.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -565,24 +565,17 @@ def get_coordinates_from_raw_dat(raw_text: list[str]) -> np.ndarray:
565565
Returns: A Nx2 ndarray of airfoil coordinates [x, y].
566566
567567
"""
568-
raw_coordinates = []
569-
570-
def is_number(s: str) -> bool:
571-
# Determines whether a string is representable as a float
572-
try:
573-
float(s)
574-
except ValueError:
575-
return False
576-
return True
568+
raw_coordinates: list[list[float]] = []
577569

578570
def parse_line(line: str) -> list[float] | None:
579-
# Given a single line of a `*.dat` file, tries to parse it into a list of two floats [x, y].
580-
# If not possible, returns None.
571+
"""Parse a single line of a *.dat file into [x, y] floats, or None if not parseable."""
581572
line_split = re.split(r"[;|,|\s|\t]", line)
582573
line_items = [s for s in line_split if s != ""]
583-
if len(line_items) == 2 and all([is_number(item) for item in line_items]):
584-
return line_items
585-
else:
574+
if len(line_items) != 2:
575+
return None
576+
try:
577+
return [float(line_items[0]), float(line_items[1])]
578+
except ValueError:
586579
return None
587580

588581
for line in raw_text:
@@ -593,12 +586,10 @@ def parse_line(line: str) -> list[float] | None:
593586
if len(raw_coordinates) == 0:
594587
raise ValueError("Could not read any coordinates from the `raw_text` input!")
595588

596-
coordinates = np.array(raw_coordinates, dtype=float)
597-
598-
return coordinates
589+
return np.array(raw_coordinates)
599590

600591

601-
def get_file_coordinates(filepath: str | os.PathLike):
592+
def get_file_coordinates(filepath: str | os.PathLike) -> np.ndarray:
602593
possible_errors = (FileNotFoundError, UnicodeDecodeError)
603594

604595
if isinstance(filepath, np.ndarray):

aerosandbox/library/regulations/far_part_23.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import aerosandbox.numpy as np
2+
from aerosandbox.numpy.typing import Vectorizable
23
from aerosandbox.tools import units as u
34
from typing import Literal
45

@@ -8,9 +9,9 @@
89

910

1011
def limit_load_factors(
11-
design_mass_TOGW: float,
12+
design_mass_TOGW: Vectorizable,
1213
category: Literal["normal", "utility", "acrobatic", "commuter"] = "normal",
13-
) -> tuple[float, float]:
14+
) -> tuple[Vectorizable, Vectorizable]:
1415
"""
1516
Computes the required limit load factors for FAR Part 23 certification.
1617

aerosandbox/numpy/calculus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def gradient(
150150
dx_shape[axis] = shape[axis] - 1
151151
dx = reshape(dx, dx_shape)
152152

153-
def get_slice(slice_obj: slice) -> tuple[slice]:
153+
def get_slice(slice_obj: slice) -> tuple[slice, ...]:
154154
slices = [slice(None)] * len(shape)
155155
slices[axis] = slice_obj
156156
return tuple(slices)

aerosandbox/numpy/finite_difference_operators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def finite_difference_coefficients(
5353
"""
5454
### Check inputs
5555
if derivative_degree < 1:
56-
return ValueError("The parameter derivative_degree must be an integer >= 1.")
56+
raise ValueError("The parameter derivative_degree must be an integer >= 1.")
5757
expected_order_of_accuracy = length(x) - derivative_degree
5858
if expected_order_of_accuracy < 1:
59-
return ValueError(
59+
raise ValueError(
6060
"You need to provide at least (derivative_degree+1) grid points in the x vector."
6161
)
6262

aerosandbox/structures/ignore/wing_structure_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_ribs_from_section_span_fractions(
4040
self,
4141
section_index: int,
4242
section_span_fractions: float | int | list[float] | np.ndarray,
43-
rib_thickness: float = None,
43+
rib_thickness: float | None = None,
4444
):
4545
if rib_thickness is None:
4646
rib_thickness = self.default_rib_thickness
@@ -81,7 +81,7 @@ def add_ribs_from_section_span_fractions(
8181
)
8282

8383
def add_ribs_from_xsecs(
84-
self, indexes: list[int] = None, rib_thickness: float = None
84+
self, indexes: list[int] | None = None, rib_thickness: float | None = None
8585
):
8686
if rib_thickness is None:
8787
rib_thickness = self.default_rib_thickness
@@ -117,7 +117,7 @@ def add_ribs_from_xsecs(
117117
def add_ribs_from_span_fractions(
118118
self,
119119
span_fractions: float | list[float] | np.ndarray = np.linspace(0, 1, 10),
120-
rib_thickness: float = None,
120+
rib_thickness: float | None = None,
121121
):
122122
### Handle span_fractions if it's not an iterable
123123
try:
@@ -164,7 +164,7 @@ def add_tube_spar(
164164
y_over_c_location_root=None,
165165
x_over_c_location_tip=None,
166166
y_over_c_location_tip=None,
167-
diameter_tip: float = None,
167+
diameter_tip: float | None = None,
168168
cut_ribs: bool = True,
169169
):
170170
if diameter_tip is None:

0 commit comments

Comments
 (0)