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.2.tar.gz
.
File metadata
- Download URL: rustfrc-1.1.2.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db2a48c13eb81371cfa055ae7ff0c16dc500ffebbf10d9e160132398c9095916 |
|
MD5 | 6774d0a252327f710770573334d611f8 |
|
BLAKE2b-256 | c84b806499b47ff37ee56d39e8c79895e40025ec959bdda422fa67f2560beb12 |
File details
Details for the file rustfrc-1.1.2-cp310-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp310-none-win_amd64.whl
- Upload date:
- Size: 211.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c5450af5c938a07cbc2950b6fbfc4be18fbdb0887a411d5c5a4f5356169aca |
|
MD5 | d41b640c56ce1b9ceada22d036bccea1 |
|
BLAKE2b-256 | f918f5afb5da5ea3ade95f80808c63d23b2e71dd0309a7127be02148882983d0 |
File details
Details for the file rustfrc-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0189b8b57f6067bc78b9647a325bec537029ca8f31fd441eff3c77dd4790a47 |
|
MD5 | 8dd82ee6b8a8dfd5c43cd1c3968f19b5 |
|
BLAKE2b-256 | 91ecbedba04b2be961fd3ce535ac5b13f538d4d95fe2d6e11c9fbefe7421bd64 |
File details
Details for the file rustfrc-1.1.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 629.5 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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aff02975f8c7d13f663183f6b06bce533c89f3c5f77506adef7819df3fa8993e |
|
MD5 | 8b4b970d0a5fe1165af23408ab943e60 |
|
BLAKE2b-256 | a6b1a2c6b4732e44540a02f3368e31c1ef133df131ffd1a84b07b9a7ee085a28 |
File details
Details for the file rustfrc-1.1.2-cp310-cp310-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp310-cp310-macosx_10_7_x86_64.whl
- Upload date:
- Size: 326.6 kB
- Tags: CPython 3.10, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04fc152b32d337e89d228067feb82d56690b7effd728881c299725e581ca2787 |
|
MD5 | cf87efda15b429646efd6e1f9194dfd6 |
|
BLAKE2b-256 | f37d3871c9a5b0d30814049f57b8030b219588274ee6cbded17a7cb590c2d860 |
File details
Details for the file rustfrc-1.1.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 211.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b872e62900fe49043d0eccd6268fa805ef562043a081c4446d842ea6eac85f |
|
MD5 | 93bed66c46ed6cc2e47726d558d49fe5 |
|
BLAKE2b-256 | 58f316a132084fa078a039f0c412cb02337291d42870b6c8a9ae456558387a3b |
File details
Details for the file rustfrc-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75597e8b14386ba1960960f76b03f9f053dcafc159f0d8eb4bea0c3aed9ecb73 |
|
MD5 | 979a5822d1acbe4f7e6aa6c082b4f494 |
|
BLAKE2b-256 | b0db79b462396776039e899d7ab44e022e3d8f4ac973502f1dce401c734474f0 |
File details
Details for the file rustfrc-1.1.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 629.9 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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f15ed04efc43e3c3f86a938dc3e3ae554e22a0adde73ffaeeb2049091b8af9b |
|
MD5 | 857ba70c29dc7abb3792858c65c0924e |
|
BLAKE2b-256 | 9073ab1f42b34c165b85be5ac13a27176986af27fa680348bb7358843eff98a1 |
File details
Details for the file rustfrc-1.1.2-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 326.8 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1232fe9b0739cd096d554eb006435953b57e98c3ef1e96609e08efabfe605a7 |
|
MD5 | ea91eb9f8fbfe7b24924615c68eaa04d |
|
BLAKE2b-256 | 2a0f6d1e33d82bf3293300023dfe9e9ad76e08ba238690f37528b421746bc99a |
File details
Details for the file rustfrc-1.1.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 211.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c694832bb267e70515141c73dc5a7a15eeb91b6529c13e833c1c714604a9e87c |
|
MD5 | 706daa5291933686614be6003d66812b |
|
BLAKE2b-256 | 7a480e110f926ecba38b216c0d8c3b8c219038cfe1044827a0d2bb27edb637ff |
File details
Details for the file rustfrc-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3cb286659d1a5922d754fc75864bbdc81037e919a70451fe569568c84d7be56 |
|
MD5 | 8ab7ac36463452285b89cedbdc5c190c |
|
BLAKE2b-256 | a649662d3b599239177abac1a0cb3e7cbc19b0fe1afb857fa34a9b66147a2749 |
File details
Details for the file rustfrc-1.1.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.2-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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64647115953a0f79cfa6e3dd408986b8d4518aba623cf51cba926b5a1ebab71f |
|
MD5 | 1f831ef917f863ad458a609ecb808f58 |
|
BLAKE2b-256 | 1e2de843f4a15cae03d8b7306bff5f2eb7d392948f232e082cfecc540867a039 |
File details
Details for the file rustfrc-1.1.2-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 326.8 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 003ef3bafc4c963f02e1a23e91a8bff21141547c2148f03317b942ebf28d7507 |
|
MD5 | bee7b7194e8a2c947fbc14abf9e7673d |
|
BLAKE2b-256 | e7ab48055db9961ddc21c0a2ce6cd0026c2fd74cb9faf58d85d03dbfe9581216 |
File details
Details for the file rustfrc-1.1.2-cp37-none-win_amd64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp37-none-win_amd64.whl
- Upload date:
- Size: 211.7 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | facab9eac7bc45d139d7182a50482bdf9d5010e4f5af314f723fef21223ebfe4 |
|
MD5 | 156ccfe9be44adeb2fb853bb0970ef6b |
|
BLAKE2b-256 | 0802c7fd41b24a7965d70f780ff8405ef30eaf61125f9393658a43e88acef100 |
File details
Details for the file rustfrc-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8afe8156a2cc2a8174da553adf22e625c61662d77bafd92632e78d71e482346c |
|
MD5 | ee2a32e3d2996cae593523f61debaafb |
|
BLAKE2b-256 | f0b84044f744496cfea156b4b537b41e4a10db0b3e5a9951ccb5d937729bd705 |
File details
Details for the file rustfrc-1.1.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 629.3 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/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a615b97e5a6193fe16ba4e79ed948b972a097247d922e6b03ae792ed423306 |
|
MD5 | a48a0a41f10095aefa7f7e5a39344fb0 |
|
BLAKE2b-256 | 177ae5c725db8037bbf91fc5fe6162edf1eeca8bf8795b983aaab4301d0f6e26 |
File details
Details for the file rustfrc-1.1.2-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rustfrc-1.1.2-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 326.7 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ac2d42bd668a2337c208e82f6ae896b1a507075648d0066b1526585026eb8e |
|
MD5 | a7c6215d6ec0916225156bf6d6253402 |
|
BLAKE2b-256 | 0afbead1b006aa7ec7278b06d1ada7360431a2b827ab0fdafee3d3f3989d4823 |