예제 #1
0
def change_axis_schema(datashape,
                       axis,
                       start=None,
                       stop=None,
                       chunk=None,
                       overlap=None,
                       name=None):
    """
    Create a new DataShape by modifying the parameters of one axis

    Parameters
    ----------
    datashape : SciDBDataShape
        The template data shape
    axis : int
        Which axis to modify
    stop : int (optional)
        New axis upper bound
    chunk : int (optional)
        New chunk size
    overlap : int (optional)
        New chunk overlap
    name : str (optional)
        New dimension name

    Returns
    -------
    new_schema : SciDBDataShape
       The new schema, obtained by overriding the input parameters
       of the template datashape along the specified axis
    """
    from .scidbarray import SciDBDataShape

    names = list(datashape.dim_names)
    starts = list(datashape.dim_low)
    stops = list(datashape.dim_high)
    chunks = list(datashape.chunk_size)
    overlaps = list(datashape.chunk_overlap)
    if stop is not None:
        stops[axis] = stop
    if chunk is not None:
        chunks[axis] = chunk
    if overlap is not None:
        overlaps[axis] = overlap
    if name is not None:
        names[axis] = name
    if start is not None:
        starts[axis] = start
    return SciDBDataShape(None,
                          datashape.sdbtype,
                          dim_names=names,
                          chunk_size=chunks,
                          chunk_overlap=overlaps,
                          dim_low=starts,
                          dim_high=stops)