Skip to content

Conversation

@SZeltaat
Copy link
Contributor

Description

This is the implementation of combined steel cross-sections allowing multiple steel grades in one section
(We must facilitate creating such cross-section as well. I will add a new parent issue for such features and will work on them after the refactor is done.)

The pattern is builder-composite.
I have made a questionable choice with adding a hidden method to SteelCrossSection only to be used in CombinedSteelCrossSection. Please give me feedback on that!

Fixes #824

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fe0e5d4) to head (f8cd24f).
⚠️ Report is 1 commits behind head on 734-refactor-steel-profiles.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           734-refactor-steel-profiles      #826   +/-   ##
=============================================================
  Coverage                       100.00%   100.00%           
=============================================================
  Files                              397       399    +2     
  Lines                            12249     12298   +49     
=============================================================
+ Hits                             12249     12298   +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a CombinedSteelCrossSection class to enable steel cross-sections composed of multiple components with potentially different steel grades. The implementation follows a builder-composite pattern using immutable dataclasses with a fluent API.

Key changes:

  • Introduced SteelCrossSectionProtocol to define the common interface for steel cross-sections
  • Added position/orientation fields (x_offset, y_offset, rotation_angle) to SteelCrossSection with a _transform method for internal use
  • Created CombinedSteelCrossSection with a builder pattern API via add_steel_cross_section method
  • Updated test files to use raw strings (r-prefix) for regex patterns in pytest assertions

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
blueprints/structural_sections/steel/steel_cross_section.py Adds Protocol definition, position/orientation fields, and internal _transform method to support combined sections
blueprints/structural_sections/steel/combined_steel_cross_section.py New class implementing the builder-composite pattern for combining multiple steel cross-sections
blueprints/structural_sections/steel/init.py Exports new classes for public API
tests/structural_sections/steel/test_steel_cross_section.py Adds tests for new position/orientation fields and _transform method
tests/structural_sections/steel/test_combined_steel_cross_section.py Comprehensive test suite for CombinedSteelCrossSection functionality
tests/structural_sections/test_polygon_builder.py Updates regex patterns to use raw strings
tests/structural_sections/steel/steel_profile_sections/test_strip_profile.py Updates regex patterns to use raw strings
tests/structural_sections/steel/steel_profile_sections/test_rhs_profile.py Updates regex patterns to use raw strings
tests/structural_sections/steel/steel_profile_sections/test_i_profile.py Updates regex patterns to use raw strings
tests/structural_sections/steel/steel_profile_sections/test_chs_profile.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_tube.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_triangle.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_rectangle.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_hexagon.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_cornered.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_circle.py Updates regex patterns to use raw strings
tests/structural_sections/geometric_cross_sections/test_cross_section_annular_sector.py Updates regex patterns to use raw strings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

y_offset : MM, optional
The y-coordinate offset of the cross-section's centroid [mm]. Default is 0.0.
rotation_angle : DEG, optional
The rotation angle of the cross-section in degrees (counter-clockwise). Default is 0.0
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period at the end of the sentence. The description should end with a period for consistency with other parameter descriptions in the docstring.

Suggested change
The rotation angle of the cross-section in degrees (counter-clockwise). Default is 0.0
The rotation angle of the cross-section in degrees (counter-clockwise). Default is 0.0.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,127 @@
"""Module containing the class definition for a combined steel cross-section, allowing for cross-sections with multiple steel materials."""
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The module docstring mentions "multiple steel materials" but the implementation allows combining multiple steel cross-sections that may differ in geometry, material, or both. Consider using more precise wording like "allowing for combined cross-sections with multiple steel components" or "enabling cross-sections composed of multiple steel parts with potentially different materials and geometries".

Suggested change
"""Module containing the class definition for a combined steel cross-section, allowing for cross-sections with multiple steel materials."""
"""Module containing the class definition for a combined steel cross-section, enabling cross-sections composed of multiple steel components with potentially different materials and geometries."""

Copilot uses AI. Check for mistakes.
steel_cross_section: SteelCrossSection,
kwargs: dict,
) -> None:
"""Test that the optional parameters can be set correctly."""
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says "Test that the optional parameters can be set correctly" but the test actually verifies that these parameters cannot be set via __init__ (they raise TypeError). The docstring should accurately describe what is being tested. Consider: "Test that the optional parameters cannot be set via initialization and raise TypeError."

Suggested change
"""Test that the optional parameters can be set correctly."""
"""Test that the optional parameters cannot be set via initialization and raise TypeError."""

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +32
Usage example:
```python
combined_section = (
CombinedSteelCrossSection()
.add_steel_cross_section(
steel_cross_section=main_steel_cross_section,
x_offset=0,
y_offset=0,
rotation_angle=0,
)
.add_steel_cross_section(
steel_cross_section=stiffener,
x_offset=0,
y_offset=main_steel_cross_section.cross_section.cross_section_height / 2 + stiffener.cross_section.cross_section_height / 2,
rotation_angle=0,
)
)
```
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The usage example references main_steel_cross_section and stiffener variables that are not defined in the example. For better clarity, consider either defining these variables in the example or adding a comment indicating they should be pre-defined, e.g.:

# Assuming main_steel_cross_section and stiffener are already defined
combined_section = (
    CombinedSteelCrossSection()
    ...
)

Copilot uses AI. Check for mistakes.
…t-combinedsteelcrosssection-with-the-possibility-of-cross-sections-with-multiple-steel-grades
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants