@@ -2532,13 +2532,18 @@ def execute(self,
2532
2532
if not self .parameters .execute_until_finished ._get (context ):
2533
2533
break
2534
2534
2535
- # REPORT EXECUTION
2536
- if self .prefs .reportOutputPref and (context .execution_phase & ContextFlags .PROCESSING | ContextFlags .LEARNING ):
2537
- self ._report_mechanism_execution (
2538
- self .get_input_values (context ),
2539
- output = self .output_port .parameters .value ._get (context ),
2540
- context = context
2541
- )
2535
+ # REPORT EXECUTION if called from command line
2536
+ # If called by a Composition, it handles reporting.
2537
+ if context .source == ContextFlags .COMMAND_LINE :
2538
+ if self .prefs .reportOutputPref and (context .execution_phase & ContextFlags .PROCESSING | ContextFlags .LEARNING ):
2539
+ from psyneulink .core .compositions .composition import _report_node_execution
2540
+ from rich import print
2541
+ print (
2542
+ _report_node_execution (self ,
2543
+ input_val = self .get_input_values (context ),
2544
+ output_val = self .output_port .parameters .value ._get (context ),
2545
+ context = context )
2546
+ )
2542
2547
2543
2548
return value
2544
2549
@@ -2965,7 +2970,7 @@ def _gen_llvm_invoke_function(self, ctx, builder, function, params, state, varia
2965
2970
return fun_out , builder
2966
2971
2967
2972
def _gen_llvm_is_finished_cond (self , ctx , builder , params , state ):
2968
- return pnlvm . ir . IntType ( 1 ) (1 )
2973
+ return ctx . bool_ty (1 )
2969
2974
2970
2975
def _gen_llvm_mechanism_functions (self , ctx , builder , params , state , arg_in ,
2971
2976
ip_output , * , tags :frozenset ):
@@ -3043,8 +3048,7 @@ def _gen_llvm_function(self, *, extra_args=[], ctx:pnlvm.LLVMBuilderContext, tag
3043
3048
ctx .get_input_struct_type (self ).as_pointer (),
3044
3049
ctx .get_output_struct_type (self ).as_pointer ()]
3045
3050
3046
- builder = ctx .create_llvm_function (args , self ,
3047
- return_type = pnlvm .ir .IntType (1 ),
3051
+ builder = ctx .create_llvm_function (args , self , return_type = ctx .bool_ty ,
3048
3052
tags = tags )
3049
3053
params , state = builder .function .args [:2 ]
3050
3054
finished = self ._gen_llvm_is_finished_cond (ctx , builder , params , state )
@@ -3083,7 +3087,7 @@ def _gen_llvm_function_body(self, ctx, builder, params, state, arg_in, arg_out,
3083
3087
args_t = [a .type for a in builder .function .args ]
3084
3088
internal_builder = ctx .create_llvm_function (args_t , self ,
3085
3089
name = builder .function .name + "_internal" ,
3086
- return_type = pnlvm . ir . IntType ( 1 ) )
3090
+ return_type = ctx . bool_ty )
3087
3091
iparams , istate , iin , iout = internal_builder .function .args [:4 ]
3088
3092
internal_builder , is_finished = self ._gen_llvm_function_internal (ctx , internal_builder ,
3089
3093
iparams , istate , iin , iout , tags = tags )
@@ -3131,74 +3135,6 @@ def _gen_llvm_function_body(self, ctx, builder, params, state, arg_in, arg_out,
3131
3135
3132
3136
return builder
3133
3137
3134
- def _report_mechanism_execution (self , input_val = None , params = None , output = None , context = None ):
3135
-
3136
- if input_val is None :
3137
- input_val = self .get_input_values (context )
3138
- if output is None :
3139
- output = self .output_port .parameters .value ._get (context )
3140
- params = params or {p .name : p ._get (context ) for p in self .parameters }
3141
-
3142
- if 'mechanism' in self .name or 'Mechanism' in self .name :
3143
- mechanism_string = ' '
3144
- else :
3145
- mechanism_string = ' mechanism'
3146
-
3147
- # FIX: kmantel: previous version would fail on anything but iterables of things that can be cast to floats
3148
- # if you want more specific output, you can add conditional tests here
3149
- try :
3150
- input_string = [float ("{:0.3}" .format (float (i ))) for i in input_val ].__str__ ().strip ("[]" )
3151
- except TypeError :
3152
- input_string = input_val
3153
-
3154
- print ("\n \' {}\' {} executed:\n - input: {}" .format (self .name , mechanism_string , input_string ))
3155
-
3156
- try :
3157
- include_params = re .match ('param(eter)?s?' , self .reportOutputPref , flags = re .IGNORECASE )
3158
- except TypeError :
3159
- include_params = False
3160
-
3161
- if include_params :
3162
- print ("- params:" )
3163
- # Sort for consistency of output
3164
- params_keys_sorted = sorted (params .keys ())
3165
- for param_name in params_keys_sorted :
3166
- # No need to report:
3167
- # function_params here, as they will be reported for the function itself below;
3168
- # input_ports or output_ports, as these are inherent in the structure
3169
- if param_name in {FUNCTION_PARAMS , INPUT_PORTS , OUTPUT_PORTS }:
3170
- continue
3171
- param_is_function = False
3172
- param_value = params [param_name ]
3173
- if isinstance (param_value , Function ):
3174
- param = param_value .name
3175
- param_is_function = True
3176
- elif isinstance (param_value , type (Function )):
3177
- param = param_value .__name__
3178
- param_is_function = True
3179
- elif isinstance (param_value , (types .FunctionType , types .MethodType )):
3180
- param = param_value .__self__ .__class__ .__name__
3181
- param_is_function = True
3182
- else :
3183
- param = param_value
3184
- print ("\t {}: {}" .format (param_name , str (param ).__str__ ().strip ("[]" )))
3185
- if param_is_function :
3186
- # Sort for consistency of output
3187
- func_params_keys_sorted = sorted (self .function .parameters .names ())
3188
- for fct_param_name in func_params_keys_sorted :
3189
- print ("\t \t {}: {}" .
3190
- format (fct_param_name ,
3191
- str (getattr (self .function .parameters , fct_param_name )._get (context )).__str__ ().strip ("[]" )))
3192
-
3193
- # FIX: kmantel: previous version would fail on anything but iterables of things that can be cast to floats
3194
- # if you want more specific output, you can add conditional tests here
3195
- try :
3196
- output_string = re .sub (r'[\[,\],\n]' , '' , str ([float ("{:0.3}" .format (float (i ))) for i in output ]))
3197
- except TypeError :
3198
- output_string = output
3199
-
3200
- print ("- output: {}" .format (output_string ))
3201
-
3202
3138
@tc .typecheck
3203
3139
def _show_structure (self ,
3204
3140
show_functions :bool = False ,
0 commit comments