Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type cast in spaces families #2490

Closed
wants to merge 5 commits into from
Closed

Type cast in spaces families #2490

wants to merge 5 commits into from

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Nov 17, 2021

1. spaces.Dict

in __init__:

  • convert tuple to OrderedDict as well (same as list)
  • raise AssertionError when the user does not pass a dict or list / tuple of keyvalue pairs.

2. spaces.Tuple:

in __init__:

  • convert input spaces to tuple:

in contains:

  • convert the input sample to tuple:

Fixes #2140.
Fixes #2479.

3. spaces.MultiBinary:

in __init__:

  • convert input shapes to tuple of ints.
  • raise AssertionError when any entry of the input shapes is not positive.

4. spaces.MultiDiscrete:

in __init__:

  • make a copy of the input nvec

    >>> import numpy as np
    >>> a = np.array([1, 2, 3], np.int64)
    >>> np.asarray(a) is a
    True
    
    >>> np.asarray(a)[0] = 4
    >>> a
    array([4, 2, 3])
  • raise AssertionError when any entry of the input shapes is not positive (convert to ints first).

in contains:

  • convert tuple to np.ndarray as well (same as list)

5. spaces.Discrete:

in __init__:

  • convert the input shape int.
  • raise AssertionError when the input shape is not positive (convert to ints first).

@XuehaiPan XuehaiPan changed the title Support equality and member checks for list and numpy.ndarray of space.Tuple Type cast in spaces families Nov 17, 2021
@XuehaiPan XuehaiPan closed this Nov 17, 2021
@XuehaiPan XuehaiPan deleted the tuple-eq-contains branch November 17, 2021 10:37
@XuehaiPan
Copy link
Contributor Author

Closed due to changing branch name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant