partitions = np.array([[1, 1, 2, 2, 1, 2, 2, 2, 1, 1], [1, 2, 2, 1, 2, 1, 2,
    2, 2, 1], [1, 1, 1, 2, 2, 2, 1, 3, 3, 2]])
n = np.max(partitions)
d = (partitions.T[:, (None), :] == np.arange(1, n + 1)[:, (None)]).astype(np
    .int)
d = d.reshape(partitions.shape[1], -1)
d.dot(d.T)
numpy equivalent of matlab dummyvar