From dc22846ca3f5933789db44fb2ff71f8abab4ec38 Mon Sep 17 00:00:00 2001 From: Ella Wu <602725+ewu63@users.noreply.github.com> Date: Tue, 7 May 2024 13:45:22 -0700 Subject: [PATCH] fix reshaping --- pyoptsparse/pyOpt_history.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyoptsparse/pyOpt_history.py b/pyoptsparse/pyOpt_history.py index b204f192..efc31dd7 100644 --- a/pyoptsparse/pyOpt_history.py +++ b/pyoptsparse/pyOpt_history.py @@ -651,7 +651,10 @@ def getValues(self, names=None, callCounters=None, major=True, scale=False, stac # reshape lists into numpy arrays for name in names: # we just stack along axis 0 - data[name] = np.stack(data[name], axis=0) + if len(data[name]) > 0: + data[name] = np.stack(data[name], axis=0) + else: + data[name] = np.array(data[name]) # we cast 1D arrays to 2D, for scalar values if data[name].ndim == 1: data[name] = np.expand_dims(data[name], 1)