Skip to content

Commit 4c983c5

Browse files
authored
fix(doctest): fix retro-compatibility of PropertyField.scoping docstring example (#2527)
1 parent 9aaff16 commit 4c983c5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ansys/dpf/core/property_field.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,29 @@ def location(self):
158158
Returns
159159
-------
160160
location : str
161-
Location string, can be found in :class:`ansys.dpf.core.locations`: ie.
161+
Location string, can be found in :class:`ansys.dpf.core.locations`: i.e.
162162
``dpf.locations.nodal`` or ``dpf.locations.elemental``.
163163
164164
Examples
165165
--------
166166
Create a property field and request the location.
167167
168168
>>> from ansys.dpf import core as dpf
169+
>>> from ansys.dpf.core.check_version import meets_version
169170
>>> pfield = dpf.PropertyField()
170-
>>> pfield.location = dpf.locations.nodal
171+
>>> if meets_version(dpf.SERVER.version, "11.0"):
172+
... pfield.location = dpf.locations.elemental
173+
... else:
174+
... pfield.scoping = dpf.Scoping()
175+
... pfield.scoping.location = dpf.locations.elemental
171176
>>> pfield.location
172-
'Nodal'
177+
'Elemental'
173178
174179
"""
175180
if meets_version(self._server.version, "11.0"):
176181
if self._field_definition:
177182
return self._field_definition.location
178-
elif self.scoping:
183+
elif self.scoping is not None:
179184
return self.scoping.location
180185
else:
181186
return None

0 commit comments

Comments
 (0)