-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from opendilab/dev/graphviz
- Loading branch information
Showing
136 changed files
with
5,555 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import importlib.util | ||
import os | ||
from types import ModuleType | ||
|
||
|
||
def get_module(filename) -> ModuleType: | ||
_, _simple_filename = os.path.split(filename) | ||
_module_name, _ = _simple_filename.split('.', maxsplit=1) | ||
|
||
spec = importlib.util.spec_from_file_location(_module_name, filename) | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
|
||
return module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
from treevalue.entry.cli import treevalue_cli | ||
|
||
if __name__ == '__main__': | ||
treevalue_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
|
||
from treevalue import FastTreeValue, graphics, TreeValue | ||
|
||
|
||
class MyFastTreeValue(FastTreeValue): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
t = MyFastTreeValue({ | ||
'a': 1, | ||
'b': np.array([[5, 6], [7, 8]]), | ||
'x': { | ||
'c': 3, | ||
'd': 4, | ||
'e': np.array([[1, 2], [3, 4]]) | ||
}, | ||
}) | ||
t2 = TreeValue({'ppp': t.x, 'x': {'t': t, 'y': t.x}}) | ||
|
||
g = graphics( | ||
(t, 't'), (t2, 't2'), | ||
title="This is a demo of 2 trees.", | ||
cfg={'bgcolor': '#ffffff00'}, | ||
) | ||
g.render('graphics.dat.gv', format='svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import numpy as np | ||
|
||
from treevalue import FastTreeValue, graphics | ||
|
||
|
||
class MyFastTreeValue(FastTreeValue): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
t = MyFastTreeValue({ | ||
'a': [4, 3, 2, 1], | ||
'b': np.array([[5, 6], [7, 8]]), | ||
'x': { | ||
'c': np.array([[5, 7], [8, 6]]), | ||
'd': {'a', 'b', 'c'}, | ||
'e': np.array([[1, 2], [3, 4]]) | ||
}, | ||
}) | ||
t1 = MyFastTreeValue({ | ||
'aa': t.a, | ||
'bb': np.array([[5, 6], [7, 8]]), | ||
'xx': { | ||
'cc': t.x.c, | ||
'dd': t.x.d, | ||
'ee': np.array([[1, 2], [3, 4]]) | ||
}, | ||
}) | ||
|
||
g = graphics( | ||
(t, 't'), (t1, 't1'), | ||
(MyFastTreeValue({'a': t, 'b': t1, 'c': [1, 2], 'd': t1.xx}), 't2'), | ||
# Here is the dup value, with several types | ||
# np.ndarray and list type will use the same value node, | ||
# but set type is not in this tuple, so will not share the same node. | ||
dup_value=(np.ndarray, list), | ||
title="This is a demo of 2 trees with dup value.", | ||
cfg={'bgcolor': '#ffffff00'}, | ||
) | ||
g.render('graphics_dup_value.dat.gv', format='svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from treevalue.utils import build_graph | ||
|
||
if __name__ == '__main__': | ||
t = {'a': 1, 'b': 2, 'x': {'c': 3, 'd': 4}} | ||
g = build_graph((t, 't'), graph_title="Demo of build_graph.") | ||
|
||
print(g.source) | ||
print(g.render('build_graph_demo.dat.gv', format='svg')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from treevalue.utils import build_graph | ||
|
||
if __name__ == '__main__': | ||
t1 = {'a': 1, 'b': 2, 'x': {'c': 3, 'd': 4}} | ||
t2 = {'f': 4, 'y': t1['x'], 'z': {'e': [5, 7], 'f': "string"}} | ||
g = build_graph((t1, 't1'), (t2, 't2'), graph_title="Complex demo of build_graph.") | ||
|
||
print(g.source) | ||
print(g.render('build_graph_complex_demo.dat.gv', format='svg')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
treevalue.utils.color | ||
=========================== | ||
|
||
Color | ||
---------------- | ||
|
||
.. autoclass:: treevalue.utils.color.Color | ||
:members: __init__, alpha, rgb, hsv, hls, __repr__, __str__, __getstate__, __setstate__, __hash__, __eq__, from_hsv, from_hls | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
treevalue.utils.exception | ||
================================ | ||
|
||
str_traceback | ||
----------------- | ||
|
||
.. autofunction:: treevalue.utils.exception.str_traceback | ||
|
Oops, something went wrong.