rlmesh.numpy.asarray

functionfrom rlmesh.numpy import asarray[source]

Return a writable NumPy array copied from an RLMesh tensor.

asarray(tensor: Tensor | bool | int | float) -> NumpyArray

Always 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

NameTypeDescription
tensorTensor | bool | int | floatRLMesh tensor or scalar primitive to convert.

Returns

TypeDescription
NumpyArrayA writable NumPy array owning a copy of the tensor data.