Skip to content

Commit f9dc947

Browse files
committed
Prepare spatial plotting release 0.6.1
1 parent 4308b9e commit f9dc947

File tree

6 files changed

+278
-89
lines changed

6 files changed

+278
-89
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "canns-lib"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2021"
55
license = "Apache-2.0"
66
authors = ["Sichao He <[email protected]>"]

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,34 @@ Plots and CSV summaries are emitted to `benchmarks/spatial/outputs/`.
8585
- **Full parity** with RatInABox API (Environment, Agent, trajectory import/export)
8686
- **Polygon & hole support** with adaptive projection and wall vectors
8787
- **Parity comparison tools** in `example/trajectory_comparison.py`
88+
- **Visualization utilities**: drop-in replacements for RatInABox's plotting
89+
helpers (trajectory, heatmaps, histograms)
8890
- **Benchmark scripts** for long-step drift and speedup under
8991
`benchmarks/spatial/`
9092

93+
#### Visualization Helpers
94+
95+
```python
96+
from canns_lib import spatial
97+
98+
env = spatial.Environment(dimensionality="2D", boundary_conditions="solid")
99+
agent = spatial.Agent(env, rng_seed=2025)
100+
101+
for _ in range(2_000):
102+
agent.update(dt=0.02)
103+
104+
# Trajectory with RatInABox-style colour fading and agent marker
105+
agent.plot_trajectory(color="changing", colorbar=True)
106+
107+
# Other helpers mirror RatInABox naming
108+
agent.plot_position_heatmap()
109+
agent.plot_histogram_of_speeds()
110+
agent.plot_histogram_of_rotational_velocities()
111+
```
112+
113+
See `example/spatial_plotting_demo.py` for a full script that produces the
114+
trajectory, heatmap, and histogram figures showcased above.
115+
91116
### 🚀 Coming Soon
92117

93118
- **Dynamics**: High-performance dynamics computation for neural networks

example/spatial_plotting_demo.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Demonstrate trajectory plotting helpers for canns_lib.spatial.Agent.
33
44
The script mirrors RatInABox usage: we create an environment with walls and a
5-
central hole, simulate a stochastic agent, and save several plots:
5+
central hole, simulate two stochastic agents, and save several plots:
66
77
- trajectory.png: path overlaid on the environment
88
- heatmap.png: spatial occupancy heatmap
@@ -60,12 +60,24 @@
6060
def main() -> None:
6161
env = spatial.Environment(**ENVIRONMENT_PARAMS)
6262
agent = spatial.Agent(env, params=AGENT_PARAMS, rng_seed=2025, init_pos=[0.4, 0.2])
63+
agent_two = spatial.Agent(
64+
env,
65+
params={**AGENT_PARAMS, "speed_std": 0.03},
66+
rng_seed=2026,
67+
init_pos=[0.75, 0.7],
68+
)
6369

6470
for _ in range(2000):
6571
agent.update(dt=0.02)
72+
agent_two.update(dt=0.02)
6673

6774
# Trajectory plot
68-
fig, ax = agent.plot_trajectory()
75+
fig, ax = agent.plot_trajectory(
76+
color="changing",
77+
colorbar=True,
78+
decay_point_size=True,
79+
plot_all_agents=True,
80+
)
6981
fig.savefig(OUTPUT_DIR / "trajectory.png", dpi=150)
7082
plt.close(fig)
7183

python/canns_lib/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Project-wide version string."""
22

3-
__version__ = "0.6.0"
3+
__version__ = "0.6.1"

0 commit comments

Comments
 (0)