# Course: Programming For Social Scientists

Python Object-Oriented Programming Agent-Based Modelling GEOG5995M
##### September 20, 2019

Here are some things to take from this week’s intensive introduction to programming in Python.

You can find the notes for the course here – in fact, working through the links on that webpage is all we did this week, as Dr Andy Evans who put the course together is, I think, unwell, and so was unable to teach in person.

## Culture

“Becoming a programmer isn’t just about knowing how to code, there’s a whole culture and history to engage with as well.”

## The Top Ten Algorithms:

1946: The Metropolis Algorithm for Monte Carlo. Through the use of random processes, this algorithm offers an efficient way to stumble toward answers to problems that are too complicated to solve exactly.

1947: Simplex Method for Linear Programming. An elegant solution to a common problem in planning and decision-making.

1950: Krylov Subspace Iteration Method. A technique for rapidly solving the linear equations that abound in scientific computation.

1951: The Decompositional Approach to Matrix Computations. A suite of techniques for numerical linear algebra.

1957: The Fortran Optimizing Compiler. Turns high-level code into efficient computer-readable code.

1959: QR Algorithm for Computing Eigenvalues. Another crucial matrix operation made swift and practical.

1962: Quicksort Algorithms for Sorting. For the efficient handling of large databases.

1965: Fast Fourier Transform. Perhaps the most ubiquitous algorithm in use today, it breaks down waveforms (like sound) into periodic components.

1977: Integer Relation Detection. A fast method for spotting simple equations satisfied by collections of seemingly unrelated numbers.

1987: Fast Multipole Method. A breakthrough in dealing with the complexity of n-body calculations, applied in problems ranging from celestial mechanics to protein folding.

## Git, Github, & Version Control

git clone ...
git commit -m "..."
git push


You can make your code citable with a DOI (that is, a Digital Object Identifier).

The most important thing to remember about GitHub: Never, ever, allow passwords to be pushed to GitHub.

## Floating-Point Arithmetic

“On most machines today, floats are approximated using a binary fraction with the numerator using the first 53 bits starting with the most significant bit and with the denominator as a power of two.”

>>> 0.1
0.1000000000000000055511151231257827021181583404541015625


## Data Structures

See documentation

## Documentation

You can automate documentation with Sphinx, in particular by using the autodoc extension to extract explanatory function docstrings.

I prefer Google Style docstrings to the not-quite-Markdown thing that is reStructuredText, so use the napoleon extension.

# conf.py
...

# -- General configuration ---------------------------------------------------

master_doc = 'index'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon'
]