-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.py
More file actions
41 lines (33 loc) · 1.16 KB
/
action.py
File metadata and controls
41 lines (33 loc) · 1.16 KB
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
class Action:
def __init__(self, q, theta):
"""
Initializes an action with a given quantity (q) and theta value.
Args:
q (float): Production quantity.
theta (float): Theta value.
"""
self.q = q
self.theta = theta
def __hash__(self):
"""
Returns the hash value of the Action object based on its q and theta values.
Returns:
int: Hash value of the Action object.
"""
return hash((self.q, self.theta))
def __eq__(self, other):
"""
Compares two Action objects for equality based on their q and theta values.
Args:
other (Action): The other Action object to compare.
Returns:
bool: True if the Action objects are equal, False otherwise.
"""
return isinstance(other, Action) and self.q == other.q and self.theta == other.theta
def __repr__(self):
"""
Returns a string representation of the Action object.
Returns:
str: String representation of the Action object.
"""
return f"Action(q={self.q}, theta={self.theta})"