From 4bbbb941e59c140eb6a768f79f13e428a9fd9a50 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 12 Jun 2024 12:00:59 +0200 Subject: [PATCH 1/4] fix: Rename built in shadowing variables --- src/ansys/geometry/core/plotting/plotter.py | 46 ++++++++++++--------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/ansys/geometry/core/plotting/plotter.py b/src/ansys/geometry/core/plotting/plotter.py index 0cef862613..bc84bb2284 100644 --- a/src/ansys/geometry/core/plotting/plotter.py +++ b/src/ansys/geometry/core/plotting/plotter.py @@ -301,7 +301,7 @@ def add_design_point(self, design_point: DesignPoint, **plotting_options) -> Non def plot_iter( self, plotting_list: List[Any], - filter: str = None, + name_filter: str = None, **plotting_options, ) -> None: """ @@ -314,17 +314,17 @@ def plot_iter( ---------- plotting_list : List[Any] List of objects you want to plot. - filter : str, default: None + name_filter : str, default: None Regular expression with the desired name or names you want to include in the plotter. **plotting_options : dict, default: None Keyword arguments. For allowable keyword arguments, see the :meth:`Plotter.add_mesh ` method. """ for object in plotting_list: - _ = self.plot(object, filter, **plotting_options) + _ = self.plot(object, name_filter, **plotting_options) # Override add function from plotter - def plot(self, object: Any, filter: str = None, **plotting_options) -> None: + def plot(self, plottable_object: Any, name_filter: str = None, **plotting_options) -> None: """ Add a custom mesh to the plotter. @@ -332,7 +332,9 @@ def plot(self, object: Any, filter: str = None, **plotting_options) -> None: ---------- object : Any Object to add. - filter : str, default: None + plottable_object : str, default: None + Regular expression with the desired name or names you want to include in the plotter. + name_filter: str, default: None Regular expression with the desired name or names you want to include in the plotter. **plotting_options : dict, default: None Keyword arguments. For allowable keyword arguments, depend of the backend implementation @@ -351,24 +353,28 @@ def plot(self, object: Any, filter: str = None, **plotting_options) -> None: else: merge_components = None # Add the custom object to the plotter - if isinstance(object, DesignPoint): - self.add_design_point(object, **plotting_options) - elif isinstance(object, Sketch): - self.add_sketch(object, **plotting_options) - elif isinstance(object, Body) or isinstance(object, MasterBody): - self.add_body(object, merge_bodies, **plotting_options) - elif isinstance(object, Design) or isinstance(object, Component): - self.add_component(object, merge_components, merge_bodies, **plotting_options) - elif isinstance(object, List) and object != [] and isinstance(object[0], pv.PolyData): - self.add_sketch_polydata(object, **plotting_options) - elif isinstance(object, List): - self.plot_iter(object, filter, **plotting_options) - elif isinstance(object, MeshObjectPlot): + if isinstance(plottable_object, DesignPoint): + self.add_design_point(plottable_object, **plotting_options) + elif isinstance(plottable_object, Sketch): + self.add_sketch(plottable_object, **plotting_options) + elif isinstance(plottable_object, Body) or isinstance(object, MasterBody): + self.add_body(plottable_object, merge_bodies, **plotting_options) + elif isinstance(plottable_object, Design) or isinstance(object, Component): + self.add_component(plottable_object, merge_components, merge_bodies, **plotting_options) + elif ( + isinstance(plottable_object, List) + and plottable_object != [] + and isinstance(plottable_object[0], pv.PolyData) + ): + self.add_sketch_polydata(plottable_object, **plotting_options) + elif isinstance(plottable_object, List): + self.plot_iter(plottable_object, name_filter, **plotting_options) + elif isinstance(plottable_object, MeshObjectPlot): self._backend.pv_interface.set_add_mesh_defaults(plotting_options) - self._backend.pv_interface.plot(object, filter, **plotting_options) + self._backend.pv_interface.plot(plottable_object, name_filter, **plotting_options) else: # any left type should be a PyVista object - self._backend.pv_interface.plot(object, filter, **plotting_options) + self._backend.pv_interface.plot(plottable_object, name_filter, **plotting_options) def show( self, From 4e252372773d0258f39ee0661ed0307c9a1cd6ca Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot Date: Wed, 12 Jun 2024 10:08:06 +0000 Subject: [PATCH 2/4] Adding changelog entry: 1257.fixed.md --- doc/changelog.d/1257.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/1257.fixed.md diff --git a/doc/changelog.d/1257.fixed.md b/doc/changelog.d/1257.fixed.md new file mode 100644 index 0000000000..e2c3574c61 --- /dev/null +++ b/doc/changelog.d/1257.fixed.md @@ -0,0 +1 @@ +fix: Rename built in shadowing variables \ No newline at end of file From ec48a1048c5a48714369434b9f8c9a4c554608c1 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 12 Jun 2024 12:36:08 +0200 Subject: [PATCH 3/4] fix: Update viz tool dependency --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index abae03d92e..30a11d361f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ dependencies = [ "ansys-api-geometry==0.4.4", "ansys-tools-path>=0.3,<1", - "ansys-tools-visualization-interface>=0.2.4,<1", + "ansys-tools-visualization-interface>=0.2.6,<1", "beartype>=0.11.0,<0.19", "grpcio>=1.35.0,<2", "grpcio-health-checking>=1.45.0,<2", @@ -50,7 +50,7 @@ all = [ tests = [ "ansys-platform-instancemanagement==1.1.2", "ansys-tools-path==0.6.0", - "ansys-tools-visualization-interface==0.2.4", + "ansys-tools-visualization-interface==0.2.6", "beartype==0.18.5", "docker==7.1.0", "grpcio==1.64.1", @@ -77,7 +77,7 @@ tests-minimal = [ ] doc = [ "ansys-sphinx-theme[autoapi]==0.16.5", - "ansys-tools-visualization-interface==0.2.4", + "ansys-tools-visualization-interface==0.2.6", "beartype==0.18.5", "docker==7.1.0", "ipyvtklink==0.2.3", From 5664a74b0dc1fab383223f4352d540e19853d0b4 Mon Sep 17 00:00:00 2001 From: Alex Fernandez <21alex295@gmail.com> Date: Wed, 12 Jun 2024 13:05:28 +0200 Subject: [PATCH 4/4] Update src/ansys/geometry/core/plotting/plotter.py Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> --- src/ansys/geometry/core/plotting/plotter.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ansys/geometry/core/plotting/plotter.py b/src/ansys/geometry/core/plotting/plotter.py index bc84bb2284..856279fa1f 100644 --- a/src/ansys/geometry/core/plotting/plotter.py +++ b/src/ansys/geometry/core/plotting/plotter.py @@ -330,8 +330,6 @@ def plot(self, plottable_object: Any, name_filter: str = None, **plotting_option Parameters ---------- - object : Any - Object to add. plottable_object : str, default: None Regular expression with the desired name or names you want to include in the plotter. name_filter: str, default: None