Skip to main content

A minimal JAX library for connectivity modelling at scale

Project description

tests DOI

JAXScape Logo

JAXScape is a minimal JAX library for connectivity analysis at scales. It provide key utilities to build your own connectivity analysis workflow, including

  • differentiable and GPU-accelerated graph distance metrics
  • differentiable raster to graph and graph to raster mappings
  • moving window utilities for the implementations for large-scale connectivity analysis pipelines

JAXScape leverages JAX's capabilities to accelerate distance computations on CPUs/GPUs/TPUs, while ensuring differentiability of all implemented classes and methods for awesome sensitivity analysis and optimization.

Installation

uv add jaxscape

For GPU compatibility, install JAX following the official JAX installation guide. JAXScape will automatically use the JAX backend you have configured.

You may be required to install optional linear solvers for large-scale resistance distance computations (see the documentation page).

Quick start

import jax.numpy as jnp
from jaxscape import GridGraph
from jaxscape import LCPDistance, ResistanceDistance, RSPDistance
import numpy as np

# loading jax array representing permeability
permeability = jnp.array(np.loadtxt("permeability.csv", delimiter=","))
grid = GridGraph(grid=permeability)

# Calculating distances of all pixels to top left pixel
source = grid.coord_to_index(jnp.array([0]), jnp.array([0]))

distances = {
    "LCP distance": LCPDistance(),
    "Resistance distance": ResistanceDistance(solver = CholmodSolver()),
    "RSP distance": RSPDistance(theta=0.01, cost=lambda x: 1 / x)
}

fig, axs = plt.subplots(1, 3, figsize=(10, 4))
for ax, (title, distance) in zip(axs, distances.items()):
    dist_to_node = distance(grid, source)
    cbar = ax.imshow(grid.node_values_to_array(dist_to_node.ravel()), cmap="magma")
    ax.axis("off")
    ax.set_title(title)
    fig.colorbar(cbar, ax=ax, shrink=0.2)

fig.suptitle("Distance to top left pixel")
plt.tight_layout()
plt.show()
Distances

But what's really cool about JAXscape is that you can autodiff through thoses distances! Check out the documentation to learn about applications and more!

Documentation

Comprehensive documentation is available at https://vboussange.github.io/jaxscape

Features and roadmap 🚀

See issues; most notably:

  • Support for direct and iterative sparse solvers on GPU (cf spineax)
  • Benchmark against CircuitScape, ConScape.jl and radish.

License

jaxscape is distributed under the terms of the MIT license.

Related packages

  • gdistance
  • ConScape
  • Circuitscape
  • graphhab
  • conefor
  • resistanceGA
  • landscapemetrics
  • radish

Citation

If you use JAXScape in your research, please cite:

@software{jaxscape2024,
  author = {Boussange, Victor},
  title = {JAXScape: A minimal JAX library for connectivity modelling at scale},
  year = {2024},
  doi = {10.5281/zenodo.15267703},
  url = {https://github.com/vboussange/jaxscape}
}

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

jaxscape-0.0.6.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

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

jaxscape-0.0.6-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file jaxscape-0.0.6.tar.gz.

File metadata

  • Download URL: jaxscape-0.0.6.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for jaxscape-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6de6950d610894b8b683b068d697bbfc8a736dd9b45fde884b5f2ab021e166d7
MD5 7374f5633024c86f4dd9a52e20b730bf
BLAKE2b-256 e29fae32937294eeefbdb8f953c9f13d64e7c521f7e32a78eb863e9f815da712

See more details on using hashes here.

File details

Details for the file jaxscape-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: jaxscape-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for jaxscape-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5be5be29f5e2c10c6832ba75a8617a732ebf1368bfa30c8ab13b5cb5e996785a
MD5 78856146443a52321d47780dd8f23a96
BLAKE2b-256 cd1676b521119c6fec76a1bcc12ebd58e10bfcc20ef39fa39b0a4498850ecf81

See more details on using hashes here.

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