From 16d48871e1e016390eae2e09719ec892a85afc94 Mon Sep 17 00:00:00 2001 From: Chaoming Wang Date: Sun, 5 Jan 2025 19:04:02 +0800 Subject: [PATCH] `Quantity` initialization does not call jax.numpy.asarray when mantissa is a python number --- .gitignore | 1 + brainunit/_base.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 11a6355..de0c454 100644 --- a/.gitignore +++ b/.gitignore @@ -227,3 +227,4 @@ cython_debug/ /docs/apis/changelog.md /dist-hist/ /dist-hist/ +/examples/ diff --git a/brainunit/_base.py b/brainunit/_base.py index 566b963..f31b396 100644 --- a/brainunit/_base.py +++ b/brainunit/_base.py @@ -2187,7 +2187,8 @@ def __init__( # skip 'asarray' if dtype is not provided elif isinstance(mantissa, (jnp.number, numbers.Number)): - mantissa = jnp.array(mantissa, dtype=dtype) + # mantissa = jnp.array(mantissa, dtype=dtype) + mantissa = mantissa else: mantissa = mantissa