laser.cohorts.utils
utils
Utility helpers for the laser.cohorts package.
static_routing
static_routing(routing_2d, nticks)
Return a time-invariant 3-D routing view via np.broadcast_to.
Creates a read-only (nticks, nnodes, nnodes) view of a 2-D routing
matrix without allocating a copy. Pass the result directly to
Migration(..., routing=static_routing(r2d, nticks)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
routing_2d
|
ndarray
|
Shape |
required |
nticks
|
int
|
Number of simulation ticks. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Read-only shape |
Example
r2d = np.array([[0, 1], [1, 0]], dtype=np.float64) r3d = static_routing(r2d, nticks=365) r3d.shape (365, 2, 2) r3d.base is r2d False import numpy as np; np.shares_memory(r3d, r2d) True