minerllabs / minerl

MineRL Competition for Sample Efficient Reinforcement Learning - Python Package
http://minerl.io/docs/
Other
711 stars 153 forks source link

Numpy bool alias is depricated in Numpy > 1.20 #711

Closed JD-The-65th closed 1 year ago

JD-The-65th commented 1 year ago

Hey, when running the following script made from this tutorial, it bugs out since numpy deprecated the np.bool alias


import gym
import minerl
import logging

logging.basicConfig(level=logging.DEBUG)

env = gym.make('MineRLBasaltFindCave-v0')

obs = env.reset()

done = False

while not done:
    # Take a random action
    action = env.action_space.sample()
    # In BASALT environments, sending ESC action will end the episode
    # Lets not do that
    action["ESC"] = 0
    obs, reward, done, _ = env.step(action)
    env.render()
(soprano) ➜  Minecraft  python mine.py 
/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/hero/handlers/agent/observations/lifestats.py:62: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  space=spaces.Box(low=False, high=True, shape=(), dtype=np.bool),
Traceback (most recent call last):
  File "mine.py", line 2, in <module>
    import minerl
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/__init__.py", line 6, in <module>
    import minerl.herobraine.envs
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/envs.py", line 30, in <module>
    MINERL_HUMAN_SURVIVAL_V0 = HumanSurvival()
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/env_specs/human_survival_specs.py", line 17, in __init__
    super().__init__(
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/env_specs/human_controls.py", line 54, in __init__
    super().__init__(name, *args, **kwargs)
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/env_spec.py", line 38, in __init__
    self.reset()
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/env_spec.py", line 43, in reset
    self.observables = self.create_observables()
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/env_specs/human_survival_specs.py", line 31, in create_observables
    handlers.ObservationFromLifeStats(),
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/hero/handlers/agent/observations/lifestats.py", line 22, in __init__
    _IsAliveObservation(),
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/minerl/herobraine/hero/handlers/agent/observations/lifestats.py", line 62, in __init__
    space=spaces.Box(low=False, high=True, shape=(), dtype=np.bool),
  File "/home/deck/miniconda3/envs/soprano/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

This CAN be fixed by forcing numpy < 1.20, ex 1.19.5, but it'd just be a better idea to replace it with just bool instead of downgrading numpy.

Miffyli commented 1 year ago

Yup fun stuff. I would be happy to accept a PR that changes the instances of np.bool to bool, but also the requirements change will work. I might have time to do it but on a later date (currently working for deadlines yet again, so focus is elsewhere for a week at least).

JD-The-65th commented 1 year ago

Closing with #712