Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Enhance native API coverage common.py #5757

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
62 changes: 62 additions & 0 deletions src/ansys/aedt/core/visualization/report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ansys.aedt.core.generic.constants import LineStyle
from ansys.aedt.core.generic.constants import SymbolStyle
from ansys.aedt.core.generic.constants import TraceType
from ansys.aedt.core.generic.errors import AEDTRuntimeError
from ansys.aedt.core.generic.file_utils import generate_unique_name
from ansys.aedt.core.generic.file_utils import write_configuration_file
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
Expand Down Expand Up @@ -2643,6 +2644,67 @@
self._post.oreportsetup.ApplyReportTemplate(self.plot_name, input_file, property_type)
return True

@pyaedt_function_handler(trace_name="name")
def add_trace_characteristics(self, name, arguments=None, solution_range=None):
"""Add a trace characteristic to the plot.

Parameters
----------
name : str
Name of the trace characteristic.
arguments : list, optional
Arguments if any. The default is ``None``.
solution_range : list, optional
Output range. The default is ``None``, in which case
the full range is used.

Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
if not arguments:
arguments = []
if not solution_range:
solution_range = ["Full"]
self._post.oreportsetup.AddTraceCharacteristics(self.plot_name, name, arguments, solution_range)
return True

Check warning on line 2671 in src/ansys/aedt/core/visualization/report/common.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/visualization/report/common.py#L2666-L2671

Added lines #L2666 - L2671 were not covered by tests

@pyaedt_function_handler()
def export_table_to_file(self, plot_name, output_file, table_type="Marker"):
"""Export a marker table or a legend (with trace characteristics result) from a report to a file.

Parameters
----------
plot_name : str
Plot name.
output_file : str
Full path of the outputted file.
Valid extensions for the output file are: ``.tab``, ``.csv``
table_type : str
Valid table types are: ``Marker``, ``DeltaMarker``, ``Legend``.
Default table_type is ``Marker``.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

References
----------
>>> oModule.ExportTableToFile
"""
plot_names = [plot.plot_name for plot in self._post.plots]
if plot_name not in plot_names:
raise AEDTRuntimeError("Please enter a plot name.")
extension = os.path.splitext(output_file)[1]
if extension not in [".tab", ".csv"]:
raise AEDTRuntimeError("Please enter a valid file extension: ``.tab``, ``.csv``.")
if table_type not in ["Marker", "DeltaMarker", "Legend"]:
raise AEDTRuntimeError("Please enter a valid file extension: ``Marker``, ``DeltaMarker``, ``Legend``.")
self._post.oreportsetup.ExportTableToFile(plot_name, output_file, table_type)
return True

Check warning on line 2706 in src/ansys/aedt/core/visualization/report/common.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/visualization/report/common.py#L2697-L2706

Added lines #L2697 - L2706 were not covered by tests

@staticmethod
@pyaedt_function_handler()
def __props_with_default(dict_in, key, default_value=None):
Expand Down
52 changes: 0 additions & 52 deletions src/ansys/aedt/core/visualization/report/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,32 +448,6 @@ def clear_all_eye_measurements(self):
self._post.oreportsetup.ClearAllTraceCharacteristics(self.plot_name)
return True

@pyaedt_function_handler(trace_name="name")
def add_trace_characteristics(self, name, arguments=None, solution_range=None):
"""Add a trace characteristic to the plot.

Parameters
----------
name : str
Name of the trace characteristic.
arguments : list, optional
Arguments if any. The default is ``None``.
solution_range : list, optional
Output range. The default is ``None``, in which case
the full range is used.

Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
if not arguments:
arguments = []
if not solution_range:
solution_range = ["Full"]
self._post.oreportsetup.AddTraceCharacteristics(self.plot_name, name, arguments, solution_range)
return True

@pyaedt_function_handler(out_file="output_file")
def export_mask_violation(self, output_file=None):
"""Export the eye diagram mask violations to a TAB file.
Expand Down Expand Up @@ -1035,32 +1009,6 @@ def clear_all_eye_measurements(self):
self._post.oreportsetup.ClearAllTraceCharacteristics(self.plot_name)
return True

@pyaedt_function_handler(trace_name="name")
def add_trace_characteristics(self, name, arguments=None, solution_range=None):
"""Add a trace characteristic to the plot.

Parameters
----------
name : str
Name of the trace characteristic.
arguments : list, optional
Arguments if any. The default is ``None``.
solution_range : list, optional
Output range. The default is ``None``, in which case
the full range is used.

Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
if not arguments:
arguments = []
if not solution_range:
solution_range = ["Full"]
self._post.oreportsetup.AddTraceCharacteristics(self.plot_name, name, arguments, solution_range)
return True

@pyaedt_function_handler(out_file="output_file")
def export_mask_violation(self, output_file=None):
"""Export the eye diagram mask violations to a TAB file.
Expand Down
Binary file not shown.
34 changes: 27 additions & 7 deletions tests/system/general/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import sys
import uuid

import ansys.aedt.core
from ansys.aedt.core import Quantity
from ansys.aedt.core.generic.errors import AEDTRuntimeError
from ansys.aedt.core.generic.file_utils import read_json
from ansys.aedt.core.generic.general_methods import is_linux
from ansys.aedt.core.generic.settings import settings
Expand All @@ -37,17 +39,11 @@
from tests import TESTS_GENERAL_PATH
from tests.system.general.conftest import config

test_field_name = "Potter_Horn_231"
test_project_name = "coax_setup_solved_231"
array = "array_simple_231"
sbr_file = "poc_scat_small_solved"
q3d_file = "via_gsg_231"
m2d_file = "m2d_field_lines_test_231"
m2d_trace_export_table = "m2d_trace_export_table"


test_circuit_name = "Switching_Speed_FET_And_Diode"
eye_diagram = "SimpleChannel"
ami = "ami"
test_subfolder = "T12"
settings.enable_pandas_output = True

Expand All @@ -59,6 +55,13 @@ def aedtapp(add_app):
app.close_project(app.project_name)


@pytest.fixture(scope="class")
def m2d_app(add_app):
app = add_app(project_name=m2d_trace_export_table, subfolder=test_subfolder, application=ansys.aedt.core.Maxwell2d)
yield app
app.close_project(app.project_name)


class TestClass:

@pytest.mark.skipif(config["NonGraphical"], reason="Failing on build machine when running in parallel.")
Expand Down Expand Up @@ -803,3 +806,20 @@ def test_75_tune_derivative(self, aedtapp):
setup_derivative_auto = aedtapp.setups[2]
assert setup_derivative.set_tuning_offset({"inner_radius": 0.1})
assert setup_derivative_auto.set_tuning_offset({"inner_radius": 0.1})

def test_trace_characteristics(self, m2d_app, local_scratch):
m2d_app.set_active_design("Design1")
assert m2d_app.post.plots[0].add_trace_characteristics("XAtYVal", arguments=["0"], solution_range=["Full"])

def test_trace_export_table(self, m2d_app, local_scratch):
m2d_app.set_active_design("Design2")
plot_name = m2d_app.post.plots[0].plot_name
output_file_path = os.path.join(local_scratch.path, "zeroes.tab")
assert m2d_app.post.plots[0].export_table_to_file(plot_name, output_file_path, "Legend")
assert os.path.exists(output_file_path)
with pytest.raises(AEDTRuntimeError):
m2d_app.post.plots[0].export_table_to_file("Invalid Name", output_file_path, "Legend")
with pytest.raises(AEDTRuntimeError):
m2d_app.post.plots[0].export_table_to_file(plot_name, "Invalid Path", "Legend")
with pytest.raises(AEDTRuntimeError):
m2d_app.post.plots[0].export_table_to_file(plot_name, output_file_path, "Invalid Export Type")
Loading