ssh/ssh_phase_diagram_multiprocessing.py
def save_img(eigenval, eigenvec, k_means_label, file_name):
    """ Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian. 
    Here, we explicitly indicate that only the first two eigenvectors will be used (using the knowledge that k means clustering returns two clusters, see k_means).
    Args:
        eigenval, eigenvec: outputs from get_spectrum
        file_name: name of the image file.

    Returns:
        None.

    """
    logger.info('saving image')
    fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5))
    ax[0].tick_params(axis='x', labelsize=20)
    ax[0].tick_params(axis='y', labelsize=20)
    ax[1].tick_params(axis='x', labelsize=20)
    ax[1].tick_params(axis='y', labelsize=20)
    c_list = []
    c_choice = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
    ax[0].plot(list(range(len(eigenval))), eigenval, '.k', linewidth=1)
    ax[0].plot(list(range(len(eigenval))), [0.2 for i in range(len(eigenval))], '-.k', linewidth=1)

    num_clusters = np.max(k_means_label) + 1
    assert num_clusters < len(c_choice), 'too many clusters'
    for i in k_means_label:
        for j in range(num_clusters):
            if i == j:
                c_list.append(c_choice[j])
                break
    ax[1].scatter(eigenvec[:, 0], eigenvec[:, 1], c=c_list, linewidth=1)
    ax[1].set_xlim(eigenvec[:, 0].min() - 0.1, eigenvec[:, 0].max() + 0.1)
    plt.tight_layout()

    name_dir = os.path.dirname(file_name)
    os.makedirs(name_dir, exist_ok=True)
    plt.savefig(file_name + '.pdf', format='pdf')
 Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian. 
    Here, we explicitly indicate that only the first two eigenvectors will be used (using the knowledge that k means clustering returns two clusters, see k_means).
    Args:
        eigenval, eigenvec: outputs from get_spectrum
        file_name: name of the image file.

    Returns:
        None.

    
Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian.
Here, we explicitly indicate that only the first two eigenvectors will be used (using the knowledge that k means clustering returns two clusters, see k_means).
Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian . Here we explicitly indicate that only the first two eigenvectors will be used ( using the knowledge that k means clustering returns two clusters see k_means ) .
def save_img(eigenval, eigenvec, k_means_label, file_name):
    logger.info('saving image')
    fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5))
    ax[0].tick_params(axis='x', labelsize=20)
    ax[0].tick_params(axis='y', labelsize=20)
    ax[1].tick_params(axis='x', labelsize=20)
    ax[1].tick_params(axis='y', labelsize=20)
    c_list = []
    c_choice = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
    ax[0].plot(list(range(len(eigenval))), eigenval, '.k', linewidth=1)
    ax[0].plot(list(range(len(eigenval))), [0.2 for i in range(len(eigenval))], '-.k', linewidth=1)
    num_clusters = np.max(k_means_label) + 1
    assert num_clusters < len(c_choice), 'too many clusters'
    for i in k_means_label:
        for j in range(num_clusters):
            if i == j:
                c_list.append(c_choice[j])
                break
    ax[1].scatter(eigenvec[:, 0], eigenvec[:, 1], c=c_list, linewidth=1)
    ax[1].set_xlim(eigenvec[:, 0].min() - 0.1, eigenvec[:, 0].max() + 0.1)
    plt.tight_layout()
    name_dir = os.path.dirname(file_name)
    os.makedirs(name_dir, exist_ok=True)
    plt.savefig(file_name + '.pdf', format='pdf')
def save_img ( eigenval , eigenvec , k_means_label , file_name ) : logger . info ( 'saving image' ) fig , ax = plt . subplots ( nrows = 1 , ncols = 2 , figsize = ( 10 , 5 ) ) ax [ 0 ] . tick_params ( axis = 'x' , labelsize = 20 ) ax [ 0 ] . tick_params ( axis = 'y' , labelsize = 20 ) ax [ 1 ] . tick_params ( axis = 'x' , labelsize = 20 ) ax [ 1 ] . tick_params ( axis = 'y' , labelsize = 20 ) c_list = [ ] c_choice = [ 'b' , 'g' , 'r' , 'c' , 'm' , 'y' , 'k' ] ax [ 0 ] . plot ( list ( range ( len ( eigenval ) ) ) , eigenval , '.k' , linewidth = 1 ) ax [ 0 ] . plot ( list ( range ( len ( eigenval ) ) ) , [ 0.2 for i in range ( len ( eigenval ) ) ] , '-.k' , linewidth = 1 ) num_clusters = np . max ( k_means_label ) + 1 assert num_clusters < len ( c_choice ) , 'too many clusters' for i in k_means_label : for j in range ( num_clusters ) : if i == j : c_list . append ( c_choice [ j ] ) break ax [ 1 ] . scatter ( eigenvec [ : , 0 ] , eigenvec [ : , 1 ] , c = c_list , linewidth = 1 ) ax [ 1 ] . set_xlim ( eigenvec [ : , 0 ] . min ( ) - 0.1 , eigenvec [ : , 0 ] . max ( ) + 0.1 ) plt . tight_layout ( ) name_dir = os . path . dirname ( file_name ) os . makedirs ( name_dir , exist_ok = True ) plt . savefig ( file_name + '.pdf' , format = 'pdf' )
Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian.
Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian .
""" Saves eigenvalue spectrum and distribution of persistence diagram in the space of eigenvectors of the random walk Laplacian. 
    Here, we explicitly indicate that only the first two eigenvectors will be used (using the knowledge that k means clustering returns two clusters, see k_means).
    Args:
        eigenval, eigenvec: outputs from get_spectrum
        file_name: name of the image file.

    Returns:
        None.

    """
None
eigenval
eigenvec
k_means_label
file_name
name of the image file.
name of the image file .
eigenval, eigenvec
outputs from get_spectrum
outputs from get_spectrum