Skip to main content

A Python Sparse Grid Package

Project description

sparse_grid

A Python Sparse Grid Package

Tests Documentation Ruff

codecov Quality Gate Status License: BSD-3

PyPI Downloads Python versions

sparse_grid is a pure-Python implementation of regular sparse grids over box domains. It provides hierarchical index generation, nodal-to-hierarchical coefficient conversion, and fast function evaluation using the hat basis:

$$f_n(\mathbf{x}) = \sum_{\lvert\mathbf{l}\rvert_1 \le n+d-1} \sum_{\mathbf{p}} \alpha_{\mathbf{l},\mathbf{p}}, \prod_{i=1}^{d} \phi_{l_i, p_i}(x_i)$$

Quick example

from sparse_grid import SparseGrid

sg = SparseGrid(dim=2, level=3)
sg.generate_points()

for index in sg.indices:
    pos = sg.g_p[tuple(index)].pos
    sg.g_p[tuple(index)].fv = (
        4.0 * pos[0] * (1.0 - pos[0]) * 4.0 * pos[1] * (1.0 - pos[1])
    )

sg.nodal_2_hier()
print(sg.eval_funct([0.25, 0.75]))

Installation

pip install sparse_grid

Requires Python 3.10+. No external runtime dependencies. See the full installation guide for uv, poetry, and source builds.

Documentation

License

BSD-3-Clause — see LICENSE.

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

sparse_grid-0.1.3.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

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

sparse_grid-0.1.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file sparse_grid-0.1.3.tar.gz.

File metadata

  • Download URL: sparse_grid-0.1.3.tar.gz
  • Upload date:
  • Size: 58.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sparse_grid-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fc9bd18580e3d071cae2efe7cd4a22a61a78f9f45f7cb2d9f8bf5a94b6da1b9e
MD5 485e3eb94da9ee8b2e5ef90a90425643
BLAKE2b-256 57a26c6d767c4413c47ed795de5682d273ced0e09174605355d17075ea0b7012

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_grid-0.1.3.tar.gz:

Publisher: publish_dist.yml on eggzec/sparse_grid

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

File details

Details for the file sparse_grid-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sparse_grid-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sparse_grid-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5e51517cd5873972925c16606c6ccc8d4a785c0c7ee0d44e52569daf7708cbd3
MD5 d2858969193df1996db71346fa3757e0
BLAKE2b-256 28aff1c268477fc4143c762883697f6c4abfd3583406e50a8258381351d9324b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_grid-0.1.3-py3-none-any.whl:

Publisher: publish_dist.yml on eggzec/sparse_grid

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 Pingdom Monitoring Sentry Error logging StatusPage Status page