Skip to content

Commit

Permalink
Merge branch 'main' into update-demo-ippm
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudh1666 authored Sep 27, 2024
2 parents 44f1394 + 0ebb9da commit da76c55
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
16 changes: 8 additions & 8 deletions demos/demo_ippm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
"id": "f6b85f98",
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-27T15:20:26.252284Z",
"start_time": "2024-09-27T15:20:24.316631Z"
"end_time": "2024-09-27T16:03:01.862603Z",
"start_time": "2024-09-27T16:03:00.048055Z"
}
},
"outputs": [
Expand Down Expand Up @@ -128,8 +128,8 @@
"id": "cdaeaae4",
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-27T15:20:27.734695Z",
"start_time": "2024-09-27T15:20:26.252972Z"
"end_time": "2024-09-27T16:03:03.197904Z",
"start_time": "2024-09-27T16:03:01.863761Z"
}
},
"outputs": [
Expand Down Expand Up @@ -226,8 +226,8 @@
"id": "796b5fe8",
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-27T15:20:27.984418Z",
"start_time": "2024-09-27T15:20:27.738629Z"
"end_time": "2024-09-27T16:03:03.386047Z",
"start_time": "2024-09-27T16:03:03.198665Z"
}
},
"outputs": [
Expand Down Expand Up @@ -301,8 +301,8 @@
"id": "7c826ce0",
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-27T15:20:28.373884Z",
"start_time": "2024-09-27T15:20:27.986193Z"
"end_time": "2024-09-27T16:03:03.569138Z",
"start_time": "2024-09-27T16:03:03.387436Z"
}
},
"outputs": [
Expand Down
19 changes: 18 additions & 1 deletion kymata/ippm/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@ def plot_ippm(
def __get_label(inc_edge: str) -> str:
try:
# assumes inc edge is named as transform-x.
label = inc_edge[:inc_edge.index("-")]
label = inc_edge[:inc_edge.rindex("-")]
return label
except ValueError:
# "-" not found in inc_edge. Therefore, it must be input transform.
return inc_edge

non_terminal = set()
for node in graph.values():
non_terminal.update(node.inc_edges)

def __is_terminal_node(inc_edge: str) -> bool:
"""Returns whether the named node is a terminal node in the graph"""
return inc_edge not in non_terminal

# first lets aggregate all the information.
node_x = list(range(len(graph.keys()))) # x coordinates for nodes eg. (x, y) = (node_x[i], node_y[i])
Expand Down Expand Up @@ -116,6 +124,15 @@ def __get_label(inc_edge: str) -> str:

ax.scatter(x=node_x, y=node_y, c=node_colors, s=node_sizes, marker="H", zorder=2)

# Show lines trailing off into the future from terminal nodes
future_width = 20 # ms
for node in graph.keys():
if __is_terminal_node(node):
step_1 = max(node_x) + future_width / 2
step_2 = max(node_x) + future_width
ax.plot([graph[node].position.x, step_1], [graph[node].position.y, graph[node].position.y], color=colors[__get_label(node)], linewidth=linewidth, linestyle="solid")
ax.plot([step_1, step_2], [graph[node].position.y, graph[node].position.y], color=colors[__get_label(node)], linewidth=linewidth, linestyle="dotted")

if title is not None:
plt.title(title)

Expand Down

0 comments on commit da76c55

Please sign in to comment.