glass-dev / glass

Generator for Large Scale Structure
https://glass.readthedocs.io
MIT License
31 stars 8 forks source link

API(points): return flat lists of points #86

Closed ntessore closed 1 year ago

ntessore commented 1 year ago

Amend the changes #80 to return only flat, 1-D columns of longitudes and latitudes from the glass.points sampling functions, even for inputs with extra dimensions. This makes it easier to pass the results to other functions, which might not accept ragged lists of arrays.

If extra dimensions are present in the inputs, the output count is an array of counts with the shape of the extra dimensions. This is convenient, because it can be passed directly e.g. as the size= argument in random sampling functions.

A count array also makes it easy to create a column of labels for the sampled populations of points:

label_col = np.repeat(labels, count.flat)

The change also introduces a broadcast_leading_axes() utility function that broadcasts a varying number leading axes for given arrays.

BREAKING CHANGE: Point sampling functions return flat arrays.

Fixes: #85