Skip to main content

Scarfs

pypi build docs

A library to find an approximate fixed point for a bounded vector valued function.

Installation

pip install scarfs

Usage

Define the function you want to find a fixed point of using numba:

import numpy as np
from numba import njit

@njit
def roll(simp: np.ndarray) -> np.ndarray:
    return np.roll(simp, 1)

For performance reasons, this function must be compiled by numba as a cfunc or in nopython mode. A bare @njit is the simplest accepted form; if you annotate an explicit signature, the argument must be a C-contiguous one-dimensional float64 array (float64[::1]), while the return may have any layout — so @jit(float64[::1](float64[::1])) works, but a map whose argument is typed as non-contiguous (float64[:]) is rejected with a numba TypeError. Jitclass functions are currently not supported. The function must also lie in a bounded space, three default spaces are provided: the simplex, the simplotope, and the unit hypercube. If your bounded space is not one of these, you'll need to first compute a homeomorphism between your space and one of these. The main algorithm runs on the simplex, so you may find it faster if you can project there directly.

Once your function is defined, simply call one of the fixed point functions with an initial position and a discretization:

from scarfs import simplex_fixed_point

sol = simplex_fixed_point(roll, np.array([1, 0, 0, 0], float), 100)

The result is guaranteed to be within 1 / discretization of a true fixed point (or a little larger for the other bounded spaces).

Note that fixed points are difficult to approximate generally, so this may run for a very long time.

The public entry points validate the discretization and initial point and raise a descriptive ValueError on bad values, but the map itself is trusted: passing one with an incompatible signature surfaces as an arcane numba TypeError.

Development

uv run ruff format --check
uv run ruff check
uv run pyright
uv run pytest

Publishing

Releases are cut from the release GitHub Actions workflow, which bumps the version, builds, and publishes to PyPI via trusted publishing.

Download files

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

Source Distribution

scarfs-0.2.2.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scarfs-0.2.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file scarfs-0.2.2.tar.gz.

File metadata

  • Download URL: scarfs-0.2.2.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scarfs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c9f162ce4af6f9448fc10ebbb561f90ce1a421a07b810d2836802d3afcac07f2
MD5 8083ae98d6449d5e2e2dc1800135a1c4
BLAKE2b-256 1feb52e7c5a87b5fa8dff1c8025d1d8b91ac60787bc8210f50ce0a00f0d32dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for scarfs-0.2.2.tar.gz:

Publisher: release.yml on erikbrinkman/scarfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scarfs-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: scarfs-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scarfs-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2c807b9e104b264b29eb9752fe1324aa402e20b0ea191136a72b0e97e8cdf4
MD5 772ddc4319bd66fce34318d980b0d418
BLAKE2b-256 71d9d85508b07ffb9e23d9417049c2011a419c711372f0c749d9a08d11d70dc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for scarfs-0.2.2-py3-none-any.whl:

Publisher: release.yml on erikbrinkman/scarfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page