Tests for Task 4: Is transmission possible¶
This page describes the tests for Task 4. For each task, we provide a short description of the test, information about how to recreate the test in ipython3, and the expected result.
To run the tasks for Task 4, run the following command at the Linux command-line:
$ py.test -xvk 'possible'
When you run this command, you’ll see that some tests are labelled as SKIPPED. You can ignore these tests for now,we’ll come back to them later when we introduce vaccines into our simulation.
Test 0¶
Description: Small city where everyone is susceptible.
To run this test in ipython3 :
city = [('S', 0), # loc: 0
('S', 0), # loc: 1
('S', 0), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 1¶
Description: Small city where everyone is recovered
To run this test in ipython3 :
city = [('R', 0), # loc: 0
('R', 0), # loc: 1
('R', 0), # loc: 2
('R', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 2¶
Description: Small city here everyone is infected
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 0), # loc: 1
('I', 0), # loc: 2
('I', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 3¶
Description: Larger city with mix of susceptible and recovered people
To run this test in ipython3 :
city = [('R', 0), # loc: 0
('S', 0), # loc: 1
('R', 0), # loc: 2
('S', 0), # loc: 3
('R', 0), # loc: 4
('S', 0), # loc: 5
('R', 0), # loc: 6
('S', 0), # loc: 7
('R', 0), # loc: 8
('S', 0), # loc: 9
('R', 0), # loc: 10
('S', 0), # loc: 11
('R', 0), # loc: 12
('S', 0), # loc: 13
('R', 0), # loc: 14
('S', 0), # loc: 15
('R', 0), # loc: 16
('S', 0), # loc: 17
('R', 0), # loc: 18
('S', 0)] # loc: 19
sir.is_transmission_possible(city)
Expected result: False
Test 4¶
Description: Small city: susceptible person in location 1 has an infected neighbor
To run this test in ipython3 :
city = [('I', 1), # loc: 0
('S', 0), # loc: 1
('S', 0), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 5¶
Description: Small city: susceptible people in locations 0 and 2 have infected neighbors
To run this test in ipython3 :
city = [('S', 0), # loc: 0
('I', 1), # loc: 1
('S', 0), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 6¶
Description: Small city: susceptible people in locations 1 and 3 have infected neighbors
To run this test in ipython3 :
city = [('S', 0), # loc: 0
('S', 0), # loc: 1
('I', 1), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 7¶
Description: Small city: susceptible people in locations 0 and 2 have infected neighbors
To run this test in ipython3 :
city = [('S', 0), # loc: 0
('S', 0), # loc: 1
('S', 0), # loc: 2
('I', 1)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 8¶
Description: Small city with one infected in slot 0, rest recovered
To run this test in ipython3 :
city = [('I', 1), # loc: 0
('R', 0), # loc: 1
('R', 0), # loc: 2
('R', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 9¶
Description: Larger city with a mix of infected and recovered people.
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 0), # loc: 2
('I', 1), # loc: 3
('I', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('I', 0), # loc: 8
('I', 1), # loc: 9
('I', 0), # loc: 10
('R', 1), # loc: 11
('I', 0), # loc: 12
('I', 1), # loc: 13
('R', 2), # loc: 14
('I', 1), # loc: 15
('I', 0), # loc: 16
('I', 1), # loc: 17
('I', 3), # loc: 18
('I', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: False
Test 10¶
Description: Larger city with one susceptible person who has an infected neighbor.
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 0), # loc: 2
('I', 1), # loc: 3
('I', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('I', 0), # loc: 8
('S', 1), # loc: 9
('I', 0), # loc: 10
('I', 1), # loc: 11
('R', 0), # loc: 12
('I', 1), # loc: 13
('I', 2), # loc: 14
('I', 1), # loc: 15
('I', 0), # loc: 16
('R', 1), # loc: 17
('I', 3), # loc: 18
('R', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: True
Test 11¶
Description: Larger city, more than one susceptible person with an infected neighbor.
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 0), # loc: 2
('I', 1), # loc: 3
('I', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('I', 0), # loc: 8
('S', 1), # loc: 9
('I', 0), # loc: 10
('I', 1), # loc: 11
('R', 0), # loc: 12
('I', 1), # loc: 13
('I', 2), # loc: 14
('I', 1), # loc: 15
('I', 0), # loc: 16
('S', 1), # loc: 17
('I', 3), # loc: 18
('R', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: True
Test 12¶
Description: Larger city, all susceptible people are protected by recovered people
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 0), # loc: 2
('I', 1), # loc: 3
('I', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('R', 0), # loc: 8
('S', 1), # loc: 9
('S', 0), # loc: 10
('S', 1), # loc: 11
('R', 0), # loc: 12
('I', 1), # loc: 13
('I', 2), # loc: 14
('I', 1), # loc: 15
('I', 0), # loc: 16
('I', 1), # loc: 17
('I', 3), # loc: 18
('R', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: False
Tests for Task 6-4: add vaxxed people¶
This section describes tests for Task 4 that include vaccinated people. Work through these tests after you have completed Tasks 1-5.
To run the tasks for Task 6-4, run the following command at the Linux command-line:
$ py.test -xvk possible --runvax
Test 0¶
Description: Small city with all vaxxed people
To run this test in ipython3 :
city = [('V', 0), # loc: 0
('V', 0), # loc: 1
('V', 0), # loc: 2
('V', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 1¶
Description: Larger city with mix of susceptible, recovered, and vaxxed
To run this test in ipython3 :
city = [('R', 0), # loc: 0
('S', 0), # loc: 1
('R', 0), # loc: 2
('S', 0), # loc: 3
('R', 0), # loc: 4
('S', 0), # loc: 5
('R', 0), # loc: 6
('V', 0), # loc: 7
('R', 0), # loc: 8
('S', 0), # loc: 9
('R', 0), # loc: 10
('V', 0), # loc: 11
('R', 0), # loc: 12
('S', 0), # loc: 13
('R', 0), # loc: 14
('V', 0), # loc: 15
('R', 0), # loc: 16
('S', 0), # loc: 17
('R', 0), # loc: 18
('S', 0)] # loc: 19
sir.is_transmission_possible(city)
Expected result: False
Test 2¶
Description: Small city: infected followed by vaxxed
To run this test in ipython3 :
city = [('I', 1), # loc: 0
('V', 0), # loc: 1
('V', 0), # loc: 2
('V', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 3¶
Description: Small city: susceptible and vaxxed vaxxed
To run this test in ipython3 :
city = [('V', 1), # loc: 0
('S', 0), # loc: 1
('V', 0), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: False
Test 4¶
Description: Small city: susceptible person at location 3 has an infected neighbor.
To run this test in ipython3 :
city = [('V', 1), # loc: 0
('V', 0), # loc: 1
('I', 0), # loc: 2
('S', 0), # loc: 3
('R', 0)] # loc: 4
sir.is_transmission_possible(city)
Expected result: True
Test 5¶
Description: Small city: susceptible person at location 3 has an infected neighbor.
To run this test in ipython3 :
city = [('I', 1), # loc: 0
('V', 0), # loc: 1
('S', 0), # loc: 2
('S', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 6¶
Description: Small city: susceptible person at location 0 has an infected neighbor.
To run this test in ipython3 :
city = [('S', 1), # loc: 0
('V', 0), # loc: 1
('S', 0), # loc: 2
('I', 0)] # loc: 3
sir.is_transmission_possible(city)
Expected result: True
Test 7¶
Description: Larger city: several susceptible people have infected nighbors
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('V', 0), # loc: 2
('V', 1), # loc: 3
('V', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('I', 0), # loc: 8
('S', 1), # loc: 9
('I', 0), # loc: 10
('I', 1), # loc: 11
('R', 0), # loc: 12
('I', 1), # loc: 13
('I', 2), # loc: 14
('I', 1), # loc: 15
('I', 0), # loc: 16
('S', 1), # loc: 17
('I', 3), # loc: 18
('R', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: True
Test 8¶
Description: Larger city: all susceptible people are protected by vaxed or recovered people
To run this test in ipython3 :
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('V', 0), # loc: 2
('V', 1), # loc: 3
('V', 0), # loc: 4
('I', 1), # loc: 5
('I', 0), # loc: 6
('R', 1), # loc: 7
('V', 0), # loc: 8
('S', 1), # loc: 9
('V', 0), # loc: 10
('I', 1), # loc: 11
('R', 0), # loc: 12
('I', 1), # loc: 13
('I', 2), # loc: 14
('I', 1), # loc: 15
('V', 0), # loc: 16
('S', 1), # loc: 17
('R', 3), # loc: 18
('R', 1)] # loc: 19
sir.is_transmission_possible(city)
Expected result: False