Skip to content

Commit 25d2e4b

Browse files
committed
update numpy typing to be compatible with v2.0
1 parent 9349f08 commit 25d2e4b

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

simulation-system/libs/gym-csle-apt-game/src/gym_csle_apt_game/dao/apt_game_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AptGameConfig(SimulationEnvInputConfig):
1313
def __init__(self, env_name: str,
1414
T: npt.NDArray[Any], O: npt.NDArray[np.int_], Z: npt.NDArray[Any],
1515
C: npt.NDArray[Any], S: npt.NDArray[np.int_], A1: npt.NDArray[np.int_],
16-
A2: npt.NDArray[np.int_], b1: npt.NDArray[np.float_], N: int, p_a: float,
16+
A2: npt.NDArray[np.int_], b1: npt.NDArray[np.float64], N: int, p_a: float,
1717
save_dir: str, checkpoint_traces_freq: int, gamma: float = 1) -> None:
1818
"""
1919
Initializes the DTO

simulation-system/libs/gym-csle-apt-game/src/gym_csle_apt_game/dao/apt_game_state.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AptGameState(JSONSerializable):
1010
Represents the state of the optimal APT game
1111
"""
1212

13-
def __init__(self, b1: npt.NDArray[np.float_]) -> None:
13+
def __init__(self, b1: npt.NDArray[np.float64]) -> None:
1414
"""
1515
Intializes the state
1616

simulation-system/libs/gym-csle-apt-game/src/gym_csle_apt_game/envs/apt_game_mdp_attacker_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, config: AptGameAttackerMdpConfig):
4747
self.reset()
4848
super().__init__()
4949

50-
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.float_]) \
50+
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.float64]) \
5151
-> Tuple[npt.NDArray[Any], int, bool, bool, Dict[str, Any]]:
5252
"""
5353
Takes a step in the environment by executing the given action

simulation-system/libs/gym-csle-apt-game/src/gym_csle_apt_game/util/apt_game_util.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AptGameUtil:
1212
"""
1313

1414
@staticmethod
15-
def b1(N: int) -> npt.NDArray[np.float_]:
15+
def b1(N: int) -> npt.NDArray[np.float64]:
1616
"""
1717
Gets the initial belief
1818
@@ -177,7 +177,7 @@ def sample_next_state(T: npt.NDArray[Any], s: int, a1: int, a2: int, S: npt.NDAr
177177
return int(np.random.choice(np.arange(0, len(S)), p=state_probs))
178178

179179
@staticmethod
180-
def sample_initial_state(b1: npt.NDArray[np.float_]) -> int:
180+
def sample_initial_state(b1: npt.NDArray[np.float64]) -> int:
181181
"""
182182
Samples the initial state
183183
@@ -202,7 +202,7 @@ def sample_next_observation(Z: npt.NDArray[Any], s_prime: int, O: npt.NDArray[np
202202
return int(o)
203203

204204
@staticmethod
205-
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float_], pi2: npt.NDArray[Any],
205+
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any],
206206
config: AptGameConfig) -> float:
207207
"""
208208
A Bayesian filter to compute the belief of player 1
@@ -236,8 +236,8 @@ def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float_], pi2:
236236
return b_prime_s_prime
237237

238238
@staticmethod
239-
def next_belief(o: int, a1: int, b: npt.NDArray[np.float_], pi2: npt.NDArray[Any],
240-
config: AptGameConfig, a2: int = 0, s: int = 0) -> npt.NDArray[np.float_]:
239+
def next_belief(o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any],
240+
config: AptGameConfig, a2: int = 0, s: int = 0) -> npt.NDArray[np.float64]:
241241
"""
242242
Computes the next belief using a Bayesian filter
243243

simulation-system/libs/gym-csle-intrusion-response-game/src/gym_csle_intrusion_response_game/dao/intrusion_response_game_state_local.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class IntrusionResponseGameStateLocal(JSONSerializable):
1111
with public observations)
1212
"""
1313

14-
def __init__(self, d_b1: npt.NDArray[np.float_], a_b1: npt.NDArray[np.float_], s_1_idx: int,
14+
def __init__(self, d_b1: npt.NDArray[np.float64], a_b1: npt.NDArray[np.float64], s_1_idx: int,
1515
S: npt.NDArray[Any], S_A: npt.NDArray[Any], S_D: npt.NDArray[Any]) -> None:
1616
"""
1717
Initializes the DTO

simulation-system/libs/gym-csle-intrusion-response-game/src/gym_csle_intrusion_response_game/dao/local_intrusion_response_game_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class LocalIntrusionResponseGameConfig(JSONSerializable):
1414
def __init__(self, env_name: str, T: npt.NDArray[Any], O: npt.NDArray[np.int_], Z: npt.NDArray[Any],
1515
R: npt.NDArray[Any], S: npt.NDArray[np.int_], S_A: npt.NDArray[np.int_],
1616
S_D: npt.NDArray[np.int_], s_1_idx: int, zones: npt.NDArray[np.int_],
17-
A1: npt.NDArray[np.int_], A2: npt.NDArray[np.int_], d_b1: npt.NDArray[np.float_],
18-
a_b1: npt.NDArray[np.float_], gamma: float,
17+
A1: npt.NDArray[np.int_], A2: npt.NDArray[np.int_], d_b1: npt.NDArray[np.float64],
18+
a_b1: npt.NDArray[np.float64], gamma: float,
1919
beta: float, C_D: npt.NDArray[Any], eta: float, A_P: npt.NDArray[Any],
2020
Z_D_P: npt.NDArray[Any], Z_U: npt.NDArray[Any]) -> None:
2121
"""

simulation-system/libs/gym-csle-intrusion-response-game/src/gym_csle_intrusion_response_game/util/intrusion_response_game_util.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def local_initial_state_idx(initial_zone: int, S: npt.NDArray[Any]) -> int:
140140
raise ValueError("Initial state not recognized")
141141

142142
@staticmethod
143-
def local_initial_state_distribution(initial_state_idx, S: npt.NDArray[Any]) -> npt.NDArray[np.float_]:
143+
def local_initial_state_distribution(initial_state_idx, S: npt.NDArray[Any]) -> npt.NDArray[np.float64]:
144144
"""
145145
Gets the initial state distribution
146146
@@ -153,7 +153,7 @@ def local_initial_state_distribution(initial_state_idx, S: npt.NDArray[Any]) ->
153153
return rho
154154

155155
@staticmethod
156-
def local_initial_defender_belief(S_A: npt.NDArray[Any]) -> npt.NDArray[np.float_]:
156+
def local_initial_defender_belief(S_A: npt.NDArray[Any]) -> npt.NDArray[np.float64]:
157157
"""
158158
Gets the initial defender belief for a local version of the game
159159
@@ -165,7 +165,7 @@ def local_initial_defender_belief(S_A: npt.NDArray[Any]) -> npt.NDArray[np.float
165165
return d_b1
166166

167167
@staticmethod
168-
def local_initial_attacker_belief(S_D: npt.NDArray[Any], initial_zone) -> npt.NDArray[np.float_]:
168+
def local_initial_attacker_belief(S_D: npt.NDArray[Any], initial_zone) -> npt.NDArray[np.float64]:
169169
"""
170170
Gets the initial attacker belief for a local version of the game
171171
@@ -270,7 +270,7 @@ def local_workflow_utility(beta: float, reachable: bool, s: npt.NDArray[Any], in
270270
return beta * impact * int(not IntrusionResponseGameUtil.is_local_state_shutdown_or_redirect(s=s))
271271

272272
@staticmethod
273-
def constant_defender_action_costs(A1: npt.NDArray[np.int_], constant_cost: float) -> npt.NDArray[np.float_]:
273+
def constant_defender_action_costs(A1: npt.NDArray[np.int_], constant_cost: float) -> npt.NDArray[np.float64]:
274274
"""
275275
Returns a vector with the local defender action costs where each action has the same constant cost
276276
@@ -297,7 +297,7 @@ def zones(num_zones: int) -> npt.NDArray[Any]:
297297
return np.array(list(range(1, num_zones + 1)))
298298

299299
@staticmethod
300-
def constant_zone_utilities(zones: npt.NDArray[np.int_], constant_utility: float) -> npt.NDArray[np.float_]:
300+
def constant_zone_utilities(zones: npt.NDArray[np.int_], constant_utility: float) -> npt.NDArray[np.float64]:
301301
"""
302302
Returns a vector with the zone utilities where each zone has the same constant utility
303303
@@ -312,7 +312,7 @@ def constant_zone_utilities(zones: npt.NDArray[np.int_], constant_utility: float
312312

313313
@staticmethod
314314
def constant_zone_detection_probabilities(zones: npt.NDArray[np.int_], constant_detection_prob: float) \
315-
-> npt.NDArray[np.float_]:
315+
-> npt.NDArray[np.float64]:
316316
"""
317317
Returns a vector with the zone detection probabilities where each zone as the same uniform detection
318318
probability

simulation-system/libs/gym-csle-stopping-game/src/gym_csle_stopping_game/dao/stopping_game_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, env_name: str,
1414
T: npt.NDArray[Any], O: npt.NDArray[np.int_], Z: npt.NDArray[Any],
1515
R: npt.NDArray[Any], S: npt.NDArray[np.int_], A1: npt.NDArray[np.int_],
1616
A2: npt.NDArray[np.int_], L: int, R_INT: int, R_COST: int, R_SLA: int, R_ST: int,
17-
b1: npt.NDArray[np.float_],
17+
b1: npt.NDArray[np.float64],
1818
save_dir: str, checkpoint_traces_freq: int, gamma: float = 1, compute_beliefs: bool = True,
1919
save_trace: bool = True) -> None:
2020
"""

simulation-system/libs/gym-csle-stopping-game/src/gym_csle_stopping_game/dao/stopping_game_state.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class StoppingGameState(JSONSerializable):
1010
Represents the state of the optimal stopping game
1111
"""
1212

13-
def __init__(self, b1: npt.NDArray[np.float_], L: int) -> None:
13+
def __init__(self, b1: npt.NDArray[np.float64], L: int) -> None:
1414
"""
1515
Intializes the state
1616

simulation-system/libs/gym-csle-stopping-game/src/gym_csle_stopping_game/envs/stopping_game_mdp_attacker_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, config: StoppingGameAttackerMdpConfig):
4848
self.reset()
4949
super().__init__()
5050

51-
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.float_]) \
51+
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.float64]) \
5252
-> Tuple[npt.NDArray[Any], int, bool, bool, Dict[str, Any]]:
5353
"""
5454
Takes a step in the environment by executing the given action

simulation-system/libs/gym-csle-stopping-game/src/gym_csle_stopping_game/util/stopping_game_util.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class StoppingGameUtil:
1111
"""
1212

1313
@staticmethod
14-
def b1() -> npt.NDArray[np.float_]:
14+
def b1() -> npt.NDArray[np.float64]:
1515
"""
1616
Gets the initial belief
1717
@@ -233,7 +233,7 @@ def sample_next_state(T: npt.NDArray[Any], l: int, s: int, a1: int, a2: int, S:
233233
return int(np.random.choice(np.arange(0, len(S)), p=state_probs))
234234

235235
@staticmethod
236-
def sample_initial_state(b1: npt.NDArray[np.float_]) -> int:
236+
def sample_initial_state(b1: npt.NDArray[np.float64]) -> int:
237237
"""
238238
Samples the initial state
239239
@@ -264,7 +264,7 @@ def sample_next_observation(Z: npt.NDArray[Any], s_prime: int, O: npt.NDArray[np
264264
return int(o)
265265

266266
@staticmethod
267-
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float_], pi2: npt.NDArray[Any], l: int,
267+
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any], l: int,
268268
config: StoppingGameConfig) -> float:
269269
"""
270270
A Bayesian filter to compute the belief of player 1
@@ -302,8 +302,8 @@ def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float_], pi2:
302302
return float(b_prime_s_prime)
303303

304304
@staticmethod
305-
def next_belief(o: int, a1: int, b: npt.NDArray[np.float_], pi2: npt.NDArray[Any],
306-
config: StoppingGameConfig, l: int, a2: int = 0, s: int = 0) -> npt.NDArray[np.float_]:
305+
def next_belief(o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any],
306+
config: StoppingGameConfig, l: int, a2: int = 0, s: int = 0) -> npt.NDArray[np.float64]:
307307
"""
308308
Computes the next belief using a Bayesian filter
309309

0 commit comments

Comments
 (0)