Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort

Expand Down
9 changes: 7 additions & 2 deletions src/ansys/fluent/visualization/matplotlib/matplot_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional

from ansys.fluent.core.meta import Command
from ansys.fluent.core.post_objects.post_helper import PostAPIHelper
from ansys.fluent.core.post_objects.post_object_definitions import (
MonitorDefn,
XYPlotDefn,
Expand All @@ -22,8 +23,12 @@ class Plots(PlotsContainer):
session so that plots can be created.
"""

def __init__(self, session, local_surfaces_provider=None):
super().__init__(session, sys.modules[__name__], local_surfaces_provider)
def __init__(
self, session, post_api_helper=PostAPIHelper, local_surfaces_provider=None
):
super().__init__(
session, sys.modules[__name__], post_api_helper, local_surfaces_provider
)


class XYPlot(XYPlotDefn):
Expand Down
9 changes: 7 additions & 2 deletions src/ansys/fluent/visualization/pyvista/pyvista_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Optional

from ansys.fluent.core.meta import Command
from ansys.fluent.core.post_objects.post_helper import PostAPIHelper
from ansys.fluent.core.post_objects.post_object_definitions import (
ContourDefn,
MeshDefn,
Expand All @@ -26,8 +27,12 @@ class Graphics(GraphicsContainer):
session so that graphics objects can be created.
"""

def __init__(self, session, local_surfaces_provider=None):
super().__init__(session, sys.modules[__name__], local_surfaces_provider)
def __init__(
self, session, post_api_helper=PostAPIHelper, local_surfaces_provider=None
):
super().__init__(
session, sys.modules[__name__], post_api_helper, local_surfaces_provider
)


class Mesh(MeshDefn):
Expand Down
15 changes: 9 additions & 6 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ def __init__(self, obj=None):


def test_field_api():
pyvista_graphics = Graphics(session=None)
pyvista_graphics = Graphics(session=None, post_api_helper=MockAPIHelper)
contour1 = pyvista_graphics.Contours["contour-1"]

field_info = contour1._api_helper.field_info()
field_data = contour1._api_helper.field_data()

Expand Down Expand Up @@ -432,21 +433,23 @@ def test_surface_object():
assert "surf-1" in cont1.surfaces_list.allowed_values

# New surface is not available in allowed values for plots.
matplotlib_plots = Plots(session=None)
matplotlib_plots = Plots(session=None, post_api_helper=MockAPIHelper)
p1 = matplotlib_plots.XYPlots["p-1"]
assert "surf-1" not in p1.surfaces_list.allowed_values

# With local surface provider it becomes available.
local_surfaces_provider = Graphics(session=None).Surfaces
matplotlib_plots = Plots(
session=None, local_surfaces_provider=local_surfaces_provider
session=None,
post_api_helper=MockAPIHelper,
local_surfaces_provider=local_surfaces_provider,
)
assert "surf-1" in p1.surfaces_list.allowed_values


def test_create_plot_objects():
matplotlib_plots1 = Plots(session=None)
matplotlib_plots2 = Plots(session=None)
matplotlib_plots1 = Plots(session=None, post_api_helper=MockAPIHelper)
matplotlib_plots2 = Plots(session=None, post_api_helper=MockAPIHelper)
matplotlib_plots1.XYPlots["p-1"]
matplotlib_plots2.XYPlots["p-2"]

Expand All @@ -457,7 +460,7 @@ def test_create_plot_objects():

def test_xyplot_object():

matplotlib_plots = Plots(session=None)
matplotlib_plots = Plots(session=None, post_api_helper=MockAPIHelper)
p1 = matplotlib_plots.XYPlots["p-1"]
field_info = p1._api_helper.field_info()

Expand Down