-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.py
96 lines (71 loc) · 2.08 KB
/
events.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
===========================
Events associated with model function.
===========================
Dr. Cai Wingfield
---------------------------
Embodied Cognition Lab
Department of Psychology
University of Lancaster
caiwingfield.net
---------------------------
2019
---------------------------
"""
from abc import ABC
from dataclasses import dataclass
from typing import Set
from .basic_types import ActivationValue, Item
@dataclass
class ModelEvent(ABC):
"""An event associated with model activity."""
# The time at which the event occurred.
time: int
# Events are always Truthy, so we can use None as the Falsy alternative.
def __bool__(self) -> bool: return True
@dataclass
class ItemEvent(ModelEvent, ABC):
"""An event involving an item."""
# The item being activated.
item: Item
@dataclass
class BufferEvent(ModelEvent, ABC):
"""Events involving the working memory buffer."""
pass
@dataclass
class SubstitutionEvent(BufferEvent):
"""Represents a substitution of an item in the buffer."""
# New item entering the buffer as part of the substitution
new_item: Item
# Item being displaced as part of the substitution
displaced_item: Item
@dataclass
class ItemActivatedEvent(ItemEvent):
"""An item is activated."""
activation: ActivationValue
fired: bool
@dataclass
class ItemEnteredBufferEvent(BufferEvent, ItemActivatedEvent):
"""An item was activated and entered the working memory buffer."""
pass
@dataclass
class ItemLeftBufferEvent(BufferEvent, ItemEvent):
"""An item left the buffer."""
pass
@dataclass
class ItemDecayedOutEvent(ItemLeftBufferEvent):
"""An item left the buffer by decaying."""
pass
@dataclass
class ItemDisplacedEvent(ItemLeftBufferEvent):
"""An item left the buffer by being displaced."""
pass
@dataclass
class BufferFloodEvent(BufferEvent):
"""The buffer becomes full after having each member replaced."""
pass
@dataclass
class BailoutEvent(ModelEvent):
"""Model running ended with a bailout"""
concurrent_activations: int