src/graphnet/components/pool.py
def group_by(data: Data, keys: List[str]) -> LongTensor:
    """Group nodes in `data` that have identical values of `keys`.

    This grouping is done with in each event in case of batching. This allows
    for, e.g., assigning the same index to all pulses on the same PMT or DOM in
    the same event. This can be used for coarsening graphs, e.g., from pulse-
    level to DOM-level by aggregating feature across each group returned by this
    method.

    Example:
      Given:
        data.f1 = [1,1,2,2,2]
        data.f2 = [6,7,7,7,8]
      Calls:
        groupby(data, ['f1'])       -> [0, 0, 1, 1, 1]
        groupby(data, ['f2'])       -> [0, 1, 1, 1, 2]
        groupby(data, ['f1', 'f2']) -> [0, 1, 2, 2, 3]
    """
    features = [getattr(data, key) for key in keys]
    tensor = torch.stack(features).T  # .int()  @TODO: Required? Use rounding?
    batch = getattr(tensor, "batch", None)
    index = _group_identical(tensor, batch)
    return index
Group nodes in `data` that have identical values of `keys`.

    This grouping is done with in each event in case of batching. This allows
    for, e.g., assigning the same index to all pulses on the same PMT or DOM in
    the same event. This can be used for coarsening graphs, e.g., from pulse-
    level to DOM-level by aggregating feature across each group returned by this
    method.

    Example:
      Given:
        data.f1 = [1,1,2,2,2]
        data.f2 = [6,7,7,7,8]
      Calls:
        groupby(data, ['f1'])       -> [0, 0, 1, 1, 1]
        groupby(data, ['f2'])       -> [0, 1, 1, 1, 2]
        groupby(data, ['f1', 'f2']) -> [0, 1, 2, 2, 3]
    
Group nodes in `data` that have identical values of `keys`.
This grouping is done with in each event in case of batching. This allows
for, e.g., assigning the same index to all pulses on the same PMT or DOM in
the same event. This can be used for coarsening graphs, e.g., from pulse
level to DOM-level by aggregating feature across each group returned by this
method.
Group nodes in ` data ` that have identical values of ` keys ` . This grouping is done with in each event in case of batching . This allows for e . g . assigning the same index to all pulses on the same PMT or DOM in the same event . This can be used for coarsening graphs e . g . from pulse level to DOM - level by aggregating feature across each group returned by this method .
def group_by(data: Data, keys: List[str]) -> LongTensor:
    features = [getattr(data, key) for key in keys]
    tensor = torch.stack(features).T  
    batch = getattr(tensor, "batch", None)
    index = _group_identical(tensor, batch)
    return index
def group_by ( data : Data , keys : List [ str ] ) -> LongTensor : features = [ getattr ( data , key ) for key in keys ] tensor = torch . stack ( features ) . T batch = getattr ( tensor , "batch" , None ) index = _group_identical ( tensor , batch ) return index
Group nodes in `data` that have identical values of `keys`.
Group nodes in ` data ` that have identical values of ` keys ` .
"""Group nodes in `data` that have identical values of `keys`.

    This grouping is done with in each event in case of batching. This allows
    for, e.g., assigning the same index to all pulses on the same PMT or DOM in
    the same event. This can be used for coarsening graphs, e.g., from pulse-
    level to DOM-level by aggregating feature across each group returned by this
    method.

    Example:
      Given:
        data.f1 = [1,1,2,2,2]
        data.f2 = [6,7,7,7,8]
      Calls:
        groupby(data, ['f1'])       -> [0, 0, 1, 1, 1]
        groupby(data, ['f2'])       -> [0, 1, 1, 1, 2]
        groupby(data, ['f1', 'f2']) -> [0, 1, 2, 2, 3]
    """ # .int()  @TODO: Required? Use rounding?
data
Data
keys
List[str]
examples
None