Fast utility functions useful for Fourier Ring/Shell Correlation: binom_split, pois_gen, square_abs.
Project description
rustfrc
rustfrc is a Python package with some fast Rust functions that are using when performing Fourier Ring Correlation (FRC) computations for resolution determination in microscopy (specifically optical nanoscopy). It is in development for use in a Bachelor end project for the TU Delft in the period 2021-2022.
Since rustfrc contains compiled (Rust) extensions and is not pure Python, it is not available for all platforms, but only for those with available compiled wheels or a Rust toolchain and maturin
support (see below). They are available for Windows (x86_64), macOS (x86_64 and universal2, which includes Apple Silicon) and Linux (x86_64). However, since Rust and Python are supported on many platforms, it is not difficult to compile for other platforms (see below).
Features
Currently, rustfrc does not have many features. The primary one is binom_split(x: ndarray) -> ndarray
which samples binomial (n, 0.5) with n as the array element value. The operation is fully parallelized and somewhere between 3-10x faster than sampling using NumPy.
Furthermore, there are also (since version 1.1) sqr_abs(a: ndarray) -> ndarray
and pois_gen(lam: float, shape: tuple[int, ...]) -> ndarray
.
sqr_abs
computes the element-wise norm and square of a complex array, while pois_gen
generates an array of the specified size using the Poisson distribution and a single parameter λ.
Requirements
- Python 3.7 or greater
- NumPy 1.18 or greater
Installation
You can most easily install rustfrc as follows:
pip install rustfrc
However, for an optimal Python experience, use poetry and install it using poetry add rustfrc
.
From source (using maturin)
rustfrc uses poetry as its Python dependency manager. For best results, create a poetry
virtualenv (be sure to install virtualenv as a systems package) with the pyproject.toml
and run poetry update
to install the required packages.
Installing maturin manually should also work. It is also necessary to have a Rust toolchain installed on your computer. Rust can be easily installed using rustup.
Build a wheel file like this (if using poetry, append poetry run
before the command) from the project directory:
maturin build --release
If you want to choose which versions of Python to build for, you can write e.g. maturin build --release -i python3.9 python3.8 python3.7
. Here, for example 'python3.7
' should be an available Python command installed on your computer.
This generates .whl
files in /target/wheels
. Then, create a Python environment of your choosing (with numpy ^1.18
and python ^3.7
), drop the .whl
file in it and run pip install <.whl filename>
, for example: pip install rustfrc-0.1.0-cp39-none-win_amd64.whl
. Then, use import rustfrc
in your Python script to be able to use the Rust functions. This should be generally valid for all platforms. The only real requirement is the availability of a Rust toolchain and Python for your platform.
Take a look at PyO3 for other installation options as the only true requirement for building is using a tool that understands PyO3 bindings, as those are used in the Rust code.
Manylinux
If you want to build .whl files that are compatible with a wide range of Linux distributions and can be uploaded to PyPI, using a manylinux container is necessary.
This example assumes a manylinux2014 (x86_64) target, using other docker base images should work to compile for other targets. Go into the rustfrc/docker
directory and run:
docker pull quay.io/pypa/manylinux2014_x86_64
docker build --no-cache -t tmtenbrink/manylinux2014-rustfrc --build-arg PY_ABI=cp39-cp39 .
After the image is built, run it as a container:
docker run -it tmtenbrink/manylinux2014-rustfrc
The repository should now be installed at /opt/rustfrc
, with its dependencies and maturin
installed. Then follow the same steps as above, but when the wheels are built run the following, which should resolve any issues:
find . -name '*.whl' -exec auditwheel repair {} \;
The complete wheel files can now be found in a /wheelhouse
directory.
Take a look at the GitHub Actions for this project for an idea of how to automate this.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file rustfrc-1.1.3.tar.gz
.
File metadata
- Download URL: rustfrc-1.1.3.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0f571b15204b0434c21f065d81f834912a7e05fd29e7610ea10724178ba24fc |
|
MD5 | 0afbc56302245e9bfb3e18f2d0c3ba3b |
|
BLAKE2b-256 | c09de7bd7293c9b44fdcbef2472ba84837c546d29905d6a400eb3760c3ffe86d |
File details
Details for the file rustfrc-1.1.3-cp310-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp310-none-win_amd64.whl
- Upload date:
- Size: 218.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b175c5435c895009905429b9acc42407c4ef60329bf12eddc61386aaf384b48 |
|
MD5 | c895a0e87806ef26e820eb919ab25d75 |
|
BLAKE2b-256 | e9e017ca4bdb04ecfc622ea50f8630379f3f1f3b62ba4346c29bd99a1f0237ef |
File details
Details for the file rustfrc-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4fe149848210459004dc76bd0ca24129163d8c4ca5b3075a13ab738e2a5ad41 |
|
MD5 | 4e3fb6676ec8d069ba524e3c62faa544 |
|
BLAKE2b-256 | f3839bb1f728fc31d1a2e9a7c732d700ff5e282e7d692878de3cd0d4bafc1d6a |
File details
Details for the file rustfrc-1.1.3-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 628.0 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc3649a0e4023bdb6fc63f473750ec92b32f0407ba60b9bfa14d32c379cede2d |
|
MD5 | de2ae46f5ae48f81ea11343420017e0d |
|
BLAKE2b-256 | 390383f2e64f83c7cad83382d9943109bff3d1217066afab4758016c89751881 |
File details
Details for the file rustfrc-1.1.3-cp310-cp310-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp310-cp310-macosx_10_7_x86_64.whl
- Upload date:
- Size: 326.9 kB
- Tags: CPython 3.10, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49c1e924268e471a8342d32bb3eec47c9a81197951263709e507140357e09977 |
|
MD5 | e490e81a16840ba98697b2ec5f9c0605 |
|
BLAKE2b-256 | db29675fc90ae3d5cf94a0bf7acc5f69840a28a0f3596e6fe5575041e60e28b9 |
File details
Details for the file rustfrc-1.1.3-cp39-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp39-none-win_amd64.whl
- Upload date:
- Size: 218.1 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8659b6633614ddc5db4f423f0a5c3260dcc84df0ea4dd13660d4f47a3892d3b5 |
|
MD5 | 678e76829632b738ff471ebbba85e52d |
|
BLAKE2b-256 | 6b3f8cffedb9aa0b81a24d1d36a90aabdea8778b1747aa66e2f8d08bd89a5585 |
File details
Details for the file rustfrc-1.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafdba460fafc3591de15eeee65d75435ae77992bb7e29c2cfc08f2976828490 |
|
MD5 | 664253bc146ba8f63916d40cc6ef3dbf |
|
BLAKE2b-256 | ba4037c34a92235143922fac67fa0cd1cb47d0822e8f38c0b753a141b23a994d |
File details
Details for the file rustfrc-1.1.3-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 628.4 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cbc644146702e50bbc57be8c6836ce42202576b65d761e6253d07328776e0da |
|
MD5 | cc56bd5a497114c08ce03eb326b7824f |
|
BLAKE2b-256 | a2349923ca0562b80de5710723f2942f761f89a39c8991a84d06d7edf649261c |
File details
Details for the file rustfrc-1.1.3-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 327.0 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d00ec2334dc00ae3f707fb352d40e0e47ff046f333433ce84d54276eb20273 |
|
MD5 | 0aeb6c201f3def1800838ec21723254d |
|
BLAKE2b-256 | fa370c748b7043bfd02ba78e164330c2883c4f0f262e18b57fa80085d08041e0 |
File details
Details for the file rustfrc-1.1.3-cp38-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp38-none-win_amd64.whl
- Upload date:
- Size: 218.2 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ffb4c467ad36936646cf3adf348b61757f8160b79e9421ae0834096a9c9d2e |
|
MD5 | 2a532893827171e24a57a8a95ac13c40 |
|
BLAKE2b-256 | ae4510898605b517e79d4d9f9dcc144648a4a87e8a0bd4e14919e28c493461e0 |
File details
Details for the file rustfrc-1.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fdb201a99c124546c07de021259ef2ac08534377920e29040747b5b4577fd1a |
|
MD5 | 40ef5a7436704ad1186501205e262abb |
|
BLAKE2b-256 | 6ae807332d4d34dca59dd278dfb0ec9b63a0706bd1471a106677675c4948ee08 |
File details
Details for the file rustfrc-1.1.3-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 629.5 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 224edbae7ac627fde1d889885b0e9912f663d29a22b403a82c58dc7c56e2f18f |
|
MD5 | e042d1962aab54e7d424a2d7d9d957a9 |
|
BLAKE2b-256 | b630047b03dd5deb37eeace15ea0c9960b6e6eaccffdee2e53390dae593feb97 |
File details
Details for the file rustfrc-1.1.3-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 327.2 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62fc22c29db19ac56321eca38b91885dec86c05a94df924e44c592dc8eb029ee |
|
MD5 | 9ae6bc7a7e52c113f3e89ec6aaaaeba2 |
|
BLAKE2b-256 | 81c4c3ca0aafeacb6822243a435222939bf30e4a04e1b4572f5b555b429d4fbf |
File details
Details for the file rustfrc-1.1.3-cp37-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp37-none-win_amd64.whl
- Upload date:
- Size: 218.1 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a04393a5438855fbcec4690c25bf4101f6650cef0cca32f3e222583d893b3f8 |
|
MD5 | efea7ff1b277da074720afc84fa2a073 |
|
BLAKE2b-256 | 92646b5e30649c79835beacfb31bf061c2f38173249c81a8b865581bfe96800a |
File details
Details for the file rustfrc-1.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcecc7f65df7056155dd896ab047dc78dc31f4b9999278d7e793381fcdee62e2 |
|
MD5 | 0a172f2baf04602de353082e42319c62 |
|
BLAKE2b-256 | 15970b4a563536af54b0bdbc45be38ac7839b103c63c0b4e982609b71046688f |
File details
Details for the file rustfrc-1.1.3-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 629.8 kB
- Tags: CPython 3.7m, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4a69342dde71c82fc5cd9f20f30253c9ad87ae424cb050659ad0236666c9a56 |
|
MD5 | 53ce5868da25588a396c9dfbe750e50a |
|
BLAKE2b-256 | 7c4ff30fd334a30a25ac79520f8121be72422343dfc1d76208161a122fc0fe9f |
File details
Details for the file rustfrc-1.1.3-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.3-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 327.4 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b9be37a46e416a48c1353d3669bec361a5ccd042a4e587c709186e58361e53f |
|
MD5 | 9e375dce760bd89d37c1ed9801e4b03d |
|
BLAKE2b-256 | 4f2e2a23fa63d5c97877c5d65261b4e6f760a3dda0c2e7e7d3bafd0bfb136629 |