feat: add rpsd method to MapdlGrpc for variable retrieval as an array#4114
feat: add rpsd method to MapdlGrpc for variable retrieval as an array#4114
Conversation
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Reviewer's GuideAdds an rpsd wrapper in MapdlGrpc to retrieve power spectral density variables as numpy arrays, alongside a dedicated pytest fixture and unit test to validate the new functionality. Class diagram for the new rpsd method in MapdlGrpcclassDiagram
class MapdlBase {
+rpsd(ir, ia, ib, itype, datum, name, signif, **kwargs)
}
class MapdlGrpc {
+rpsd(ir, ia, ib, itype, datum, name, signif, **kwargs) NDArray[np.float64]
+vget(varname, index)
}
MapdlGrpc --|> MapdlBase
MapdlGrpc : +rpsd overrides MapdlBase.rpsd
MapdlGrpc : +rpsd returns numpy array
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new rpsd method to the MapdlGrpc class that wraps the MAPDL RPSD command and returns the result as a numpy array, making it more convenient for Python users to work with power spectral density analysis results.
- Adds
rpsdmethod wrapper toMapdlGrpcclass that returns numpy arrays instead of raw MAPDL output - Includes test coverage with a PSD analysis fixture
- Follows the established pattern of other wrapped methods like
esol
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ansys/mapdl/core/mapdl_grpc.py | Adds the rpsd method wrapper that calls the parent method and returns results via vget |
| tests/conftest.py | Adds psd_analysis fixture using vm203 example for testing |
| tests/test_mapdl.py | Adds test case for the new rpsd method |
There was a problem hiding this comment.
Hey @germa89 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/ansys/mapdl/core/mapdl_grpc.py:3294` </location>
<code_context>
return self.vget("_temp", nvar)
+ @wraps(MapdlBase.rpsd)
+ def rpsd(
+ self,
+ ir: str = "",
+ ia: str = "",
+ ib: str = "",
+ itype: int | str = "",
+ datum: int | str = "",
+ name: str = "",
+ signif: str = "",
+ **kwargs,
+ ) -> NDArray[np.float64]:
+ """Wraps RPSD to return the variable as an array."""
</code_context>
<issue_to_address>
Default argument values may not align with expected RPSD usage.
Defaulting 'itype' and 'datum' to empty strings, despite their int | str type hints, may lead to type errors. Using None as the default and handling type checks inside the method is recommended.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4114 +/- ##
=======================================
Coverage 91.39% 91.40%
=======================================
Files 189 189
Lines 15667 15671 +4
=======================================
+ Hits 14319 14324 +5
+ Misses 1348 1347 -1 🚀 New features to boost your workflow:
|
|
@pyansys-ci-bot LGTM. |

Description
As the title.
It allows to do:
Issue linked
Related to #3865 so we can facilitate PSD related works.
Checklist
draftif it is not ready to be reviewed yet.feat: adding new MAPDL command)