Skip to content

fix(doctest): fix retro-compatibility of PropertyField.scoping docstring example #2527

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

Merged
merged 1 commit into from
Aug 7, 2025
Merged
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
13 changes: 9 additions & 4 deletions src/ansys/dpf/core/property_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,29 @@ def location(self):
Returns
-------
location : str
Location string, can be found in :class:`ansys.dpf.core.locations`: ie.
Location string, can be found in :class:`ansys.dpf.core.locations`: i.e.
``dpf.locations.nodal`` or ``dpf.locations.elemental``.

Examples
--------
Create a property field and request the location.

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core.check_version import meets_version
>>> pfield = dpf.PropertyField()
>>> pfield.location = dpf.locations.nodal
>>> if meets_version(dpf.SERVER.version, "11.0"):
... pfield.location = dpf.locations.elemental
... else:
... pfield.scoping = dpf.Scoping()
... pfield.scoping.location = dpf.locations.elemental
>>> pfield.location
'Nodal'
'Elemental'

"""
if meets_version(self._server.version, "11.0"):
if self._field_definition:
return self._field_definition.location
elif self.scoping:
elif self.scoping is not None:
return self.scoping.location
else:
return None
Expand Down
Loading