-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
891 lines (808 loc) · 43.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Software Development for Engineering Research - Classes and Objects</title>
<meta name="description" content="
Lecture on classes and objects for ME 599: Software Development for Engineering Research
">
<meta name="author" content="Kyle Niemeyer">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>Classes, Objects, Package Structure</h2>
<h3>Software Development for Engineering Research</h3>
<br/>
<h3>Kyle Niemeyer. 13 Jan 2022</h3>
<h3>ME 599, Corvallis, OR</h3>
</section>
<section data-markdown>
<textarea data-template>
## Today: Using classes and objects for research code, structuring your packages
</textarea>
</section>
<section>
<section>
<p class="fragment"><strong>Classes:</strong>
organize data, methods, and functions
</p>
<p class="fragment"><strong>Objects:</strong>
manifestations of classes
</p>
<p class="fragment">
We can use object-oriented programming to cleanly organize
behaviors and data in our code.
</p>
</section>
<section>
<h3>Object Orientation</h3>
<br/>
<p class="fragment">
It provides a framework for classifying distinct concepts into comprehensible sizes.
These smaller conceptual units facilitate cleaner, more scalable modeling.
</p>
</section>
<section>
<h3>Object Orientation</h3>
<br/>
<ul>
<li class="fragment">Classes and objects combine functions with data to make both easier to manage.</li>
<li class="fragment">A class defines the behaviors of a new kind of thing, while an object is a particular thing.</li>
<li class="fragment">Classes have constructors that describe how to create a new object of a particular kind.</li>
<li class="fragment">An interface describes what an object can do; an implementation defines how.</li>
<li class="fragment">One class can inherit from another and override just those things that it wants to change.</li>
</ul>
</section>
<section>
<h3>Object Orientation</h3>
<br/>
<ul>
<li class="fragment"><em>Encapsulation</em> is the property of owning data
</li>
<li class="fragment"><em>Inheritance</em> establishes a relationship hierarchy between models
</li>
<li class="fragment"><em>Polymorphism</em> allows for models to customize their own behavior even when they are based on other models
</li>
</ul>
</section>
</section>
<section>
<section>
<h3>Objects</h3>
<br/>
<p class="fragment"><strong>Everything</strong> in Python is an object.
</p>
<p class="fragment">All objects in Python have attributes and methods.
</p>
</section>
<section>
<h3>Object example: integers</h3>
<br>
<pre><code data-trim class="fragment python">
a = 1
help(a) # gives info about the object
dir(a) # gives list of data and behaviors associated with class
</code></pre>
<br>
<div style="font-size:25px">
<p class="fragment">What do double underscores around <code>__abs__</code> mean?</p>
<p class="fragment"> <code>__</code> = "dunder".
From <a href="https://www.python.org/dev/peps/pep-0008/">PEP8</a>: "magic objects or attributes that live in user-controlled namespaces.
E.g. <code>__init__</code>, <code>__import__</code> or <code>__file__</code>.
Never invent such names; only use them as documented."
</p>
<p class="fragment">Generally don't call dunder methods directly; instead, use built-in functions.</p>
</div>
</section>
<section>
<p class="fragment">... what about functions?</p>
<pre><code data-trim class="fragment python">
import math
dir(math.sin)
</code></pre>
<p class="fragment">Even functions are objects!</p>
<img class="fragment" src="https://media.giphy.com/media/xT0xeJpnrWC4XWblEk/giphy.gif" height="300" alt="Head explode gif">
</section>
</section>
<section>
<section>
<h3>What about classes?</h3><br>
<p class="fragment">
Classes define logical collections of attributes and methods describing a kind of object,
and how to create objects of that kind.
</p>
<p class="fragment">
Choose classes to encapsulate internal data and functions for different types of objects.
</p>
</section>
<section>
<h3>Example: particle physics</h3>
<br>
<pre><code data-trim class="fragment python">
class Particle(object):
"""A particle is a constituent unit of the universe."""
# class body definition here
</code></pre>
<p class="fragment">
What else do classes include?
<ul>
<li class="fragment"> Class variables </li>
<li class="fragment"> Constructors </li>
<li class="fragment"> Methods </li>
</ul>
</p>
</section>
<section>
<h3>Elementary Particles</h3>
<img src="./images/elementary-particles.png" height="400" alt="The Standard Model of Elementary Particles (source: Wikipedia)">
</section>
<section>
<h3>Class variables</h3>
<br>
<p class="fragment">Data universally applicable to all objects of the class</p>
<pre><code data-trim class="fragment python">
# contents of particle.py
class Particle(object):
"""A particle is a constituent unit of the universe."""
# class body definition here
roar = "I am a particle!"
</code></pre>
<pre><code data-trim class="fragment python">
# import particle module
import particle as p
print(p.Particle.roar)
</code></pre>
<pre><code data-trim class="fragment python">
# create instance of Particle
import particle as p
higgs = p.Particle()
print(higgs.roar)
</code></pre>
</section>
<section>
<h3>Instance variables</h3>
<br>
<p class="fragment">Data with different values for each instance of the class</p>
<p class="fragment">Example: particle position.</p>
<div style="font-size:30px">
<pre><code data-trim class="fragment python">
import particle as p
# create empty list to hold observed particle data
obs = []
# append first particle
obs.append(p.Particle())
# assign its position
obs[0].r = {'x': 100.0, 'y': 38.0, 'z': -42.0}
# append second particle and assign its position
obs.append(p.Particle())
obs[1].r = {'x': 0.01, 'y': 99.0, 'z': 32.0}
# print positions of each particle
print(obs[0].r)
print(obs[1].r)
</code></pre>
</div>
</section>
<section>
<p class="fragment">Using instance variables, we can store all data associated with a particle
observation (position, mass, charge, spin, etc.) without much more complexity
</p>
<p class="fragment">(Hopefully the value of this reduced complexity is obvious.)
</p>
<p class="fragment">How to accomplish in class definition? Constructor: <code>__init()__</code> function.
</p>
</section>
<section>
<h3>Constructors</h3>
<br>
<p class="fragment">Constructor: <code>__init__()</code> function, executed upon instantiation of object.
</p>
<p class="fragment">Constructor <em>not</em> required; every class inherits default constructor from <code>object</code>.
</p>
<p class="fragment">Tip: good to initialize all instance variables in constructor, to ensure they are initialized when you need them.
</p>
</section>
<section>
<div style="font-size:30px">
<pre><code data-trim class="python">
# particle.py
class Particle(object):
"""A particle is a constituent unit of the universe.
Attributes
----------
c : charge in units of [e]
m : mass in units of [kg]
r : position in units of [meters]
"""
roar = "I am a particle!"
def __init__(self):
"""Initializes the particle with default values for charge c, mass m, and position r.
"""
self.c = 0
self.m = 0
self.r = {'x': 0, 'y': 0, 'z': 0}
</code></pre>
</div>
<p class="fragment"><code>self</code> argument required since function is method; binds to specific instance of the class.
</p>
</section>
<section>
<div style="font-size:30px">
<p class="fragment">More efficient: specify data values upon initialization.
</p>
<pre><code data-trim class="fragment python">
# particle.py
class Particle(object):
"""A particle is a constituent unit of the universe.
Attributes
----------
c : charge in units of [e]
m : mass in units of [kg]
r : position in units of [meters]
"""
roar = "I am a particle!"
def __init__(self, charge, mass, position):
"""Initializes the particle with supplied values for charge c, mass m, and position r.
"""
self.c = charge
self.m = mass
self.r = position
</code></pre>
</div>
</section>
<section>
<h3>Methods</h3>
<p class="fragment" style="font-size:30px">
Methods: functions tied to a class definition; may operate on data contained by object.
</p>
<div style="font-size:20px">
<pre><code data-trim class="fragment python">
# particle.py
class Particle(object):
"""A particle is a constituent unit of the universe.
Attributes
----------
c : charge in units of [e]
m : mass in units of [kg]
r : position in units of [meters]
"""
roar = "I am a particle!"
def __init__(self, charge, mass, position):
"""Initializes the particle with supplied values for charge c, mass m, and position r.
"""
self.c = charge
self.m = mass
self.r = position
def hear_me(self):
"""Print information about particle.
"""
myroar = self.roar + (
" My charge is: " + str(self.c) +
" My mass is: " + str(self.m) +
" My x position is: " + str(self.r['x']) +
" My y position is: " + str(self.r['y']) +
" My z position is: " + str(self.r['z']))
print(myroar)
</code></pre>
</div>
</section>
<section>
<p class="fragment">
Example: proton
</p>
<div style="font-size:30px">
<pre><code data-trim class="fragment python">
from scipy import constants
import particle as p
m_p = constants.m_p
r_p = {'x': 1, 'y': 1, 'z': 53}
a_p = p.Particle(1, m_p, r_p)
a_p.hear_me()
</code></pre>
</div>
</section>
<section>
<p class="fragment">
Methods can alter instance variables. Example: <code>Quark</code> class
with instance variable <code>flavor</code>.
</p>
<div style="font-size:30px">
<pre><code data-trim class="fragment python">
def flip(self):
"""Flip quark's flavor to complementary flavor.
"""
if self.flavor == "up":
self.flavor = "down"
elif self.flavor == "down":
self.flavor = "up"
elif self.flavor == "top":
self.flavor = "bottom"
elif self.flavor == "bottom":
self.flavor = "top"
elif self.flavor == "strange":
self.flavor = "charm"
elif self.flavor == "charm":
self.flavor = "strange"
else:
raise AttributeError("The quark cannot be flipped, because the flavor is invalid.")
</code></pre>
</div>
</section>
<section>
<div>
<pre><code data-trim class="fragment python">
from quark import Quark
t = Quark()
t.flavor = "top"
t.flip()
print(t.flavor)
</code></pre>
</div>
</section>
<section>
<p class="fragment">
<code>Particle</code> capture relationship between uncertainty in momentum and uncertainty in position:
<div class="fragment">
<script type="math/tex; mode=display">
\Delta x \Delta p_x \geq \frac{\hbar}{2}
</script>
</div>
</p>
<div style="font-size:30px">
<pre><code data-trim class="fragment python">
from scipy import constants
class Particle(object):
"""A particle is a constituent unit of the universe.
# ... other parts of class definition ...
def delta_x_min(self, delta_p_x):
"""Returns minimum possible value of Δx
"""
hbar = constants.hbar
delx_min = hbar / (2.0 * delta_p_x)
return delx_min
</code></pre>
</div>
</section>
<section>
<h3>Static Methods</h3>
<div style="font-size:30px">
<p class="fragment">
Example: <code>Quark</code> class can include function that lists all possible values of flavor;
possible values are static irrespective of specific instance.
</p>
<pre><code data-trim class="fragment python">
def possible_flavors():
return ["up", "down", "top", "bottom", "strange", "charm"]
</code></pre>
<p class="fragment">
Use <code>@staticmethod</code> decorator to define a method not bound to object.
</p>
<pre><code data-trim class="fragment python">
class Particle(object):
"""A particle is a constituent unit of the universe.
"""
# ... other parts of class definition ...
@staticmethod
def possible_flavors():
return ["up", "down", "top", "bottom", "strange", "charm"]
</code></pre>
</div>
</section>
<section>
<h3>Duck Typing </h3>
<div style="font-size:30px">
<blockquote class="fragment">
“When I see a bird that walks like a duck and swims like a duck and quacks like a duck,
I call that bird a duck.”
</blockquote>
<p class="fragment">
Meaning: Python does not explicitly check for object types like other languages.
It only checks for behavior when a method is called or attribute accessed.
</p>
<p class="fragment">
If different object types both "quack like a duck", then it treats them like a duck.
An object does not need to be of a certain type in order for its methods to be invoked;
must merely possess those method.
</p>
</div>
</section>
<section>
<div style="font-size:30px">
<p class="fragment">
Example: all particles with a valid <code>c</code> attribute for charge can be used identically.
</p>
<pre><code data-trim class="fragment python">
def total_charge(particles):
"""Calculate the total charge of a collection of particles.
"""
tot = 0
for p in particles:
tot += p.c
return tot
</code></pre>
<pre><code data-trim class="fragment python">
p = Proton()
e1 = Electron()
e2 = Electrion()
particles = [p, e1, e2]
total_charge(particles)
</code></pre>
<pre><code data-trim class="fragment python">
# overrule duck typing when inconvenient
def total_charge(particles):
"""Calculate the total charge of a collection of particles.
"""
tot = 0
for p in particles:
if isinstance(p, Particle):
tot += p.c
return tot
</code></pre>
</div>
</section>
<section>
<h3> Polymorphism </h3>
<div style="font-size:30px">
<p class="fragment">
When class inherits attributes of a parent class. General rule: what works for parent class
should work for subclass (plus specialized behavior).
</p>
<pre><code data-trim class="fragment python">
# elementary.py
class ElementaryParticle(Particle):
"""No distinct constituent particles, have spin.
"""
def __init__(self, spin):
self.s = spin
self.is_fermion = bool(spin % 1.0)
self.is_boson = not self.is_fermion
</code></pre>
<pre><code data-trim class="fragment python">
# composite.py
class CompositeParticle(Particle):
"""Particles like protons and neutrons, composed of elementary particles
but don't share attributes.
"""
def __init__(self, parts):
self.constituents = parts
</code></pre>
</div>
</section>
<section>
<h3> Subclasses </h3>
<div style="font-size:30px">
<p class="fragment">
<code>ElementaryParticle</code> and <code>CompositeParticle</code> <strong>are</strong>
<code>Particle</code> objects, and thus have (inherit) all of the functions and data of the original class.
</p>
<p class="fragment">
Can override that data and those behaviors if desired.
</p>
<pre><code data-trim class="fragment python">
# elementary.py
class ElementaryParticle(Particle):
"""No distinct constituent particles, have spin.
"""
roar = "I am an Elementary Particle!"
def __init__(self, spin):
self.s = spin
self.is_fermion = bool(spin % 1.0)
self.is_boson = not self.is_fermion
</code></pre>
<pre><code data-trim class="fragment python">
from elementary import ElementaryParticle
p = ElementaryParticle(1.5)
p.s
p.hear_me()
</code></pre>
</div>
</section>
<section>
<h3> Superclasses </h3>
<div style="font-size:30px">
<p class="fragment">
Any class, including a subclass, can be a superclass or <em>parent</em> class;
the subclass inherits from its parent.
</p>
<p class="fragment">
<code>ElementaryParticle</code> can also be a superclass:
</p>
<pre><code data-trim class="fragment python">
class Quark(ElementaryParticle):
"""No distinct constituent particles, have spin.
"""
def __init__(self, color, charge, color_charge, spin, flavor):
self.color = color
self.charge = charge
self.color_charge = color_charge
self.spin = spin
self.flavor = flavor
</code></pre>
</div>
</section>
<section>
<h3>Inheritance of class contructors</h3>
<p class="fragment">
Best/most Pythonic way of handling inherited + additional
constructor arguments: be explicit.
</p>
</section>
<section>
<div style="font-size:25px">
<pre><code data-trim class="fragment python">
# particle.py
class Particle(object):
"""A particle is a constituent unit of the universe.
"""
roar = "I am a particle!"
def __init__(self, charge, mass, position):
"""Initializes the particle with supplied values for charge c, mass m, and position r.
"""
self.c = charge
self.m = mass
self.r = position
def hear_me(self):
"""Print information about particle.
"""
myroar = self.roar + (
" My charge is: " + str(self.c) +
" My mass is: " + str(self.m) +
" My x position is: " + str(self.r['x']) +
" My y position is: " + str(self.r['y']) +
" My z position is: " + str(self.r['z']))
print(myroar)
</code></pre>
<pre><code data-trim class="fragment python">
# elementary.py
class ElementaryParticle(Particle):
"""No distinct constituent particles, have spin.
"""
roar = "I am an Elementary Particle!"
def __init__(self, charge, mass, position, spin):
super().__init__(charge, mass, position)
self.s = spin
self.is_fermion = bool(spin % 1.0)
self.is_boson = not self.is_fermion
</code></pre>
</div>
</section>
<section>
<h3> Metaprogramming </h3>
<div style="font-size:30px">
<p class="fragment">
When definition of a class or function is specified (in part or in full)
by code outside the definition itself.
</p>
<p class="fragment">
Example: add an <code>is_particle</code> class attribute to <code>Particle</code> class:
</p>
<pre><code data-trim class="fragment python">
def add_is_particle(cls):
cls.is_particle = True
return cls
@add_is_particle
class Particle(object):
"""A particle is a constituent unit of the universe.
# ... other parts of class definition ...
</code></pre>
</div>
</section>
<section>
<h3> Practical Example </h3>
<br>
<p>
Take a look at my code PyTeCK, which uses classes to hide lots of details of performing simulations:
<a href="https://github.com/kyleniemeyer/PyTeCK">https://github.com/kyleniemeyer/PyTeCK</a>
</p>
</section>
</section>
<section>
<section>
<h2>(Python) packaging</h1>
<br/>
<p><strong>package:</strong> a collection of modules in the same directory</p>
<br/>
<p class="fragment">Package directory must contain <code>__init__.py</code> for Python to "see" it</p>
</section>
<section>
<h3><code>compphys</code> package structure:</h3>
<br/>
<pre><code data-trim>
compphys/
|-- __init__.py
|-- constants.py
|-- physics.py
|-- more/
| |-- __init__.py
| |-- morephysics.py
| |-- evenmorephysics.py
|-- assets/
| |-- data.txt
| |-- orphan.py
|-- tests/
| |-- test_physics.py
| |-- test_morephysics.py
...
</code></pre>
</section>
<section>
<h4><code>compphys</code> contents:</h4>
<br/>
<ul>
<li class="fragment"><code>__init__.py</code>:
tells Python this is a package; does not need any contents. Executed first before any other modules imported.
</li>
<li class="fragment">Three modules: <code>__init__.py</code>, <code>constants.py</code>, and <code>physics.py</code>
</li>
<li class="fragment"><code>more</code> is a submodule
</li>
<li class="fragment"><code>raw</code> is just a subdirectory;
not a submodule since it doesn't have <code>__init__.py</code> (<code>orphan.py</code> is unreachable!)
</li>
</ul>
</section>
<section>
<h3>Importing submodules</h3>
<br/>
<p>Use attribute access operator: <code>.</code></p>
<pre><code data-trim class="fragment python">
import compphys.constants
import compphys.more.morephysics
two_pi = 2 * compphys.constants.pi
</code></pre>
<p class="fragment">These are <strong>absolute imports</strong></p>
</section>
<section>
<h3>Explicit relative imports</h3>
<br/>
<p class="fragment">From <code>physics.py</code>:
<pre><code data-trim class="python fragment">
from . import constants
from .constants import pi, h
from .more import morephysics
</code></pre>
</p>
<p class="fragment">From <code>evenmorephysics.py</code>:
<pre><code data-trim class="python fragment">
from . import morephysics
from .. import constants
from ..constants import pi, h
</code></pre>
</p>
</section>
<section>
<h3>Important: while easy to create new functions and modules, don't reinvent the wheel!</h3>
<br/>
<p class="fragment">Rely on the Python standard library, NumPy, SciPy, etc. as much as you need.</p>
</section>
<section>
<h4>Useful modules in Python standard library:</h4>
<br/>
<small>
<table style="width:100%">
<tr>
<td><code>os</code></td>
<td>Operating system abstractions: file path operations, file removal</td>
</tr>
<tr>
<td><code>sys</code></td>
<td>System-specific; gets into Python interpreter</td>
</tr>
<tr>
<td><code>math</code></td>
<td>Common mathematical functions and constants</td>
</tr>
<tr>
<td><code>re</code></td>
<td>Regular expressions library</td>
</tr>
<tr>
<td><code>subprocess</code></td>
<td>Spawns child processes and shells; good for running other command-line tools</td>
</tr>
<tr>
<td><code>argparse</code></td>
<td>Creates easy and beautiful command-line utilities</td>
</tr>
<tr>
<td><code>collections</code></td>
<td>Advanced collection types and tools</td>
</tr>
<tr>
<td><code>random</code></td>
<td>Pseudo-random number generators</td>
</tr>
<tr>
<td><code>csv</code></td>
<td>Tools for reading/writing comma-separated value files</td>
</tr>
</table>
</small>
</section>
<section>
<h4>Useful third-party packages for computing:</h4>
<br/>
<small>
<table style="width:100%">
<tr>
<td><a href="http://www.numpy.org"><code>numpy</code></a></td>
<td>Essential library for creating and manipulating numerical data</td>
</tr>
<tr>
<td><a href="https://docs.scipy.org/doc/scipy/reference/"><code>scipy</code></a></td>
<td>High-level scientific computing library</td>
</tr>
<tr>
<td><a href="https://matplotlib.org"><code>matplotlib</code></a></td>
<td>Plotting with Python</td>
</tr>
<tr>
<td><a href="http://www.sympy.org/"><code>sympy</code></a></td>
<td>Symbolic mathametics computation library</td>
</tr>
<tr>
<td><a href="https://pandas.pydata.org"><code>pandas</code></a></td>
<td>Python data structures and analysis library</td>
</tr>
<tr>
<td><a href="https://pint.readthedocs.io/en/latest/"><code>pint</code></a></td>
<td>Package for parsing, defining, and working with units</td>
</tr>
<tr>
<td><a href="http://ipython.org"><code>ipython</code></a></td>
<td>Interactive computing shell for Python</td>
</tr>
<tr>
<td><a href="https://wxpython.org"><code>wxPython</code></a></td>
<td>cross-platform GUI toolkit for Python </td>
</tr>
<tr>
<td><a href="http://scikit-learn.org/stable/"><code>scikit-learn</code></a></td>
<td>Python-based machine learning library</td>
</tr>
<tr>
<td><a href="http://numba.pydata.org"><code>numba</code></a></td>
<td>Write high-performance functions in Python</td>
</tr>
</table>
</small>
</section>
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
</script>
</body>
</html>