rlmesh.numpy.asarray
Return a writable NumPy array copied from an RLMesh tensor.
asarray(tensor: Tensor | bool | int | float) -> NumpyArrayAlways copies: the returned array owns a fresh buffer (exactly one copy of
the tensor bytes, taken through a zero-copy buffer-protocol view), so it is
writable, never aliases the wire buffer, and matches Gymnasium, where
reset/step observations are writable (idioms such as
obs /= 255.0 work). Scalar primitives (bool/int/float) are
accepted for symmetry with rlmesh.torch.as_tensor() and become 0-d
arrays. For an opt-in zero-copy view that shares the tensor buffer, use the
buffer protocol or DLPack directly (for example
numpy.from_dlpack(tensor)), treating the result as read-only.
Parameters
| Name | Type | Description |
|---|---|---|
tensor | Tensor | bool | int | float | RLMesh tensor or scalar primitive to convert. |
Returns
| Type | Description |
|---|---|
NumpyArray | A writable NumPy array owning a copy of the tensor data. |