Skip to content

Commit d942383

Browse files
committed
Hide numba code
1 parent 063367f commit d942383

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lectures/wealth_dynamics.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ update_cross_section_jax = jax.jit(update_cross_section_jax, static_argnums=(1,3
495495
Here's some type information to help Numba.
496496

497497
```{code-cell} ipython3
498+
---
499+
tags: [hide-input]
500+
---
498501
wealth_dynamics_data = [
499502
('w_hat', float64), # savings parameter
500503
('s_0', float64), # savings parameter
@@ -518,6 +521,9 @@ Here's a class that stores instance data and implements methods that update
518521
the aggregate state and household wealth.
519522

520523
```{code-cell} ipython3
524+
---
525+
tags: [hide-input]
526+
---
521527
@jitclass(wealth_dynamics_data)
522528
class WealthDynamics:
523529
@@ -613,6 +619,9 @@ Now here's function to simulate a cross section of households forward in time.
613619
Note the use of parallelization to speed up computation.
614620

615621
```{code-cell} ipython3
622+
---
623+
tags: [hide-input]
624+
---
616625
@njit(parallel=True)
617626
def update_cross_section(wdy, w_distribution, shift_length=500):
618627
"""
@@ -709,7 +718,12 @@ def generate_lorenz_and_gini_jax(wdy, num_households=100_000, T=500):
709718
return qe.gini_coefficient(ψ_star), qe.lorenz_curve(ψ_star)
710719
```
711720

721+
The following function uses the numba implementation
722+
712723
```{code-cell} ipython3
724+
---
725+
tags: [hide-input]
726+
---
713727
# Uses numba
714728
def generate_lorenz_and_gini(wdy, num_households=100_000, T=500):
715729
"""
@@ -754,6 +768,9 @@ plt.show()
754768
Now let's try to run the same code snippet but using the numba version.
755769

756770
```{code-cell} ipython3
771+
---
772+
tags: [hide-input]
773+
---
757774
%%time
758775
759776
fig, ax = plt.subplots()
@@ -829,6 +846,9 @@ plt.show()
829846
Using numba, we get,
830847

831848
```{code-cell} ipython3
849+
---
850+
tags: [hide-input]
851+
---
832852
%%time
833853
834854
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)