You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was messing around with categorical actions, where one word out of a predefined word set could be selected (e.g. "sit", "walk", "fly"). My first attempt as to define the charset as the whole words and limit the size to 1
It actually worked, and I was very glad this could be supported. However it seems like the contains implementation for this space has the supposition that all strings in charset have length 1 (which makes sense as its primary use is to store characters). Therefore, space.contains('sit') always returns False, even if it should be True.
...
defcontains(self, x: Any) ->bool:
"""Return boolean specifying if x is a valid member of this space."""ifisinstance(x, str):
ifself.min_length<=len(x) <=self.max_length:
returnall(cinself.character_setforcinx)
returnFalse
Should Text allow multi-char symbols?
Code example
from gymnasium.spaces import Text
S = frozenset(['sit', 'walk', 'fly'])
space = Text(max_length=1, charset=S)
assert space.contains('sit') # Assertion Error
System info
Gymnasium was installed via pip in a conda environment
Gymnasium version: 1.0.0
OS: Ubuntu 20.04
Python version: 3.11.11
Additional context
No response
Checklist
I have checked that there is no similar issue in the repo
The text was updated successfully, but these errors were encountered:
Interestingly, this is not how the space was meant to be used. The intention is that each element of the charset has length == 1.
If you want categorical actions, I would recommend using Discrete with some converter wrapper to change between the categorical words and discrete values.
Describe the bug
I was messing around with categorical actions, where one word out of a predefined word set could be selected (e.g. "sit", "walk", "fly"). My first attempt as to define the charset as the whole words and limit the size to 1
It actually worked, and I was very glad this could be supported. However it seems like the contains implementation for this space has the supposition that all strings in charset have length 1 (which makes sense as its primary use is to store characters). Therefore,
space.contains('sit')
always returns False, even if it should be True.Should Text allow multi-char symbols?
Code example
System info
Gymnasium was installed via pip in a conda environment
Gymnasium version: 1.0.0
OS: Ubuntu 20.04
Python version: 3.11.11
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: