Skip to content

Commit d2b2998

Browse files
committed
ContentAddressableMemory: Check for empty arrays when converting weights to integers
Numpy doesn't like evaluating boolean values of empty arrays. Numpy <2 issues a warning, Numpy 2 raises an exception. Closes: PrincetonUniversity#3215 Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
1 parent 11ea075 commit d2b2998

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

psyneulink/core/components/functions/stateful/memoryfunctions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def _distance_field_weights_setter(value, owning_component=None, context=None):
393393
# NOTE: need the following to accommodate various forms of specification (single value, None's, etc)
394394
# that are resolved elsewhere
395395
# FIX: STANDARDIZE FORMAT FOR FIELDWEIGHTS HERE (AS LIST OF INTS) AND GET RID OF THE FOLLOWING
396-
test_val = np.array([int(np.array(val).item()) if val else 0 for val in value])
396+
test_val = np.array([int(np.array(val).item()) if (arr := np.array(val)).size and arr.item() else 0 for val in value])
397397
test_val = np.full(len(variable), test_val) if len(test_val) == 1 else test_val
398398
test_curr_field_weights = np.array([int(np.array(val).item()) if val else 0 for val in current_field_weights])
399399
test_curr_field_weights = (np.full(len(variable), test_curr_field_weights) if len(variable) == 1

0 commit comments

Comments
 (0)