Skip to content

Commit 8bf7cdb

Browse files
committed
Make pretty
1 parent 6c0ea66 commit 8bf7cdb

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

lessons/python/yet_another_oop.ipynb

+25-26
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,17 @@
540540
" # Note: I didn't realize this when I originally wrote the class, but we won't actually need dz\n",
541541
" # Want to know why? Check out the documentation for np.gradient -> https://numpy.org/doc/stable/reference/generated/numpy.gradient.html\n",
542542
" # (What does the second argument to np.gradient do?)\n",
543-
" \n",
543+
"\n",
544544
" # We'll need attributes for rho, c, and k\n",
545545
" # You could also store info about boundary conditions at this point, if you want\n",
546546
" self.rho = 917\n",
547547
" self.c = 2093\n",
548548
" self.k = 2.1\n",
549549
"\n",
550550
" # Let's store boundary conditions too\n",
551-
" \n",
551+
"\n",
552552
" # Maybe we should go ahead and calculate diffusivity right away?\n",
553-
" \n",
553+
"\n",
554554
" # Let's keep track of the elapsed time\n",
555555
"\n",
556556
" def calc_diffusivity(self) -> float:\n",
@@ -559,7 +559,7 @@
559559
"\n",
560560
" def calc_heat_flux(self) -> np.ndarray:\n",
561561
" \"\"\"The heat flux is -kappa * dT / dz.\"\"\"\n",
562-
" \n",
562+
"\n",
563563
" # How should we calculate the difference in temperature with depth? (hint: see dz, above)\n",
564564
"\n",
565565
" # Are dT and dz the same size? Are they the same size as z?\n",
@@ -634,16 +634,16 @@
634634
"\n",
635635
"dt = 60 * 60 * 24 * 20\n",
636636
"\n",
637-
"for i in range(30000): \n",
637+
"for i in range(30000):\n",
638638
" model.run_one_step(dt)\n",
639639
"\n",
640640
" if i % 1000 == 0:\n",
641-
" print(f'{model.time_elapsed / 31556926} years.')\n",
641+
" print(f\"{model.time_elapsed / 31556926} years.\")\n",
642642
"\n",
643643
"plt.plot(model.temperature, model.z)\n",
644-
"plt.xlabel('Temperature ($^\\circ$ C)')\n",
645-
"plt.ylabel('Depth (m)')\n",
646-
"plt.gca().invert_yaxis() # This forces matplotlib to invert the y-axis\n",
644+
"plt.xlabel(r\"Temperature ($^\\circ$ C)\")\n",
645+
"plt.ylabel(\"Depth (m)\")\n",
646+
"plt.gca().invert_yaxis() # This forces matplotlib to invert the y-axis\n",
647647
"plt.show()"
648648
]
649649
},
@@ -662,8 +662,7 @@
662662
"metadata": {},
663663
"outputs": [],
664664
"source": [
665-
"# Initialize your model with a new bottom boundary condition\n",
666-
"\n"
665+
"# Initialize your model with a new bottom boundary condition"
667666
]
668667
},
669668
{
@@ -675,16 +674,16 @@
675674
"source": [
676675
"dt = 60 * 60 * 24 * 20\n",
677676
"\n",
678-
"for i in range(30000): \n",
677+
"for i in range(30000):\n",
679678
" model.run_one_step(dt)\n",
680679
"\n",
681680
" if i % 1000 == 0:\n",
682-
" print(f'{model.time_elapsed / 31556926} years.')\n",
681+
" print(f\"{model.time_elapsed / 31556926} years.\")\n",
683682
"\n",
684683
"plt.plot(model.temperature, model.z)\n",
685-
"plt.xlabel('Temperature ($^\\circ$ C)')\n",
686-
"plt.ylabel('Depth (m)')\n",
687-
"plt.gca().invert_yaxis() # This forces matplotlib to invert the y-axis\n",
684+
"plt.xlabel(r\"Temperature ($^\\circ$ C)\")\n",
685+
"plt.ylabel(\"Depth (m)\")\n",
686+
"plt.gca().invert_yaxis() # This forces matplotlib to invert the y-axis\n",
688687
"plt.show()"
689688
]
690689
},
@@ -717,8 +716,8 @@
717716
"source": [
718717
"class SimpleGlacier:\n",
719718
" \"\"\"Models the temperature profile with a glacier.\n",
720-
" \n",
721-
" This model is based off of: \n",
719+
"\n",
720+
" This model is based off of:\n",
722721
" The Physics of Glaciers (Cuffey and Paterson, 2010).\n",
723722
" Lecture notes from Andy Aschwanden (McCarthy school, summer 2012).\n",
724723
"\n",
@@ -736,7 +735,7 @@
736735
" self.dz = np.gradient(self.z)\n",
737736
" # Note: I didn't realize this when I originally wrote the class, but we won't need dz\n",
738737
" # Want to know why? Check out the documentation for np.gradient -> https://numpy.org/doc/stable/reference/generated/numpy.gradient.html\n",
739-
" \n",
738+
"\n",
740739
" # We'll need attributes for rho, c, and k\n",
741740
" # You could also store info about boundary conditions at this point, if you want\n",
742741
" self.rho = 917\n",
@@ -746,10 +745,10 @@
746745
" # Let's store boundary conditions too\n",
747746
" self.surface_temperature = -10.0\n",
748747
" self.basal_heat_flux = 0.0\n",
749-
" \n",
748+
"\n",
750749
" # Maybe we should go ahead and calculate diffusivity right away?\n",
751750
" self.kappa = self.calc_diffusivity()\n",
752-
" \n",
751+
"\n",
753752
" # Let's keep track of the elapsed time\n",
754753
" self.time_elapsed = 0.0\n",
755754
"\n",
@@ -759,7 +758,7 @@
759758
"\n",
760759
" def calc_heat_flux(self) -> np.ndarray:\n",
761760
" \"\"\"The heat flux is -kappa * dT / dz.\"\"\"\n",
762-
" \n",
761+
"\n",
763762
" # How should we calculate the difference in temperature with depth? (hint: see dz, above)\n",
764763
" temperature_gradient = np.gradient(self.temperature, self.z)\n",
765764
"\n",
@@ -770,15 +769,15 @@
770769
" temperature_gradient[-1] = self.basal_heat_flux\n",
771770
"\n",
772771
" return -self.kappa * temperature_gradient\n",
773-
" \n",
772+
"\n",
774773
" def calc_divergence(self) -> np.ndarray:\n",
775774
" \"\"\"In 1D, divergence is just the derivative. yay!\"\"\"\n",
776775
" heat_flux = self.calc_heat_flux()\n",
777-
" \n",
776+
"\n",
778777
" flux_divergence = np.gradient(heat_flux, self.z)\n",
779-
" \n",
778+
"\n",
780779
" return flux_divergence\n",
781-
" \n",
780+
"\n",
782781
" def run_one_step(self, dt: float):\n",
783782
" \"\"\"Advance the model by one step of size dt.\"\"\"\n",
784783
" flux_divergence = self.calc_divergence()\n",

0 commit comments

Comments
 (0)