Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for typo in handling of flat_src_indices #1642

Merged
merged 1 commit into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openmdao/core/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ def update_src_indices(name, key):
(self.msginfo, name, str(src_indices),
str(meta['src_indices'])))
if 'flat_src_indices' in meta and meta['flat_src_indices'] is not None:
if not meta['flat_src_indices'] == src_indices:
if not meta['flat_src_indices'] == flat_src_indices:
raise RuntimeError("%s: Trying to promote input '%s' with flat_src_indices"
"=%s but flat_src_indices has already been specified as"
" %s." %
Expand Down
31 changes: 31 additions & 0 deletions openmdao/core/tests/test_auto_ivc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,34 @@ def test_mixed_src_indices_no_src_indices(self):
prob.setup()

prob.run_model()

def test_flat_src_inds_2_levels(self):
# this test passes if it doesn't raise an exception.
class Burn1(om.Group):
def setup(self):
self.add_subsystem('comp1', om.ExecComp(['y1=x*2'], y1=np.ones(4), x=np.ones(4)),
promotes_outputs=['*'])

self.add_subsystem('comp2', om.ExecComp(['y2=x*2'], y2=np.ones(4), x=np.ones(4)),
promotes_outputs=['*'])

def configure(self):
self.promotes('comp1', inputs=[('x', 'design:x')],
src_indices=[0, 0, 0, 0], flat_src_indices=True)

self.set_input_defaults('design:x', 75.3)


class Traj(om.Group):
def setup(self):
self.add_subsystem('burn1', Burn1(),
promotes_outputs=['*'])

def configure(self):
self.promotes('burn1', inputs=['design:x'],
src_indices=[0, 0, 0, 0], flat_src_indices=True)

prob = om.Problem(model=Traj())

prob.setup()
prob.run_model()