Skip to content

Commit

Permalink
Remove some redundant code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot committed May 19, 2023
1 parent d11cfd1 commit 76bf3b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
10 changes: 7 additions & 3 deletions smarts/core/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,9 +1513,7 @@ def _check_ground_plane(self):
)
self._setup_pybullet_ground_plane(self._bullet_client)

def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
if not self._envision:
return
def _gen_envision_state(self, provider_state: ProviderState, obs, scores):

filter = self._envision.envision_state_filter

Expand Down Expand Up @@ -1671,6 +1669,12 @@ def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
ego_agent_ids=list(self._agent_manager.ego_agent_ids),
frame_time=self._rounder(self._elapsed_sim_time + self._total_sim_time),
)
return state

def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
if not self._envision:
return
state = self._gen_envision_state(provider_state, obs, scores)
self._envision.send(state)

def _try_emit_visdom_obs(self, obs):
Expand Down
22 changes: 4 additions & 18 deletions smarts/env/gymnasium/hiway_env_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ class HiWayEnvV1(gym.Env):
action_space: spaces.Space
observation_space: spaces.Space

# Created
_np_random: Optional[np.random.Generator] = None

def __init__(
self,
scenarios: Sequence[str],
Expand Down Expand Up @@ -403,27 +400,16 @@ def close(self):
if self._smarts is not None:
self._smarts.destroy()

@property
def unwrapped(self) -> gym.Env[ObsType, ActType]:
"""Returns the base non-wrapped environment.
Returns:
Env: The base non-wrapped :class:`gymnasium.Env` instance
"""
return self

@property
def np_random(self) -> np.random.Generator:
"""Returns the environment's internal :attr:`_np_random` that if not set will initialise with a random seed.
Returns:
Instances of `np.random.Generator`.
"""
return super().np_random

@np_random.setter
def np_random(self, value: np.random.Generator):
self._np_random = value
warnings.warn(
"The generator in `np_random` is not used. This method will have no effect on the environment."
)
super()._np_random = value

def __str__(self):
"""Returns a string of the environment with :attr:`spec` id's if :attr:`spec`.
Expand Down

0 comments on commit 76bf3b8

Please sign in to comment.