Skip to content

feat: parameterize tests for element and volume selection in post-processing - #4110

Merged
germa89 merged 2 commits into
mainfrom
refactor/incomplete-plotting
Jul 21, 2025
Merged

germa89 merged 2 commits into
mainfrom
refactor/incomplete-plotting

Conversation

@germa89

@germa89 germa89 commented Jul 21, 2025 •

Copy link
Copy Markdown
Collaborator

Description

As the title.

Also making sure we can do uncomplete selection plots.

Issue linked

Close #3782

Checklist

Summary by Sourcery

Parameterize post-processing tests for incomplete element and node selections and add volume-based selection tests to verify plotting behavior with partial selections

Enhancements:

  • Parameterize incomplete element selection tests using varying vmin, vmax, and vinc parameters
  • Parameterize incomplete node selection tests using varying vmin, vmax, and vinc parameters
  • Add parameterized volume selection test for plot_element_displacement

Copilot AI review requested due to automatic review settings July 21, 2025 10:57
@germa89
germa89 requested a review from a team as a code owner July 21, 2025 10:57
@ansys-reviewer-bot

Copy link
Copy Markdown
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@germa89 germa89 self-assigned this Jul 21, 2025
@sourcery-ai

sourcery-ai Bot commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors post-processing tests by parameterizing incomplete element and node selection ranges and introducing a parameterized volume selection test using pytest.mark.parametrize and dynamic mesh-based calculations.

File-Level Changes

Change Details Files
Parameterized incomplete element selection tests
  • Added pytest.mark.parametrize for vmin, vmax, vinc
  • Replaced manual mapdl.esel calls with dynamic n_elem-based calculations
  • Removed hardcoded selection cases
tests/test_post.py
Added parameterized volume selection test
  • Introduced test_plot_volume_selection with pytest.mark.parametrize over vol
  • Invoked mapdl.vsel and mapdl.eslv per volume parameter
tests/test_post.py
Parameterized incomplete node selection tests
  • Applied pytest.mark.parametrize for vmin, vmax, vinc on node tests
  • Refactored mapdl.nsel calls to use dynamic n_node-based calculations
  • Eliminated redundant static selection logic
tests/test_post.py

Assessment against linked issues

Issue Objective Addressed Explanation
#3782 Fix the crash that occurs when plotting nodal displacement after an incomplete node selection (e.g., after using mapdl.nsel with a subset of nodes). ✅
#3782 Ensure that incomplete element or node selections do not cause plotting functions (such as plot_nodal_displacement) to fail or crash Python. ✅
#3782 Add or update tests to verify that plotting with incomplete node or element selections works without errors. ✅

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors post-processing tests to use parameterized testing for element and node selection scenarios. The changes improve test coverage by systematically testing various selection ranges and increments, while also ensuring that incomplete selection plots function correctly.

  • Converts hardcoded test cases to parameterized tests using pytest.mark.parametrize
  • Adds systematic testing of different selection ranges (0-100%, 20-30%, etc.) with various increments
  • Separates volume selection testing into a dedicated parameterized test method
Comments suppressed due to low confidence (1)

tests/test_post.py:1284

  • The function name 'test_plot_incomplete_node_selection' should be 'test_plot_incomplete_nodal_selection' to maintain consistency with the original function name and the nodal displacement method being tested.
    def test_plot_incomplete_node_selection(mapdl, resume, vmin, vmax, vinc):

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @germa89 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions github-actions Bot added the new feature Request or proposal for a new feature label Jul 21, 2025
@codecov

codecov Bot commented Jul 21, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.36%. Comparing base (f021ab2) to head (c5dfd0c).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4110      +/-   ##
==========================================
- Coverage   91.39%   91.36%   -0.04%     
==========================================
  Files         189      189              
  Lines       15667    15667              
==========================================
- Hits        14319    14314       -5     
- Misses       1348     1353       +5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@germa89

germa89 commented Jul 21, 2025

Copy link
Copy Markdown
Collaborator Author

@pyansys-ci-bot LGTM.

@germa89
germa89 enabled auto-merge (squash) July 21, 2025 18:45

@pyansys-ci-bot pyansys-ci-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Approving this PR because germa89 said so in here 😬

LGTM

@germa89
germa89 merged commit 42f0749 into main Jul 21, 2025
@germa89
germa89 deleted the refactor/incomplete-plotting branch July 21, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Request or proposal for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete plots fails when nodes are selected

3 participants