def get_chunk_size(N, n):
    """Given a two-dimensional array with a dimension of size 'N', 
        determine the number of rows or columns that can fit into memory.

    Parameters
    ----------
    N : int
        The size of one of the dimensions of a two-dimensional array.  

    n : int
        The number of arrays of size 'N' times 'chunk_size' that can fit in memory.

    Returns
    -------
    chunk_size : int
        The size of the dimension orthogonal to the one of size 'N'. 
    """

    mem_free = memory()['free']
    if mem_free > 60000000:
        chunk_size = int(((mem_free - 10000000) * 1000) / (4 * n * N))
        return chunk_size
    elif mem_free > 40000000:
        chunk_size = int(((mem_free - 7000000) * 1000) / (4 * n * N))
        return chunk_size
    elif mem_free > 14000000:
        chunk_size = int(((mem_free - 2000000) * 1000) / (4 * n * N))
        return chunk_size
    elif mem_free > 8000000:
        chunk_size = int(((mem_free - 1400000) * 1000) / (4 * n * N))
        return chunk_size
    elif mem_free > 2000000:
        chunk_size = int(((mem_free - 900000) * 1000) / (4 * n * N))
        return chunk_size
    elif mem_free > 1000000:
        chunk_size = int(((mem_free - 400000) * 1000) / (4 * n * N))
        return chunk_size
    else:
        print("\nERROR: Cluster_Ensembles: get_chunk_size: "
              "this machine does not have enough free memory resources "
              "to perform ensemble clustering.\n")
        sys.exit(1)
def get_chunk_size ( N , n ) : mem_free = memory ( ) [ 'free' ] if mem_free > 60000000 : chunk_size = int ( ( ( mem_free - 10000000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size elif mem_free > 40000000 : chunk_size = int ( ( ( mem_free - 7000000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size elif mem_free > 14000000 : chunk_size = int ( ( ( mem_free - 2000000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size elif mem_free > 8000000 : chunk_size = int ( ( ( mem_free - 1400000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size elif mem_free > 2000000 : chunk_size = int ( ( ( mem_free - 900000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size elif mem_free > 1000000 : chunk_size = int ( ( ( mem_free - 400000 ) * 1000 ) / ( 4 * n * N ) ) return chunk_size else : print ( "\nERROR: Cluster_Ensembles: get_chunk_size: " "this machine does not have enough free memory resources " "to perform ensemble clustering.\n" ) sys . exit ( 1 )
Given a two-dimensional array with a dimension of size 'N', 
        determine the number of rows or columns that can fit into memory.

    Parameters
    ----------
    N : int
        The size of one of the dimensions of a two-dimensional array.  

    n : int
        The number of arrays of size 'N' times 'chunk_size' that can fit in memory.

    Returns
    -------
    chunk_size : int
        The size of the dimension orthogonal to the one of size 'N'.