Skip to content

Commit

Permalink
Combined new error with existing error
Browse files Browse the repository at this point in the history
  • Loading branch information
DKilkenny committed Oct 23, 2019
1 parent a88e184 commit 7970524
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
7 changes: 2 additions & 5 deletions openmdao/core/system.py
Expand Up @@ -2020,17 +2020,14 @@ def resolve(to_match, io_types, matches, proms):
pmap[name] = gname + name if gname else name

not_found = (set(names).union(renames).union(patterns)) - found
if self._var_promotes['any']:
if not self._var_abs2meta and isinstance(self, openmdao.core.group.Group):
raise RuntimeError('No inputs or outputs found. Check %s '
'to make sure it is not empty' % (self.msginfo))
if not_found:
print(not_found)
if len(io_types) == 2:
call = 'promotes'
else:
call = 'promotes_%ss' % io_types[0]
raise RuntimeError("%s: '%s' failed to find any matches for the following "
"names or patterns: %s." %
"names or patterns: %s. Check to make sure it is not empty" %
(self.msginfo, call, sorted(not_found)))

maps = {'input': {}, 'output': {}}
Expand Down
26 changes: 17 additions & 9 deletions openmdao/core/tests/test_group.py
Expand Up @@ -408,7 +408,8 @@ def test_group_renames_errors_not_found(self):
p.setup()
self.assertEqual(str(err.exception),
"IndepVarComp (comp1): 'promotes_outputs' failed to find any matches for "
"the following names or patterns: ['xx'].")
"the following names or patterns: ['xx']. "
"Check to make sure it is not empty")

def test_group_renames_errors_bad_tuple(self):
p = om.Problem()
Expand Down Expand Up @@ -473,7 +474,8 @@ def setup(self):
p.setup()
self.assertEqual(str(err.exception),
"SellarDis2 (d1): 'promotes_outputs' failed to find any matches for "
"the following names or patterns: ['foo'].")
"the following names or patterns: ['foo']. "
"Check to make sure it is not empty")

def test_group_nested_conn(self):
"""Example of adding subsystems and issuing connections with nested groups."""
Expand Down Expand Up @@ -659,7 +661,8 @@ def test_promote_not_found1(self):
p.setup()
self.assertEqual(str(context.exception),
"ExecComp (C2): 'promotes_outputs' failed to find any matches for "
"the following names or patterns: ['x*'].")
"the following names or patterns: ['x*']. "
"Check to make sure it is not empty")

def test_promote_not_found2(self):
p = om.Problem()
Expand All @@ -672,7 +675,8 @@ def test_promote_not_found2(self):
p.setup()
self.assertEqual(str(context.exception),
"ExecComp (C2): 'promotes_inputs' failed to find any matches for "
"the following names or patterns: ['xx'].")
"the following names or patterns: ['xx']. "
"Check to make sure it is not empty")

def test_promote_not_found3(self):
p = om.Problem()
Expand All @@ -685,7 +689,8 @@ def test_promote_not_found3(self):
p.setup()
self.assertEqual(str(context.exception),
"ExecComp (C2): 'promotes' failed to find any matches for "
"the following names or patterns: ['xx'].")
"the following names or patterns: ['xx']. "
"Check to make sure it is not empty")

def test_empty_group(self):
p = om.Problem()
Expand All @@ -694,8 +699,9 @@ def test_empty_group(self):
with self.assertRaises(Exception) as context:
p.setup()
self.assertEqual(str(context.exception),
"No inputs or outputs found. Check Group (G1) "
"to make sure it is not empty")
"Group (G1): 'promotes' failed to find any matches for "
"the following names or patterns: ['*']. "
"Check to make sure it is not empty")

def test_missing_promote_var(self):
p = om.Problem()
Expand All @@ -710,7 +716,8 @@ def test_missing_promote_var(self):
p.setup()
self.assertEqual(str(context.exception),
"ExecComp (d1): 'promotes_inputs' failed to find any matches for "
"the following names or patterns: ['foo'].")
"the following names or patterns: ['foo']. "
"Check to make sure it is not empty")

def test_missing_promote_var2(self):
p = om.Problem()
Expand All @@ -725,7 +732,8 @@ def test_missing_promote_var2(self):
p.setup()
self.assertEqual(str(context.exception),
"ExecComp (d1): 'promotes_outputs' failed to find any matches for "
"the following names or patterns: ['bar', 'blammo'].")
"the following names or patterns: ['bar', 'blammo']. "
"Check to make sure it is not empty")

def test_promote_src_indices(self):
import numpy as np
Expand Down

0 comments on commit 7970524

Please sign in to comment.