From e6638bb9ede616f3d20094f041934670a6ebb1ae Mon Sep 17 00:00:00 2001 From: Katherine Mantel Date: Thu, 26 Jan 2023 21:18:55 -0500 Subject: [PATCH 1/2] GradientOptimization: fix potentially uninitialized local variable --- .../components/functions/nonstateful/optimizationfunctions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py b/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py index d64947cc55f..1adad1270bb 100644 --- a/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py +++ b/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py @@ -1189,6 +1189,8 @@ def reset(self, default_variable=None, objective_function=None, context=None, ** if self.owner: owner_str = ' of {self.owner.name}' + else: + owner_str = '' # Get bounds from search_space if it has any non-None entries if any(i is not None for i in self.search_space): From 93b54115a5e9f6397d6830e73438a330ddeb4d35 Mon Sep 17 00:00:00 2001 From: Katherine Mantel Date: Fri, 9 Dec 2022 22:52:51 -0500 Subject: [PATCH 2/2] GradientOptimization: fix error on default bounds bounds are checked only during reset, and the default value of search_space causes this to fail (lower == upper) --- .../components/functions/nonstateful/optimizationfunctions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py b/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py index 1adad1270bb..db49504e52b 100644 --- a/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py +++ b/psyneulink/core/components/functions/nonstateful/optimizationfunctions.py @@ -1245,9 +1245,9 @@ def reset(self, default_variable=None, objective_function=None, context=None, ** # Array specified for upper bound, so replace any None's with +inf upper = np.array([[float('inf')] if n[0] is None else n for n in upper.reshape(sample_len,1)]) - if not all(lower= corresponding upper for one or " + f"{owner_str} resulted in lower > corresponding upper for one or " f"more elements (lower: {lower.tolist()}; uuper: {upper.tolist()}).") bounds = (lower,upper)