Conversation
…ction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for incomparable-parfait-2417f8 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Build Failure AnalysisBoth CI checks (preview and execution-checks) are failing for the same root cause: 1.
|
|
@mmcky , can you please have a look. i asked claude to report on the issues but not fix so i don't tread on your toes. I'm just running a build on the GPU server so I might add to this PR in the next 30 minutes -- I'll be done after that. (PS spelling is colab not collab) |
Local Build Results (GPU server)Ran a local build on a GPU server using the
|
|
all yours @mmcky . the local build on the GPU server flagged some problems with other lectures as well -- would you mind checking those too? |
There was a problem hiding this comment.
Pull request overview
This PR adds a new “Racial Segregation” section to the lecture series, introducing a five-lecture sequence on the Schelling segregation model that progressively moves from pure Python to NumPy to JAX and parallel JAX, culminating in a persistent-shocks extension.
Changes:
- Added 5 new Schelling-model lectures (
schelling*.md) covering Python, NumPy, JAX, parallel JAX, and persistent shocks. - Updated
lectures/_toc.ymlto include a new “Racial Segregation” part with the five lectures in sequence. - Added new static assets: 5 satellite
.webpmaps and 4 lecture-specific.pngfigures.
Reviewed changes
Copilot reviewed 6 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| lectures/_toc.yml | Adds the new “Racial Segregation” section and orders the new lecture sequence. |
| lectures/schelling.md | Introduces the model and a pure-Python implementation plus background maps. |
| lectures/schelling_numpy.md | Reimplements the model with NumPy arrays and helper functions. |
| lectures/schelling_jax.md | Ports the model to JAX and introduces JIT + key-based RNG patterns. |
| lectures/schelling_jax_parallel.md | Introduces a parallel JAX variant and a “horse race” comparison. |
| lectures/schelling_shocks.md | Extends the parallel JAX model with persistent type-flip shocks. |
| lectures/_static/fig/columbus.webp | Satellite map used in the introductory lecture. |
| lectures/_static/fig/memphis.webp | Satellite map used in the introductory lecture. |
| lectures/_static/fig/washington_dc.webp | Satellite map used in the introductory lecture. |
| lectures/_static/fig/houston.webp | Satellite map used in the introductory lecture. |
| lectures/_static/fig/miami.webp | Satellite map used in the introductory lecture. |
| lectures/_static/lecture_specific/schelling/schelling_fig1.png | Lecture-specific figure used across the Schelling sequence. |
| lectures/_static/lecture_specific/schelling/schelling_fig2.png | Lecture-specific figure used across the Schelling sequence. |
| lectures/_static/lecture_specific/schelling/schelling_fig3.png | Lecture-specific figure used across the Schelling sequence. |
| lectures/_static/lecture_specific/schelling/schelling_fig4.png | Lecture-specific figure used across the Schelling sequence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lectures/schelling_jax.md
Outdated
|
|
||
| # Check if everyone is happy | ||
| if num_unhappy == 0: | ||
| break | ||
|
|
||
| # Update only the unhappy agents | ||
| for j in range(int(num_unhappy)): |
There was a problem hiding this comment.
num_unhappy returned from get_unhappy_agents is a JAX scalar (jax.Array). if num_unhappy == 0: will raise a TypeError because the condition is an array, not a Python bool. Convert to a Python scalar (e.g., num_unhappy = int(num_unhappy) / .item()) before the if (and reuse that scalar for the subsequent range).
| # Check if everyone is happy | |
| if num_unhappy == 0: | |
| break | |
| # Update only the unhappy agents | |
| for j in range(int(num_unhappy)): | |
| num_unhappy = int(num_unhappy) | |
| # Check if everyone is happy | |
| if num_unhappy == 0: | |
| break | |
| # Update only the unhappy agents | |
| for j in range(num_unhappy): |
There was a problem hiding this comment.
Fixed in 1e38ec3. Added num_unhappy = int(num_unhappy) after get_unhappy_agents returns. The int() conversion must happen at the call site because get_unhappy_agents is @jit-compiled and can only return JAX arrays.
|
@jstac this is now building and I have resolved the COPILOT review feedback. I have resolved the straightforward issues -- Are you happy with these code changes? The fixes are committed and the comment provides some context. |
|
@jstac 👀 on the code cell background in the preview. Looking into this now. |
|
@jstac this looks good to me now. https://69d330e5b5b2cac0e3a13d13--incomparable-parfait-2417f8.netlify.app/intro.html Let me know what you think of the code changes in 1e38ec3 |
|
Thanks @mmcky ! Looks good. Please go ahead and merge when ready. |
Summary
This PR adds a new Racial Segregation section to the lecture series, containing five new lectures on the Schelling segregation model. The lectures form a progressive sequence that builds from pure Python through to parallelized JAX, making them a natural fit for this JAX-focused lecture site.
New lectures
The five lectures added are:
Schelling's Model of Racial Segregation (
schelling.md) — Introduces the classic 1969 Schelling model of racial residential segregation. Covers the motivation (real-world segregation patterns in US cities), the model setup (agents on a grid with mild preferences for same-type neighbors), and a pure Python implementation. Includes satellite imagery of Columbus, Memphis, Washington DC, Houston, and Miami illustrating observed segregation patterns.Schelling Model with NumPy (
schelling_numpy.md) — Rewrites the model using NumPy arrays and vectorized operations for improved performance over the pure Python version, at some cost to readability.Schelling Model with JAX (
schelling_jax.md) — Ports the model to JAX, introducing JIT compilation and GPU/TPU acceleration. Demonstrates how JAX — widely used for AI workflows — can be repurposed for agent-based economic simulations.Parallelizing the Algorithm (
schelling_jax_parallel.md) — Addresses the inherently sequential nature of the basic Schelling algorithm by introducing a parallel variant. Explores how to restructure the computation to better exploit JAX's parallelization capabilities.Segregation with Persistent Shocks (
schelling_shocks.md) — Extends the model by adding persistent stochastic shocks, moving beyond the static equilibrium of the basic model to study ongoing dynamics.Structural changes
_toc.yml: Added a new "Racial Segregation" section (placed before the existing "Other" section), containing all five lectures in the sequence listed above._static/fig/: New directory containing five.webpsatellite images of US cities (Columbus, Memphis, Washington DC, Houston, Miami) used in the introductory lecture to illustrate real-world segregation patterns._static/lecture_specific/schelling/: Four.pngfigures (schelling_fig1.pngthroughschelling_fig4.png) used across the lectures.Cross-references
The lectures use
{doc}cross-references to link to each other in sequence (e.g., "In the {doc}previous lecture <schelling>..."), forming a coherent reading path through the material.Build verification
execute_notebooks: "off"(no new warnings — only pre-existing lexing warnings from!pip/!nvidia-smicommands in other lectures).TODO
🤖 Generated with Claude Code