Skip to content

Option to manually choose between computation backends #95

@cjcarver

Description

@cjcarver

I think it would be nice to not have to completely change my virtual environment every time I want to test simphony with or without JAX installed. So I was thinking we could just have a environment variable available for those who have JAX installed to optionally use the numpy environment. I was thinking something like this:

import os

backend = os.environ.get("SIMPHONY_BACKEND", "numpy")

JAX_AVAILABLE = False
if backend == "jax":
    try:
        import jax
        import jax.numpy as jnp
        JAX_AVAILABLE = True
    except ImportError:
        print("JAX not found, falling back to NumPy backend")
        backend = "numpy"
        
if backend == "numpy":
    import numpy as jnp
    from simphony.utils import jax 

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions