Spaces:
Running on Zero
Running on Zero
Download tests/test_large_visualization.py from ImAnouar1/SocialDynamics_Lab: direct link, hf CLI and curl.
- Browser
- Download file 900 Bytes
-
https://huggingface.co/spaces/ImAnouar1/SocialDynamics_Lab/resolve/main/tests/test_large_visualization.py
- Command line
-
hf download hf://spaces/ImAnouar1/SocialDynamics_Lab/tests/test_large_visualization.py
-
curl -L -o test_large_visualization.py https://huggingface.co/spaces/ImAnouar1/SocialDynamics_Lab/resolve/main/tests/test_large_visualization.py
900 Bytes
| from unittest.mock import patch | |
| from socialdynamics.simulation import OpinionSimulation, SimulationConfig | |
| from socialdynamics.visualization import influence_figure, network_figure | |
| def test_large_network_visualization_avoids_spring_layout(): | |
| for n_agents in (500, 1000): | |
| sim = OpinionSimulation(SimulationConfig(n_agents=n_agents, steps=1, seed=11)) | |
| with patch("networkx.spring_layout", side_effect=AssertionError("spring_layout called")): | |
| fig = network_figure(sim) | |
| assert len(fig.data) == 2 | |
| assert len(sim._layout_cache) == n_agents | |
| def test_influence_map_supports_all_population_sizes(): | |
| for n_agents in (100, 500, 1000): | |
| sim = OpinionSimulation(SimulationConfig(n_agents=n_agents, steps=2, seed=7)) | |
| sim.run() | |
| fig = influence_figure(sim) | |
| assert len(fig.data) == 1 | |
| assert len(fig.data[0].x) == n_agents | |