Skip to content

Add Space.is_subset and generalize Space.clip to base class #4

@realquantumcookie

Description

@realquantumcookie

Summary

Introduce two base APIs:

class Space(...):
    def is_subset(self, other: "Space") -> bool:
        ...

    def clip(self, x: Any) -> Any:
        ...

Goal: make subspace relationships explicit and allow projecting data from a superset space into a subset space in a uniform way.

Motivation

We already rely on contains for validation, but we lack:

  • a way to reason about relationships between spaces (subset)
  • a way to project data across compatible spaces (clip)

BoxSpace.clip already exists, but this concept should be generalized across all spaces (especially DictSpace / TupleSpace) for wrappers, dataset adapters, and action/observation projection.

Proposed semantics

Core contract:

If target.is_subset(source) is True, then any $x \in \text{source}$ should be projectable via
target.clip(x) such that target.contains(output).

Ownership: clip is defined on the target (subset) space.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions