Skip to content

Commit e38e48f

Browse files
Passing pyright checks
1 parent d2f06c9 commit e38e48f

File tree

11 files changed

+105
-80
lines changed

11 files changed

+105
-80
lines changed

src/concreteproperties/analysis_section.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ def plot_mesh(
427427
cmap = ListedColormap(colour_array)
428428

429429
# plot the mesh colours
430-
ax.tripcolor(
430+
ax.tripcolor( # pyright: ignore
431431
self.mesh_nodes[:, 0],
432432
self.mesh_nodes[:, 1],
433-
self.mesh_elements[:, 0:3],
433+
self.mesh_elements[:, 0:3], # pyright: ignore
434434
c,
435435
cmap=cmap,
436436
)
@@ -439,7 +439,7 @@ def plot_mesh(
439439
ax.triplot(
440440
self.mesh_nodes[:, 0],
441441
self.mesh_nodes[:, 1],
442-
self.mesh_elements[:, 0:3],
442+
self.mesh_elements[:, 0:3], # pyright: ignore
443443
lw=0.5,
444444
color="black",
445445
alpha=alpha,
@@ -467,10 +467,10 @@ def plot_shape(
467467
cmap = ListedColormap(colour_array)
468468

469469
# plot the mesh colours
470-
ax.tripcolor(
470+
ax.tripcolor( # pyright: ignore
471471
self.mesh_nodes[:, 0],
472472
self.mesh_nodes[:, 1],
473-
self.mesh_elements[:, 0:3],
473+
self.mesh_elements[:, 0:3], # pyright: ignore
474474
c,
475475
cmap=cmap,
476476
)

src/concreteproperties/concrete_section.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import matplotlib.patches as mpatches
1010
import numpy as np
1111
import sectionproperties.pre.geometry as sp_geom
12+
import sectionproperties.pre.pre as sp_pre
1213
from rich.live import Live
1314
from scipy.optimize import brentq
1415

@@ -83,6 +84,11 @@ def __init__(
8384
cp_geom = CPGeom(geom=geom.geom, material=geom.material)
8485
self.strand_geometries.append(cp_geom)
8586
else:
87+
if isinstance(geom.material, sp_pre.Material):
88+
msg = "'material' must be a concreteproperties Material object, "
89+
msg += "not a sectionproperties Material object."
90+
raise RuntimeError(msg)
91+
8692
cp_geom = CPGeom(geom=geom.geom, material=geom.material)
8793

8894
if cp_geom.material.meshed:
@@ -330,7 +336,7 @@ def calculate_cracked_properties(
330336
b=b,
331337
args=(cracked_results),
332338
xtol=1e-3,
333-
rtol=1e-6,
339+
rtol=1e-6, # pyright: ignore [reportArgumentType]
334340
full_output=True,
335341
disp=False,
336342
)
@@ -937,7 +943,7 @@ def ultimate_bending_capacity(
937943
b=b,
938944
args=(n, ultimate_results),
939945
xtol=1e-3,
940-
rtol=1e-6,
946+
rtol=1e-6, # pyright: ignore [reportArgumentType]
941947
full_output=True,
942948
disp=False,
943949
)

src/concreteproperties/design_codes/as3600.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def create_concrete_material(
147147
colour=colour,
148148
)
149149

150-
def create_steel_material(
150+
def create_steel_material( # pyright: ignore [reportIncompatibleMethodOverride]
151151
self,
152152
yield_strength: float = 500,
153153
ductility_class: str = "N",
@@ -338,7 +338,7 @@ def get_n_ub(
338338

339339
return balanced_res.n
340340

341-
def ultimate_bending_capacity(
341+
def ultimate_bending_capacity( # pyright: ignore [reportIncompatibleMethodOverride]
342342
self,
343343
theta: float = 0,
344344
n_design: float = 0,
@@ -382,7 +382,7 @@ def non_linear_phi(phi_guess):
382382
a=phi_0,
383383
b=0.85,
384384
xtol=1e-3,
385-
rtol=1e-6,
385+
rtol=1e-6, # pyright: ignore [reportArgumentType]
386386
full_output=True,
387387
disp=False,
388388
)
@@ -454,7 +454,7 @@ def non_linear_phi(phi_guess):
454454

455455
return f_ult_res, ult_res, phi
456456

457-
def moment_interaction_diagram(
457+
def moment_interaction_diagram( # pyright: ignore [reportIncompatibleMethodOverride]
458458
self,
459459
theta: float = 0,
460460
limits: list[tuple[str, float]] | None = None,
@@ -580,7 +580,7 @@ def moment_interaction_diagram(
580580

581581
return f_mi_res, mi_res, phis
582582

583-
def biaxial_bending_diagram(
583+
def biaxial_bending_diagram( # pyright: ignore [reportIncompatibleMethodOverride]
584584
self,
585585
n_design: float = 0,
586586
n_points: int = 48,

src/concreteproperties/design_codes/nzs3101.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ def max_comp_strength(
641641
# Calculate maximum axial compression strength for a singly reinf wall
642642
# member about minor axis
643643
max_comp = 0.06 * conc_capacity
644+
else:
645+
msg = "Invalid section type"
646+
raise RuntimeError(msg)
644647

645648
return max_comp
646649

@@ -821,7 +824,7 @@ def check_f_c_limits(
821824
msg += f"{compressive_strength:.0f} MPa was specified for this material"
822825
raise ValueError(msg)
823826

824-
def create_concrete_material(
827+
def create_concrete_material( # pyright: ignore [reportIncompatibleMethodOverride]
825828
self,
826829
compressive_strength: float,
827830
ultimate_strain: float = 0.003,
@@ -963,7 +966,7 @@ def predefined_steel_materials(self) -> tuple[dict, list[str], list[str]]:
963966

964967
return properties_dict, nom_properties, prob_properties
965968

966-
def create_steel_material(
969+
def create_steel_material( # pyright: ignore [reportIncompatibleMethodOverride]
967970
self,
968971
steel_grade: str | None = None,
969972
yield_strength: float | None = None,
@@ -1180,6 +1183,11 @@ def create_steel_material(
11801183
if steel_grade.lower() in prob_properties and colour in ["red"]:
11811184
colour = "steelblue"
11821185

1186+
# ensure properties are valid
1187+
if phi_os is None or yield_strength is None or fracture_strain is None:
1188+
msg = "Invalid property specification"
1189+
raise RuntimeError(msg)
1190+
11831191
return NZS3101.SteelBarNZ(
11841192
name=name,
11851193
steel_grade=steel_grade,
@@ -1602,7 +1610,7 @@ def create_prob_section(
16021610

16031611
return prob_concrete_section
16041612

1605-
def ultimate_bending_capacity(
1613+
def ultimate_bending_capacity( # pyright: ignore [reportIncompatibleMethodOverride]
16061614
self,
16071615
pphr_class: str = "NDPR",
16081616
analysis_type: str = "nom_chk",
@@ -1668,7 +1676,7 @@ def ultimate_bending_capacity(
16681676

16691677
return f_ult_res, ult_res, phi
16701678

1671-
def moment_interaction_diagram(
1679+
def moment_interaction_diagram( # pyright: ignore [reportIncompatibleMethodOverride]
16721680
self,
16731681
pphr_class: str = "NDPR",
16741682
analysis_type: str = "nom_chk",
@@ -1786,7 +1794,7 @@ def moment_interaction_diagram(
17861794

17871795
return f_mi_res, mi_res, phis
17881796

1789-
def biaxial_bending_diagram(
1797+
def biaxial_bending_diagram( # pyright: ignore [reportIncompatibleMethodOverride]
17901798
self,
17911799
pphr_class: str = "NDPR",
17921800
analysis_type: str = "nom_chk",

src/concreteproperties/material.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Concrete(Material):
5858

5959
name: str
6060
density: float
61-
stress_strain_profile: ssp.ConcreteServiceProfile
61+
stress_strain_profile: ssp.ConcreteServiceProfile # pyright: ignore [reportIncompatibleVariableOverride]
6262
ultimate_stress_strain_profile: ssp.ConcreteUltimateProfile
6363
flexural_tensile_strength: float
6464
colour: str
@@ -161,7 +161,7 @@ class SteelStrand(Steel):
161161

162162
name: str
163163
density: float
164-
stress_strain_profile: ssp.StrandProfile
164+
stress_strain_profile: ssp.StrandProfile # pyright: ignore [reportIncompatibleVariableOverride]
165165
colour: str
166166
prestress_stress: float = 0
167167
meshed: bool = field(default=False, init=False)

src/concreteproperties/post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def plotting_context(
6060

6161
try:
6262
if axis_index is None:
63-
axis_index = (0,) * ax.ndim
64-
ax = ax[axis_index]
63+
axis_index = (0,) * ax.ndim # pyright: ignore
64+
ax = ax[axis_index] # pyright: ignore
6565
except (AttributeError, TypeError):
6666
pass # only 1 axis, not an array
6767
except IndexError as exc:

src/concreteproperties/pre.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from sectionproperties.pre.geometry import Geometry
1313
from sectionproperties.pre.library.primitive_sections import circular_section_by_area
1414
from shapely import LineString, Polygon
15+
from shapely.geometry.base import GeometrySequence
1516
from shapely.ops import split
1617

1718
from concreteproperties.material import Concrete
@@ -185,7 +186,8 @@ def split_section(
185186
Geometries above and below the line
186187
"""
187188
# round point
188-
point = np.round(point, 6)
189+
pt_rounded = np.round(np.array(point), 6)
190+
point = (pt_rounded[0], pt_rounded[1])
189191

190192
# generate unit vector
191193
vector = np.cos(theta), np.sin(theta)
@@ -204,6 +206,10 @@ def split_section(
204206
polys = [self.geom]
205207

206208
# sort geometries
209+
if isinstance(polys, GeometrySequence):
210+
msg = "Geometry split failure."
211+
raise RuntimeError(msg)
212+
207213
top_polys, bot_polys = self.sort_polys(polys=polys, point=point, vector=vector)
208214

209215
# assign material properties and create cp geometry objects
@@ -339,7 +345,7 @@ def to_sp_geom(self) -> Geometry:
339345
Returns:
340346
``sectionproperties`` geometry object
341347
"""
342-
return Geometry(geom=self.geom, material=self.material)
348+
return Geometry(geom=self.geom, material=self.material) # pyright: ignore [reportArgumentType]
343349

344350

345351
class CPGeomConcrete(CPGeom):
@@ -372,7 +378,7 @@ def add_bar(
372378
x: float,
373379
y: float,
374380
n: int = 4,
375-
) -> CompoundGeometry:
381+
) -> Geometry | CompoundGeometry:
376382
"""Adds a reinforcing bar to a ``sectionproperties`` geometry.
377383
378384
Bars are discretised by four points by default.
@@ -388,7 +394,7 @@ def add_bar(
388394
Returns:
389395
Reinforced concrete geometry with added bar
390396
"""
391-
bar = circular_section_by_area(area=area, n=n, material=material).shift_section(
397+
bar = circular_section_by_area(area=area, n=n, material=material).shift_section( # pyright: ignore [reportArgumentType]
392398
x_offset=x, y_offset=y
393399
)
394400

@@ -406,7 +412,7 @@ def add_bar_rectangular_array(
406412
anchor: tuple[float, float] = (0, 0),
407413
exterior_only: bool = False,
408414
n: int = 4,
409-
) -> CompoundGeometry:
415+
) -> Geometry | CompoundGeometry:
410416
"""Adds a rectangular array of reinforcing bars to a ``sectionproperties`` geometry.
411417
412418
Bars are discretised by four points by default.
@@ -438,7 +444,7 @@ def add_bar_rectangular_array(
438444
add_bar = True
439445

440446
if add_bar:
441-
bar = circular_section_by_area(area=area, n=n, material=material)
447+
bar = circular_section_by_area(area=area, n=n, material=material) # pyright: ignore [reportArgumentType]
442448
x = anchor[0] + i_idx * x_s
443449
y = anchor[1] + j_idx * y_s
444450
bar = bar.shift_section(x_offset=x, y_offset=y)
@@ -456,7 +462,7 @@ def add_bar_circular_array(
456462
theta_0: float = 0,
457463
ctr: tuple[float, float] = (0, 0),
458464
n: int = 4,
459-
) -> CompoundGeometry:
465+
) -> Geometry | CompoundGeometry:
460466
"""Adds a circular array of reinforcing bars to a ``sectionproperties`` geometry.
461467
462468
Bars are discretised by four points by default.
@@ -478,7 +484,7 @@ def add_bar_circular_array(
478484
d_theta = 2 * np.pi / n_bar
479485

480486
for idx in range(n_bar):
481-
bar = circular_section_by_area(area=area, n=n, material=material)
487+
bar = circular_section_by_area(area=area, n=n, material=material) # pyright: ignore [reportArgumentType]
482488
theta = theta_0 + idx * d_theta
483489
x = ctr[0] + r_array * np.cos(theta)
484490
y = ctr[1] + r_array * np.sin(theta)

src/concreteproperties/prestressed_section.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(
9797
self.gross_properties.n_prestress = n_prestress
9898
self.gross_properties.m_prestress = m_prestress
9999

100-
def calculate_cracked_properties(
100+
def calculate_cracked_properties( # pyright: ignore [reportIncompatibleMethodOverride]
101101
self,
102102
m_ext: float,
103103
n_ext: float = 0,
@@ -164,7 +164,7 @@ def calculate_cracked_properties(
164164
b=b,
165165
args=(cracked_results),
166166
xtol=1e-3,
167-
rtol=1e-6,
167+
rtol=1e-6, # pyright: ignore [reportArgumentType]
168168
full_output=True,
169169
disp=False,
170170
)
@@ -175,7 +175,7 @@ def calculate_cracked_properties(
175175

176176
return cracked_results
177177

178-
def calculate_cracking_moment(
178+
def calculate_cracking_moment( # pyright: ignore [reportIncompatibleMethodOverride]
179179
self,
180180
n: float,
181181
m_int: float,
@@ -308,7 +308,7 @@ def calc_min_stress():
308308

309309
return min_stress
310310

311-
def moment_curvature_analysis(
311+
def moment_curvature_analysis( # pyright: ignore [reportIncompatibleMethodOverride]
312312
self,
313313
positive: bool = True,
314314
n: float = 0,
@@ -376,7 +376,7 @@ def find_intial_curvature(kappa0):
376376
progress_bar=progress_bar,
377377
)
378378

379-
def ultimate_bending_capacity(
379+
def ultimate_bending_capacity( # pyright: ignore [reportIncompatibleMethodOverride]
380380
self,
381381
positive: bool = True,
382382
n: float = 0,
@@ -398,23 +398,23 @@ def ultimate_bending_capacity(
398398

399399
return super().ultimate_bending_capacity(theta=theta, n=n)
400400

401-
def moment_interaction_diagram(self):
401+
def moment_interaction_diagram(self): # pyright: ignore [reportIncompatibleMethodOverride]
402402
"""Generates a moment interaction diagram.
403403
404404
Raises:
405405
NotImplementedError: This feature has not yet been implemented.
406406
"""
407407
raise NotImplementedError
408408

409-
def biaxial_bending_diagram(self):
409+
def biaxial_bending_diagram(self): # pyright: ignore [reportIncompatibleMethodOverride]
410410
"""Generates a biaxial bending diagram.
411411
412412
Raises:
413413
NotImplementedError: This feature has not yet been implemented.
414414
"""
415415
raise NotImplementedError
416416

417-
def calculate_uncracked_stress(
417+
def calculate_uncracked_stress( # pyright: ignore [reportIncompatibleMethodOverride]
418418
self,
419419
n: float = 0,
420420
m: float = 0,
@@ -554,7 +554,7 @@ def calculate_uncracked_stress(
554554
strand_forces=strand_forces,
555555
)
556556

557-
def calculate_cracked_stress(
557+
def calculate_cracked_stress( # pyright: ignore [reportIncompatibleMethodOverride]
558558
self,
559559
cracked_results: res.CrackedResults,
560560
) -> res.StressResult:

0 commit comments

Comments
 (0)