Skip to content

Commit d2a1db3

Browse files
committed
Merge branch 'main' into rcanton/remove_result_props
2 parents 9596bd6 + da20bde commit d2a1db3

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ jobs:
198198
matrix:
199199
version:
200200
- ${{ fromJson(vars.ANSYS_VERSIONS_RETRO_WITH_PATCH) }}
201-
- ${{ fromJson(vars.ANSYS_VERSION_LAST_RELEASED_WITH_PATCH) }}
201+
docstring:
202+
- "false"
203+
include:
204+
- version: ${{ fromJson(vars.ANSYS_VERSION_LAST_RELEASED_WITH_PATCH) }}
205+
docstring: "true"
202206
uses: ./.github/workflows/tests.yml
203207
with:
204208
ANSYS_VERSION: ${{ matrix.version.version }}
205209
python_versions: '["3.10"]'
206-
DOCSTRING: false
210+
DOCSTRING: ${{ matrix.docstring }}
207211
standalone_suffix: ${{ matrix.version.patch }}
208212
secrets: inherit

src/ansys/dpf/core/available_result.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ class AvailableResult:
125125
>>> transient = examples.download_transient_result()
126126
>>> model = dpf.Model(transient)
127127
>>> result_info = model.metadata.result_info
128+
>>> res = result_info["displacement"]
129+
>>> res.name
130+
'displacement'
131+
>>> res.homogeneity
132+
'length'
133+
>>> res.dimensionality
134+
'vector'
128135
129136
Create the operator of the given available result.
130137

src/ansys/dpf/core/collection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
from ansys.dpf.core.collection_base import CollectionBase
3333
from ansys.dpf.core.common import create_dpf_instance
3434

35-
TYPE = TypeVar("TYPE")
35+
T = TypeVar("T")
36+
S = TypeVar("S")
3637

3738

38-
# Explicit Generic[TYPE] helps some type checkers Collection as a generic.
39-
class Collection(CollectionBase[TYPE], Generic[TYPE]):
39+
class Collection(CollectionBase[T]):
4040
"""Represents a collection of dpf objects organised by label spaces.
4141
4242
Parameters
@@ -94,7 +94,7 @@ def get_entries(self, label_space):
9494
"""
9595
return super()._get_entries(label_space)
9696

97-
def get_entry(self, label_space_or_index) -> TYPE:
97+
def get_entry(self, label_space_or_index) -> T:
9898
"""Retrieve the entry at a requested index or label space.
9999
100100
Raises an exception if the request returns more than one entry.
@@ -126,7 +126,7 @@ def add_entry(self, label_space, entry):
126126
return super()._add_entry(label_space, Any.new_from(entry, server=self._server))
127127

128128
@classmethod
129-
def collection_factory(cls, subtype: TYPE) -> Type[Collection[TYPE]]:
129+
def collection_factory(cls, subtype: Type[S]) -> Type[Collection[S]]:
130130
"""Create classes deriving from Collection at runtime for a given subtype.
131131
132132
This factory method dynamically creates a new class that inherits from Collection
@@ -141,7 +141,7 @@ def collection_factory(cls, subtype: TYPE) -> Type[Collection[TYPE]]:
141141
142142
Returns
143143
-------
144-
Type[Collection[TYPE]]
144+
Type[Collection[S]]
145145
A new class that inherits from Collection and is specialized for the given
146146
subtype. The class name will be "{subtype.__name__}sCollection".
147147

src/ansys/dpf/core/result_info.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ class ResultInfo:
110110
>>> model = dpf.Model(transient)
111111
>>> result_info = model.metadata.result_info # printable result_info
112112
113+
>>> result_info["displacement"].name
114+
'displacement'
115+
>>> result_info["displacement"].homogeneity
116+
'length'
117+
113118
"""
114119

115120
def __init__(

tests/test_resultinfo.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,18 @@ def test_byitem_resultinfo(model):
137137
assert res[0] is not None
138138

139139

140-
# def test_get_result_resultinfo_from_index(model):
141-
# res = model.metadata.result_info[3]
142-
# assert res.name == "acceleration"
143-
# assert res.n_components == 3
144-
# assert res.dimensionality == "vector"
145-
# assert res.homogeneity == "acceleration"
146-
# assert res.unit == "m/s^2"
147-
# assert res.name == "acceleration"
148-
# assert res.qualifiers == []
140+
def test_get_result_resultinfo_from_index(model):
141+
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_11_0:
142+
res = model.metadata.result_info[3]
143+
else:
144+
res = model.metadata.result_info[2]
145+
assert res.name == "acceleration"
146+
assert res.n_components == 3
147+
assert res.dimensionality == "vector"
148+
assert res.homogeneity == "acceleration"
149+
assert res.unit == "m/s^2"
150+
assert res.name == "acceleration"
151+
assert res.qualifiers == []
149152

150153

151154
def test_print_result_info(model):

0 commit comments

Comments
 (0)