Skip to content

Commit 99ed06c

Browse files
committed
Modifying examples
1 parent fcdbfab commit 99ed06c

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/ansys/dpf/core/property_field.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def _load_field_definition(self):
155155
def location(self):
156156
"""Location of the property field.
157157
158-
A property field contains a scoping, which is the location that is read.
159-
To update location, directly update the scoping location.
158+
The property field location is the one contained in its field definition.
159+
To update location, just update the property field location.
160160
161161
Returns
162162
-------
@@ -166,22 +166,19 @@ def location(self):
166166
167167
Examples
168168
--------
169-
Create a property field and request the location. ##TODO Important, modify this example! as well as the description
169+
Create a property field and request the location.
170170
171171
>>> from ansys.dpf import core as dpf
172172
>>> pfield = dpf.PropertyField()
173-
>>> list_ids = [1, 2, 4, 6, 7]
174-
>>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal)
175-
>>> pfield.scoping = scop
176-
>>> pfield.scoping.location = dpf.locations.nodal
173+
>>> pfield.location = dpf.locations.nodal
177174
>>> pfield.location
178175
'Nodal'
179176
180177
"""
181178
if meets_version(self._server.version, "11.0"):
182179
if self._field_definition:
183180
return self._field_definition.location
184-
if self.scoping:
181+
elif self.scoping:
185182
return self.scoping.location
186183
else:
187184
return None
@@ -200,14 +197,32 @@ def location(self, value):
200197
--------
201198
>>> from ansys.dpf import core as dpf
202199
>>> pfield = dpf.PropertyField()
203-
>>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal)
204-
>>> pfield.scoping = scop
200+
>>> list_ids = [1, 2, 4, 6, 7]
205201
>>> pfield.location = 'Nodal'
206202
>>> pfield.location
207203
'Nodal'
208204
209205
"""
210-
self.scoping.location = value
206+
if meets_version(self._server.version, "11.0"):
207+
if self._field_definition:
208+
self._field_definition.location = value
209+
else:
210+
raise Exception(
211+
"Property field location is based on field definition, and field definition is not defined"
212+
)
213+
elif self.scoping:
214+
self.scoping.location = value
215+
else:
216+
raise Exception(
217+
"Property field location before v11.0 was based on scoping, and scoping is not defined"
218+
)
219+
220+
if self.scoping:
221+
self.scoping.location = value
222+
else:
223+
raise Exception(
224+
"Property field location is based on scoping, and scoping is not defined"
225+
)
211226

212227
@property
213228
def component_count(self):

0 commit comments

Comments
 (0)