Utilities

utils.normalize_columns(matrix)[source]

Normalize the input matrix such that each column of the result matrix sums to one.

utils.normalize_rows(matrix)[source]

Normalize the input matrix such that each row of the result matrix sums to one.

utils.xy_inside_horseshoe(xx, yy, horseshoe_curve)[source]

Check whether a set of coordinates are inside the horseshoe shape.

Parameters:

xx, yy: ndarrays of the same size

The (x,y) coordinates to be determined whether inside the horseshoe.

horseshoe_curve: ndarray of size `Nx2`

Each row of the matrix is an (x,y) coordinate for a monochromatic color, and the wavelength of those colors should increase from short (blue) to long (red) monotonically.

Returns:

A boolean ndarray of the same size as xx and yy.