Skip to main content

Fast utility functions useful for Fourier Ring/Shell Correlation: binom_split, pois_gen, square_abs.

Project description

rustfrc

GitHub release License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustfrc-1.1.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distributions

rustfrc-1.1.1-cp310-none-win_amd64.whl (211.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

rustfrc-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (629.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.1-cp310-cp310-macosx_10_7_x86_64.whl (326.7 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

rustfrc-1.1.1-cp39-none-win_amd64.whl (211.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

rustfrc-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (630.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.1-cp39-cp39-macosx_10_7_x86_64.whl (326.9 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rustfrc-1.1.1-cp38-none-win_amd64.whl (211.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

rustfrc-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (630.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.1-cp38-cp38-macosx_10_7_x86_64.whl (326.8 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rustfrc-1.1.1-cp37-none-win_amd64.whl (211.7 kB view details)

Uploaded CPython 3.7 Windows x86-64

rustfrc-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

rustfrc-1.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (629.9 kB view details)

Uploaded CPython 3.7m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.1-cp37-cp37m-macosx_10_7_x86_64.whl (326.7 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

File details

Details for the file rustfrc-1.1.1.tar.gz.

File metadata

  • Download URL: rustfrc-1.1.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1.tar.gz
Algorithm Hash digest
SHA256 43686f159b5032d282504371c23dc7aead72160bc4cbcd9957bffa99d1e65fc9
MD5 f4b6efac7f37dde902967e8515e1e7ab
BLAKE2b-256 42014ad8699d214ae80de26ca0a586bfac4079c1466228da4c5350af8612edd2

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp310-none-win_amd64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 211.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 d2489ae3ed9862efb9229b9cbb1a290d2b4b0b4d1c2fa919b50bb1d69a9be22f
MD5 2183844cda326e9eb5d10c61834fb77c
BLAKE2b-256 0415e3ddb2cb890a2ae8c890f26952d64db7f58f89554d7b7b7f8d978b03dacd

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a565e04f3c1324d3c4462fc5d38a011f90f469941d33a1c782eb25e70ea4f2f9
MD5 ac85c92e433e5aeccbba22bc287a10b6
BLAKE2b-256 57bf98deda47433a819b13ab221df689d5558b2a0c0686c63598d774767a144f

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 8dbd254a2ffe2a3d3a20bfd26190df31dc826e63956df3af7f842d9de58d6be1
MD5 cd8951b0e6a5d7fbd74d83ddba6fedd9
BLAKE2b-256 a45985b60e2046ad61798e95a8434101260ec0283621cdaabc5895839366c61a

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-cp310-cp310-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 326.7 kB
  • Tags: CPython 3.10, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 8cabee681084553b5390393dd6cc5289f007e082b58379bc05202717f8d295ae
MD5 45ac0377004fb7711be8e3bc2302b424
BLAKE2b-256 bdfcaf6b2e3e87ec65c5fccf07d4c843e5f7c3df88c121162806c4a1aa8289ef

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp39-none-win_amd64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 f3c8510cebfcee5098e5a4c008172c37246023aa35277c44d6f88669bfa15453
MD5 37e6006672e35f07138fb5612024d3f1
BLAKE2b-256 a1946619d2ef2270cde0c29a4c6c051fa9d3557632acf58178e3e23ec5fae5c1

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 857437ba1c4c6699c1167bcb313271455f5c9b52bb52d4ac363c3756a5a3a1af
MD5 40247cd5fe50a3cb306d34fea4d82964
BLAKE2b-256 fb86bd80ecb126636b07f56e32fd359dfdd17734566843db891f0b1b2d3fc1a7

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a2f7541f3594b7b47eb6d5d4c1cb8aedf73f6847c407a04fece8c917f5bac663
MD5 8a037a2acc5d82b21a6d61067d05d9fb
BLAKE2b-256 5c11a779ea412c03c8218f347f3e5ec950084d285292b58792f0cf300749e5fa

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 326.9 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 8384aed40bc7cdddb09af0ff05ea424c8061818d60a0e660516011928e6f92a6
MD5 8614d6753706a2f78ba621ac42ee7175
BLAKE2b-256 61d0fa0aa27542b35b9612e045a9e1f0e9448032e4f747a662f9edbe94ee110e

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp38-none-win_amd64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fa7b4ff4fd93361dd5edc1648e4e4f42ccd1caa29319962ae2a51194a77feb5b
MD5 20b0e8e498c7a92de96896fb5392bc02
BLAKE2b-256 c751548ee0f3257aeadd922e4206f2f5d4ad0106617b844a9cff464774c762b8

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 93a46742f9d203c6c7efb54ce8f91ab3df4c631ccb566196518b9a540c9e9045
MD5 466ee6c345a06f8bd05424cd16e91b70
BLAKE2b-256 f31585eff63d4537ce4ba3a1dece7cb1c044d80ce0d35208c1de0eec0a2c6610

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2fb7f1b05f855a1c3970f746d8b04f9790733423563597721c5fd644eddfc179
MD5 68bfe15ccde123161751a9070ce528dd
BLAKE2b-256 64e17124942a8f332342ac3b1adb8d0f7c17228d610ee7d36368bd239872ce53

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b46d6e883c5db191dfe068531bfd473a07751e9d046f55bf95ea888f493baac5
MD5 79738d4b66647576507d6419e5b7c1bd
BLAKE2b-256 b6bc403b3c0a8b065a48b24040579bd095901c110f2650f8e5646783dfe86611

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp37-none-win_amd64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 45361d1fbe1d8fff32f79416dd91c719375521ddb4a1dcb452cbb6f2ae450012
MD5 dac98dd54de432089b32251c9560aaef
BLAKE2b-256 89a0fa83f983eab517e060c83d18ae5f81b8a0c865a59a1e8789143b5b09ae9b

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e14b8d562ef339df8a3358af2cf9f2d11580799fb7e71c86d9fbe1fdd2a860ca
MD5 711dac5efc02df44c69a6907a6b10549
BLAKE2b-256 26f4a16883f29d639dc8e7521dcfe94bcf99c429f3610367346d6834cca9fe54

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 5136be5f8c3ecaea9416ba6ae737e23552d25c080139bb5bedcd8390758b7a0d
MD5 69c25ba9483d470a65d8861b5b0acf2a
BLAKE2b-256 918d3b501c3d4b9d2ad473183854d832a65a8ff6a96f72b8a967e8810f17652a

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.1-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rustfrc-1.1.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for rustfrc-1.1.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0e6091ebb725f6e43f16cd879522984302fb4d08250525e0968180afdaa33a85
MD5 f4b8407e41053de57b45d5af3b882e54
BLAKE2b-256 ab2cd289e551f906e3a68805455e1e51b40df7fe406ccbc64b5fc2d324d290b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page