Skip to content

Commit

Permalink
Merge branch 'master' into mnale/bugs/25.1/element__volume_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelNale committed Sep 20, 2024
2 parents 136a176 + b5b2afd commit 990710d
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 36 deletions.
41 changes: 23 additions & 18 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
changelog:
categories:
- title: Enhancements
labels:
- enhancement
- title: Bug fixes
labels:
- bug
- title: Documentation
labels:
- documentation
- examples
- title: CI/CD
labels:
- CI/CD
- title: Maintenance
labels:
- maintenance
- dependencies
exclude:
authors:
- dependabot[bot]
categories:
- title: Enhancements
labels:
- enhancement
- title: Bug fixes
labels:
- bug
- title: Documentation
labels:
- documentation
- title: Examples
labels:
- examples
- title: CI/CD
labels:
- CI/CD
- title: Maintenance
labels:
- maintenance
- dependencies
9 changes: 9 additions & 0 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ jobs:
command: |
pytest $DEBUG $COVERAGE $RERUNS --junitxml=tests/junit/test-results9.xml test_service/.
- name: "Test Operators"
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 2
shell: bash
command: |
pytest $DEBUG $COVERAGE $RERUNS --junitxml=../tests/junit/test-results12.xml tests/operators/.
# - name: "Test API Entry"
# shell: bash
# working-directory: tests
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,18 @@ jobs:
- name: "Kill all servers"
uses: ansys/pydpf-actions/kill-dpf-servers@v2.3

- name: "Test Operators"
uses: nick-fields/retry@v2
with:
timeout_minutes: 2
max_attempts: 2
shell: bash
command: |
pytest $DEBUG $COVERAGE $RERUNS --junitxml=../tests/junit/test-results12.xml tests/operators/.
- name: "Kill all servers"
uses: ansys/pydpf-actions/kill-dpf-servers@v2.3

- name: "Upload Test Results"
uses: actions/upload-artifact@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@
###############################################################################
# Get the rotation matrix of the LCS ID 12.
# The first 9 values in the ``cs`` output is the rotation matrix.
cs = dpf.operators.result.coordinate_system()
cs.inputs.data_sources.connect(model)
try:
# Starting with DPF 2025.1.pre1
cs = dpf.operators.result.coordinate_system()
cs.inputs.data_sources.connect(model)
except KeyError:
# For previous DPF versions
cs = model.operator(r"mapdl::rst::CS")

cs.inputs.cs_id.connect(12)
cs_rot_mat = cs.outputs.field.get_data().data.T[0:9]

Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements_build.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black==24.4.2
build==1.2.1
black==24.8.0
build==1.2.2
chevron==0.14.0
wheel==0.43.0
wheel==0.44.0
12 changes: 6 additions & 6 deletions requirements/requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
ansys_sphinx_theme==0.16.5
ansys_sphinx_theme==1.0.10
enum-tools[sphinx]==0.12.0
graphviz==0.20.1
imageio==2.35.1
imageio-ffmpeg==0.4.7
nbsphinx==0.9.3
imageio-ffmpeg==0.5.1
nbsphinx==0.9.5
pypandoc==1.13
pytest-sphinx==0.6.3
pyvista==0.44.1
sphinx==7.1.0
sphinx-autobuild==2024.2.4
sphinx-copybutton==0.5.2
sphinx-gallery==0.17.0
sphinx-notfound-page==1.0.0
sphinx-gallery==0.17.1
sphinx-notfound-page==1.0.4
sphinx-reredirects==0.1.3
sphinx_design==0.6.0
sphinx_design==0.6.1
sphinxcontrib-napoleon==0.7
2 changes: 1 addition & 1 deletion requirements/requirements_install.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
importlib-metadata==7.1.0
importlib-metadata==8.5.0
numpy==1.26.4
packaging==24.0
psutil==6.0.0
Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ansys-platform-instancemanagement==1.1.2
coverage==7.6.0
coverage==7.6.1
imageio==2.35.1
imageio-ffmpeg==0.4.7
imageio-ffmpeg==0.5.1
pytest==7.4.2
pytest-cov==5.0.0
pytest-order==1.2.1
pytest-order==1.3.0
pytest-rerunfailures==14.0
pyvista==0.44.1
1 change: 1 addition & 0 deletions src/ansys/dpf/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

from ansys.dpf.core.collection import CollectionFactory as _CollectionFactory
from ansys.dpf.core.collection import Collection as _Collection
from ansys.dpf.core.label_space import LabelSpace


# register classes for collection types:
Expand Down
10 changes: 8 additions & 2 deletions src/ansys/dpf/core/collection_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
dpf_vector,
dpf_array,
)
from typing import Optional, Generic, TypeVar, TYPE_CHECKING
from typing import List, Optional, Generic, TypeVar, TYPE_CHECKING

if TYPE_CHECKING:
from ansys.dpf.core.support import Support
Expand Down Expand Up @@ -235,7 +235,13 @@ def _get_labels(self) -> list:
out.append(self._api.collection_get_label(self, i))
return out

labels = property(_get_labels, set_labels, "labels")
@property
def labels(self) -> List[str]:
return self._get_labels()

@labels.setter
def labels(self, labels: List[str]):
self.set_labels(labels=labels)

def has_label(self, label) -> bool:
"""Check if a collection has a specified label.
Expand Down
15 changes: 14 additions & 1 deletion src/ansys/dpf/core/label_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import warnings
import traceback
from typing import Dict
from ansys.dpf.gate import (
label_space_capi,
label_space_grpcapi,
Expand Down Expand Up @@ -68,10 +69,22 @@ def _data_processing_core_api(self):
core_api.init_data_processing_environment(self)
return core_api

def fill(self, label_space):
def fill(self, label_space: Dict[str, int]):
for key, index in label_space.items():
self._api.label_space_add_data(self, key, index)

def __str__(self):
return str(dict(self))

def __iter__(self):
yield from [
(
self._api.label_space_get_labels_name(self, i),
self._api.label_space_get_labels_value(self, i),
)
for i in range(self._api.label_space_get_size(self))
]

def __dict__(self):
if isinstance(self._internal_obj, dict):
return self._internal_obj
Expand Down
59 changes: 59 additions & 0 deletions tests/operators/test_coordinate_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (C) 2020 - 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.

# Tests the result.coordinate_system operator
import ansys.dpf.core as dpf
from ansys.dpf.core import examples
import conftest
import numpy as np


def test_operator_coordinate_system_rst(server_type):
model = dpf.Model(examples.download_hemisphere(server=server_type), server=server_type)
if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_9_1:
# Starting with DPF 2025.1.pre1
cs = dpf.operators.result.coordinate_system(server=server_type)
cs.inputs.data_sources.connect(model)
else:
# For previous DPF versions
cs = model.operator(r"mapdl::rst::CS")
cs.inputs.cs_id.connect(12)
cs_rot_mat = cs.outputs.field().data
ref = np.array(
[
[
-0.18966565,
0.91517569,
0.35564083,
-0.91517569,
-0.03358143,
-0.40165376,
-0.35564083,
-0.40165376,
0.84391579,
4.74164122,
22.87939222,
8.89102077,
]
]
)
assert np.allclose(cs_rot_mat.data, ref)
5 changes: 5 additions & 0 deletions tests/operators/test_operator_mesh_plan_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@

import ansys.dpf.core as dpf
import conftest
import pytest


@pytest.mark.skipif(
not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
reason="Mesh clip plan operator not functional before 5.0,",
)
def test_operator_mesh_plan_clip_rst(simple_bar):
model = dpf.Model(simple_bar)
main_mesh = model.metadata.meshed_region
Expand Down
32 changes: 32 additions & 0 deletions tests/test_label_space.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2020 - 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.

import ansys.dpf.core as dpf


def test_label_space_(server_type):
reference = {"test": 1, "various": 2}
ls = dpf.LabelSpace(label_space=reference)
assert dict(ls) == reference
assert str(ls)
reference = {"test": 1, "various": 2}
ls.fill(label_space=reference)

0 comments on commit 990710d

Please sign in to comment.