Repository navigation
12: the course's Explore section, built on the package - #2
Merged
Merged
Conversation
…ckage On 2026-10-20 the REE 4301 course copy of Module 0 (Tools/build_toy_lp_notebook.py in the course folder) gained an "Explore - for your reflection" section: sliders for the battery day and for the build decision, a cell where the student writes a gurobipy constraint, and one that moves the demand peak, with six reflection questions. This notebook had none of it. The model and every number are otherwise the same in both copies (compared 2026-10-22). The course's Exercises F.1 and F.2 were already here as the last two "Where to take this next" bullets. What changed in the port, and why: - The course version defines its slider functions in the teaching section and rebuilds the networks inline. Here they sit after the agreement assertion, below "Now the streamlined version" (Part 3), and call energy.day_network / energy.solve_day, which that assertion has just compared with the hand-built model. Each explorer first checks that, at the table's own numbers, it reproduces the hand-built result: Part E's $18,132.63 day and Part F's build (Part 3, "a check that the wrapper reproduces the hand-built result"). - The deliberate blank works on a copy of Part B's model, so the cells above are untouched. Until the student writes the line, it prints Part B's answer and says it is still Part B's (Part 5: a blank fails with a message). Checked with the line written: $1,549.80, solar 30, gas 70, shadow price $0.00, because solar is now on the margin, which is what question 5 asks. - The one figure committed (the move-the-peak call) uses line style and marker as well as colour, and its cell prints a sentence saying what it shows, generated from the solve. The figure sentence does not name charging hours, because this notebook teaches that those are a tie. - energy.day_profiles takes peak_hour (default 19, which still reproduces the CSV exactly) so moving the peak does not need a second copy of the demand formula in the notebook. Tested. Also: ipywidgets joins the energy extra; the folder README says what Explore is and drops two stale claims (that energy-system-modeling is private and 404s; it has been public since 2026-09-13), and says to keep the venv out of Temp. The orteach-energy venv had been built in AppData\Local\Temp, which Windows cleaned, leaving a kernel registration that pointed at nothing. It is rebuilt from `.[dev,energy]`. Re-executed under PyPSA 1.4.0 / pandas 3.1.0 (was 1.3.0): all 21 original code cells produce identical output apart from the version line. Gate: 182 passed (base); 12/12 tests/test_energy.py in the energy venv with ORTEACH_REQUIRE_PYPSA=1; 17 notebooks and 11 seeds clean; ruff clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1. The base is
ci/clean-machine-ci: this PR needs that one'senergyextra and its changes totest_energy.py. Merge #1 first; GitHub will then retarget this PR tomain.Why
On 20 Oct the REE 4301 course copy of Module 0 gained an Explore section, which teaching-code's notebook 12 lacked. Apart from that, the two copies share the same model and the same numbers (checked 22 Oct). The course's Exercises F.1 and F.2 were already here, as the last two "Where to take this next" bullets.
What
New cells after the agreement assertion (the code standard keeps helper functions out of the teaching section):
How they're built:
energy.day_networkandenergy.solve_dayinstead of rebuilding the model inline. Each one first checks that, at the table's own numbers, it reproduces what the student built by hand ($18,132.63 for the day; the Part F build).Supporting changes:
energy.day_profiles(peak_hour=19). The default still reproduces the CSV exactly; tested.ipywidgetsadded to theenergyextra.Evidence
tests/test_energy.pyin the energy venv withORTEACH_REQUIRE_PYPSA=1: 12/12;Machine note (not in the diff)
The
orteach-energykernel's venv had been built inAppData\Local\Temp, which Windows cleaned out. It's been rebuilt atC:\Users\jonesec\dev\venvs\orteach-energy.🤖 Generated with Claude Code