コード例 #1
0
def multiple_day_ahead_beliefs_about_ex_post_time_slot_event(
        ex_post_time_slot_sensor: DBSensor, test_source_a: DBBeliefSource):
    """Define multiple day-ahead beliefs about an ex post time slot event."""
    n = 10
    event_start = datetime(2025, 1, 2, 22, 45, tzinfo=utc)
    beliefs = []
    for i in range(n):
        belief = DBTimedBelief(
            source=test_source_a,
            sensor=ex_post_time_slot_sensor,
            value=10 + i,
            belief_time=ex_post_time_slot_sensor.knowledge_time(event_start) -
            timedelta(hours=i + 1),
            event_start=event_start,
        )
        session.add(belief)
        beliefs.append(belief)
    return beliefs
コード例 #2
0
def test_ex_post_time_slot_sensor(ex_post_time_slot_sensor: DBSensor):
    event_start = datetime(2018, 1, 1, 15, tzinfo=utc)
    assert ex_post_time_slot_sensor.knowledge_time(event_start) < event_start
コード例 #3
0
def test_time_slot_sensor(time_slot_sensor: DBSensor):
    assert time_slot_sensor.event_resolution == timedelta(minutes=15)
    event_start = datetime(2018, 1, 1, 15, tzinfo=utc)
    event_end = event_start + time_slot_sensor.event_resolution
    assert time_slot_sensor.knowledge_time(event_start) == event_end