Skip to content

Commit

Permalink
changed directory structure; test for dynamic Scenic
Browse files Browse the repository at this point in the history
  • Loading branch information
dfremont committed Sep 15, 2020
1 parent dab2bef commit c951eff
Show file tree
Hide file tree
Showing 89 changed files with 7,833 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Scenic cache files
*.snet

# Webots temporary files
.*.wbproj

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ If you have any problems using VerifAI, please submit an issue to the GitHub rep

* _examples_: examples and additional documentation for particular simulators, including CARLA, Webots, X-Plane, and OpenAI Gym;

* _verifai_: the source for the `verifai` package proper.
* _src/verifai_: the source for the `verifai` package proper;

* _tests_: the VerifAI test suite.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7,778 changes: 7,778 additions & 0 deletions tests/Town01.xodr

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/scenic_driving.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import scenic

param map = localPath('Town01.xodr')
param carla_map = 'Town01'

model scenic.domains.driving.model

simulator scenic.core.simulators.DummySimulator()

ego = Car at Range(-5, 5) @ 2, with behavior FollowLaneBehavior
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dotmap import DotMap

import pytest
from verifai.tests.utils import sampleWithFeedback, checkSaveRestore
from tests.utils import sampleWithFeedback, checkSaveRestore

pytest.importorskip('GPyOpt')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from verifai.samplers import *
from dotmap import DotMap

from verifai.tests.utils import sampleWithFeedback, checkSaveRestore
from tests.utils import sampleWithFeedback, checkSaveRestore

def test_crossEntropy():
carDomain = Struct({
Expand Down
2 changes: 1 addition & 1 deletion verifai/tests/test_distBO.py → tests/test_distBO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from verifai.samplers import *
from dotmap import DotMap
from verifai.samplers.dist_BO import DistBayesOptSampler
from verifai.tests.utils import sampleWithFeedback
from tests.utils import sampleWithFeedback

import pytest

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion verifai/tests/test_halton.py → tests/test_halton.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from verifai.features import *
from verifai.samplers import *
from verifai.tests.utils import checkSaveRestore
from tests.utils import checkSaveRestore

def test_halton():
carDomain = Struct({
Expand Down
File renamed without changes.
43 changes: 34 additions & 9 deletions verifai/tests/test_scenic.py → tests/test_scenic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

import pytest
from dotmap import DotMap

from verifai.samplers.scenic_sampler import ScenicSampler
from verifai.tests.utils import sampleWithFeedback, checkSaveRestore
from verifai.scenic_server import ScenicServer
from verifai.falsifier import generic_falsifier
from tests.utils import sampleWithFeedback, checkSaveRestore

## Basic

Expand Down Expand Up @@ -87,20 +90,42 @@ def test_active_save_restore(tmpdir):

## Webots

def test_webots_mars(pathToLocalFile):
path = pathToLocalFile('scenic_mars.scenic')
sampler = ScenicSampler.fromScenario(path)

def runSampler(sampler):
for i in range(3):
sample = sampler.nextSample()
print(f'Sample #{i}:')
print(sample)

def test_webots_mars(pathToLocalFile):
path = pathToLocalFile('scenic_mars.scenic')
sampler = ScenicSampler.fromScenario(path)
runSampler(sampler)

def test_webots_road(pathToLocalFile):
path = pathToLocalFile('scenic_road.scenic')
sampler = ScenicSampler.fromScenario(path)
runSampler(sampler)

for i in range(3):
sample = sampler.nextSample()
print(f'Sample #{i}:')
print(sample)
## Driving domain

def test_driving(pathToLocalFile):
path = pathToLocalFile('scenic_driving.scenic')
sampler = ScenicSampler.fromScenario(path)
runSampler(sampler)

## Dynamic scenarios

def test_driving_dynamic(pathToLocalFile):
path = pathToLocalFile('scenic_driving.scenic')
sampler = ScenicSampler.fromScenario(path)
falsifier_params = DotMap(
n_iters=3,
save_error_table=False,
save_safe_table=False,
)
server_options = DotMap(maxSteps=2, verbosity=3)
falsifier = generic_falsifier(sampler=sampler,
falsifier_params=falsifier_params,
server_class=ScenicServer,
server_options=server_options)
falsifier.run_falsifier()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from verifai.features import *
from verifai.samplers import *
from verifai.tests.utils import sampleWithFeedback, checkSaveRestore
from tests.utils import sampleWithFeedback, checkSaveRestore

## Utilities

Expand Down
File renamed without changes.

0 comments on commit c951eff

Please sign in to comment.