-
Notifications
You must be signed in to change notification settings - Fork 4
Tests env #36
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
base: master
Are you sure you want to change the base?
Tests env #36
Conversation
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.
Looks good to me! Just two small questions/comments.
|
||
self.visible.extend(lane_leaders) | ||
self.visible.extend(lane_followers) | ||
self.visible.extend([lane_follower]) |
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.
Are these changes just to more clearly show when the list of visible cars is being changed?
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.
this is to fix a bug where the list of visible vehicles sometimes includes '' strings
eta = 8 # 0.25 | ||
rl_actions = np.array([1]) | ||
accel_threshold = 0 | ||
np.tanh(np.mean(np.abs(rl_actions))) |
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.
is this line supposed to do anything?
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.
nice catch, will fix
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.
done
flow/envs/base_env.py
Outdated
@@ -124,6 +124,18 @@ def __init__(self, env_params, sumo_params, scenario): | |||
if not hasattr(self.env_params, "evaluate"): | |||
self.env_params.evaluate = False | |||
|
|||
# list of sorted ids (defaults to regular list of vehicle ids if the | |||
# "sort_vehicles" attribute in env_params is set to False) | |||
self.sorted_ids = deepcopy(self.vehicles.get_ids()) |
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.
This doesn't seem like it's sorted?
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.
good point, I'll call the method here as well
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.
+1
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.
done
|
||
class TestTestEnv(unittest.TestCase): | ||
|
||
"""Tests the TestEnv environment in flow/envs/test.py""" |
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.
This isn't a comment, but the name of this class is surreal.
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.
hahaha
/ self.env.scenario.max_speed, | ||
self.env.get_x_by_id(veh_id) / | ||
self.env.scenario.length] | ||
for veh_id in self.env.sorted_ids]) |
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 sort of agree with Nish, what is the point of tests like these? This is just copying code and checking that the code you've copied is the same. Note, this is meant constructively; I'm sure I'm missing something.
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.
they're for two reasons:
- solidifying certain aspects of the codebase that we are not interested in developing on anymore. Personally for me, the environments feel very fragile as is.
- maintaining some level of confidence that an environment will train. since we cannot easily run RL tests to completion, we can at least ensure that the environments are still the same (I have lost a good deal of time trying to figure out what's changed in an old environment just to find out that I or someone else had introduced new bugs, probably when they were trying something locally)
generally speaking, tests for environments should cover more intricate methods, but the ones I tested were pretty generic, minus I guess testing the reset
method for WaveAttenuationEnv
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.
Okay, I'm convinced of the value of this for now. We should replace these later with some sort of regression testing (TBD).
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.
So in conclusion, it's a saved version of the envs.
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.
yup, I was thinking the same about regression testing. these could just be a sanity test for now
Broadly, what's the point of these tests of the envs? It seems like the code is copied from the original env and then we check that the code has been copied correctly. |
@@ -29,17 +29,20 @@ class and returns a real number. | |||
|
|||
@property | |||
def action_space(self): | |||
return Box(low=0, high=0, shape=0, dtype=np.float32) | |||
return Box(low=0, high=0, shape=(0,), dtype=np.float32) |
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.
This file should not be named test.py as it's a little confusing
self.assertAlmostEqual(self.env.vehicles.get_speed("rl_0"), 0.1, 2) | ||
|
||
|
||
class TestLaneChangeAccelEnv(unittest.TestCase): |
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.
If this test is specific to the loop, it's a little misnamed
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.
LGTM, see +1 comment as it is unaddressed I think.
WaveAttenuationEnv
)base_env
and theVehicles
class while writing the environment tests