Skip to main content

No project description provided

Project description

🤏 tinyspace

license version pyversion tests docs

A simple and lightweight spaces implementation for RL environments, in place of gym.spaces.

Quickstart

pip install tinyspace

Example

from tinyspace import TinySpace, Space

action_space = TinySpace(shape=(), dtype=np.int, low=0, high=10, desc="action space", cls="discrete")
if action_space["cls"] == "discrete":  # access like a dictionary
    ...
elif action_space.cls == "box":  # or dot access
    ...

observation_space = TinySpace(shape=(3, 224, 224), dtype=torch.uint8, low=0, high=255)  # a valid `Space`
_nd_shape = (-1, 3)  # can use `-1` or `None` for variable-length dimensions
_pcd_space = TinySpace(shape=_nd_space, dtype=np.float32, low=-np.inf, high=np.inf, desc="partial point cloud")
observation_space = dict(  # dict where each value is a `TinySpace` is also a valid `Space`
    rgb=observation_space,
    endeffector_pos=TinySpace(shape=(3,), dtype=np.float32, low=-np.inf, high=np.inf),
    pcd=_pcd_space,
)

def check_obs(obs, space: Space):  # use `Space` type for either `TinySpace` or dict of `TinySpace`
    if isinstance(space, TinySpace):
        low = space["low"]  # preferred, so that space can also just be a standard dict
        high = space.high  # but could also use dot access if you don't need that use case
        ...
    else:
        return {k: check_obs(obs[k], v) for k, v in space.items()}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinyspace-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

tinyspace-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file tinyspace-0.1.1.tar.gz.

File metadata

  • Download URL: tinyspace-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for tinyspace-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f71f70cddea529269604fa8ea11d83bab5f5124c4104afc249556b102b003977
MD5 7a34195ab83600b4a371b0fa8f7c1b43
BLAKE2b-256 f73097a9aa35239bd1f86a5b2d7c6cb4f0a87775ed8440d41793eb4a790bc819

See more details on using hashes here.

File details

Details for the file tinyspace-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tinyspace-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for tinyspace-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa530180e0f6800bb9c4765830726490fe7e94cdd89dd5ba112ff896654b0bcb
MD5 f23bd8e33f577db3fd1de1d728c344a2
BLAKE2b-256 c53e5fec78f8aaf56e52a2f2a77a7eb37699accd3cb8d9f90324bda82987cfd3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page