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

New Coding Style guide #95

Merged
merged 18 commits into from
May 24, 2022
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
82 changes: 43 additions & 39 deletions doc/source/abstractions/app-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,49 @@ within this method.

.. code:: python

def create_open_region(self, frequency="1GHz", boundary="Radiation",
apply_infinite_gp=False, gp_axis="-z"):
"""Create an open region on the active editor.

Parameters
----------
frequency : str, optional
Frequency with units. The default is ``"1GHz"``.
boundary : str, optional
Type of the boundary. The default is ``"Radiation"``.
apply_infinite_gp : bool, optional
Whether to apply an infinite ground plane. The default is ``False``.
gp_axis : str, optional
The default is ``"-z"``.

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

Examples
--------
Create an open region in the active editor at 1 GHz.

>>> hfss.create_open_region(frequency="1GHz")

"""
vars = [
"NAME:Settings",
"OpFreq:=", frequency,
"Boundary:=", boundary,
"ApplyInfiniteGP:=", apply_infinite_gp
]
if apply_infinite_gp:
vars.append("Direction:=")
vars.append(gp_axis)

self._omodelsetup.CreateOpenRegion(vars)
return True
def create_open_region(
self, frequency="1GHz", boundary="Radiation", apply_infinite_gp=False, gp_axis="-z"
):
"""Create an open region in the active editor.

Parameters
----------
frequency : str, optional
Frequency with units. The default is ``"1GHz"``.
boundary : str, optional
Type of the boundary. The default is ``"Radiation"``.
apply_infinite_gp : bool, optional
Whether to apply an infinite ground plane. The default is ``False``.
gp_axis : str, optional
The default is ``"-z"``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default is ``"-z"``.
Axis for the ground plane. The default is ``"-z"``.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter needed to have a description. Please review and correct as necessary.


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

Examples
--------
Create an open region in the active editor at 1 GHz.

>>> hfss.create_open_region(frequency="1GHz")

"""
vars = [
"NAME:Settings",
"OpFreq:=",
frequency,
"Boundary:=",
boundary,
"ApplyInfiniteGP:=",
apply_infinite_gp,
]
if apply_infinite_gp:
vars.append("Direction:=")
vars.append(gp_axis)

self._omodelsetup.CreateOpenRegion(vars)
return True

Here, the COM ``CreateOpenRegion`` method is abstracted, encapsulating
the model setup object. There's no reason why a user needs direct
Expand Down
43 changes: 43 additions & 0 deletions doc/source/coding-style/code/tox-flit.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. code-block:: ini

[tox]
description = Default tox environments list
envlist =
style,{py37,py38,py39,py310}{,-coverage},doc
skip_missing_interpreters = true
isolated_build = true
isolated_build_env = build

[testenv]
description = Checks for project unit tests and coverage (if desired)
basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py: python3
{style,reformat,doc,build}: python3
setenv =
PYTHONUNBUFFERED = yes
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.product --cov-report=term --cov-report=xml --cov-report=html
deps =
-r{toxinidir}/requirements/requirements_tests.txt
commands =
pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}

[testenv:style]
description = Checks project code style
skip_install = true
deps =
pre-commit
commands =
pre-commit install
pre-commit run --all-files --show-diff-on-failure

[testenv:doc]
description = Check if documentation generates properly
deps =
-r{toxinidir}/requirements/requirements_doc.txt
commands =
sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out" --color -vW -bhtml

46 changes: 46 additions & 0 deletions doc/source/coding-style/code/tox-poetry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. code-block:: ini

[tox]
description = Default tox environments list
envlist =
style,{py37,py38,py39,py310}{,-coverage},doc
skip_missing_interpreters = true
isolated_build = true

[testenv]
description = Checks for project unit tests and coverage (if desired)
basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py: python3
{style,reformat,doc,build}: python3
skip_install = true
whitelist_externals =
poetry
setenv =
PYTHONUNBUFFERED = yes
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.product --cov-report=term --cov-report=xml --cov-report=html
deps =
-r{toxinidir}/requirements/requirements_tests.txt
commands =
poetry install
poetry run pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}

[testenv:style]
description = Checks project code style
skip_install = true
deps =
pre-commit
commands =
pre-commit install
pre-commit run --all-files --show-diff-on-failure

[testenv:doc]
description = Check if documentation generates properly
deps =
-r{toxinidir}/requirements/requirements_doc.txt
commands =
poetry run sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out" --color -vW -bhtml

Loading