```
def checkerboard(shape):
return np.indices(shape).sum(axis=0) % 2
```

Most compact, probably the fastest, and also the only solution posted that generalizes to n-dimensions.

### Related Contents:

- Cartesian product of x and y array points into single array of 2D points
- NumPy array is not JSON serializable
- Is there any numpy group by function?
- Compiling numpy with OpenBLAS integration
- Plotting a 2D heatmap with Matplotlib
- Quick way to upsample numpy array by nearest neighbor tiling [duplicate]
- Numpy matrix to array
- How do you use the ellipsis slicing syntax in Python?
- Is it possible to vectorize recursive calculation of a NumPy array where each element depends on the previous one?
- Numpy random choice to produce a 2D-array with all unique values
- Bin elements per row – Vectorized 2D Bincount for NumPy
- Most efficient way to find mode in numpy array
- How to check if a value is in the list in selection from pandas data frame?
- Import Error: No module named numpy
- Pandas: Subtracting two date columns and the result being an integer
- Transform a set of numbers in numpy so that each number gets converted into a number of other numbers which are less than it
- How to get stable results with TensorFlow, setting random seed
- Select multiple ranges of columns in Pandas DataFrame
- Numpy: Fix array with rows of different lengths by filling the empty elements with zeros
- LogisticRegression: Unknown label type: ‘continuous’ using sklearn in python
- How to make a multidimension numpy array with a varying row size?
- How do I compute derivative using Numpy?
- Force NumPy ndarray to take ownership of its memory in Cython
- how to extract frequency associated with fft values in python
- Numpy – add row to array
- Handling of duplicate indices in NumPy assignments
- python pandas flatten a dataframe to a list
- Index 2D numpy array by a 2D array of indices without loops
- Slicing a numpy array along a dynamically specified axis
- NumPy Broadcasting: Calculating sum of squared differences between two arrays
- Linear regression with matplotlib / numpy
- How to apply numpy.linalg.norm to each row of a matrix?
- Binary random array with a specific proportion of ones?
- Numpy: Creating a complex array from 2 real ones?
- ‘invalid value encountered in double_scalars’ warning, possibly numpy
- Convert RGB to black OR white
- Shuffling NumPy array along a given axis
- NotImplementedError: Cannot convert a symbolic Tensor (lstm_2/strided_slice:0) to a numpy array. T
- Circular shift of vector (equivalent to numpy.roll)
- How to fix ‘numpy.ndarray’ object has no attribute ‘get_figure’ when plotting subplots
- How to get the indices list of all NaN value in numpy array?
- Linear regression of arrays containing NANs in Python/Numpy
- Numpy individual element access slower than for lists
- How to convert a 3d numpy array to 2d
- Create new dataframe in pandas with dynamic names also add new column
- Numpy array dimensions
- How to display progress of scipy.optimize function?
- Sort array’s rows by another array in Python
- Select elements of numpy array via boolean mask array
- How to access a column in a list of lists in python