Writing self-documenting scientific code using physical quantities
summary
Argues that code should carry physical units and shows a working workflow using the Python quantities (pq) package with numpy integration to keep magnitudes paired with units, perform dimensional analysis, and call rescale to convert results. Reproduces a momentum example (hockey puck plus rubber octopus) and fixes a miles per hour → m/s bug, cites Gimli Glider and Mars Climate Orbiter unit failures, demonstrates defining custom units (milk_bags = 4/3 L), applies units to spike‑raster neuroscience code, and publishes an IPython notebook at tibicoli pycon ca 2012.
AI-written summary · about
