MCPcopy
hub / github.com/DLR-RM/stable-baselines3 / reset

Method reset

stable_baselines3/common/monitor.py:66–85  ·  view source on GitHub ↗

Calls the Gym environment reset. Can only be called if the environment is over, or if allow_early_resets is True :param kwargs: Extra keywords saved for the next episode. only if defined by reset_keywords :return: the first observation of the environment

(self, **kwargs)

Source from the content-addressed store, hash-verified

64 self.current_reset_info: dict[str, Any] = {}
65
66 def reset(self, **kwargs) -> tuple[ObsType, dict[str, Any]]:
67 """
68 Calls the Gym environment reset. Can only be called if the environment is over, or if allow_early_resets is True
69
70 :param kwargs: Extra keywords saved for the next episode. only if defined by reset_keywords
71 :return: the first observation of the environment
72 """
73 if not self.allow_early_resets and not self.needs_reset:
74 raise RuntimeError(
75 "Tried to reset an environment before done. If you want to allow early resets, "
76 "wrap your env with Monitor(env, path, allow_early_resets=True)"
77 )
78 self.rewards = []
79 self.needs_reset = False
80 for key in self.reset_keywords:
81 value = kwargs.get(key)
82 if value is None:
83 raise ValueError(f"Expected you to pass keyword argument {key} into reset")
84 self.current_reset_info[key] = value
85 return self.env.reset(**kwargs)
86
87 def step(self, action: ActType) -> tuple[ObsType, SupportsFloat, bool, bool, dict[str, Any]]:
88 """

Callers 8

test_monitorFunction · 0.95
test_monitor_error_casesFunction · 0.95
_setup_learnMethod · 0.45
collect_rolloutsMethod · 0.45
_check_returned_valuesFunction · 0.45
check_envFunction · 0.45
collect_rolloutsMethod · 0.45

Calls 1

getMethod · 0.45

Tested by 3

test_monitorFunction · 0.76
test_monitor_error_casesFunction · 0.76