Skip to content

Commit

Permalink
Fix/log/tuple datum value (#601)
Browse files Browse the repository at this point in the history
* • System
  - show_graph():
    fixed bug producing empty image for graphs with just one Mechanism
    added auto-recurrent projections

* • Log
  - added numpy_array output method

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* • Log
  - fixed bugs preventing logging during INITIALIZATION

* • Log
  - fixed bugs preventing logging during INITIALIZATION

* -

* -

* -

* -

* -

* • Log
  - logged_item, print_entries:  corrected to use 'value' rather than owner's name in reports

* • Log
  - logged_item, print_entries:  corrected to use 'value' rather than owner's name in reports

• Tests
  test_log:  added test_log_initialization

* • Log
  - _alias_owner_name:  added to used 'value' rather than owner's name in reports
  - nparray: bug fix to handle None values

• Tests
  test_log:  added test_log_initialization

* • Log
  - log_value: added

• Tests
  - test_multilayer: added test of log_value

* • Log
  - log_value: implemented
  - logged_item, print_entries:  corrected to use 'value' rather than owner's name in reports

• Tests
  - test_multilayer: added test of log_value

* • Log
  - log_value: implemented
  - logged_item, print_entries:  corrected to use 'value' rather than owner's name in reports

• Tests
  - test_multilayer: added test of log_value

* -

* • Component
  - moved value property to Component (from Mechanism, Projection and State)
    (left an override on ControlSignal that needs it for the getter)

* • Log
  - docstring: added hint about using call_before_trial and call_after_trial
    to log values

* • ComponentPreferenceSet
  - fixed bug in which instantiation of classPreferences assigned same
    PreferenceSet to class and object

* • ComponentPreferenceSet
  - fixed bug in which instantiation of classPreferences assigned same
    PreferenceSet to class and object

* • Log
  - docstring: reinstated test on log_value (now that pref bug is fixed)

* -

* • State
  - parse_state_spec(): fixed bug in evaluating state_spec

• ComponentPreferenceSet
  - get_pref_settting_for_level(): bug instantiating classPreferences

* • State
  - parse_state_spec(): fixed bug in evaluating state_spec

• ComponentPreferenceSet
  - get_pref_settting_for_level(): bug instantiating classPreferences

* -

* -

* • Log
  nparray(): fixed bug in preventing logging of tuple valuess
  • Loading branch information
jdcpni authored Dec 14, 2017
1 parent f8bdb6e commit 223b57b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 48 deletions.
21 changes: 21 additions & 0 deletions .idea/runConfigurations/Nieuwenhuis_documented.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 42 additions & 42 deletions psyneulink/components/states/modulatorysignals/controlsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,48 +957,48 @@ def update(self, params=None, time_scale=TimeScale.TRIAL, context=None):
cost_change_string = "+" + str(cost_change)
print("Cost: {0} [{1}])".format(self.cost, cost_change_string))

#region Record control_signal values in owner Mechanism's log
# Notes:
# * Log control_signals for ALL states of a given Mechanism in the Mechanism's log
# * Log control_signals for EACH state in a separate entry of the Mechanism's log

# Get receiver Mechanism and state
controller = self.owner

# Get logPref for Mechanism
log_pref = controller.prefs.logPref

# Get context
if not context:
context = controller.name + " " + self.name + kwAssign
else:
context = context + SEPARATOR_BAR + self.name + kwAssign

# If context is consistent with log_pref:
if (log_pref is LogCondition.ALL_ASSIGNMENTS or
(log_pref is LogCondition.EXECUTION and EXECUTING in context) or
(log_pref is LogCondition.VALUE_ASSIGNMENT and (EXECUTING in context))):
# record info in log

# FIX: ENCODE ALL OF THIS AS 1D ARRAYS IN 2D PROJECTION VALUE, AND PASS TO .value FOR LOGGING
controller.log.entries[self.name + " " +
kpIntensity] = LogEntry('time_placeholder', context, float(self.intensity))
if not self.ignoreIntensityFunction:
controller.log.entries[self.name + " " + kpAllocation] = LogEntry('time_placeholder',
context,
float(self.allocation))
controller.log.entries[self.name + " " + kpIntensityCost] = LogEntry('time_placeholder',
context,
float(self.intensity_cost))
controller.log.entries[self.name + " " + kpAdjustmentCost] = LogEntry('time_placeholder',
context,
float(self.adjustment_cost))
controller.log.entries[self.name + " " + kpDurationCost] = LogEntry('time_placeholder',
context,
float(self.duration_cost))
controller.log.entries[self.name + " " + kpCost] = LogEntry('time_placeholder',
context,
float(self.cost))
# #region Record control_signal values in owner Mechanism's log
# # Notes:
# # * Log control_signals for ALL states of a given Mechanism in the Mechanism's log
# # * Log control_signals for EACH state in a separate entry of the Mechanism's log
#
# # Get receiver Mechanism and state
# controller = self.owner
#
# # Get logPref for Mechanism
# log_pref = controller.prefs.logPref
#
# # Get context
# if not context:
# context = controller.name + " " + self.name + kwAssign
# else:
# context = context + SEPARATOR_BAR + self.name + kwAssign
#
# # If context is consistent with log_pref:
# if (log_pref is LogCondition.ALL_ASSIGNMENTS or
# (log_pref is LogCondition.EXECUTION and EXECUTING in context) or
# (log_pref is LogCondition.VALUE_ASSIGNMENT and (EXECUTING in context))):
# # record info in log
#
# # FIX: ENCODE ALL OF THIS AS 1D ARRAYS IN 2D PROJECTION VALUE, AND PASS TO .value FOR LOGGING
# controller.log.entries[self.name + " " +
# kpIntensity] = LogEntry('time_placeholder', context, float(self.intensity))
# if not self.ignoreIntensityFunction:
# controller.log.entries[self.name + " " + kpAllocation] = LogEntry('time_placeholder',
# context,
# float(self.allocation))
# controller.log.entries[self.name + " " + kpIntensityCost] = LogEntry('time_placeholder',
# context,
# float(self.intensity_cost))
# controller.log.entries[self.name + " " + kpAdjustmentCost] = LogEntry('time_placeholder',
# context,
# float(self.adjustment_cost))
# controller.log.entries[self.name + " " + kpDurationCost] = LogEntry('time_placeholder',
# context,
# float(self.duration_cost))
# controller.log.entries[self.name + " " + kpCost] = LogEntry('time_placeholder',
# context,
# float(self.cost))
#endregion

def _parse_state_specific_specs(self, owner, state_dict, state_specific_spec):
Expand Down
24 changes: 18 additions & 6 deletions psyneulink/globals/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,15 +1237,27 @@ def nparray(self,
time_col = iter(time_values)
for datum in self.logged_entries[entry]:
if time_values:
# for time in next(time_col,None):
# if time is None:
# break
# if datum.item != time:
# row.append(None)
# MODIFIED 12/14/17 OLD:
while datum.time != next(time_col,None):
row.append(None)
value = None if datum.value is None else datum.value.tolist()
value = None if datum.value is None else np.array(datum.value).tolist()
row.append(value)
# # MODIFIED 12/14/17 NEW:
# for i in range(len(time_values)):
# time = next(time_col,None)
# if time is None:
# break
# if datum.time != time:
# row.append(None)
# continue
# value = None if datum.value is None else datum.value.tolist()
# row.append(value)
# break
# else:
# value = None if datum.value is None else datum.value.tolist()
# row.append(value)
# MODIFIED 12/14/17 END

if header:
entry_header = "{}{}{}{}".format(owner_name_str, lb, self._alias_owner_name(entry), rb)
row = [entry_header] + row
Expand Down

0 comments on commit 223b57b

Please sign in to comment.