Skip to content

Commit

Permalink
Merge branch 'main' into release/0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed May 28, 2024
2 parents 61f74e9 + 5759fa0 commit ba723e1
Show file tree
Hide file tree
Showing 126 changed files with 2,814 additions and 1,417 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ updates:
- "maintenance"
- "dependencies"
commit-message:
prefix: "MAINT"
prefix: "CHORE"

- package-ecosystem: "github-actions"
directory: "/"
Expand All @@ -26,4 +26,4 @@ updates:
- "maintenance"
- "dependencies"
commit-message:
prefix: "MAINT"
prefix: "CHORE"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- --max-line-length=120

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -48,7 +48,7 @@ repos:

# validate GitHub workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.2
rev: 0.28.4
hooks:
- id: check-github-workflows

Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
PyAEDT is a Python library that interacts directly with the API for
Ansys Electronics Desktop (AEDT) to make scripting simpler. The architecture
for PyAEDT can be reused for all AEDT 3D products (HFSS, Icepak, Maxwell 3D,
and Q3D Extractor), 2D tools, and Ansys Mechanical. PyAEDT also provides
and Q3D Extractor), 2D tools, and Ansys Mechanical inside AEDT. PyAEDT also provides
support for circuit tools like Nexxim and system simulation tools like
Twin Builder. Finally, PyAEDT provides scripting capabilities in Ansys layout
tools like HFSS 3D Layout and EDB. The PyAEDT class and method structures
tools like HFSS 3D Layout. The Ansys Electronics Database
([EDB](https://edb.docs.pyansys.com/version/stable/)) is included
with PyAEDT as a dependency and is recommended for any automated manipulation and
setup of layout data for PCBs, electronic packages, and integrated circuits.

The PyAEDT class and method structures
simplify operation while reusing information as much as possible across
the API.

Expand Down Expand Up @@ -130,6 +135,31 @@ To reach the project support team, email [[email protected]](mailto:pyansys
To run PyAEDT, you must have a local licenced copy of AEDT.
PyAEDT supports AEDT versions 2022 R1 or newer.

## Contributing

For comprehensive information on contributing to the PyAnsys project, see the [PyAnsys developer's guide](https://dev.docs.pyansys.com).


Note that PyAEDT uses semantic naming for pull requests (PR). This convention
greatly simplifies the review process by providing meaningful
information in the PR title. The
following
[prefixes](https://github.com/ansys/actions/blob/main/commit-style/action.yml)
should be used for pull request name:

- "BUILD"
- "CHORE"
- "CI"
- "DOCS"
- "FEAT"
- "FIX"
- "PERF"
- "REFACTOR"
- "REVERT"
- "STYLE"
- "TEST"


## Student version

PyAEDT supports AEDT Student versions 2022 R1 and later. For more information, see the
Expand Down
30 changes: 30 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Copyright (C) 2024 ANSYS, Inc. and/or its affiliates.
SPDX-License-Identifier: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->

# Security Policy

## Reporting a Vulnerability

If you detect a vulnerability, contact the [PyAnsys Core team](mailto:[email protected])
mentioning the repository and the details of your finding. The team will address it as soon as possible.
Binary file added _unittest/example_models/T20/sphere.stl
Binary file not shown.
1 change: 1 addition & 0 deletions _unittest/example_models/T20/test_cad.nas
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ CPENTA 25328 9 26 28 25 34 35 30
CHEXA 1 105 40 41 42 43 44 45
* 46 47
CTETRA 1 115 50 51 52 53
CQUAD 1 115 50 51 52 53 40

ENDDATA
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Expand Down
4 changes: 4 additions & 0 deletions _unittest/example_models/T20/test_cad_2.nas
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ GRID* 5 812.95973 486.74968*
* 1495.9564
GRID* 6 812.99916 484.24676*
* 1470.1764
GRID* 7 812.99916 484.24676*
* 1070.1764
CTRIA3* 75986 19 4 5
* 6
CQUAD4* 75987 19 4 5
* 6 7


ENDDATA
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def test_27_odesktop(self):
"<class 'win32com.client.CDispatch'>",
"<class 'PyDesktopPlugin.AedtObjWrapper'>",
"<class 'pyaedt.generic.grpc_plugin.AedtObjWrapper'>",
"<class 'pyaedt.generic.grpc_plugin_dll_class.AedtObjWrapper'>",
]

def test_28_get_pyaedt_app(self):
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_toolkit_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ def validate_file_exists_and_pyaedt_tabs_added(file_path):
root = tree.getroot()
panels = root.findall("./panel")
panel_names = [panel.attrib["label"] for panel in panels]
assert "Panel_PyAEDT_Toolkits" in panel_names
assert "Panel_PyAEDT_Extensions" in panel_names
return root
14 changes: 8 additions & 6 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import sys

from _unittest.conftest import config
from matplotlib.figure import Figure
import pytest
from pyvista.plotting.plotter import Plotter

from pyaedt import Circuit
from pyaedt import Icepak
Expand Down Expand Up @@ -597,18 +599,18 @@ def test_70_far_field_data(self):
assert ffdata.origin == [0, 0, 1]

img1 = os.path.join(self.local_scratch.path, "ff_2d1.jpg")
ffdata.plot_2d_cut(primary_sweep="Theta", secondary_sweep_value="all", image_path=img1)
ffdata.plot_2d_cut(primary_sweep="Theta", secondary_sweep_value="all", image_path=img1, show=False)
assert os.path.exists(img1)
img2 = os.path.join(self.local_scratch.path, "ff_2d2.jpg")
ffdata.plot_2d_cut(secondary_sweep_value=[0, 1], image_path=img2)
ffdata.plot_2d_cut(secondary_sweep_value=[0, 1], image_path=img2, show=False)
assert os.path.exists(img2)
img3 = os.path.join(self.local_scratch.path, "ff_2d2.jpg")
ffdata.plot_2d_cut(image_path=img3)
ffdata.plot_2d_cut(image_path=img3, show=False)
assert os.path.exists(img3)
curve_2d = ffdata.plot_2d_cut(show=False)
assert len(curve_2d[0]) == 3
assert isinstance(curve_2d, Figure)
data = ffdata.polar_plot_3d(show=False)
assert len(data) == 3
assert isinstance(data, Figure)

img4 = os.path.join(self.local_scratch.path, "ff_3d1.jpg")
ffdata.polar_plot_3d_pyvista(
Expand All @@ -623,7 +625,7 @@ def test_70_far_field_data(self):
data_pyvista = ffdata.polar_plot_3d_pyvista(
quantity="RealizedGain", show=False, background=[255, 0, 0], show_geometry=False, convert_to_db=True
)
assert data_pyvista
assert isinstance(data_pyvista, Plotter)

@pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="FarFieldSolution not supported by IronPython")
def test_71_antenna_plot(self, field_test):
Expand Down
7 changes: 6 additions & 1 deletion _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,12 @@ def test_59_test_nastran(self):

cads = self.aedtapp.modeler.import_nastran(example_project)
assert len(cads) > 0
assert self.aedtapp.modeler.import_nastran(example_project2)
assert self.aedtapp.modeler.import_nastran(example_project2, decimation=0.5)
example_project = os.path.join(local_path, "../_unittest/example_models", test_subfolder, "sphere.stl")
from pyaedt.modules.solutions import simplify_stl

out = simplify_stl(example_project, decimation=0.8, aggressiveness=5)
assert os.path.exists(out)

def test_60_set_variable(self):
self.aedtapp.variable_manager.set_variable("var_test", expression="123")
Expand Down
4 changes: 3 additions & 1 deletion _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,11 @@ def test_42_create_wire(self):

def test_43_display_wire_properties(self):
self.aedtapp.set_active_design("CreateWireTest")
assert self.aedtapp.modeler.wire.display_wire_properties(
wire = self.aedtapp.modeler.components.get_wire_by_name("wire_name_test")
assert wire.display_wire_properties(
name="wire_name_test", property_to_display="NetName", visibility="Value", location="Top"
)

assert not self.aedtapp.modeler.wire.display_wire_properties(
name="invalid", property_to_display="NetName", visibility="Value", location="Top"
)
Expand Down
2 changes: 2 additions & 0 deletions _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def test_13a_create_edge_port(self):
assert self.aedtapp.edit_source_from_file(
port_wave.name, time_domain, is_time_domain=True, x_scale=1e-6, y_scale=1e-3, data_format="Voltage"
)
self.aedtapp.boundaries[0].object_properties.props["Boundary Type"] = "PEC"
assert list(self.aedtapp.oboundary.GetAllBoundariesList())[0] == self.aedtapp.boundaries[0].name

def test_14a_create_coaxial_port(self):
port = self.aedtapp.create_coax_port("port_via", 0.5, "Top", "Lower")
Expand Down
5 changes: 4 additions & 1 deletion _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ def test_55_native_components_history(self):
def test_56_mesh_priority(self):
self.aedtapp.insert_design("mesh_priority")
b = self.aedtapp.modeler.create_box([0, 0, 0], [20, 50, 80])
self.aedtapp.create_ipk_3dcomponent_pcb(
board = self.aedtapp.create_ipk_3dcomponent_pcb(
"Board",
link_data,
solution_freq,
Expand All @@ -1050,6 +1050,9 @@ def test_56_mesh_priority(self):
assert self.aedtapp.mesh.add_priority(
entity_type=2, component=self.aedtapp.modeler.user_defined_component_names[0], priority=1
)
fan = self.aedtapp.create_fan(name="TestFan", is_2d=True)
rect = self.aedtapp.modeler.create_rectangle(0, [0, 0, 0], [1, 2], name="TestRectangle")
assert self.aedtapp.mesh.assign_priorities([[fan.name, board.name], [b.name, rect.name]])

def test_57_update_source(self):
self.aedtapp.modeler.create_box([0, 0, 0], [20, 20, 20], name="boxSource")
Expand Down
72 changes: 72 additions & 0 deletions _unittest/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Test utility functions of PyAEDT.
"""

import logging
from unittest.mock import MagicMock
from unittest.mock import patch

import pytest

from pyaedt import settings
from pyaedt.generic.general_methods import pyaedt_function_handler

SETTINGS_RELEASE_ON_EXCEPTION = settings.release_on_exception
SETTINGS_ENABLE_ERROR_HANDLER = settings.enable_error_handler
ERROR_MESSAGE = "Dummy message."


@pyaedt_function_handler(deprecated_arg="trigger_exception")
def foo(trigger_exception=True):
"""Some dummy function used for testing."""
if trigger_exception:
raise Exception(ERROR_MESSAGE)


@patch("pyaedt.generic.desktop_sessions._desktop_sessions")
def test_handler_release_on_exception(mock_sessions):
"""Test handler while activating or deactivating error handler."""
mock_session = MagicMock()
mock_sessions.values.return_value = [mock_session]
settings.enable_error_handler = True
settings.release_on_exception = True

# Check that release desktop is called once
foo()
assert mock_session.release_desktop.assert_called_once

# Check that release desktop is not called
settings.release_on_exception = False
foo()
assert mock_session.release_desktop.assert_called

# Teardown
settings.enable_error_handler = SETTINGS_ENABLE_ERROR_HANDLER
settings.release_on_exception = SETTINGS_RELEASE_ON_EXCEPTION


def test_handler_enable_error_handler():
"""Test handler while activating/deactivating error handler."""
settings.enable_error_handler = True
assert foo() == False

settings.enable_error_handler = False
with pytest.raises(Exception) as exec_info:
foo()
assert str(exec_info.value) == ERROR_MESSAGE

# Teardown
settings.enable_error_handler = SETTINGS_ENABLE_ERROR_HANDLER


def test_handler_deprecation_log_warning(caplog):
"""Test handler deprecation argument mechanism."""
EXPECTED_ARGUMENT = "Argument `deprecated_arg` is deprecated for method `foo`; use `trigger_exception` instead."

with caplog.at_level(logging.WARNING, logger="Global"):
foo(deprecated_arg=False)
assert len(caplog.records) == 1
assert "WARNING" == caplog.records[0].levelname
assert EXPECTED_ARGUMENT == caplog.records[0].message

foo(trigger_exception=False)
assert len(caplog.records) == 1
2 changes: 1 addition & 1 deletion doc/source/API/Application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Application and solvers
The PyAEDT API includes classes for different applications available in Ansys Electronics Desktop (AEDT).
You must initialize AEDT to get access to all PyAEDT modules and methods.

.. image:: ../Resources/aedt_2.webp
.. image:: ../Resources/aedt_2.png
:width: 800
:alt: Ansys Electronics Desktop (AEDT) is a platform that enables true electronics system design.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/API/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and Mechanical solvers for comprehensive multiphysics analysis.
Tight integration among these solutions provides unprecedented ease of use for setup and
faster resolution of complex simulations for design and optimization.

.. image:: ../Resources/aedt_2.webp
.. image:: ../Resources/aedt_2.png
:width: 800
:alt: AEDT Applications
:target: https://www.ansys.com/products/electronics
Expand Down
2 changes: 1 addition & 1 deletion doc/source/Getting_started/About.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ and mechanical solvers for comprehensive multiphysics analysis.
Tight integration among these solutions provides unprecedented ease of use for setup and
faster resolution of complex simulations for design and optimization.

.. image:: ../Resources/aedt_collage.webp
.. image:: ../Resources/aedt_collage.jpg
:width: 800
:alt: AEDT Applications
:target: https://www.ansys.com/products/electronics
Expand Down
Loading

0 comments on commit ba723e1

Please sign in to comment.