Tests for Task 9: Vaccinate and run simulation

This page describes the tests for Task 9. 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 9, 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, 0.0),    # loc: 0
        ('S', 10, 0.0),    # loc: 1
        ('S', 0, 0.0),    # loc: 2
        ('S', 0, 0.0),    # loc: 3
        ('S', 0, 0.0),    # loc: 4
        ('I', 0, 1.0),    # loc: 5
        ('S', 0, 0.0)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 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, 1.0),    # loc: 0
        ('S', 0, 1.0),    # loc: 1
        ('S', 0, 1.0),    # loc: 2
        ('S', 0, 1.0),    # loc: 3
        ('S', 0, 1.0),    # loc: 4
        ('I', 5, 1.0),    # loc: 5
        ('S', 0, 1.0)]    # loc: 6
sir.vaccinate_and_simulate(city, 3, 20170217)

Expected result:

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

Test 2

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

To run this test in ipython3 :

city = [('I', 0, 1.0),    # loc: 0
        ('I', 1, 1.0),    # loc: 1
        ('I', 2, 1.0),    # loc: 2
        ('R', 0, 1.0)]    # loc: 3
sir.vaccinate_and_simulate(city, 3, 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.

To run this test in ipython3 :

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

Expected result:

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

Test 4

Description: Citizens with different levels of interest in getting the vaccine. Not everyone who wants the vaccine will get it.

To run this test in ipython3 :

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

Expected result:

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

Test 5

Description: Uses a different seed

To run this test in ipython3 :

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

Expected result:

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