def broadcast_1d_array(arr, ndim, axis=<NUM_LIT:1>):
ext_arr = arr<EOL>for i in range(ndim - <NUM_LIT:1>):<EOL><INDENT>ext_arr = np.expand_dims(ext_arr, axis=axis)<EOL><DEDENT>return ext_arr<EOL>
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).

Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.