This reference describes unreleased code on main; no release documents it yet.

rlmesh::spaces::Space

structPreviewuse rlmesh::spaces::Space;[source]

A space: a spec plus its sampler.

struct Space(/* private field */)

Clones share one handle, so two names drive one RNG. seed, sample and contains may run concurrently.

new

associated function[source]
fn new(spec: SpaceSpec) -> Space

A space for spec, seeded from OS entropy. Accepts every kind, including a spec with no payload (which cannot be sampled).

spec

method[source]
fn spec(&self) -> &SpaceSpec

The space’s spec.

kind

method[source]
fn kind(&self) -> SpaceKind

The space’s kind.

shape

method[source]
fn shape(&self) -> &[i64]

The element shape.

dtype

method[source]
fn dtype(&self) -> DType

The element dtype.

seed

method[source]
fn seed(&self, seed: Option<u64>) -> u64

Restart the sample stream from seed and return it; None draws a seed from OS entropy. A Dict’s children keep their own streams.

sample

method[source]
fn sample(&self) -> Result<Value>

Draw a value. Fails (ValueError class) for a spec that cannot be sampled, such as one with no payload.

contains

method[source]
fn contains(&self, value: &Value) -> bool

Whether value is a member of this space; never fails. A Box takes a Tensor of its dtype or a number or nested list of numbers of its exact shape; a Discrete an Int, a Bool, an integral Float or a one-element Tensor; a Dict a dict holding every key (others are ignored); a Tuple a tuple or list.

as_box

method[source]
fn as_box(&self) -> Option<&Box>

This space as a Box, when it is one.

as_discrete

method[source]
fn as_discrete(&self) -> Option<&Discrete>

This space as a Discrete, when it is one.

as_dict

method[source]
fn as_dict(&self) -> Option<&Dict>

This space as a Dict, when it is one.

Trait implementations

  • impl SpaceExt for Space
  • impl PartialEq<Space> for Box
  • impl PartialEq<Box> for Space
  • impl From<Box> for Space
  • impl TryFrom<Space> for Box
  • impl PartialEq<Space> for Dict
  • impl PartialEq<Dict> for Space
  • impl From<Dict> for Space
  • impl TryFrom<Space> for Dict
  • impl PartialEq<Space> for Discrete
  • impl PartialEq<Discrete> for Space
  • impl From<Discrete> for Space
  • impl TryFrom<Space> for Discrete
  • impl Clone for Space
  • impl PartialEq for Space
  • impl Display for Space
  • impl Debug for Space
  • impl From<Space> for SpaceSpec
  • impl From<&Space> for SpaceSpec