Tests for Task 11: Vaccinate and simulate

This page describes the tests for Task 11. 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 11, run the following command at the Linux command-line:

$ py.test -xvk vaccinate_and_simulate

Test 0

Description: No one wants to be vaccinated except the infected person. No one gets vaxxed

To run this test in ipython3 :

city = [('S', 0, False),    # loc: 0
        ('S', 10, False),    # loc: 1
        ('S', 0, False),    # loc: 2
        ('S', 0, False),    # loc: 3
        ('S', 0, False),    # loc: 4
        ('I', 0, True),    # loc: 5
        ('S', 0, False)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0, 20170217)

Expected result:

([['I', 1],    # loc: 0
  ['I', 0],    # loc: 1
  ['I', 0],    # loc: 2
  ['I', 1],    # loc: 3
  ['I', 2],    # loc: 4
  ['R', 0],    # loc: 5
  ['I', 2]],    # loc: 6
 3)

Test 1

Description: Everyone is falling over themselves to get vaccinated.

To run this test in ipython3 :

city = [('S', 0, True),    # loc: 0
        ('S', 0, True),    # loc: 1
        ('S', 0, True),    # loc: 2
        ('S', 0, True),    # loc: 3
        ('S', 0, True),    # loc: 4
        ('I', 1, True),    # loc: 5
        ('S', 0, True)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0.5, 20170217)

Expected result:

([['I', 0],    # loc: 0
  ['I', 2],    # loc: 1
  ['R', 1],    # loc: 2
  ['R', 4],    # loc: 3
  ['R', 5],    # loc: 4
  ['R', 7],    # loc: 5
  ['R', 5]],    # loc: 6
 9)

Test 2

Description: Everyone wants to get vaccinated, but no one is eligible.

To run this test in ipython3 :

city = [('I', 0, True),    # loc: 0
        ('I', 1, True),    # loc: 1
        ('I', 2, True),    # loc: 2
        ('R', 0, True)]    # loc: 3
sir.vaccinate_and_simulate(city, 3, 0, 20170217)

Expected result:

([['I', 0],    # loc: 0
  ['I', 1],    # loc: 1
  ['I', 2],    # loc: 2
  ['R', 0]],    # loc: 3
 0)

Test 3

Description: High level of interest. All but one susceptible person ends up vaccinated. Low infection probability.

To run this test in ipython3 :

city = [('S', 0, True),    # loc: 0
        ('S', 0, True),    # loc: 1
        ('S', 0, True),    # loc: 2
        ('S', 0, True),    # loc: 3
        ('S', 0, False),    # loc: 4
        ('I', 0, True),    # loc: 5
        ('S', 0, True)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0.2, 20170217)

Expected result:

([['V', 4],    # loc: 0
  ['V', 4],    # loc: 1
  ['V', 4],    # loc: 2
  ['V', 4],    # loc: 3
  ['R', 0],    # loc: 4
  ['R', 1],    # loc: 5
  ['V', 4]],    # loc: 6
 4)

Test 4

Description: High level of interest. All but one susceptible person ends up vaccinated. High infection probability.

To run this test in ipython3 :

city = [('S', 0, True),    # loc: 0
        ('S', 0, True),    # loc: 1
        ('S', 0, True),    # loc: 2
        ('S', 0, True),    # loc: 3
        ('S', 0, False),    # loc: 4
        ('I', 0, True),    # loc: 5
        ('S', 0, True)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0.8, 20170217)

Expected result:

([['I', 2],    # loc: 0
  ['I', 1],    # loc: 1
  ['I', 0],    # loc: 2
  ['I', 2],    # loc: 3
  ['R', 0],    # loc: 4
  ['R', 1],    # loc: 5
  ['R', 0]],    # loc: 6
 4)

Test 5

Description: Uses a different seed.

To run this test in ipython3 :

city = [('S', 0, True),    # loc: 0
        ('S', 0, True),    # loc: 1
        ('S', 0, True),    # loc: 2
        ('S', 0, True),    # loc: 3
        ('S', 0, False),    # loc: 4
        ('I', 0, True),    # loc: 5
        ('S', 0, True)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0.2, 20170218)

Expected result:

([['I', 0],    # loc: 0
  ['I', 2],    # loc: 1
  ['R', 2],    # loc: 2
  ['R', 4],    # loc: 3
  ['R', 7],    # loc: 4
  ['R', 8],    # loc: 5
  ['R', 5]],    # loc: 6
 11)

Test 6

Description: Uses a different seed.

To run this test in ipython3 :

city = [('S', 0, True),    # loc: 0
        ('S', 0, True),    # loc: 1
        ('S', 0, True),    # loc: 2
        ('S', 0, True),    # loc: 3
        ('S', 0, False),    # loc: 4
        ('I', 0, True),    # loc: 5
        ('S', 0, True)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 0.8, 20170218)

Expected result:

([['I', 1],    # loc: 0
  ['I', 0],    # loc: 1
  ['I', 0],    # loc: 2
  ['I', 1],    # loc: 3
  ['I', 2],    # loc: 4
  ['R', 0],    # loc: 5
  ['I', 2]],    # loc: 6
 3)