Skip to content
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

SharedParameter: improve source detection #2142

Merged
merged 1 commit into from
Oct 8, 2021
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
10 changes: 9 additions & 1 deletion psyneulink/core/globals/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,11 +1775,19 @@ def source(self):
f' cannot be stateful.'
)
obj = obj.values[None]
except (AttributeError, KeyError):
except AttributeError:
try:
obj = getattr(self._owner._owner, self.attribute_name)
except AttributeError:
return None
except KeyError:
# KeyError means there is no stored value for this
# parameter, which should only occur when the source is
# desired for a descriptive parameter attribute value (e.g.
# stateful or loggable) and when either self._owner._owner
# is a type or is in the process of instantiating a
# Parameter for an instance of a Component
obj = getattr(self._owner._owner.defaults, self.attribute_name)

try:
obj = getattr(obj.parameters, self.shared_parameter_name)
Expand Down