Skip to content

Commit

Permalink
[skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcpni committed Nov 25, 2024
1 parent cc55248 commit bc40c3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions psyneulink/library/compositions/emcomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,11 +1898,16 @@ def _validate_memory_specs(self, memory_template, memory_capacity, memory_fill,
if all([fw is None for fw in _field_wts]):
raise EMCompositionError(f"The entries in 'field_weights' arg for {name} can't all be 'None' "
f"since that will preclude the construction of any keys.")
# if all([fw in {0, None} for fw in _field_wts]):

if not any(_field_wts):
warnings.warn(f"All of the entries in the 'field_weights' arg for {name} "
f"are either None or set to 0; this will result in no retrievals "
f"unless/until the 0(s) is(are) changed to a positive value.")
f"unless/until one or more of them are changed to a positive value.")

elif any([fw == 0 for fw in _field_wts if fw is not None]):
warnings.warn(f"Some of the entries in the 'field_weights' arg for {name} "
f"are set to 0; those fields will be ignored during retrieval "
f"unless/until they are changed to a positive value.")

# If field_names has more than one value it must match the first dimension (axis 0) of memory_template:
if field_names and len(field_names) != num_fields:
Expand Down
9 changes: 8 additions & 1 deletion tests/composition/test_emcomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,14 @@ def construct_em(field_weights):
construct_em(field_weights)
warning_msg = ("All of the entries in the 'field_weights' arg for EM_Composition "
"are either None or set to 0; this will result in no retrievals "
"unless/until the 0(s) is(are) changed to a positive value.")
"unless/until one or more of them are changed to a positive value.")
assert warning_msg in str(warning[0].message)

elif any([fw == 0 for fw in field_weights]):
with pytest.warns(UserWarning) as warning:
construct_em(field_weights)
warning_msg = ("Some of the entries in the 'field_weights' arg for EM_Composition are set to 0; those "
"fields will be ignored during retrieval unless/until they are changed to a positive value.")
assert warning_msg in str(warning[0].message)

else:
Expand Down

0 comments on commit bc40c3d

Please sign in to comment.