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

Fixed show_progress error #1794

Merged
merged 4 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions openmdao/core/problem.py
Expand Up @@ -1471,6 +1471,9 @@ def check_totals(self, of=None, wrt=None, out_stream=_DEFAULT_OUT_STREAM, compac
For 'rel error', 'abs error', 'magnitude' the value is: A tuple containing norms for
forward - fd, adjoint - fd, forward - adjoint.
"""
if out_stream == _DEFAULT_OUT_STREAM:
out_stream = sys.stdout

if self._metadata['setup_status'] < _SetupStatus.POST_FINAL_SETUP:
raise RuntimeError(self.msginfo + ": run_model must be called before total "
"derivatives can be checked.")
Expand Down
7 changes: 6 additions & 1 deletion openmdao/core/tests/test_check_derivs.py
Expand Up @@ -18,7 +18,8 @@
from openmdao.test_suite.components.simple_comps import DoubleArrayComp
from openmdao.test_suite.components.array_comp import ArrayComp
from openmdao.test_suite.groups.parallel_groups import FanInSubbedIDVC, Diamond
from openmdao.utils.assert_utils import assert_near_equal, assert_warning, assert_check_partials
from openmdao.utils.assert_utils import assert_near_equal, assert_warning, assert_check_partials, \
assert_no_warning
from openmdao.utils.mpi import MPI

try:
Expand Down Expand Up @@ -2586,6 +2587,10 @@ def test_check_totals_show_progress(self):
lines = stream.getvalue()
self.assertFalse("Checking derivatives with respect to" in lines)

msg = "'_ReprClass' object has no attribute 'write'"
with assert_no_warning(AttributeError, msg):
prob.check_totals(method='fd', show_progress=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the assert here.. just doing the check_totals without specifying an out_stream suffices to show that it's working.. (it fails with a hard error without your fix... the assert doesn't do anything)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


def test_desvar_as_obj(self):
prob = om.Problem()
prob.model = SellarDerivatives()
Expand Down