Skip to main content

Research Numpy: run either JAX or standard Numpy from a common interface

Project description

RNUMPY: A JAX/Numpy Package to Write JAX-Optional Code with JAX Syntax

What is RNUMPY?

RNUMPY is a Python package designed to let users write code in the JAX format while seamlessly falling back to NumPy if JAX is not installed. This enables developers to leverage the benefits of JAX speed when desired without requiring all users to overcome the challenges of JAX installation. It’s especially useful in scenarios where:

  • Portability: You want your code to be usable by others who may not have JAX installed.
  • Ease of Use: Users with simpler computational needs may prefer to avoid installing JAX.
  • Code Consistency: You want a single codebase to work with either library.

Use Cases

  • Sharing JAX-like code with collaborators who face installation constraints.
  • Writing reusable Python libraries that can flexibly work with JAX or NumPy.
  • Prototyping JAX-based projects without committing to the full ecosystem immediately.

Installation

To install RNUMPY, use pip. This will not install JAX. To install JAX as well, please see the official instructions here: JAX Install.

pip install rnp

Usage Examples

Example: Basic Operations

Original JAX code:

import jax.numpy as jnp

x = jnp.array([1, 2, 3])
y = jnp.array([4, 5, 6])

# Perform operations
dot_product = jnp.dot(x, y)
print(dot_product)

RNUMPY equivalent:

import RNUMPY as rnp

# Compatible with both JAX and NumPy
x = rnp.array([1, 2, 3])
y = rnp.array([4, 5, 6])

# Perform operations
dot_product = rnp.dot(x, y)
print(dot_product)  # Output will match JAX

To use NumPy only:

import RNUMPY as rnp

# rnp defaults to JAX unless told otherwise, change at anytime
rnp.use_jax = False

# Compatible with both JAX and NumPy
x = rnp.array([1, 2, 3])
y = rnp.array([4, 5, 6])

# Perform operations
dot_product = rnp.dot(x, y)
print(dot_product)  # Output will match NumPy

Ethos

RNUMPY aims to be:

  1. A Drop-In for JAX: All function calls and API structures mimic JAX’s documentation, ensuring that users familiar with JAX can transition effortlessly.
  2. Up-to-Date: We strive to keep this package aligned with the latest JAX updates to maintain compatibility and feature parity.
  3. JAX-first functionality: All functions will have JAX convention and functionality. In cases where numpy functionality differs, only the JAX functionality will be accessible.

Contributions

Contributions are welcome! If you spot inconsistencies with JAX’s API, have feature requests, or want to help maintain parity with JAX updates, feel free to open an issue or submit a pull request.

RNP Todos:

RNUMPY has all the basic JAX Numpy features, except the following, which are works in progress. There are no inherent technical challenges, this project is in a beta state. We welcome pull requests to finish these area.

  • ufuncs
  • mgrid/ogrids, c_, r_, s_
  • bitwise operators
  • isinf/isnan etc..
  • Set Routines
  • Most of the Scipy folder We stubbed out these functions, so you will find a NotImplementedError if you try calling these.

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

rnp-0.1.0.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

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

rnp-0.1.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file rnp-0.1.0.tar.gz.

File metadata

  • Download URL: rnp-0.1.0.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rnp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5422e5268b93baec1a935e5c06a4b48e04f35313abc44de32c14588bcb2dd568
MD5 945ad78633633f75d94af6084303cc37
BLAKE2b-256 674cf29f51bfac0564dfe50dacdec36ecf5e9952ad004ea2754afc154189f011

See more details on using hashes here.

Provenance

The following attestation bundles were made for rnp-0.1.0.tar.gz:

Publisher: publish.yml on RCAIDE/RNUMPY

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

File details

Details for the file rnp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rnp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rnp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6edb4a2a4eba96714218f628d11210b5f96134a55390fbcdf3c55f874134afef
MD5 10f94dfc11d097ac71b51c0eee68dcc3
BLAKE2b-256 7077623aae5e3f0cec90da04ce4c6ce8f0c4b4f33bbf552763eb416dd1352ae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rnp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on RCAIDE/RNUMPY

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