"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/).\n",
"- Also see [pyopenGL](http://pyopengl.sourceforge.net/): graphics programming in python (used in FSLeyes)\n",
" - [os](https://docs.python.org/3/library/os.html#module-os)/[sys](https://docs.python.org/3/library/sys.html): Miscellaneous operating system interfaces\n",
" - [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)\n",
" - [pickle](https://docs.python.org/3/library/pickle.html): Store/load any python object\n",
" - [time](https://docs.python.org/3/library/time.html)/[timeit](https://docs.python.org/3/library/timeit.html): Timing your code\n",
" - [warnings](https://docs.python.org/3/library/warnings.html#module-warnings): tell people they are not using your code properly"
]
},
...
...
%% 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:
-[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