Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions fix_nb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json

nb = json.load(open("tutorials/cosmology/baryon_boost.ipynb"))

for cell in nb["cells"]:
src = "".join(cell["source"])
if cell["cell_type"] == "markdown" and "BACCOemuFLAMINGOPerturbations" in src:
# Fix background= in FlamingoBaryonBoostMixin.__init__
old = (
" FlamingoBaryonBoostMixin.__init__(\n"
" self,\n"
" background=background,\n"
" fgas_sigma=fgas_sigma,"
)
new = (
" FlamingoBaryonBoostMixin.__init__(\n"
" self,\n"
" fgas_sigma=fgas_sigma,"
)
src = src.replace(old, new)
# Fix [0] on matter_power_spectrum result
src = src.replace(
"Pk_bacco_with_flamingo_A = pert_bacco_flamingo_A.matter_power_spectrum(z_ref, k_eval)[0]",
"Pk_bacco_with_flamingo_A = pert_bacco_flamingo_A.matter_power_spectrum(z_ref, k_eval)",
)
cell["source"] = [src]
print("Fixed markdown cell:", cell.get("id"))
break
else:
print("Target cell not found!")

json.dump(nb, open("tutorials/cosmology/baryon_boost.ipynb", "w"), indent=1)
print("Saved.")
1,149 changes: 1,149 additions & 0 deletions tutorials/cosmology/baryon_boost.ipynb

Large diffs are not rendered by default.