Skip to content

Commit

Permalink
Merge pull request #1120 from onodip/xdsm_cleanup
Browse files Browse the repository at this point in the history
XDSM maintenance
  • Loading branch information
swryan committed Nov 18, 2019
2 parents 6b81351 + b4dfe0b commit 9b5b1e2
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 96 deletions.
5 changes: 2 additions & 3 deletions openmdao/components/exec_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ def __init__(self, exprs=[], **kwargs):
if 'vectorize' in kwargs:
warn_deprecation("The 'vectorize' option is deprecated. "
"Please use 'has_diag_partials' instead.")
kwargs['has_diag_partials'] = kwargs['vectorize']
del kwargs['vectorize']
kwargs['has_diag_partials'] = kwargs.pop('vectorize')

options = {}
for name in _disallowed_names:
Expand Down Expand Up @@ -332,7 +331,7 @@ def setup(self):
iarray = isinstance(ival, ndarray) and ival.size > 1
for out in osorted:
oval = init_vals[out]
if (iarray and isinstance(oval, ndarray) and oval.size > 1):
if iarray and isinstance(oval, ndarray) and oval.size > 1:
if oval.size != ival.size:
raise RuntimeError("%s: has_diag_partials is True but partial(%s, %s) "
"is not square (shape=(%d, %d))." %
Expand Down
7 changes: 3 additions & 4 deletions openmdao/visualization/n2_viewer/n2_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def view_tree(*args, **kwargs):
Parameters
----------
*args : dict
Postional args.
Positional args.
**kwargs : dict
Keyword args.
"""
Expand All @@ -326,7 +326,7 @@ def view_model(*args, **kwargs):
Parameters
----------
*args : dict
Postional args.
Positional args.
**kwargs : dict
Keyword args.
"""
Expand Down Expand Up @@ -372,8 +372,7 @@ def n2(data_source, outfile='n2.html', show_browser=True, embeddable=False,

# grab the model viewer data
model_data = _get_viewer_data(data_source)
options = {}
options['use_declare_partial_info'] = use_declare_partial_info
options = {'use_declare_partial_info': use_declare_partial_info}
model_data['options'] = options

model_data = 'var modelData = %s' % json.dumps(
Expand Down
58 changes: 28 additions & 30 deletions openmdao/visualization/xdsm_viewer/tests/test_xdsm_viewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import shutil
import tempfile
import unittest

import numpy as np
Expand Down Expand Up @@ -55,24 +53,24 @@ def test_pyxdsm_output_sides(self):

# Write output (outputs on the left)
filename = 'xdsm_outputs_on_the_left'
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW, quiet=QUIET,
output_side='left')
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW,
quiet=QUIET, output_side='left')

# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, PYXDSM_OUT])))

filename = 'xdsm_outputs_on_the_right'
# Write output (all outputs on the right)
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW, quiet=QUIET,
output_side='right')
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW,
quiet=QUIET, output_side='right')

# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, PYXDSM_OUT])))

filename = 'xdsm_outputs_side_mixed'
# Write output (outputs mixed)
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW, quiet=QUIET,
output_side={'optimization': 'left', 'default': 'right'})
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW,
quiet=QUIET, output_side={'optimization': 'left', 'default': 'right'})

# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, PYXDSM_OUT])))
Expand Down Expand Up @@ -130,8 +128,8 @@ def test_pyxdsm_sellar_no_recurse(self):
prob.final_setup()

# Write output
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW, recurse=False,
quiet=QUIET)
om.write_xdsm(prob, filename=filename, out_format=PYXDSM_OUT, show_browser=SHOW,
recurse=False, quiet=QUIET)

# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, PYXDSM_OUT])))
Expand Down Expand Up @@ -414,8 +412,8 @@ def setup(self):
prob.final_setup()

# Write output
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand All @@ -434,8 +432,8 @@ def test_execcomp(self):
# Conclude setup but don't run model.
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand All @@ -454,8 +452,8 @@ def test_doe(self):
# Conclude setup but don't run model.
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand Down Expand Up @@ -493,8 +491,8 @@ def test_meta_model(self):
prob.setup()
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand Down Expand Up @@ -800,8 +798,8 @@ def setup(self):
prob.final_setup()

# Write output
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand All @@ -820,8 +818,8 @@ def test_execcomp(self):
# Conclude setup but don't run model.
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand All @@ -840,8 +838,8 @@ def test_doe(self):
# Conclude setup but don't run model.
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand Down Expand Up @@ -879,8 +877,8 @@ def test_meta_model(self):
prob.setup()
prob.final_setup()

om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET, show_browser=SHOW,
show_parallel=True)
om.write_xdsm(prob, filename=filename, out_format=out_format, quiet=QUIET,
show_browser=SHOW, show_parallel=True)
# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, out_format])))

Expand Down Expand Up @@ -944,8 +942,8 @@ def test_legend_and_class_names(self):
recurse=True, legend=True)
self.assertTrue(os.path.isfile('.'.join(['xdsmjs_circuit_legend', 'html'])))

om.write_xdsm(p, 'xdsmjs_circuit_class_names', out_format='html', quiet=QUIET, show_browser=SHOW,
recurse=True, class_names=True)
om.write_xdsm(p, 'xdsmjs_circuit_class_names', out_format='html', quiet=QUIET,
show_browser=SHOW, recurse=True, class_names=True)
self.assertTrue(os.path.isfile('.'.join(['xdsmjs_circuit_class_names', 'html'])))

def test_xdsmjs_right_outputs(self):
Expand All @@ -967,8 +965,8 @@ def test_xdsmjs_right_outputs(self):

# Write output
with assert_warning(Warning, msg):
om.write_xdsm(prob, filename=filename, out_format='html', show_browser=SHOW, quiet=QUIET,
output_side='right')
om.write_xdsm(prob, filename=filename, out_format='html', show_browser=SHOW,
quiet=QUIET, output_side='right')

# Check if file was created
self.assertTrue(os.path.isfile('.'.join([filename, 'html'])))
Expand Down

0 comments on commit 9b5b1e2

Please sign in to comment.