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

Bug fix for stacked systems #29

Merged
merged 9 commits into from
May 28, 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 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