Esempio n. 1
0
    def test_update_attr_avg(self):
        """ should update arguments correctly with avg operator. """
        logging_callback = LoggingCallback()
        logging_callback.reward = 0
        logging_callback.reward_seen = 2
        logging_callback._update_attr('reward', 1, 'avg')
        check.equal(logging_callback.reward, 1 / 3)
        check.equal(logging_callback.reward_seen, 3)

        # With N/A
        logging_callback = LoggingCallback()
        logging_callback.reward = 'N/A'
        logging_callback.reward_seen = 0
        logging_callback._update_attr('reward', 1, 'avg')
        check.equal(logging_callback.reward, 1)
        check.equal(logging_callback.reward_seen, 1)
Esempio n. 2
0
 def test_update_attr_raise(self):
     """ should raise ValueError if operator is unknowed. """
     with pytest.raises(ValueError, match=r"Unknowed operator.*"):
         logging_callback = LoggingCallback()
         logging_callback.reward = 'N/A'
         logging_callback._update_attr('reward', 1, 'x')
Esempio n. 3
0
 def test_update_attr_last(self):
     """ should update arguments correctly with last operator. """
     logging_callback = LoggingCallback()
     logging_callback.reward = 2
     logging_callback._update_attr('reward', 1, 'last')
     check.equal(logging_callback.reward, 1)