rlmesh::spaces::Space
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.
Associated functions
Methods
- spec()The space's spec.
- kind()The space's kind.
- shape()The element shape.
- dtype()The element dtype.
- seed()Restart the sample stream from
seedand return it;Nonedraws a seed from OS entropy. - sample()Draw a value.
- contains()Whether
valueis a member of this space; never fails. - as_box()This space as a
Box, when it is one. - as_discrete()This space as a
Discrete, when it is one. - as_dict()This space as a
Dict, when it is one.
new
associated function[source]fn new(spec: SpaceSpec) -> SpaceA 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) -> &SpaceSpecThe space’s spec.
kind
method[source]fn kind(&self) -> SpaceKindThe space’s kind.
shape
method[source]fn shape(&self) -> &[i64]The element shape.
dtype
method[source]fn dtype(&self) -> DTypeThe element dtype.
seed
method[source]fn seed(&self, seed: Option<u64>) -> u64Restart 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) -> boolas_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