Skip to content

Commit da9e095

Browse files
Rename test_add to test_add_with_unique_id
1 parent f2ffac7 commit da9e095

File tree

4 files changed

+170
-170
lines changed

4 files changed

+170
-170
lines changed

tests/pandas/test_grid_pandas.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
)
1111
from tests.polars.test_agentset_polars import (
1212
ExampleAgentSetPolars,
13-
fix2_AgentSetPolars,
13+
fix2_AgentSetPolars_with_unique_id,
1414
)
1515

1616

1717
# This serves otherwise ruff complains about the two fixtures not being used
1818
def not_called():
1919
fix1_AgentSetPandas_with_unique_id()
20-
fix2_AgentSetPolars()
20+
fix2_AgentSetPolars_with_unique_id()
2121

2222

2323
@tg.typechecked
@@ -26,10 +26,10 @@ class TestGridPandas:
2626
def model(
2727
self,
2828
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
29-
fix2_AgentSetPolars: ExampleAgentSetPolars,
29+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
3030
) -> ModelDF:
3131
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])
3333
return model
3434

3535
@pytest.fixture
@@ -126,7 +126,7 @@ def test_get_directions(
126126
self,
127127
grid_moore: GridPandas,
128128
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
129-
fix2_AgentSetPolars: ExampleAgentSetPolars,
129+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
130130
):
131131
# Test with GridCoordinate
132132
dir = grid_moore.get_directions(pos0=[1, 1], pos1=[2, 2])
@@ -143,11 +143,11 @@ def test_get_directions(
143143
# Test with missing agents (raises ValueError)
144144
with pytest.raises(ValueError):
145145
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
147147
)
148148

149149
# 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]])
151151
dir = grid_moore.get_directions(agents0=[0, 1], agents1=[4, 5])
152152
assert isinstance(dir, pd.DataFrame)
153153
assert dir["dim_0"].to_list() == [0, -1]
@@ -156,7 +156,7 @@ def test_get_directions(
156156
# Test with two AgentSetDFs
157157
grid_moore.place_agents([2, 3], [[1, 1], [2, 2]])
158158
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
160160
)
161161
assert isinstance(dir, pd.DataFrame)
162162
assert dir["dim_0"].to_list() == [0, -1, 0, -1]
@@ -181,7 +181,7 @@ def test_get_distances(
181181
self,
182182
grid_moore: GridPandas,
183183
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
184-
fix2_AgentSetPolars: ExampleAgentSetPolars,
184+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
185185
):
186186
# Test with GridCoordinate
187187
dist = grid_moore.get_distances(pos0=[1, 1], pos1=[2, 2])
@@ -196,19 +196,19 @@ def test_get_distances(
196196
# Test with missing agents (raises ValueError)
197197
with pytest.raises(ValueError):
198198
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
200200
)
201201

202202
# 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]])
204204
dist = grid_moore.get_distances(agents0=[0, 1], agents1=[4, 5])
205205
assert isinstance(dist, pd.DataFrame)
206206
assert np.allclose(dist["distance"].to_list(), [1.0, np.sqrt(2)])
207207

208208
# Test with two AgentSetDFs
209209
grid_moore.place_agents([2, 3], [[1, 1], [2, 2]])
210210
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
212212
)
213213
assert isinstance(dist, pd.DataFrame)
214214
assert np.allclose(dist["distance"].to_list(), [1.0, np.sqrt(2), 1.0, 1.0])
@@ -430,7 +430,7 @@ def test_get_neighborhood(
430430

431431
def test_get_neighbors(
432432
self,
433-
fix2_AgentSetPolars: ExampleAgentSetPolars,
433+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
434434
grid_moore: GridPandas,
435435
grid_hexagonal: GridPandas,
436436
grid_von_neumann: GridPandas,
@@ -582,7 +582,7 @@ def test_move_agents(
582582
self,
583583
grid_moore: GridPandas,
584584
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
585-
fix2_AgentSetPolars: ExampleAgentSetPolars,
585+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
586586
):
587587
# Test with IdsLike
588588
space = grid_moore.move_agents(agents=1, pos=[1, 1], inplace=False)
@@ -595,7 +595,7 @@ def test_move_agents(
595595
# Test with AgentSetDF
596596
with pytest.warns(RuntimeWarning):
597597
space = grid_moore.move_agents(
598-
agents=fix2_AgentSetPolars,
598+
agents=fix2_AgentSetPolars_with_unique_id,
599599
pos=[[0, 0], [1, 0], [2, 0], [0, 1]],
600600
inplace=False,
601601
)
@@ -608,7 +608,7 @@ def test_move_agents(
608608
# Test with Collection[AgentSetDF]
609609
with pytest.warns(RuntimeWarning):
610610
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],
612612
pos=[[0, 2], [1, 2], [2, 2], [0, 1], [1, 1], [2, 1], [0, 0], [1, 0]],
613613
inplace=False,
614614
)
@@ -762,7 +762,7 @@ def test_place_agents(
762762
self,
763763
grid_moore: GridPandas,
764764
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
765-
fix2_AgentSetPolars: ExampleAgentSetPolars,
765+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
766766
):
767767
# Test with IdsLike
768768
with pytest.warns(RuntimeWarning):
@@ -785,7 +785,7 @@ def test_place_agents(
785785

786786
# Test with AgentSetDF
787787
space = grid_moore.place_agents(
788-
agents=fix2_AgentSetPolars,
788+
agents=fix2_AgentSetPolars_with_unique_id,
789789
pos=[[0, 0], [1, 0], [2, 0], [0, 1]],
790790
inplace=False,
791791
)
@@ -798,7 +798,7 @@ def test_place_agents(
798798
# Test with Collection[AgentSetDF]
799799
with pytest.warns(RuntimeWarning):
800800
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],
802802
pos=[[0, 2], [1, 2], [2, 2], [0, 1], [1, 1], [2, 1], [0, 0], [1, 0]],
803803
inplace=False,
804804
)
@@ -955,7 +955,7 @@ def test_remove_agents(
955955
self,
956956
grid_moore: GridPandas,
957957
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
958-
fix2_AgentSetPolars: ExampleAgentSetPolars,
958+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
959959
):
960960
grid_moore.move_agents(
961961
[0, 1, 2, 3, 4, 5, 6, 7],
@@ -982,7 +982,7 @@ def test_remove_agents(
982982

983983
# Test with Collection[AgentSetDF]
984984
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
986986
)
987987
assert [
988988
x for id in space.model.agents.index.values() for x in id.to_list()
@@ -1153,7 +1153,7 @@ def test_swap_agents(
11531153
self,
11541154
grid_moore: GridPandas,
11551155
fix1_AgentSetPandas_with_unique_id: ExampleAgentSetPandas,
1156-
fix2_AgentSetPolars: ExampleAgentSetPolars,
1156+
fix2_AgentSetPolars_with_unique_id: ExampleAgentSetPolars,
11571157
):
11581158
grid_moore.move_agents(
11591159
[0, 1, 2, 3, 4, 5, 6, 7],
@@ -1167,7 +1167,7 @@ def test_swap_agents(
11671167
assert space.agents.loc[3].tolist() == grid_moore.agents.loc[1].tolist()
11681168
# Test with AgentSetDFs
11691169
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
11711171
)
11721172
assert space.agents.loc[0].to_list() == grid_moore.agents.loc[4].to_list()
11731173
assert space.agents.loc[1].to_list() == grid_moore.agents.loc[5].to_list()

0 commit comments

Comments
 (0)