Skip to content

Commit

Permalink
Bug fix for stacked systems (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinSGray authored May 28, 2020
1 parent d0243ee commit 64c23e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyxdsm/XDSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _build_node_grid(self):
style += ',faded'

label = _parse_label(comp.label, comp.label_width)
node = node_str.format(style=comp.style, node_name=comp.node_name, node_label=label)
node = node_str.format(style=style, node_name=comp.node_name, node_label=label)
grid[i_row, j_col] = node

row_idx_map[comp.node_name] = i_row
Expand Down
31 changes: 25 additions & 6 deletions pyxdsm/tests/test_xdsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
from pyxdsm.XDSM import XDSM, __file__
from numpy.distutils.exec_command import find_executable


def filter_lines(lns):
# Empty lines are excluded.
# Leading and trailing whitespaces are removed
# Comments are removed.
return [ln.strip() for ln in lns if ln.strip() and not ln.strip().startswith('%')]

class TestXDSM(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -102,6 +109,24 @@ def test_options(self):
self.assertTrue(os.path.isfile(os.path.join(spec_dir, 'F.json')))
self.assertTrue(os.path.isfile(os.path.join(spec_dir, 'G_spec.json')))


def test_stacked_system(self):

x = XDSM()

x.add_system('test', 'Optimization', r'\text{test}', stack=True)

file_name = "stacked_test"
x.write(file_name)

tikz_file = file_name + '.tikz'
with open(tikz_file, "r") as f:
tikz = f.read()

self.assertIn(r"\node [Optimization,stack]", tikz)



def test_tikz_content(self):
# Check if TiKZ file was created.
# Compare the content of the sample below and the newly created TiKZ file.
Expand Down Expand Up @@ -222,12 +247,6 @@ def test_tikz_content(self):
\end{tikzpicture}"""

def filter_lines(lns):
# Empty lines are excluded.
# Leading and trailing whitespaces are removed
# Comments are removed.
return [ln.strip() for ln in lns if ln.strip() and not ln.strip().startswith('%')]

filename = 'xdsm_test_tikz'

x = XDSM(use_sfmath=True)
Expand Down

0 comments on commit 64c23e0

Please sign in to comment.