Skip to content

Commit

Permalink
[math] add brainpy.math.is_bp_array
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Dec 22, 2023
1 parent 68c1638 commit b561f84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion brainpy/_src/math/interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@


__all__ = [
'as_device_array', 'as_jax', 'as_ndarray', 'as_numpy', 'as_variable',
'as_device_array', 'as_jax', 'as_ndarray', 'as_numpy', 'as_variable', 'is_bp_array'
]


def _as_jax_array_(obj):
return obj.value if isinstance(obj, Array) else obj


def is_bp_array(x):
"""Check if the input is a ``brainpy.math.Array``.
"""
return isinstance(x, Array)


def as_device_array(tensor, dtype=None):
"""Convert the input to a ``jax.numpy.DeviceArray``.
Expand Down
1 change: 1 addition & 0 deletions brainpy/math/interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
as_ndarray as as_ndarray,
as_numpy as as_numpy,
as_variable as as_variable,
is_bp_array as is_bp_array,
)

0 comments on commit b561f84

Please sign in to comment.