From fdc39cd8623157b7b93817484bd7580f37c02afe Mon Sep 17 00:00:00 2001 From: NT Date: Tue, 29 Jun 2021 14:47:59 +0200 Subject: [PATCH] config and helpers --- _config.yml | 2 +- intro.md | 4 ++-- json-ipynb-removeImgs.py | 41 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 json-ipynb-removeImgs.py diff --git a/_config.yml b/_config.yml index 33df2fa..bc101c2 100644 --- a/_config.yml +++ b/_config.yml @@ -2,7 +2,7 @@ # Learn more at https://jupyterbook.org/customize/config.html title: Physics-based Deep Learning -author: Thuerey et al. +author: N. Thuerey, P. Holl, M. Mueller, P. Schnell, F. Trost, K. Um logo: resources/logo.jpg # Force re-execution of notebooks on each build. diff --git a/intro.md b/intro.md index 0e2692b..b0e5e38 100644 --- a/intro.md +++ b/intro.md @@ -81,12 +81,12 @@ This project would not have been possible without the help of many people who co If you find this book useful, please cite it via: ``` -@article{thuerey2021pbdl, +@book{thuerey2021pbdl, title={Physics-based Deep Learning}, author={Nils Thuerey and Philipp Holl and Maximilian Mueller and Patrick Schnell and Felix Trost and Kiwon Um}, url={http://physicsbaseddeeplearning.org}, year={2021}, - publisher={www} + publisher={WWW} } ``` diff --git a/json-ipynb-removeImgs.py b/json-ipynb-removeImgs.py new file mode 100644 index 0000000..e30a6ee --- /dev/null +++ b/json-ipynb-removeImgs.py @@ -0,0 +1,41 @@ +import json + +fnOut="temp_reduced.txt" + +#fn="t.json" +fn="temp.txt" +with open(fn) as file: + d = json.load(file) + +print(d.keys()) +#print(d["cells"][0].keys()) + +t="cells" +for i in range(len(d[t])): + #for i in range(len(d[t])): + #print(d[t][0]["cell_type"]) + #print(d[t][i]["cell_type"]) + + # remove images after code + + if d[t][i]["cell_type"]=="code": + #print(d[t][i].keys()) + #d[t][i]["outputs"] = "" + #print(d[t][i]["outputs"]) + + #print(len( d[t][i]["outputs"] )) + for j in range(len( d[t][i]["outputs"] )): + #print(type( d[t][i]["outputs"][j] )) + print( d[t][i]["outputs"][j].keys() ) + if d[t][i]["outputs"][j]["output_type"]=="display_data": + #if d[t][i]["outputs"][j]["data"]=="display_data": + print( d[t][i]["outputs"][j]["data"].keys() ) + #if( d[t][i]["outputs"][j]["data"].contains('image/png') ): + if( 'image/png' in d[t][i]["outputs"][j]["data"].keys() ): + d[t][i]["outputs"][j]["data"]['image/png'] = "" + +#print(d["cells"]) + +with open(fnOut,'w') as fileOut: + json.dump(d,fileOut, indent=1, sort_keys=True) +