Skip to content

Ensure tutorials only use public API. #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
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
30 changes: 14 additions & 16 deletions torax/tutorials/torax_tutorial_exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@
},
{
"metadata": {
"id": "cufUHoEGKDd6"
"id": "I4TZNOJJGBR_"
},
"cell_type": "code",
"source": [
"#@title Imports\n",
"import copy\n",
"import jax\n",
"import torax\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import xarray as xr\n",
"from torax import interpolated_param\n",
"from typing import Any\n",
"from torax._src.orchestration.run_simulation import run_simulation\n",
"from torax._src.torax_pydantic import model_config\n",
"\n",
"jax.config.update('jax_enable_x64', True)"
],
Expand Down Expand Up @@ -554,7 +552,7 @@
},
{
"metadata": {
"id": "1_eekusPKDd6"
"id": "FL-_GqQaGBSA"
},
"cell_type": "code",
"source": [
Expand Down Expand Up @@ -665,7 +663,7 @@
},
{
"metadata": {
"id": "Xz6YJLQAKDd6"
"id": "do-4obv1GBSA"
},
"cell_type": "code",
"source": [
Expand Down Expand Up @@ -699,18 +697,18 @@
},
{
"metadata": {
"id": "4-S6_hbNKDd7"
"id": "O4B4jZmAGBSA"
},
"cell_type": "code",
"source": [
"#@title Modify config function\n",
"def modify_config(\n",
" *,\n",
" Ip: interpolated_param.TimeInterpolatedInput | None = None,\n",
" nbi_power: interpolated_param.TimeInterpolatedInput | None = None,\n",
" off_axis_ec_power: interpolated_param.TimeInterpolatedInput | None = None,\n",
" off_axis_ec_location: interpolated_param.TimeInterpolatedInput | None = None,\n",
" Z_eff: interpolated_param.InterpolatedVarTimeRhoInput | None = None,\n",
" Ip = None,\n",
" nbi_power = None,\n",
" off_axis_ec_power = None,\n",
" off_axis_ec_location = None,\n",
" Z_eff = None,\n",
" W_to_Ne_ratio: float | None = None,\n",
" solver_type: str | None = None,\n",
" n_corrector_steps: int | None = None,\n",
Expand Down Expand Up @@ -821,21 +819,21 @@
},
{
"metadata": {
"id": "eF6RQNRkKDd7"
"id": "Lr6-Ipu4GBSA"
},
"cell_type": "markdown",
"source": []
},
{
"metadata": {
"id": "gPm-tYA5KDd7"
"id": "HRKQQkpJGBSA"
},
"cell_type": "code",
"source": [
"# @title Function to build and launch TORAX sim\n",
"def run_sim(config: dict[str, Any]) -\u003e xr.DataTree:\n",
" torax_config = model_config.ToraxConfig.from_dict(config)\n",
" data_tree, _ = run_simulation(torax_config, log_timestep_info=False)\n",
" torax_config = torax.ToraxConfig.from_dict(config)\n",
" data_tree, _ = torax.run_simulation(torax_config, log_timestep_info=False)\n",
" return data_tree"
],
"outputs": [],
Expand Down
18 changes: 8 additions & 10 deletions torax/tutorials/torax_tutorial_exercises_with_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
"#@title Imports\n",
"import copy\n",
"import jax\n",
"import torax\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import xarray as xr\n",
"from torax import interpolated_param\n",
"from typing import Any\n",
"from torax._src.orchestration.run_simulation import run_simulation\n",
"from torax._src.torax_pydantic import model_config\n",
"\n",
"jax.config.update('jax_enable_x64', True)"
]
Expand Down Expand Up @@ -708,11 +706,11 @@
"#@title Modify config function\n",
"def modify_config(\n",
" *,\n",
" Ip: interpolated_param.TimeInterpolatedInput | None = None,\n",
" nbi_power: interpolated_param.TimeInterpolatedInput | None = None,\n",
" off_axis_ec_power: interpolated_param.TimeInterpolatedInput | None = None,\n",
" off_axis_ec_location: interpolated_param.TimeInterpolatedInput | None = None,\n",
" Z_eff: interpolated_param.InterpolatedVarTimeRhoInput | None = None,\n",
" Ip = None,\n",
" nbi_power = None,\n",
" off_axis_ec_power = None,\n",
" off_axis_ec_location = None,\n",
" Z_eff = None,\n",
" W_to_Ne_ratio: float | None = None,\n",
" solver_type: str | None = None,\n",
" n_corrector_steps: int | None = None,\n",
Expand Down Expand Up @@ -829,8 +827,8 @@
"source": [
"# @title Function to build and launch TORAX sim\n",
"def run_sim(config: dict[str, Any]) -\u003e xr.DataTree:\n",
" torax_config = model_config.ToraxConfig.from_dict(config)\n",
" data_tree, _ = run_simulation(torax_config, log_timestep_info=False)\n",
" torax_config = torax.ToraxConfig.from_dict(config)\n",
" data_tree, _ = torax.run_simulation(torax_config, log_timestep_info=False)\n",
" return data_tree"
]
},
Expand Down