From b5473bebd8d4d054c3eae1827f63a94b851dd718 Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Thu, 24 Aug 2023 13:52:10 -0400 Subject: [PATCH 1/3] Allows parameter shape to be given as None, as it was before the parameter update. --- dymos/phase/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dymos/phase/options.py b/dymos/phase/options.py index 6f343806c..af2359203 100644 --- a/dymos/phase/options.py +++ b/dymos/phase/options.py @@ -284,7 +284,7 @@ def __init__(self, read_only=False): self.declare(name='val', types=(Iterable, np.ndarray, Number), default=0.0, desc='The default value of the parameter in the phase.') - self.declare(name='shape', check_valid=check_valid_shape, default=_unspecified, + self.declare(name='shape', check_valid=check_valid_shape, default=_unspecified, allow_none=True, desc='The shape of the parameter.') self.declare(name='lower', types=(Iterable, Number), default=None, From c5936c1021fe582841366d8e812538a1ebc08a5d Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Thu, 24 Aug 2023 14:00:58 -0400 Subject: [PATCH 2/3] allow_param_shape_none --- dymos/phase/options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dymos/phase/options.py b/dymos/phase/options.py index af2359203..5da83ffbb 100644 --- a/dymos/phase/options.py +++ b/dymos/phase/options.py @@ -3,7 +3,7 @@ import numpy as np import openmdao.api as om -from ..utils.misc import _unspecified +from ..utils.misc import _unspecified, _none_or_unspecified class ControlOptionsDictionary(om.OptionsDictionary): @@ -224,7 +224,7 @@ def check_valid_shape(name, value): Shape to check, should be a Iterable, Number, list, or tuple. """ if name == 'shape': - if value is not _unspecified and not isinstance(value, (Iterable, Number, list, tuple)): + if value not in _none_or_unspecified and not isinstance(value, (Iterable, Number, list, tuple)): raise ValueError(f"Option '{name}' with value {value} is not valid.") From f638b8ae770dd79ff6f98f1e6f47893567765c0a Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Thu, 24 Aug 2023 14:27:16 -0400 Subject: [PATCH 3/3] added test --- .../test/test_brachistochrone_path_constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dymos/examples/brachistochrone/test/test_brachistochrone_path_constraint.py b/dymos/examples/brachistochrone/test/test_brachistochrone_path_constraint.py index bdbec7517..723cb5da5 100644 --- a/dymos/examples/brachistochrone/test/test_brachistochrone_path_constraint.py +++ b/dymos/examples/brachistochrone/test/test_brachistochrone_path_constraint.py @@ -40,7 +40,7 @@ def _make_problem(self, tx): phase.add_boundary_constraint('x', loc='final', equals=10.0) phase.add_path_constraint('pc = y-x/2-1', lower=0.0) - phase.add_parameter('g', opt=False, units='m/s**2', val=9.80665, include_timeseries=True) + phase.add_parameter('g', opt=False, units='m/s**2', val=9.80665, shape=None, include_timeseries=True) phase.add_objective('time_phase', loc='final', scaler=10)