-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Round environment #48
Changes from all commits
dfb9dc1
ac9e493
d08a7e3
3a073dd
e61ecca
9b3e07f
c40ff66
4fde313
465e8bb
5f486f6
b990a13
768941d
12a35dc
377b298
b74d604
fdd57fd
d3359aa
8e02862
887199b
edf6d39
09f67da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Docker Login | ||
env: | ||
DOCKER_USER: ${{secrets.DOCKER_USER}} | ||
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | ||
run: | | ||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | ||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile --tag ${{secrets.DOCKER_USER}}/scioip34abm:latest | ||
- name: Push Docker image to DockerHub | ||
run: docker push ${{secrets.DOCKER_USER}}/scioip34abm:latest |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Python package | ||
|
||
on: [push] | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,4 +245,7 @@ cython_debug/ | |
.idea | ||
|
||
# ignore all copied env files | ||
*_copy.env | ||
*_copy.env | ||
|
||
# ignore videos | ||
*.mp4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import numpy as np | ||
import pytest | ||
from unittest import mock | ||
|
||
from abm.projects.cooperative_signaling.cs_agent import cs_supcalc | ||
|
||
|
@@ -9,11 +10,44 @@ def test_random_walk(): | |
# set random seed | ||
np.random.seed(42) | ||
|
||
dvel, dtheta = cs_supcalc.random_walk() | ||
|
||
# passing values to override abm.movementparams values read from .env file | ||
dvel, dtheta = cs_supcalc.random_walk(desired_vel=1, exp_theta_min=-0.3, exp_theta_max=0.3) | ||
assert dvel == 1.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for me random walk test fails can you please check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah it is because the env parameters, we might want to mock this so that a new local env file won't influence the test results There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is strange because all the tests in the workflow passed 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you replace the .env file (i.e. you are after running the playground tool) the tests won't pass. Or do they pass for you even with a new .env file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never had any problems with tests before or after running the playground 😅🤔 |
||
assert dtheta == -0.0752759286915825 | ||
|
||
# test case: not passing min theta, read from module fixed var | ||
with mock.patch('abm.contrib.movement_params.exp_theta_min', -0.5): | ||
dvel, dtheta = cs_supcalc.random_walk(desired_vel=1, exp_theta_min=None, exp_theta_max=0.3) | ||
assert dvel == 1.0 | ||
assert dtheta == 0.26057144512793295 | ||
|
||
# test case: not passing velocity, read from module fixed var | ||
with mock.patch('abm.contrib.movement_params.exp_vel_max', 3): | ||
dvel, dtheta = cs_supcalc.random_walk(desired_vel=None, exp_theta_min=-0.3, exp_theta_max=0.3) | ||
assert dvel == 3 | ||
assert dtheta == 0.13919636508684308 | ||
|
||
|
||
def test_reflection_from_circular_wall(): | ||
"""Test reflection_from_circular_wall()""" | ||
|
||
new_orientation = cs_supcalc.reflection_from_circular_wall( | ||
0, 1, np.pi / 2) | ||
assert new_orientation == np.pi * 3 / 2 | ||
|
||
new_orientation = cs_supcalc.reflection_from_circular_wall( | ||
1, 0, np.pi) | ||
assert new_orientation == np.pi * 2 | ||
|
||
# test very flat reflection angle | ||
orient = np.pi + np.pi / 6 | ||
vec_i = [np.cos(orient), np.sin(orient)] | ||
# orientation inside the circle | ||
i_orientation = np.pi + np.arctan2(vec_i[1], vec_i[0]) | ||
new_orientation = cs_supcalc.reflection_from_circular_wall( | ||
0, 1, orient) | ||
assert new_orientation == i_orientation | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"meter, prev_meter, prev_theta, taxis_dir, new_theta, new_taxis_dir", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this fixes the behavior, but I am wondering why it is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would guess it has something to do with the curvature of the boundary and the step size per update 😅