to_block¶
- giant.ray_tracer.utilities.to_block(vals)[source]¶
This helper function takes a list of lists/arrays and puts them all into a single contiguous array
This is used when ray tracing rays that have ignore lists of different lengths. It works by iterating through, determining the maximum length of the “rows”, creating a new array of -1 with this many columns, and then assigning each row to this new array.
For instance, an input of the form
[[1, 2, 3], [0, 1], [7, 8, 3, 4]]
will be converted to
np.array([[1, 2, 3, -1], [0, 1, -1, -1], [7, 8, 3, 4]])
- Parameters:
vals (Sequence | ndarray) – A ragged list of lists or arrays that is to be converted into a single contiguous array
- Returns:
the contiguous block
- Return type:
ndarray