rustfrc
rustfrc is a Python package with some fast Rust functions useful for FRC (Fourier Ring Correlation).
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.0%) to scientific vocabulary
Keywords
Repository
rustfrc is a Python package with some fast Rust functions useful for FRC (Fourier Ring Correlation).
Basic Info
Statistics
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 11
Topics
Metadata Files
README.md
rustfrc
rustfrc is a Python package with some fast Rust functions that are useful when performing Fourier Ring Correlation (FRC) computations for resolution determination in microscopy (specifically optical nanoscopy). It was originally developed for use in a Bachelor end project for the TU Delft in the period 2021-2022. See the Python package frc for examples of its usage. The test_split.py file in the tests directory also holds some examples.
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 (x8664), macOS (x8664 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
rustfrc has only a few 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.8-3.12
- NumPy 1.18+ (exact version might depend on Python version, e.g. Python 3.12 requires NumPy 1.26)
Performance
On an i7-8750H, a decently high performance 6-core chip from 2017, I measured the following speeds:
binom_split: ~210 ms on a 4000x4000 array, with each element Poisson-generated with a mean of 200pois_gen: ~420 ms to generate a 4000x4000 array with mean 200sqr_abs: ~40 ms on a 4000x4000 array, where each element is a complex number with both the real and imaginary parts having a mean of 200
Take this with a grain of salt, but it should provide a decent order of magnitude for larger images.
Installation
You can most easily install rustfrc as follows:
shell
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 install to install the required packages. I recommend installing maturin as a global tool (e.g. with cargo binstall).
Build a wheel file like this (if using poetry, append poetry run before the command) from the project directory:
shell
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, take a look at the GitHub Actions files and pyo3/maturin-action.
Development
Poetry
First, install Poetry. Since we aim for compatibility with Python 3.8+, it's recommended to install Python 3.8 and create a virtual environment with:
poetry env use <path to Python 3.8 executable>
Then, do poetry shell to activate the virtual environment.
Next, run poetry install to install the (development) dependencies.
Finally, build the Rust project using maturin develop (it's recommended to install maturin globally using cargo binstall maturin or pipx install maturin).
Run the tests using pytest.
Note that type information is not available for the Rust functions, you will have to look at the Rust source code. Maturin builds a package structures as follows:
- root rustfrc package
- _internal: this includes binom_split_py, etc.
- split: this is the Python source code in python/rustfrc/split.py
Owner
- Login: tmtenbrink
- Kind: user
- Company: TU Delft
- Repositories: 5
- Profile: https://github.com/tmtenbrink
Citation (CITATION.cff)
cff-version: 1.2.0
title: RustFRC
message: Please cite this software using these metadata.
type: software
authors:
- given-names: Tip
family-names: ten Brink
email: T.M.tenBrink@student.tudelft.nl
affiliation: TU Delft
orcid: 'https://orcid.org/0000-0002-3090-6538'
GitHub Events
Total
Last Year
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 32
- Total Committers: 2
- Avg Commits per committer: 16.0
- Development Distribution Score (DDS): 0.281
Top Committers
| Name | Commits | |
|---|---|---|
| Tip ten Brink | T****k@s****l | 23 |
| tmtenbrink | 6****k@u****m | 9 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 1
- Total pull requests: 1
- Average time to close issues: 18 days
- Average time to close pull requests: 1 minute
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- tmtenbrink (1)
Pull Request Authors
- tmtenbrink (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 686 last-month
- Total dependent packages: 1
- Total dependent repositories: 2
- Total versions: 10
- Total maintainers: 1
pypi.org: rustfrc
Fast utility functions useful for Fourier Ring/Shell Correlation: binom_split, pois_gen, square_abs.
- Documentation: https://rustfrc.readthedocs.io/
- License: Apache-2.0
-
Latest release: 1.1.5
published almost 2 years ago
Rankings
Maintainers (1)
Dependencies
- atomicwrites 1.4.0 develop
- attrs 21.2.0 develop
- colorama 0.4.4 develop
- importlib-metadata 4.8.2 develop
- iniconfig 1.1.1 develop
- maturin 0.11.5 develop
- packaging 21.3 develop
- pluggy 1.0.0 develop
- py 1.11.0 develop
- pyparsing 3.0.6 develop
- pytest 6.2.5 develop
- toml 0.10.2 develop
- typing-extensions 4.0.0 develop
- zipp 3.6.0 develop
- numpy 1.21.4
- maturin ^0.11.3 develop
- pytest ^6.2.5 develop
- numpy >= 1.18, < 2
- python >= 3.7, <3.11
- PyO3/maturin-action v1 composite
- actions/checkout v4 composite
- actions/download-artifact v3 composite
- actions/setup-python v5 composite
- actions/upload-artifact v3 composite
- taiki-e/install-action v2 composite
- criterion 0.3 development
- ndarray ~0.15
- ndarray-rand ~0.14
- num-complex ~0.4.5
- num-traits ~0.2.18
- numpy ~0.21
- pyo3 ~0.21.1
- quay.io/pypa/manylinux2014_x86_64 latest build