Example #1
0
    def test_contains_int(self):
        b = Bureau(User)
        agent = User(15)
        b.add(agent)

        assert 15 in b
        assert 16 not in b
Example #2
0
    def test_del_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)
        b.remove(0)

        assert agent not in b
        assert 0 not in b._agents
Example #3
0
    def test_add_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert agent in b
        assert 0 in b._agents
        assert b.get(0) == agent
Example #4
0
    def test_export_contents(self):
        b = Bureau(User)
        for i in range(10):
            b.add(User(i))

        export = b.export()
        pprint(export)

        assert b.export()[0] == User(0).export()
        assert b.export()[5] == User(5).export()
Example #5
0
    def __init__(self):
        """
            Initialize SWAP instance
            Args:
                p0: Prior probability real - in general this is derived
                empirically by considering the occurence frequency of
                interesting objects that are expertly identified within a
                fiducial dataset. It is required to initialize the likelihood
                formulation framework for each subject prior to reception of
                the first volunteer classification.

                epsilon: Estimated volunteer performance - This is either
                set arbitrarily or might be based upon judicious assesment of
                cohort-wide volunteer performance on a similar analysis task.
                It is required to initialize the likelihood formulation
                framework for each volunteer's agent.
        """

        # initialize bureaus to manage user / subject agents
        self.users = Bureau(User)
        self.subjects = Bureau(Subject)
Example #6
0
    def test_notify(self, mock):
        l = Ledger(15)
        t = Transaction(mock(), 0)
        print(mock().id)
        l.add(t)
        l.clear_changes()

        l.notify(16, Bureau(Subject))

        t.notify.assert_called_once_with(mock())
        assert l.stale is True
        assert l.changed == [16]
    def __init__(self, t_low, t_high, export=None):
        golds = gold_0 + gold_1
        self.golds = db.getExpertGold(golds)
        self.silver = self.golds.copy()
        self.t_low = t_low
        self.t_high = t_high

        self.bureau = Bureau(Bootstrap_Subject)

        self.metrics = Metrics()

        self.n = 0
Example #8
0
    def test_bureau_stats(self):
        b = Bureau(User)
        b.add(User(0))
        b.add(User(1))
        b.add(User(2))

        for u in b:
            u.ledger.recalculate()

        s = b.stats()
        assert 0 in s.stats
        assert 1 in s.stats
        assert len(s.stats) == 2
Example #9
0
    def test_get_agent_new(self):
        b = Bureau(User)
        u = b.get(15)

        assert type(u) is User
        assert u.id == 15
Example #10
0
    def test_notify_agents_getsagent(self, mock):
        l = Ledger(100)
        _ = [l.add(Transaction(mocksubject(i), 0)) for i in range(5)]

        l.notify_agents(None, Bureau(User))
        assert mock.call_count == 5
Example #11
0
 def test_contains_true(self):
     b = Bureau(User)
     agent = User(15)
     b.add(agent)
     assert agent in b
Example #12
0
    def test_has_false(self):
        b = Bureau(User)

        assert 0 not in b
Example #13
0
    def test_has_true(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert agent in b
Example #14
0
 def test_idset(self):
     b = Bureau(User)
     [b.add(User(i)) for i in range(5)]
     assert b.idset() == set(range(5))
Example #15
0
 def test_get_agent_none(self):
     b = Bureau(User)
     assert b.get(0, make_new=False) is None
Example #16
0
 def test_stats_subject(self):
     b = Bureau(Subject)
     [b.add(Subject(i)) for i in range(5)]
     [s.ledger.recalculate() for s in b]
     b.stats()
Example #17
0
 def test_contains_false(self):
     b = Bureau(User)
     agent = User(15)
     assert agent not in b
Example #18
0
    def test_get_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert b.get(0) == agent
Example #19
0
 def test_add_agent_twice_new(self):
     b = Bureau(User)
     agent = User(0)
     b.add(agent)
     b.add(agent, override=True)
Example #20
0
 def test_add_agent_twice_nonew(self):
     b = Bureau(User)
     agent = User(0)
     b.add(agent)
     with pytest.raises(KeyError):
         b.add(agent, override=False)
Example #21
0
 def test_add_agent_typecheck(self):
     b = Bureau(User)
     agent = Subject(0)
     with pytest.raises(TypeError):
         b.add(agent)
Example #22
0
 def test_init(self):
     b = Bureau(Agent)
     assert b.agent_type is Agent
     assert b._agents == {}
Example #23
0
    def get_bureau(self):
        b = Bureau(Subject)
        for i in range(5):
            b.add(Subject(i))

        return b
Example #24
0
    def test_get_newagent_isadded(self):
        b = Bureau(User)
        u = b.get(15)

        assert u in b
        assert b.get(15) == u
Example #25
0
 def test_stats_users(self):
     b = Bureau(User)
     [b.add(User(i)) for i in range(5)]
     [u.ledger.recalculate() for u in b]
     b.stats()