Installation#
To install pyzernike, you can use the following command:
pip install pyzernike-polynomials
Or install it directly from the GitHub repository using:
pip install git+https://github.com/Artezaru/pyzernike.git
The package is imported as pyzernike (the name pyzernike-polynomials is only used by pip):
import pyzernike
print(pyzernike.__version__)
Optional features#
The core of pyzernike (computation of the polynomials, fit, coefficients, conventions) only requires numpy.
The display and the symbolic expressions require additional packages, which can be installed with the
corresponding extras:
pip install "pyzernike-polynomials[display]" # matplotlib, for the display functions
pip install "pyzernike-polynomials[symbolic]" # sympy, for the symbolic expressions
pip install "pyzernike-polynomials[all]" # all the optional features
The quotes avoid the interpretation of the brackets by some shells (e.g. zsh).
The extras only install the optional dependencies: pyzernike does not keep track of how it was installed.
Installing matplotlib or sympy later, by any means (pip install sympy, conda, …), enables the
corresponding features as well.
The optional subpackages are imported only when they are used: import pyzernike never imports matplotlib
or sympy. If an optional dependency is missing, the first use of a function that needs it raises an
ImportError that names the missing package and gives the command to install it:
import pyzernike
pyzernike.zernike_polynomial(0.5, 0.0, n=2, m=0) # works with numpy only
pyzernike.zernike_symbolic(n=2, m=0) # ImportError if sympy is not installed
ImportError: The symbolic functions of pyzernike require the package 'sympy', which is not installed in this
Python environment. Install it with:
pip install sympy
(or install pyzernike with its optional dependencies: pip install "pyzernike-polynomials[symbolic]").
If you have just installed it, restart the Python session.
Note
In an interactive session (e.g. a Jupyter notebook), restart the session (or the kernel) after installing a missing dependency: a package installed while Python is running may not be found until the next start.
Dependencies#
Package |
Required for |
Use |
|---|---|---|
|
always |
All the numerical computations. |
|
|
|
|
|
|
|
|
The tests ( |
scipy is not a dependency of pyzernike: the functions returned by pyzernike.xy_zernike_least_squares()
can be given to any least squares solver, including scipy.optimize.least_squares if it is installed.