# 02 · broadcasting **演示**:`(3,)` 与 `(4,1)` 广播成 `(4,3)`;`(3,)` 与 `(4,)` 不能广播,抛 `ValueError`。规则:从右对齐,维度相等或为 1。 **运行**: ```sh uv run python examples/33-numpy-vectorization/02-broadcasting/broadcasting.py ``` **预期输出**(3.12.9 + numpy 2.5.5): ```text shape: (4, 3) grid: [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]] broadcast_shapes: (3, 4) scalar: (4, 3) error: operands could not be broadcast together with shapes (3,) (4,) ``` **依赖**:`uv sync --group science`(numpy)。 **注意**:广播不复制数据,但结果会分配新数组;不确定形状时先用 `np.broadcast_shapes` 检查。