Skip to content

Commit

Permalink
addition -* tag name / C2DH/jdh-notebook#97
Browse files Browse the repository at this point in the history
  • Loading branch information
eliselavy committed Mar 1, 2023
1 parent feba9f8 commit ecf20a0
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 35 deletions.
70 changes: 35 additions & 35 deletions paper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"shell.execute_reply": "2023-03-01T10:08:58.055157Z"
},
"tags": [
"figure-image19"
"figure-image19-*"
]
},
"outputs": [
Expand Down Expand Up @@ -242,7 +242,7 @@
"shell.execute_reply": "2023-03-01T10:08:58.074835Z"
},
"tags": [
"figure-image6"
"figure-image6-*"
]
},
"outputs": [
Expand Down Expand Up @@ -493,7 +493,7 @@
}
},
"tags": [
"figure-image35"
"figure-image35-*"
]
},
"outputs": [
Expand Down Expand Up @@ -653,7 +653,7 @@
}
},
"tags": [
"figure-image17"
"figure-image17-*"
]
},
"outputs": [
Expand Down Expand Up @@ -813,7 +813,7 @@
}
},
"tags": [
"figure-image28"
"figure-image28-*"
]
},
"outputs": [
Expand Down Expand Up @@ -1196,7 +1196,7 @@
}
},
"tags": [
"figure-image12"
"figure-image12-*"
]
},
"outputs": [
Expand Down Expand Up @@ -1241,7 +1241,7 @@
}
},
"tags": [
"figure-image25"
"figure-image25-*"
]
},
"outputs": [
Expand Down Expand Up @@ -1418,7 +1418,7 @@
}
},
"tags": [
"figure-image14"
"figure-image14-*"
]
},
"outputs": [
Expand Down Expand Up @@ -1576,7 +1576,7 @@
}
},
"tags": [
"figure-image36"
"figure-image36-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2120,7 +2120,7 @@
}
},
"tags": [
"figure-image8"
"figure-image8-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2165,7 +2165,7 @@
}
},
"tags": [
"figure-image15"
"figure-image15-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2199,7 +2199,7 @@
}
},
"tags": [
"figure-image32"
"figure-image32-*"
]
},
"source": [
Expand Down Expand Up @@ -2231,7 +2231,7 @@
}
},
"tags": [
"figure-image29"
"figure-image29-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2272,7 +2272,7 @@
}
},
"tags": [
"figure-image21"
"figure-image21-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2313,7 +2313,7 @@
}
},
"tags": [
"figure-image20"
"figure-image20-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2354,7 +2354,7 @@
}
},
"tags": [
"figure-image30"
"figure-image30-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2395,7 +2395,7 @@
}
},
"tags": [
"figure-image24"
"figure-image24-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2436,7 +2436,7 @@
}
},
"tags": [
"figure-image26"
"figure-image26-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2477,7 +2477,7 @@
}
},
"tags": [
"figure-image10"
"figure-image10-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2518,7 +2518,7 @@
}
},
"tags": [
"figure-image9"
"figure-image9-*"
]
},
"outputs": [
Expand Down Expand Up @@ -2565,7 +2565,7 @@
}
},
"tags": [
"figure-image5"
"figure-image5-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3021,7 +3021,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.415996Z"
},
"tags": [
"figure-image1"
"figure-image1-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3061,7 +3061,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.427642Z"
},
"tags": [
"figure-image2"
"figure-image2-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3109,7 +3109,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.439978Z"
},
"tags": [
"figure-image27"
"figure-image27-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3153,7 +3153,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.450292Z"
},
"tags": [
"figure-image3"
"figure-image3-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3194,7 +3194,7 @@
},
"tags": [
"narrative",
"figure-image33"
"figure-image33-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3238,7 +3238,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.472895Z"
},
"tags": [
"figure-image16"
"figure-image16-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3282,7 +3282,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.484046Z"
},
"tags": [
"figure-image34"
"figure-image34-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3326,7 +3326,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.494630Z"
},
"tags": [
"figure-image18"
"figure-image18-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3378,7 +3378,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.505354Z"
},
"tags": [
"figure-image23"
"figure-image23-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3422,7 +3422,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.517201Z"
},
"tags": [
"figure-image31"
"figure-image31-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3466,7 +3466,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.528721Z"
},
"tags": [
"figure-image4"
"figure-image4-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3526,7 +3526,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.539876Z"
},
"tags": [
"figure-image13"
"figure-image13-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3570,7 +3570,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.551158Z"
},
"tags": [
"figure-image7"
"figure-image7-*"
]
},
"outputs": [
Expand Down Expand Up @@ -3614,7 +3614,7 @@
"shell.execute_reply": "2023-03-01T10:11:25.562590Z"
},
"tags": [
"figure-image22"
"figure-image22-*"
]
},
"outputs": [
Expand Down
42 changes: 42 additions & 0 deletions technical_review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# parse the cells tag and add "-*" at the end of a tag beginning with "figure"
import sys
import nbformat


def add_figure_tag(notebook):
for cell in notebook.cells:
tags = cell.get("metadata", {}).get("tags", [])
if tags:
for tag in tags:
if tag.startswith("figure"):
print("add -* to the tag: {}".format(tag))
tags.append(tag + "-*")
tags.remove(tag)
break
return notebook



# main function
def main():
# get the notebook file name
notebook_file = sys.argv[1]
# read the notebook file
with open(notebook_file) as f:
nb = nbformat.read(f, as_version=4)
# add the figure tag
nb = add_figure_tag(nb)
# write the notebook file
with open(notebook_file, 'w') as f:
nbformat.write(nb, f)


#call the main function
if __name__ == '__main__':
main()

#call the script from the terminal
#!python technical_review.py paper.ipynb

#call the script from the notebook
#%run technical_review.py paper.ipynb

0 comments on commit ecf20a0

Please sign in to comment.