Assemble four equal-shape NumPy arrays into a 2x2 block matrix with np.block
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Write `assemble_block(top_left, top_right, bottom_left, bottom_right)` that stitches four 2-D arrays of identical shape `(m, n)` into a 2x2 grid of shape `(2m, 2n)`, with blocks placed by name. Build the result with `np.block`, not nested `hstack`/`vstack` or manual index copying.
```python
tl = np.array([[1, 2], [3, 4]])
tr = np.array([[5, 6], [7, 8]])
bl = np.array([[9, 10], [11, 12]])
br = np.array([[13, 14], [15, 16]])
assemble_block(tl, tr, bl, br)
# [[ 1 2 5 6]
# [ 3 4 7 8]
# [ 9 10 13 14]
# [11 12 15 16]]
```
```hint Nesting and axes
The nested list you pass describes the layout. Work out which axis the innermost lists are joined along and which axis the outer list is joined along, then order the four names to match.
```
### Constraints & Assumptions
- All four inputs are 2-D and share the same shape `(m, n)`.
- The output has shape `(2m, 2n)`, with `top_left` occupying rows `0` to `m - 1` and columns `0` to `n - 1`.
### What a Strong Answer Covers
- Places each block in its named corner and shows how to check the placement.
- Explains which axis each nesting level is joined along.
- States the output shape, its dtype when inputs differ, and that the result is a new array.
- Handles bad input (wrong number of dimensions, mismatched shapes) with a clear error.
### Follow-up Questions
- How does `np.block` differ from `np.concatenate` here?
- What happens if the blocks have mismatched shapes?
- What happens if you pass 1-D arrays, or blocks with different dtypes?
- How would you assemble an r-by-c grid of blocks?
Overview: Combine four 2-D NumPy arrays of the same shape into one matrix twice as tall and twice as wide, with each block in its named corner. It tests how a nested block layout maps to array axes, shape checks on the inputs, and how block assembly compares with plain concatenation.