You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we'd like to work with a slice of a Grid, which means a subset of the contained orders, luminosities and/or bins.
We can already do this using the {order,bin,lumi}_mask parameters of Grid::convolute, but we have to remember these parameters when calling other methods of Grid. Instead it would be useful to add a new method Grid::slice, passing it the desired orders, bins and lumis, which then returns a GridSlice object containing the reference of a Grid object and the corresponding masks. This would allow
to have a simpler Grid::convolute function, because the mask parameters are already in the GridSlice object
the members GridSlice::{orders,bins,lumis} to return the correct subset of the original set of the Grid.
Furthermore, Grid itself is a GridSlice, so GridSlice would be a trait and Grid::slice would return a struct implementing the trait.
The text was updated successfully, but these errors were encountered:
If you want to avoid data duplication, there should be a single owner, and multiple references around (one for each slice).
But then it would be complicated to have a mutable slice.
A possible solution might be to make the grid owning data through a reference counted Rc, and then make the slices own a Weak reference, to upgrade only when you call some slice method.
This is a solution that came to my mind, but I just wanted to point out the problem.
This won't be a problem, we'll have to model that similar to ndarray's ArrayBase::slice which uses explicit lifetime parameters. The Python interface will be more difficult, but in the first instance we can leave the API as is.
Ok, I learnt myself that explicit lifetimes are difficult (easy to fall down a path with a dead-end). But the moment there is a working example, following it is definitely a sensible choice.
I'll leave it up to you, and the moment we'll have the Rust implementation, we'll think about how to wrap it in Python. But I'm confident we'll find a suitable way to do it :)
Sometimes we'd like to work with a slice of a
Grid
, which means a subset of the contained orders, luminosities and/or bins.We can already do this using the
{order,bin,lumi}_mask
parameters ofGrid::convolute
, but we have to remember these parameters when calling other methods ofGrid
. Instead it would be useful to add a new methodGrid::slice
, passing it the desired orders, bins and lumis, which then returns aGridSlice
object containing the reference of aGrid
object and the corresponding masks. This would allowGrid::convolute
function, because the mask parameters are already in theGridSlice
objectGridSlice::{orders,bins,lumis}
to return the correct subset of the original set of theGrid
.Furthermore,
Grid
itself is aGridSlice
, soGridSlice
would be a trait andGrid::slice
would return a struct implementing the trait.The text was updated successfully, but these errors were encountered: