-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import gym | ||
import unittest | ||
from simglucose.controller.basal_bolus_ctrller import BBController | ||
from datetime import datetime | ||
|
||
|
||
class TestSeed(unittest.TestCase): | ||
def test_changing_seed_generates_different_results(self): | ||
from gym.envs.registration import register | ||
register( | ||
id='simglucose-adolescent2-v0', | ||
entry_point='simglucose.envs:T1DSimEnv', | ||
kwargs={'patient_name': 'adolescent#002'} | ||
) | ||
|
||
env = gym.make('simglucose-adolescent2-v0') | ||
|
||
env.seed(0) | ||
observation_seed0 = env.reset() | ||
self.assertEqual(env.env.scenario.start_time, datetime(2018, 1, 1, 16, 0, 0)) | ||
|
||
env.seed(1000) | ||
observation_seed1 = env.reset() | ||
self.assertEqual(env.env.scenario.start_time, datetime(2018, 1, 1, 10, 0, 0)) | ||
|
||
self.assertNotEqual(observation_seed0, observation_seed1) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |