feat: deprecate legacy plotter - #3184
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3184 +/- ##
==========================================
+ Coverage 82.80% 83.07% +0.26%
==========================================
Files 94 94
Lines 11754 11775 +21
==========================================
+ Hits 9733 9782 +49
+ Misses 2021 1993 -28 |
|
The documentation for this pull request will be available at https://dpf.docs.pyansys.com/pull/3184. Please allow some time for the documentation to be deployed. |
|
Thanks for the refactor, @moe-ad. I noticed a behavioral regression in
Is this intended? Should we preserve legacy behavior by reusing the existing internal plotter/config from This seems important for backward compatibility during deprecation. |
Great catch! The plotter created in |
| # Build a FieldsContainer restricted to the selected label_space so we can | ||
| # scatter-merge onto the mesh (later fields overwrite earlier ones). | ||
| filtered_fc = FieldsContainer(server=self._server) | ||
| for label in self.labels: |
There was a problem hiding this comment.
If you are reusing the labels from the initial FieldsContainer, then in theory you should end-up with the same number of fields, no? I am not clear on why thsi is necessary. Or did you mean to use the label_space input of the function?
There was a problem hiding this comment.
This is just to create a new FieldsContainer with the same labels, otherwise line 644 would fail with DPFServerException: the query is not correctly asked i.e. your collection doesn't have any LabelSpace.
|
Some tests with 'continue-on-error: true' have failed:
|
Closes #2918.
This PR implements changes required to deprecate the legacy
Plotterclass. By far the major blocker that has been preventing its deprecation is theplot_contourmethod, which is used directly by theFieldandMeshedRegionclasses. Theplot_contourmethod does too much for a single method, which unfortunately complicates things.In summary, this PR:
plot_contouracross:_map_field_to_meshfunction whose logic overlaps some sections ofplot_contour, so I used this opportunity to refactor things).Plotter.plot_chartto a module level function (another alternative is to make it a method ofDpfPlotter).Plotterclass so users are informed of the eventual deprecation, and to the API documentation (on the assumption that this ships with 0.17.0).In detail, this PR:
DpfPlotter.add_fields_container()as the new public method for plotting aFieldsContaineras a single contour.Plotter.plot_contour()workflow into smaller private helpers inplotter.py, and these private helpers are then reused when needed.MeshedRegion._scatter_field_to_location(), and reuses that logic fromvtk_helper._map_field_to_mesh().FieldsContainer._normalize_shell_layers()to contain the logic for normalizing multi-layer shell results before plotting.Field.plot(),FieldsContainer.plot(), andMeshedRegion.plot()to useDpfPlotterdirectly instead of relying on the legacyPlotter.plot_chart()function, while keeping Plotter.plot_chart() as a deprecated wrapper for compatibility.Plotteravailable for now, but adds deprecation warnings and deprecation notes (to the API documentation) to guide users towardDpfPlotter.End results
PlotterCheck here for appearance of API deprecation notes.