Dimensionality code and tests