"Tutorials for all sub-packages can be found [here](https://docs.scipy.org/doc/scipy-1.0.0/reference/).\n",
"\n",
"Alternative for `scipy.ndimage`:\n",
"- [Scikit-image](http://scikit-image.org/docs/stable/auto_examples/) for image manipulation/segmentation/feature detection\n",
"\n",
"## [Matplotlib](https://matplotlib.org/): Main plotting library"
]
},
...
...
@@ -865,50 +868,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternative: [pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.\n",
"Alternatives:\n",
"- [pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.\n",
"- [emcee](http://dfm.io/emcee/current/): if you just want MCMC\n",
"\n",
"\n",
"## [Pycuda](https://documen.tician.de/pycuda/): Programming the GPU\n",
"Wrapper around [Cuda](https://developer.nvidia.com/cuda-zone).\n",
"The alternative [Pyopencl](https://documen.tician.de/pyopencl/) provides a very similar wrapper around [OpenCL](https://www.khronos.org/opencl/)."
"Also see [pyopenGL](http://pyopengl.sourceforge.net/): graphics programming in python (used in FSLeyes)\n",
"- The alternative [Pyopencl](https://documen.tician.de/pyopencl/) provides a very similar wrapper around [OpenCL](https://www.khronos.org/opencl/).\n",
"- Also see [pyopenGL](http://pyopengl.sourceforge.net/): graphics programming in python (used in FSLeyes)\n",
" - [time](https://docs.python.org/3/library/time.html)/[timeit](https://docs.python.org/3/library/timeit.html): Timing your code\n",
" - [turtle](https://docs.python.org/3/library/turtle.html#module-turtle): teach python to your kids!\n",
" - [warnings](https://docs.python.org/3/library/warnings.html#module-warnings): tell people they are not using your code properly"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from turtle import *\n",
"color('red', 'yellow')\n",
"begin_fill()\n",
"speed(10)\n",
"while True:\n",
" forward(200)\n",
" left(170)\n",
" if abs(pos()) <1:\n",
"break\n",
"end_fill()\n",
"done()"
]
},
{
"cell_type": "code",
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
# Main scientific python libraries
See https://scipy.org/
Most of these packages have or are in the progress of dropping support for python2.
So use python3!
## [Numpy](http://www.numpy.org/): arrays
This is the main library underlying (nearly) all of the scientific python ecosystem.
See the tutorial in the beginner session or [the official numpy tutorial](https://docs.scipy.org/doc/numpy-dev/user/quickstart.html) for usage details.
The usual nickname of numpy is np:
%% Cell type:code id: tags:
```
import numpy as np
```
%% Cell type:markdown id: tags:
Numpy includes support for:
- N-dimensional arrays with various datatypes
- masked arrays
- matrices
- structured/record array
- basic functions (e.g., sin, log, arctan, polynomials)
- basic linear algebra
- random number generation
## [Scipy](https://scipy.org/scipylib/index.html): most general scientific tools
At the top level this module includes all of the basic functionality from numpy.
You could import this as, but you might as well import numpy directly.
%% Cell type:code id: tags:
```
import scipy as sp
```
%% Cell type:markdown id: tags:
The main strength in scipy lies in its sub-packages:
Alternative: [pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.
Alternatives:
-[pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.
-[emcee](http://dfm.io/emcee/current/): if you just want MCMC
## [Pycuda](https://documen.tician.de/pycuda/): Programming the GPU
Wrapper around [Cuda](https://developer.nvidia.com/cuda-zone).
The alternative [Pyopencl](https://documen.tician.de/pyopencl/) provides a very similar wrapper around [OpenCL](https://www.khronos.org/opencl/).
-[coverage](https://coverage.readthedocs.io/en/coverage-4.5.1/): measures which part of the code is covered by the tests
## Linters
Linters check the code for any syntax errors, [style errors](https://www.python.org/dev/peps/pep-0008/), unused variables, unreachable code, etc.
-[pylint](https://pypi.python.org/pypi/pylint): most extensive linter
-[pyflake](https://pypi.python.org/pypi/pyflakes): if you think pylint is too strict
-[pep8](https://pypi.python.org/pypi/pep8): just checks for style errors
### Optional static typing
- Document how your method/function should be called
- Static checking of whether your type hints are still up to date
- Static checking of whether you call your own function correctly
- Even if you don't assign types yourself, static type checking can still check whether you call typed functions/methods from other packages correctly.
%% Cell type:code id: tags:
```
from typing import List
def greet_all(names: List[str]) -> None:
for name in names:
print('Hello, {}'.format(name))
greet_all(['python', 'java', 'C++']) # type checker will be fine with this
greet_all('matlab') # this will actually run fine, but type checker will raise an error
```
%% Cell type:markdown id: tags:
Packages:
-[typing](https://docs.python.org/3/library/typing.html): built-in library containing generics, unions, etc.
-[mypy](http://mypy-lang.org/): linter doing static type checking
-[pyAnnotate](https://github.com/dropbox/pyannotate): automatically assign types to most of your functions/methods based on runtime
## Web frameworks
-[Django2](https://www.djangoproject.com/): includes the most features, but also forces you to do things their way
-[os](https://docs.python.org/3/library/os.html#module-os)/[sys](https://docs.python.org/3/library/sys.html): Miscellaneous operating system interfaces
-[os.path](https://docs.python.org/3/library/os.path.html)/[pathlib](https://docs.python.org/3/library/pathlib.html): utilities to deal with filesystem paths (latter provides an object-oriented interface)
-[pickle](https://docs.python.org/3/library/pickle.html): Store/load any python object
Tutorials for all sub-packages can be found [here](https://docs.scipy.org/doc/scipy-1.0.0/reference/).
Alternative for `scipy.ndimage`:
-[Scikit-image](http://scikit-image.org/docs/stable/auto_examples/) for image manipulation/segmentation/feature detection
## [Matplotlib](https://matplotlib.org/): Main plotting library
```
import matplotlib as mpl
...
...
@@ -552,39 +555,15 @@ _ = pm.traceplot(trace)
pm.summary(trace)
```
Alternative: [pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.
Alternatives:
-[pystan](https://pystan.readthedocs.io/en/latest/): wrapper around the [Stan](http://mc-stan.org/users/) probabilistic programming language.
-[emcee](http://dfm.io/emcee/current/): if you just want MCMC
## [Pycuda](https://documen.tician.de/pycuda/): Programming the GPU
Wrapper around [Cuda](https://developer.nvidia.com/cuda-zone).
The alternative [Pyopencl](https://documen.tician.de/pyopencl/) provides a very similar wrapper around [OpenCL](https://www.khronos.org/opencl/).
-[os](https://docs.python.org/3/library/os.html#module-os)/[sys](https://docs.python.org/3/library/sys.html): Miscellaneous operating system interfaces
-[os.path](https://docs.python.org/3/library/os.path.html)/[pathlib](https://docs.python.org/3/library/pathlib.html): utilities to deal with filesystem paths (latter provides an object-oriented interface)
-[pickle](https://docs.python.org/3/library/pickle.html): Store/load any python object