diff --git a/psyneulink/library/compositions/emcomposition.py b/psyneulink/library/compositions/emcomposition.py index 093028c05e..174a19b614 100644 --- a/psyneulink/library/compositions/emcomposition.py +++ b/psyneulink/library/compositions/emcomposition.py @@ -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: diff --git a/tests/composition/test_emcomposition.py b/tests/composition/test_emcomposition.py index aecb35127e..6a943982de 100644 --- a/tests/composition/test_emcomposition.py +++ b/tests/composition/test_emcomposition.py @@ -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: