diff --git a/.idea/runConfigurations/scratch.xml b/.idea/runConfigurations/scratch.xml new file mode 100644 index 00000000000..ca73a466fb5 --- /dev/null +++ b/.idea/runConfigurations/scratch.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/psyneulink/globals/log.py b/psyneulink/globals/log.py index de5def4853f..5f62ab6305c 100644 --- a/psyneulink/globals/log.py +++ b/psyneulink/globals/log.py @@ -128,8 +128,8 @@ COMMENT: FIX: THIS EXAMPLE CAN'T CURRENTLY BE EXECUTED AS IT PERMANENTLY SETS THE LogPref FOR ALL TransferMechanism COMMENT - >> import psyneulink as pnl - >> T = pnl.TransferMechanism( + >>> import psyneulink as pnl + >>> T = pnl.TransferMechanism( ... prefs={pnl.LOG_PREF: pnl.PreferenceEntry(pnl.LogCondition.INITIALIZATION, pnl.PreferenceLevel.INSTANCE)}) .. hint:: @@ -155,7 +155,6 @@ `MappingProjection` from the first to the second:: # Create a Process with two TransferMechanisms, and get a reference for the Projection created between them: - >>> import psyneulink as pnl >>> my_mech_A = pnl.TransferMechanism(name='mech_A', size=2) >>> my_mech_B = pnl.TransferMechanism(name='mech_B', size=3) >>> my_process = pnl.Process(pathway=[my_mech_A, my_mech_B]) diff --git a/psyneulink/globals/preferences/componentpreferenceset.py b/psyneulink/globals/preferences/componentpreferenceset.py index dee02c8f127..1f9e9ee708a 100644 --- a/psyneulink/globals/preferences/componentpreferenceset.py +++ b/psyneulink/globals/preferences/componentpreferenceset.py @@ -304,24 +304,25 @@ def __init__(self, if isinstance(owner_class.classPreferences, dict): raise AttributeError except AttributeError: - super(ComponentPreferenceSet, self).__init__( - owner=owner_class, - level=owner_class.classPreferenceLevel, - prefs=ComponentDefaultPrefDicts[owner_class.classPreferenceLevel], - name=name, - context=self) - - # Instantiate PreferenceSet - super(ComponentPreferenceSet, self).__init__(owner=owner, + if inspect.isclass(owner): + # If this is a call to instantiate the classPreferences, no need to keep doing it! (infinite recursion) + pass + else: + # Instantiate the classPreferences + owner_class.classPreferences = ComponentPreferenceSet( + owner=owner_class, level=owner_class.classPreferenceLevel, - prefs=prefs, + prefs=ComponentDefaultPrefDicts[owner_class.classPreferenceLevel], name=name, context=self) - # FIX: NECESSARY?? 5/30/16 + # Instantiate PreferenceSet + super().__init__(owner=owner, + level=owner_class.classPreferenceLevel, + prefs=prefs, + name=name, + context=self) self._level = level - #region verbose entry ---------------------------------------------------------------------------------------------- - @property def verbosePref(self): """Return setting of owner's verbosePref at level specified in its PreferenceEntry.level @@ -340,8 +341,6 @@ def verbosePref(self, setting): """ self.set_preference(candidate_info=setting, pref_ivar_name=kpVerbosePref) - # region param_validation ---------------------------------------------------------------------------------------------- - @property def paramValidationPref(self): """Return setting of owner's param_validationPref at level specified in its PreferenceEntry.level @@ -361,8 +360,6 @@ def paramValidationPref(self, setting): """ self.set_preference(setting,kpParamValidationPref) - #region reportOutput entry ----------------------------------------------------------------------------------------- - @property def reportOutputPref(self): """Return setting of owner's reportOutputPref at level specified in its PreferenceEntry.level @@ -382,8 +379,6 @@ def reportOutputPref(self, setting): """ self.set_preference(candidate_info=setting, pref_ivar_name=kpReportOutputPref) - #region log entry -------------------------------------------------------------------------------------------------- - @property def logPref(self): """Return setting of owner's logPref at level specified in its PreferenceEntry.level @@ -423,8 +418,6 @@ def logPref(self, setting): self.set_preference(candidate_info=setting, pref_ivar_name=kpLogPref) - #region runtimeParamModulation ------------------------------------------------------------------------------------- - @property def runtimeParamModulationPref(self): """Returns owner's runtimeParamModulationPref @@ -444,8 +437,6 @@ def runtimeParamModulationPref(self, setting): """ self.set_preference(candidate_info=setting, pref_ivar_name=kpRuntimeParamModulationPref) - #region runtimeParamStickyAssignment ------------------------------------------------------------------------------- - @property def runtimeParamStickyAssignmentPref(self): """Returns owner's runtimeParamStickyAssignmentPref diff --git a/psyneulink/globals/preferences/preferenceset.py b/psyneulink/globals/preferences/preferenceset.py index a6f6eb7938b..8d6c48471a8 100644 --- a/psyneulink/globals/preferences/preferenceset.py +++ b/psyneulink/globals/preferences/preferenceset.py @@ -49,7 +49,7 @@ class PreferenceSet(object): Description: Each PreferenceSet object stores a set of preferences in its corresponding attributes - Every class in the Function hierarchy is assigned a PreferenceLevel: + Every class in the Component hierarchy is assigned a PreferenceLevel: - System: reserved for the Component class - Category: primary function subclasses (e.g., Process, Mechanism, State, Projection, Function) - Type: Category subclasses (e.g., MappingProjection and ControlProjection subclasses of Projection, Function subclasses) @@ -530,7 +530,13 @@ def set_preference(self, candidate_info, pref_ivar_name, default_entry=None): #endregion #region candidate_info is a PreferenceEntry - if isinstance(candidate_info, PreferenceEntry): + if (isinstance(candidate_info, PreferenceEntry) + or (isinstance(candidate_info, tuple) and len(candidate_info)==2)): + # elif len(candidate_info) != 2: + # raise PreferenceSetError("Preference specification tuple for {} ({}) must have only two entries " + # "(setting and level)".format(owner_name, candidate_info)) + if not isinstance(candidate_info, PreferenceEntry): + candidate_info = PreferenceEntry(candidate_info[0], candidate_info[1]) setting_OK = self.validate_setting(candidate_info.setting, default_setting, pref_ivar_name) level_OK = isinstance(candidate_info.level, PreferenceLevel) if level_OK and setting_OK: