brainstorm/structure/buffer_structure.py
def combine_buffer_structures(shapes):
    """
    Concatenate buffer structures on the last feature dimension.

    Checks that all other dimensions match.

    Args:
        shapes (list[BufferStructure]):
            list of BufferStructures to concatenate

    Returns:
        BufferStructure: The combined BufferStructure
    """
    if not shapes:
        return BufferStructure(0)
    for s in shapes:
        assert isinstance(s, BufferStructure)

    dimensions = [s.nr_dims for s in shapes]
    if min(dimensions) != max(dimensions):
        raise ValueError('Dimensionality mismatch. {}'.format(shapes))
    shape_types = [s.buffer_type for s in shapes]
    if min(shape_types) != max(shape_types):
        raise ValidationError('All buffer shapes need to have the same type. '
                              'But were: {}'.format(shape_types))
    some_shape = shapes[0]
    fixed_feature_shape = some_shape.feature_shape[:-1]

    if not all([s.feature_shape[:-1] == fixed_feature_shape for s in shapes]):
        raise ValueError('Feature size mismatch. {}'.format(shapes))

    summed_shape = sum(s.feature_shape[-1] for s in shapes)
    final_shape = (some_shape.scaling_shape +
                   fixed_feature_shape +
                   (summed_shape,))
    return BufferStructure(*final_shape)

    Concatenate buffer structures on the last feature dimension.

    Checks that all other dimensions match.

    Args:
        shapes (list[BufferStructure]):
            list of BufferStructures to concatenate

    Returns:
        BufferStructure: The combined BufferStructure
    
Concatenate buffer structures on the last feature dimension.
Checks that all other dimensions match.
Concatenate buffer structures on the last feature dimension . Checks that all other dimensions match .
def combine_buffer_structures(shapes):
    if not shapes:
        return BufferStructure(0)
    for s in shapes:
        assert isinstance(s, BufferStructure)
    dimensions = [s.nr_dims for s in shapes]
    if min(dimensions) != max(dimensions):
        raise ValueError('Dimensionality mismatch. {}'.format(shapes))
    shape_types = [s.buffer_type for s in shapes]
    if min(shape_types) != max(shape_types):
        raise ValidationError('All buffer shapes need to have the same type. '
                              'But were: {}'.format(shape_types))
    some_shape = shapes[0]
    fixed_feature_shape = some_shape.feature_shape[:-1]
    if not all([s.feature_shape[:-1] == fixed_feature_shape for s in shapes]):
        raise ValueError('Feature size mismatch. {}'.format(shapes))
    summed_shape = sum(s.feature_shape[-1] for s in shapes)
    final_shape = (some_shape.scaling_shape +
                   fixed_feature_shape +
                   (summed_shape,))
    return BufferStructure(*final_shape)
def combine_buffer_structures ( shapes ) : if not shapes : return BufferStructure ( 0 ) for s in shapes : assert isinstance ( s , BufferStructure ) dimensions = [ s . nr_dims for s in shapes ] if min ( dimensions ) != max ( dimensions ) : raise ValueError ( 'Dimensionality mismatch. {}' . format ( shapes ) ) shape_types = [ s . buffer_type for s in shapes ] if min ( shape_types ) != max ( shape_types ) : raise ValidationError ( 'All buffer shapes need to have the same type. ' 'But were: {}' . format ( shape_types ) ) some_shape = shapes [ 0 ] fixed_feature_shape = some_shape . feature_shape [ : - 1 ] if not all ( [ s . feature_shape [ : - 1 ] == fixed_feature_shape for s in shapes ] ) : raise ValueError ( 'Feature size mismatch. {}' . format ( shapes ) ) summed_shape = sum ( s . feature_shape [ - 1 ] for s in shapes ) final_shape = ( some_shape . scaling_shape + fixed_feature_shape + ( summed_shape , ) ) return BufferStructure ( * final_shape )
Concatenate buffer structures on the last feature dimension.
Concatenate buffer structures on the last feature dimension .
"""
    Concatenate buffer structures on the last feature dimension.

    Checks that all other dimensions match.

    Args:
        shapes (list[BufferStructure]):
            list of BufferStructures to concatenate

    Returns:
        BufferStructure: The combined BufferStructure
    """
The combined BufferStructure
The combined BufferStructure
BufferStructure
shapes
list of BufferStructures to concatenate
list of BufferStructures to concatenate