Skip to content

Commit

Permalink
fix: print tree in .tree() method to make it show in terminal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
geddy11 committed May 22, 2024
1 parent 33eb1b1 commit d2b43e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
3 changes: 1 addition & 2 deletions docs/nb/Bluetooth sensor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@
" └── MCU\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
"output_type": "display_data"
}
],
"source": [
Expand Down
8 changes: 2 additions & 6 deletions src/sysloss/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import rustworkx as rx
import numpy as np
from rich.tree import Tree
from rich import print
import json
import pandas as pd
import matplotlib
Expand Down Expand Up @@ -436,11 +437,6 @@ def tree(self, name=""):
name : str, optional
Name of component to start with. If not given, print the entire system., by default ""
Returns
-------
rich.tree.Tree
System Tree class.
Raises
------
ValueError
Expand All @@ -464,7 +460,7 @@ def tree(self, name=""):
c += [j._params["name"]]
ndict[i[0]._params["name"]] = c
t.add(self._make_rtree(ndict, n))
return t
print(t)

def _set_phase_lkup(self):
"""Make lookup from node # to load phases"""
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ def test_case1():
case1.save("tests/unit/case1.json")
dfp = case1.params(limits=True)
assert len(dfp) == rows - 1, "Case1 parameters row count"
t = case1.tree()
assert type(t) == rich.tree.Tree, "Case1 tree output"
assert case1.tree() == None, "Case1 tree output"
with pytest.raises(ValueError):
case1.tree("Dummy")
t = case1.tree("5V boost")
assert type(t) == rich.tree.Tree, "Case1 subtree output"
assert case1.tree("5V boost") == None, "Case1 subtree output"
edata = {"vi": [3.6], "io": [0.1, 0.4, 0.6, 0.9], "eff": [[0.3, 0.4, 0.67, 0.89]]}
case1.change_comp(
"1.8V buck", comp=Converter("1.8V buck", vo=1.8, eff=edata, iq=12e-6)
Expand Down

0 comments on commit d2b43e3

Please sign in to comment.