Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tree_maker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ABP Computing
ABP Computing Sandbox
tree_maker
Commits
7706f1d8
Commit
7706f1d8
authored
3 years ago
by
Hamish Graham
Browse files
Options
Downloads
Patches
Plain Diff
updated
parent
ac7c9442
No related branches found
No related tags found
No related merge requests found
Pipeline
#3036711
failed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree_maker/functions_imported_tree.py
+158
-0
158 additions, 0 deletions
tree_maker/functions_imported_tree.py
with
158 additions
and
0 deletions
tree_maker/functions_imported_tree.py
0 → 100644
+
158
−
0
View file @
7706f1d8
import
tree_maker
as
tm
import
numpy
as
np
import
math
import
random
import
bokeh
from
bokeh.io
import
show
,
output_notebook
from
bokeh.plotting
import
figure
from
bokeh.layouts
import
column
,
row
from
bokeh.models
import
GraphRenderer
,
Ellipse
,
StaticLayoutProvider
,
HoverTool
,
Button
,
ColumnDataSource
,
CustomJS
from
bokeh.models.widgets
import
DataTable
,
DateFormatter
,
TableColumn
from
bokeh.palettes
import
Spectral8
from
anytree
import
AnyNode
,
RenderTree
import
numpy
as
np
from
bokeh.resources
import
INLINE
bokeh
.
io
.
output_notebook
(
INLINE
)
import
json
def
create_tree_flower
(
node
):
"""
Creates a tree with the shape of a
'
flower
'
. The nodes that have attributes; x, y, ragius, short_path, angle, min_angle, max_angle and color.
"""
if
node
.
is_leaf
:
pass
else
:
if
node
.
is_root
:
node
.
x
=
0
node
.
y
=
0
node
.
radius
=
0
#node.min_x = -2
#node.max_x = 2
node
.
short_path
=
'
/
'
.
join
(
node
.
path
.
split
(
'
/
'
)[
-
3
:])
node
.
angle
=
2
*
math
.
pi
node
.
min_angle
=
0
node
.
max_angle
=
2
*
math
.
pi
node
.
color
=
'
black
'
for
my_child
,
my_angle
in
zip
(
node
.
children
,
np
.
linspace
(
node
.
min_angle
,
node
.
max_angle
,
len
(
node
.
children
))):
#my_child.min_x = xx - (node.max_x - node.min_x)/len(node.children)/2
#my_child.max_x = xx + (node.max_x - node.min_x)/len(node.children)/2
my_child
.
color
=
"
black
"
my_child
.
short_path
=
'
/
'
.
join
(
my_child
.
path
.
split
(
'
/
'
)[
-
3
:])
my_child
.
angle
=
my_angle
my_child
.
min_angle
=
my_angle
-
(
node
.
max_angle
-
node
.
min_angle
)
/
len
(
node
.
children
)
/
2
my_child
.
max_angle
=
my_angle
+
(
node
.
max_angle
-
node
.
min_angle
)
/
len
(
node
.
children
)
/
2
my_child
.
radius
=
node
.
radius
+
1
my_child
.
x
=
my_child
.
radius
*
math
.
cos
(
my_angle
)
my_child
.
y
=
my_child
.
radius
*
math
.
sin
(
my_angle
)
create_tree_flower
(
my_child
)
def
create_tree
(
node
):
"""
Creates a tree. The nodes that have attributes; x, min_x, max_x, y, ragius, short_path, angle, min_angle, max_angle and color.
"""
if
node
.
is_leaf
:
pass
else
:
if
node
.
is_root
:
node
.
x
=
0
node
.
y
=
0
node
.
min_x
=
-
2
node
.
max_x
=
2
node
.
short_path
=
'
/
'
.
join
(
node
.
path
.
split
(
'
/
'
)[
-
3
:])
node
.
angle
=
2
*
math
.
pi
node
.
min_angle
=
0
node
.
max_angle
=
2
*
math
.
pi
node
.
color
=
'
black
'
for
my_child
,
xx
,
my_angle
in
zip
(
node
.
children
,
np
.
linspace
(
node
.
min_x
,
node
.
max_x
,
len
(
node
.
children
)),
np
.
linspace
(
node
.
min_angle
,
node
.
max_angle
,
len
(
node
.
children
))):
my_child
.
x
=
xx
my_child
.
y
=
node
.
y
-
1
my_child
.
min_x
=
xx
-
(
node
.
max_x
-
node
.
min_x
)
/
len
(
node
.
children
)
/
2
my_child
.
max_x
=
xx
+
(
node
.
max_x
-
node
.
min_x
)
/
len
(
node
.
children
)
/
2
my_child
.
color
=
"
black
"
my_child
.
short_path
=
'
/
'
.
join
(
my_child
.
path
.
split
(
'
/
'
)[
-
3
:])
my_child
.
angle
=
my_angle
my_child
.
min_angle
=
my_angle
-
(
node
.
max_angle
-
node
.
min_angle
)
/
len
(
node
.
children
)
/
2
my_child
.
max_angle
=
my_angle
+
(
node
.
max_angle
-
node
.
min_angle
)
/
len
(
node
.
children
)
/
2
create_tree
(
my_child
)
def
create_xy
(
node
):
"""
Creates a list for x_values and y_values for the nodes of a tree.
"""
x_values
=
[
node
.
x
]
y_values
=
[
node
.
y
]
path
=
[
node
.
short_path
]
for
descendant
in
node
.
descendants
:
x_values
.
append
(
descendant
.
x
)
y_values
.
append
(
descendant
.
y
)
path
.
append
(
descendant
.
short_path
)
return
x_values
,
y_values
,
path
def
color_from_status
(
my_df
,
last_key
):
# is this still relevant?
my_df
[
'
color
'
]
=
'
green
'
#for index in my_df.index:
# if my_df['status'][index] == last_key:
# my_df['color'][index] = 'green'
# else:
# my_df['color'][index] = 'black'
def
create_color
(
node
):
"""
Adds colors of nodes to an array.
"""
my_colors
=
[
node
.
color
]
for
descendant
in
node
.
descendants
:
my_colors
.
append
(
descendant
.
color
)
return
my_colors
#def create_tree_polar()
def
create_tree_cartesian
(
node
):
"""
Adds the angle attribute to an array.
"""
angles
=
[
node
.
angle
]
for
descendant
in
node
.
descendants
:
angles
.
append
(
node
.
angle
)
return
angles
def
read_json
(
path
):
"""
Returns a json file to read in python.
"""
with
open
(
path
.
log_file
)
as
json_file
:
json_data
=
json
.
load
(
json_file
)
return
json_data
def
json_tree
(
node
):
my_dictionary
=
[]
for
child
in
node
.
children
:
json_data
=
read_json
(
child
)
my_dictionary
.
append
(
json_data
)
return
my_dictionary
def
status_tree
(
node
):
for
child
in
root
.
children
:
if
len
(
read_json
(
child
))
==
4
:
return
child
.
color
==
'
red
'
def
get_color
(
handle
):
if
handle
.
has_been
(
'
started
'
):
my_color
=
'
red
'
if
handle
.
has_been
(
'
completed
'
):
my_color
=
'
green
'
else
:
my_color
=
'
black
'
return
my_color
def
get_status
(
handle
):
"""
Returns last key, the status of the job, from
'
log_file
'
.
"""
keys
=
list
(
tm
.
from_json
(
handle
.
log_file
))
if
len
(
keys
)
>
0
:
return
keys
[
-
1
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment