{"id":16475738,"url":"https://github.com/tmtenbrink/rustfrc","last_synced_at":"2025-03-23T11:32:56.257Z","repository":{"id":46038737,"uuid":"407321474","full_name":"tmtenbrink/rustfrc","owner":"tmtenbrink","description":"rustfrc is a Python package with some fast Rust functions useful for FRC (Fourier Ring Correlation).","archived":false,"fork":false,"pushed_at":"2024-06-13T16:16:04.000Z","size":1740,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T22:51:53.393Z","etag":null,"topics":["ndarray","pyo3","python","rust","rust-ndarray"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmtenbrink.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-16T21:36:28.000Z","updated_at":"2024-08-27T03:24:24.000Z","dependencies_parsed_at":"2024-04-10T20:29:07.152Z","dependency_job_id":"7dbba423-a834-451f-b5c7-ad5b7ba27caf","html_url":"https://github.com/tmtenbrink/rustfrc","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.28125,"last_synced_commit":"e5bdebb60f6fd3064f120229649b5165d017e7e3"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmtenbrink%2Frustfrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmtenbrink%2Frustfrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmtenbrink%2Frustfrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmtenbrink%2Frustfrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmtenbrink","download_url":"https://codeload.github.com/tmtenbrink/rustfrc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244297858,"owners_count":20430347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ndarray","pyo3","python","rust","rust-ndarray"],"created_at":"2024-10-11T12:39:57.274Z","updated_at":"2025-03-23T11:32:55.777Z","avatar_url":"https://github.com/tmtenbrink.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rustfrc\n\n![GitHub release](https://flat.badgen.net/github/release/tmtenbrink/rustfrc)\n![License](https://flat.badgen.net/github/license/tmtenbrink/rustfrc)\n\nrustfrc 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`](https://github.com/tmtenbrink/frc) for examples of its usage. The `test_split.py` file in the `tests` directory also holds some examples.\n\nSince 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).\n\n## Features\n\nrustfrc has only a few features. The primary one is `binom_split(x: ndarray) -\u003e 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.\n\nFurthermore, there are also (since version 1.1) `sqr_abs(a: ndarray) -\u003e ndarray` and `pois_gen(lam: float, shape: tuple[int, ...]) -\u003e ndarray`.\n\n`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 λ.\n\n## Requirements\n\n* Python 3.8-3.12\n* NumPy 1.18+ (exact version might depend on Python version, e.g. Python 3.12 requires NumPy 1.26)\n\n## Performance\n\nOn an i7-8750H, a decently high performance 6-core chip from 2017, I measured the following speeds:\n\n- `binom_split`: ~210 ms on a 4000x4000 array, with each element Poisson-generated with a mean of 200\n- `pois_gen`: ~420 ms to generate a 4000x4000 array with mean 200\n- `sqr_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\n\nTake this with a grain of salt, but it should provide a decent order of magnitude for larger images. \n\n## Installation\n\nYou can most easily install [rustfrc](https://pypi.org/project/rustfrc/) as follows:\n\n```shell\npip install rustfrc\n```\n\nHowever, for an optimal Python experience, use [poetry](https://github.com/python-poetry/poetry) and install it using `poetry add rustfrc`.\n\n### From source (using maturin)\n\nrustfrc uses [poetry](https://github.com/python-poetry/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](https://pypi.org/project/maturin/) as a global tool (e.g. with `cargo binstall`).\n\nBuild a wheel file like this (if using poetry, append `poetry run` before the command) from the project directory:\n\n```shell\nmaturin build --release\n```\n\nIf 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.\n\nThis 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 \u003c.whl filename\u003e`, 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.\n\nTake a look at [PyO3](https://github.com/PyO3/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.\n\n#### Manylinux\n\nIf 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](https://github.com/PyO3/maturin-action).\n\n## Development\n\n### Poetry\n\nFirst, 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:\n\n`poetry env use \u003cpath to Python 3.8 executable\u003e`\n\nThen, do `poetry shell` to activate the virtual environment.\n\nNext, run `poetry install` to install the (development) dependencies.\n\nFinally, build the Rust project using `maturin develop` (it's recommended to install `maturin` globally using `cargo binstall maturin` or `pipx install maturin`). \n\nRun the tests using `pytest`.\n\nNote 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:\n- root `rustfrc` package\n    - `_internal`: this includes `binom_split_py`, etc.\n    - `split`: this is the Python source code in `python/rustfrc/split.py`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmtenbrink%2Frustfrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmtenbrink%2Frustfrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmtenbrink%2Frustfrc/lists"}