10
10
)
11
11
from tests .polars .test_agentset_polars import (
12
12
ExampleAgentSetPolars ,
13
- fix2_AgentSetPolars ,
13
+ fix2_AgentSetPolars_with_unique_id ,
14
14
)
15
15
16
16
17
17
# This serves otherwise ruff complains about the two fixtures not being used
18
18
def not_called ():
19
19
fix1_AgentSetPandas_with_unique_id ()
20
- fix2_AgentSetPolars ()
20
+ fix2_AgentSetPolars_with_unique_id ()
21
21
22
22
23
23
@tg .typechecked
@@ -26,10 +26,10 @@ class TestGridPandas:
26
26
def model (
27
27
self ,
28
28
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
29
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
29
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
30
30
) -> ModelDF :
31
31
model = ModelDF ()
32
- model .agents .add ([fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars ])
32
+ model .agents .add ([fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars_with_unique_id ])
33
33
return model
34
34
35
35
@pytest .fixture
@@ -126,7 +126,7 @@ def test_get_directions(
126
126
self ,
127
127
grid_moore : GridPandas ,
128
128
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
129
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
129
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
130
130
):
131
131
# Test with GridCoordinate
132
132
dir = grid_moore .get_directions (pos0 = [1 , 1 ], pos1 = [2 , 2 ])
@@ -143,11 +143,11 @@ def test_get_directions(
143
143
# Test with missing agents (raises ValueError)
144
144
with pytest .raises (ValueError ):
145
145
grid_moore .get_directions (
146
- agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars
146
+ agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars_with_unique_id
147
147
)
148
148
149
149
# Test with IdsLike
150
- grid_moore .place_agents (fix2_AgentSetPolars , [[0 , 1 ], [0 , 2 ], [1 , 0 ], [1 , 2 ]])
150
+ grid_moore .place_agents (fix2_AgentSetPolars_with_unique_id , [[0 , 1 ], [0 , 2 ], [1 , 0 ], [1 , 2 ]])
151
151
dir = grid_moore .get_directions (agents0 = [0 , 1 ], agents1 = [4 , 5 ])
152
152
assert isinstance (dir , pd .DataFrame )
153
153
assert dir ["dim_0" ].to_list () == [0 , - 1 ]
@@ -156,7 +156,7 @@ def test_get_directions(
156
156
# Test with two AgentSetDFs
157
157
grid_moore .place_agents ([2 , 3 ], [[1 , 1 ], [2 , 2 ]])
158
158
dir = grid_moore .get_directions (
159
- agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars
159
+ agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars_with_unique_id
160
160
)
161
161
assert isinstance (dir , pd .DataFrame )
162
162
assert dir ["dim_0" ].to_list () == [0 , - 1 , 0 , - 1 ]
@@ -181,7 +181,7 @@ def test_get_distances(
181
181
self ,
182
182
grid_moore : GridPandas ,
183
183
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
184
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
184
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
185
185
):
186
186
# Test with GridCoordinate
187
187
dist = grid_moore .get_distances (pos0 = [1 , 1 ], pos1 = [2 , 2 ])
@@ -196,19 +196,19 @@ def test_get_distances(
196
196
# Test with missing agents (raises ValueError)
197
197
with pytest .raises (ValueError ):
198
198
grid_moore .get_distances (
199
- agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars
199
+ agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars_with_unique_id
200
200
)
201
201
202
202
# Test with IdsLike
203
- grid_moore .place_agents (fix2_AgentSetPolars , [[0 , 1 ], [0 , 2 ], [1 , 0 ], [1 , 2 ]])
203
+ grid_moore .place_agents (fix2_AgentSetPolars_with_unique_id , [[0 , 1 ], [0 , 2 ], [1 , 0 ], [1 , 2 ]])
204
204
dist = grid_moore .get_distances (agents0 = [0 , 1 ], agents1 = [4 , 5 ])
205
205
assert isinstance (dist , pd .DataFrame )
206
206
assert np .allclose (dist ["distance" ].to_list (), [1.0 , np .sqrt (2 )])
207
207
208
208
# Test with two AgentSetDFs
209
209
grid_moore .place_agents ([2 , 3 ], [[1 , 1 ], [2 , 2 ]])
210
210
dist = grid_moore .get_distances (
211
- agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars
211
+ agents0 = fix1_AgentSetPandas_with_unique_id , agents1 = fix2_AgentSetPolars_with_unique_id
212
212
)
213
213
assert isinstance (dist , pd .DataFrame )
214
214
assert np .allclose (dist ["distance" ].to_list (), [1.0 , np .sqrt (2 ), 1.0 , 1.0 ])
@@ -430,7 +430,7 @@ def test_get_neighborhood(
430
430
431
431
def test_get_neighbors (
432
432
self ,
433
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
433
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
434
434
grid_moore : GridPandas ,
435
435
grid_hexagonal : GridPandas ,
436
436
grid_von_neumann : GridPandas ,
@@ -582,7 +582,7 @@ def test_move_agents(
582
582
self ,
583
583
grid_moore : GridPandas ,
584
584
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
585
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
585
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
586
586
):
587
587
# Test with IdsLike
588
588
space = grid_moore .move_agents (agents = 1 , pos = [1 , 1 ], inplace = False )
@@ -595,7 +595,7 @@ def test_move_agents(
595
595
# Test with AgentSetDF
596
596
with pytest .warns (RuntimeWarning ):
597
597
space = grid_moore .move_agents (
598
- agents = fix2_AgentSetPolars ,
598
+ agents = fix2_AgentSetPolars_with_unique_id ,
599
599
pos = [[0 , 0 ], [1 , 0 ], [2 , 0 ], [0 , 1 ]],
600
600
inplace = False ,
601
601
)
@@ -608,7 +608,7 @@ def test_move_agents(
608
608
# Test with Collection[AgentSetDF]
609
609
with pytest .warns (RuntimeWarning ):
610
610
space = grid_moore .move_agents (
611
- agents = [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars ],
611
+ agents = [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars_with_unique_id ],
612
612
pos = [[0 , 2 ], [1 , 2 ], [2 , 2 ], [0 , 1 ], [1 , 1 ], [2 , 1 ], [0 , 0 ], [1 , 0 ]],
613
613
inplace = False ,
614
614
)
@@ -762,7 +762,7 @@ def test_place_agents(
762
762
self ,
763
763
grid_moore : GridPandas ,
764
764
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
765
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
765
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
766
766
):
767
767
# Test with IdsLike
768
768
with pytest .warns (RuntimeWarning ):
@@ -785,7 +785,7 @@ def test_place_agents(
785
785
786
786
# Test with AgentSetDF
787
787
space = grid_moore .place_agents (
788
- agents = fix2_AgentSetPolars ,
788
+ agents = fix2_AgentSetPolars_with_unique_id ,
789
789
pos = [[0 , 0 ], [1 , 0 ], [2 , 0 ], [0 , 1 ]],
790
790
inplace = False ,
791
791
)
@@ -798,7 +798,7 @@ def test_place_agents(
798
798
# Test with Collection[AgentSetDF]
799
799
with pytest .warns (RuntimeWarning ):
800
800
space = grid_moore .place_agents (
801
- agents = [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars ],
801
+ agents = [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars_with_unique_id ],
802
802
pos = [[0 , 2 ], [1 , 2 ], [2 , 2 ], [0 , 1 ], [1 , 1 ], [2 , 1 ], [0 , 0 ], [1 , 0 ]],
803
803
inplace = False ,
804
804
)
@@ -955,7 +955,7 @@ def test_remove_agents(
955
955
self ,
956
956
grid_moore : GridPandas ,
957
957
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
958
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
958
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
959
959
):
960
960
grid_moore .move_agents (
961
961
[0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ],
@@ -982,7 +982,7 @@ def test_remove_agents(
982
982
983
983
# Test with Collection[AgentSetDF]
984
984
space = grid_moore .remove_agents (
985
- [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars ], inplace = False
985
+ [fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars_with_unique_id ], inplace = False
986
986
)
987
987
assert [
988
988
x for id in space .model .agents .index .values () for x in id .to_list ()
@@ -1153,7 +1153,7 @@ def test_swap_agents(
1153
1153
self ,
1154
1154
grid_moore : GridPandas ,
1155
1155
fix1_AgentSetPandas_with_unique_id : ExampleAgentSetPandas ,
1156
- fix2_AgentSetPolars : ExampleAgentSetPolars ,
1156
+ fix2_AgentSetPolars_with_unique_id : ExampleAgentSetPolars ,
1157
1157
):
1158
1158
grid_moore .move_agents (
1159
1159
[0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ],
@@ -1167,7 +1167,7 @@ def test_swap_agents(
1167
1167
assert space .agents .loc [3 ].tolist () == grid_moore .agents .loc [1 ].tolist ()
1168
1168
# Test with AgentSetDFs
1169
1169
space = grid_moore .swap_agents (
1170
- fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars , inplace = False
1170
+ fix1_AgentSetPandas_with_unique_id , fix2_AgentSetPolars_with_unique_id , inplace = False
1171
1171
)
1172
1172
assert space .agents .loc [0 ].to_list () == grid_moore .agents .loc [4 ].to_list ()
1173
1173
assert space .agents .loc [1 ].to_list () == grid_moore .agents .loc [5 ].to_list ()
0 commit comments