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

REFACTOR: Deprecate props and use properties #5584

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions src/ansys/aedt/core/modeler/cad/elements_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from __future__ import absolute_import

import warnings

from ansys.aedt.core.generic.general_methods import _dim_arg
from ansys.aedt.core.generic.general_methods import clamp
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
Expand Down Expand Up @@ -1408,6 +1410,17 @@
self.segments = self.children[name].children
del self.children[name]

@property
def props(self):
"""Properties data.

Returns
-------
:class:``ansys.aedt.coree.modeler.cad.elements_3d.HistoryProps``
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 1422 in src/ansys/aedt/core/modeler/cad/elements_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/elements_3d.py#L1421-L1422

Added lines #L1421 - L1422 were not covered by tests

@property
def properties(self):
"""Properties data.
Expand Down
47 changes: 41 additions & 6 deletions src/ansys/aedt/core/modeler/cad/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
3D Layout Modeler, and Circuit Modeler.
"""

from __future__ import absolute_import # noreorder
from __future__ import absolute_import

import warnings # noreorder

from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.general_methods import PropsManager
Expand Down Expand Up @@ -439,11 +441,22 @@

@property
def props(self):
"""Properties of the coordinate system.
"""Coordinate system properties.

Returns
-------
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 451 in src/ansys/aedt/core/modeler/cad/modeler.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/modeler.py#L450-L451

Added lines #L450 - L451 were not covered by tests

@property
def properties(self):
"""Coordinate system properties.

Returns
-------
:class:`ansys.aedt.core.modeler.Modeler.CSProps`
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
if self._props or settings.aedt_version <= "2022.2" or self.name is None:
return self._props
Expand Down Expand Up @@ -733,11 +746,22 @@

@property
def props(self):
"""Coordinate system properties.

Returns
-------
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

@property
def properties(self):
"""Coordinate System Properties.

Returns
-------
:class:`ansys.aedt.core.modeler.Modeler.CSProps`
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
if self._props or settings.aedt_version <= "2022.2" or self.name is None:
return self._props
Expand Down Expand Up @@ -1269,11 +1293,22 @@

@property
def props(self):
"""Properties of the coordinate system.
"""Coordinate system properties.

Returns
-------
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 1303 in src/ansys/aedt/core/modeler/cad/modeler.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/modeler.py#L1302-L1303

Added lines #L1302 - L1303 were not covered by tests

@property
def properties(self):
"""Coordinate system properties.

Returns
-------
:class:`ansys.aedt.core.modeler.Modeler.CSProps`
:class:`ansys.aedt.core.modeler.cad.modeler.CsProps`
"""
if self._props or settings.aedt_version <= "2022.2" or self.name is None:
return self._props
Expand Down
9 changes: 8 additions & 1 deletion src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import math
import os
import secrets
import warnings

from ansys.aedt.core.application.variables import decompose_variable_value
from ansys.aedt.core.generic.constants import AEDT_UNITS
Expand Down Expand Up @@ -1252,7 +1253,13 @@

@property
def props(self):
"""Retrieve the component properties."""
"""Component properties."""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 1258 in src/ansys/aedt/core/modeler/circuits/primitives_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_circuit.py#L1257-L1258

Added lines #L1257 - L1258 were not covered by tests

@property
def properties(self):
"""Component properties."""
if not self._props:
self._props = load_keyword_in_aedt_file(self.file_name, self.name)
return self._props
Expand Down
20 changes: 15 additions & 5 deletions src/ansys/aedt/core/modeler/circuits/primitives_emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# SOFTWARE.

from collections import defaultdict
import warnings

from ansys.aedt.core.emit_core import emit_constants as emit_consts
import ansys.aedt.core.generic.constants as consts
Expand Down Expand Up @@ -1015,16 +1016,25 @@ def __init__(self, editor, design, parent_component, node_name):

@property
def props(self):
"""Returns a dictionary of all the properties for this node.
"""Node properties

Parameters
----------
None
Returns
-------
Dict
Dictionary of all the properties for this node.
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

@property
def properties(self):
"""Node properties

Returns
-------
Dict
Dictionary of all the properties for this node."""
Dictionary of all the properties for this node.
"""
prop_list = self.odesign.GetComponentNodeProperties(self.parent_component.name, self.node_name)
props = dict(p.split("=", 1) for p in prop_list)
return props
Expand Down
15 changes: 14 additions & 1 deletion src/ansys/aedt/core/modules/boundary/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

"""This module contains these classes: ``BoundaryCommon`` and ``BoundaryObject``."""

import warnings

from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.general_methods import PropsManager
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
Expand Down Expand Up @@ -269,7 +271,18 @@ def props(self):

Returns
-------
:class:BoundaryProps
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

@property
def properties(self):
"""Boundary data.

Returns
-------
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
if self.__props:
return self.__props
Expand Down
19 changes: 19 additions & 0 deletions src/ansys/aedt/core/modules/boundary/hfss_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import warnings

from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.general_methods import _dim_arg
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
Expand Down Expand Up @@ -58,6 +60,23 @@

@property
def props(self):
"""AEDT boundary component internal properties.

Returns
-------
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 70 in src/ansys/aedt/core/modules/boundary/hfss_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/hfss_boundary.py#L69-L70

Added lines #L69 - L70 were not covered by tests

@property
def properties(self):
"""AEDT boundary component internal properties.

Returns
-------
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
if not self.__props and self._app.design_properties:
if (
self.type == "FarFieldSphere"
Expand Down
62 changes: 58 additions & 4 deletions src/ansys/aedt/core/modules/boundary/icepak_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# SOFTWARE.
from abc import abstractmethod
import copy
import warnings

from ansys.aedt.core.application.variables import decompose_variable_value
from ansys.aedt.core.generic.general_methods import generate_unique_name
Expand Down Expand Up @@ -58,7 +59,23 @@

@property
def props(self):
"""Dictionary that defines all the boundary condition properties."""
"""Dictionary that defines all the boundary condition properties.

Returns
-------
dict
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 69 in src/ansys/aedt/core/modules/boundary/icepak_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/icepak_boundary.py#L68-L69

Added lines #L68 - L69 were not covered by tests

@property
def properties(self):
"""Dictionary that defines all the boundary condition properties.

Returns
-------
dict
"""
return {
"Type": self.assignment_type,
"Function": self.function_type,
Expand Down Expand Up @@ -1056,8 +1073,21 @@

@property
def props(self):
"""Link properties.

Returns
-------
list
First two elements of the list are the node names that the link connects,
the third element is the link type while the fourth contains the value
associated with the link.
"""
Get link properties.
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 1086 in src/ansys/aedt/core/modules/boundary/icepak_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/icepak_boundary.py#L1085-L1086

Added lines #L1085 - L1086 were not covered by tests

@property
def properties(self):
"""Link properties.

Returns
-------
Expand Down Expand Up @@ -1114,7 +1144,19 @@

@property
def props(self):
"""Get properties of the node.
"""Node properties.

Returns
-------
dict
Node properties.
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 1155 in src/ansys/aedt/core/modules/boundary/icepak_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/icepak_boundary.py#L1154-L1155

Added lines #L1154 - L1155 were not covered by tests

@property
def properties(self):
"""Node properties.

Returns
-------
Expand All @@ -1125,7 +1167,19 @@

@props.setter
def props(self, props):
"""Set properties of the node.
"""Node properties.

Parameters
----------
props : dict
Node properties.
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
self.properties = props

Check warning on line 1178 in src/ansys/aedt/core/modules/boundary/icepak_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/icepak_boundary.py#L1177-L1178

Added lines #L1177 - L1178 were not covered by tests

@properties.setter
def properties(self, props):
"""Node properties.

Parameters
----------
Expand Down
26 changes: 25 additions & 1 deletion src/ansys/aedt/core/modules/boundary/layout_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import warnings

from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.data_handlers import random_string
from ansys.aedt.core.generic.general_methods import GrpcApiError
Expand Down Expand Up @@ -111,6 +113,17 @@

@property
def props(self):
"""AEDT boundary component internal properties.

Returns
-------
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

@property
def properties(self):
return self.__props

@property
Expand Down Expand Up @@ -331,7 +344,18 @@

Returns
-------
:class:BoundaryProps
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
warnings.warn("This method is deprecated. Use properties instead.", DeprecationWarning)
return self.properties

Check warning on line 350 in src/ansys/aedt/core/modules/boundary/layout_boundary.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/boundary/layout_boundary.py#L349-L350

Added lines #L349 - L350 were not covered by tests

@property
def properties(self):
"""Excitation data.

Returns
-------
:class:`ansys.aedt.core.modules.boundary.common.BoundaryProps`
"""
if self.__props:
return self.__props
Expand Down
Loading
Loading