def test_statements_added_to_agent(self):
     env = Environment(self.agents, self.statements)
     student = PoissonStudent(name='John', lam=2)
     env.add_agent(student)
     self.assertEqual(len(env._agents[student.name].dt),
                      len(env._statements[student.name]),
                      msg="The agent statements and dt have different "
                      "sizes")
 def test_add_agent(self):
     env = Environment(self.agents, self.statements)
     student = PoissonStudent(name='John', lam=2)
     env.add_agent(student)
     self.assertEqual(len(env.agents),
                      2,
                      msg="Adding an agent didn't change the number of" +
                      "agent in the environment")
 def setUp(self):
     self.agents = [PoissonStudent(name='Ed', role=Role.STUDENT, lam=2)]
     self.statements = [{
         'timestamp': 0.7354156191538802,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 0.8781497209426028,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 1.144202469575485,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 1.427249032536914,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 1.5319657470218193,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 1.9421492844170225,
         'verb': 'studied',
         'actor': 'Ed',
         'object': 'resource'
     }, {
         'timestamp': 1.9421492844170225,
         'verb': 'studied',
         'actor': 'John',
         'object': 'resource'
     }, {
         'timestamp': 1.9421492844170225,
         'verb': 'studied',
         'actor': 'John',
         'object': 'resource'
     }, {
         'timestamp': 1.9421492844170225,
         'verb': 'studied',
         'actor': 'Kevin',
         'object': 'resource'
     }]
     self.base_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), os.pardir))
 def test_fit(self):
     statement = {
         'actor': u'123456789-1234-1234-1234-12345678901234',
         'verb': u'http://adlnet.gov/expapi/verbs/completed',
         'timestamp': 1519862425.0
     }
     user_name = '123456789-1234-1234-1234-12345678901234'
     lam = Uniform('lam', lower=0, upper=1)
     s1 = PoissonStudent(user_name, lam=lam)
     env = Environment([s1], [statement])
     env.add_agent(s1)
     res = env.fit([lam], method='mcmc')
     self.assertIsInstance(res,
                           MCMC,
                           msg="The output of fit is not an PYMC instance")
 def test_wrong_assignement(self):
     student = PoissonStudent(name='Ed', lam=1)
     with self.assertRaises(WrongAssignment):
         student.update(statements)
 def test_poisson_update(self):
     student = PoissonStudent(name='Dave', lam=1)
     student.update(statements)
     eq = np.array_equal(student.expT.value, [1, 1, 1, 1])
     self.assertTrue(eq)
 def test_poisson_get_timestamps(self):
     student = PoissonStudent(name='Dave', lam=1)
     timestamps = student._get_timestamps(statements)
     self.assertEqual(timestamps, [1, 2, 3, 4])
 def test_poisson_study(self):
     student = PoissonStudent(name='Ed', lam=1)
     statement = student.study()
     self.assertIsInstance(statement['timestamp'], float)