Skip to content

Commit

Permalink
update tests to use Spielberg as default test map.
Browse files Browse the repository at this point in the history
remove test on old maps (eg., Skirk, Vegas).
linting.
  • Loading branch information
luigiberducci committed Dec 19, 2023
1 parent 01acbc5 commit 90602df
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion tests/legacy_scan_gen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np

import gymnasium as gym
Expand Down
1 change: 0 additions & 1 deletion tests/test_collision_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,3 @@ def test_fps(self):
fps = 1000 / elapsed
print("gjk fps:", fps)
# self.assertGreater(fps, 500) This is a platform dependent test, not ideal.

7 changes: 6 additions & 1 deletion tests/test_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import unittest

import numpy as np
from f110_gym.envs.dynamic_models import vehicle_dynamics_ks, vehicle_dynamics_st, func_KS, func_ST
from f110_gym.envs.dynamic_models import (
vehicle_dynamics_ks,
vehicle_dynamics_st,
func_KS,
func_ST,
)


class DynamicsTest(unittest.TestCase):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_f110_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class TestEnvInterface(unittest.TestCase):
def _make_env(self, config={}):

conf = {
"map": "Spielberg",
"num_agents": 1,
Expand All @@ -18,7 +17,10 @@ def _make_env(self, config={}):
}
conf = deep_update(conf, config)

env = gym.make("f110_gym:f110-v0", config=conf,)
env = gym.make(
"f110_gym:f110-v0",
config=conf,
)
return env

def test_gymnasium_api(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class TestObservationInterface(unittest.TestCase):
@staticmethod
def _make_env(config={}) -> F110Env:

conf = {
"map": "Spielberg",
"num_agents": 1,
Expand Down Expand Up @@ -228,5 +227,7 @@ def test_gymnasium_api(self):
for obs_type_id in obs_type_ids:
env = self._make_env(config={"observation_config": {"type": obs_type_id}})
check_env(
env.unwrapped, f"Observation {obs_type_id} breaks the gymnasium API", skip_render_check=True
env.unwrapped,
f"Observation {obs_type_id} breaks the gymnasium API",
skip_render_check=True,
)
1 change: 0 additions & 1 deletion tests/test_scan_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def setUp(self):
wdir = os.path.dirname(os.path.abspath(__file__))
self.sample_scans = np.load(f"{wdir}/legacy_scan.npz")


def _test_map_scan(self, map_name: str, debug=False):
scan_rng = np.random.default_rng(seed=12345)
scan_sim = ScanSimulator2D(self.num_beams, self.fov)
Expand Down
13 changes: 1 addition & 12 deletions tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@


class TestTrack(unittest.TestCase):
def test_loading_default_tracks(self):
track_names = ["Berlin", "Example", "Levine", "Skirk", "StataBasement", "Vegas"]
for track_name in track_names:
track = Track.from_track_name(track_name)
self.assertEqual(track.spec.name, track_name)

def test_error_handling(self):
wrong_track_name = "i_dont_exists"
self.assertRaises(FileNotFoundError, Track.from_track_name, wrong_track_name)

def test_raceline(self):
track_name = "Example" # Example is the only track with a raceline for now
track_name = "Spielberg"
track = Track.from_track_name(track_name)

# check raceline is not None
Expand All @@ -39,11 +33,6 @@ def test_raceline(self):
self.assertTrue(np.isclose(track.raceline.vxs, raceline[:, vx_idx]).all())
self.assertTrue(np.isclose(track.raceline.axs, raceline[:, ax_idx]).all())

def test_missing_raceline(self):
track = Track.from_track_name("Vegas")
self.assertEqual(track.raceline, None)
self.assertEqual(track.centerline, None)

def test_map_dir_structure(self):
"""
Check that the map dir structure is correct:
Expand Down

0 comments on commit 90602df

Please sign in to comment.