def test_PlotHistMST_plot_contour_extra_option(): hmst = mist.HistMST() hmst.setup() hmst.start_group() for i in range(0, 10): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) d, l, b, s = mst.get_stats() mst_dict = hmst.get_hist(d, l, b, s) mst_dict = hmst.end_group() pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(usebox=False, plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(xlabels=['a', 'b', 'c', 'd'], plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(usefraction=True, plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(usefraction=True, usemean=False, plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(units=r'^{\circ}', plt_output='close')
def createMSTandSTATS(self, mst, local_x, local_y): d, l, b, s, l_index, b_index = mst.get_stats(include_index=True) # begins by binning the data and storing this in a dictionary. hmst = mist.HistMST() hmst.setup() mst_dict = hmst.get_hist(d, l, b, s) # plotting which takes as input the dictionary created before. pmst = mist.PlotHistMST() pmst.read_mst(mst_dict)
def test_PlotHistMST_plot_usebox(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) d, l, b, s = mst.get_stats() hmst = mist.HistMST() hmst.setup() mst_dict = hmst.get_hist(d, l, b, s) pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot(usebox=False, plt_output='close')
def test_get_hist(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) d, l, b, s = mst.get_stats() hmst = mist.HistMST() hmst.setup() mst_hist = hmst.get_hist(d, l, b, s) assert mst_hist['isgroup'] == False assert len(mst_hist['x_d']) == 6 assert len(mst_hist['y_d']) == 6 assert len(mst_hist['x_l']) == 100 assert len(mst_hist['y_l']) == 100 assert len(mst_hist['x_b']) == 100 assert len(mst_hist['y_b']) == 100 assert len(mst_hist['x_s']) == 50 assert len(mst_hist['y_s']) == 50
def test_end_group(): hmst = mist.HistMST() hmst.setup() hmst.start_group() for i in range(0, 10): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) d, l, b, s = mst.get_stats() _mst_hist = hmst.get_hist(d, l, b, s) mst_hist = hmst.end_group() assert hmst.group_mode == False assert mst_hist['isgroup'] == True assert len(mst_hist['y_d_std']) == 6 assert len(mst_hist['y_l_std']) == 100 assert len(mst_hist['y_b_std']) == 100 assert len(mst_hist['y_s_std']) == 50
def test_PlotHistMST_plot_comparison_envelope(): x_lf, y_lf, z_lf = mist.get_levy_flight(5000) mst = mist.GetMST(x=x_lf, y=y_lf, z=z_lf) d_lf, l_lf, b_lf, s_lf = mst.get_stats() hmst = mist.HistMST() hmst.setup(uselog=True) hist_lf = hmst.get_hist(d_lf, l_lf, b_lf, s_lf) hmst.start_group() for i in range(0, 10): x_alf, y_alf, z_alf = mist.get_adjusted_levy_flight(5000) mst = mist.GetMST(x=x_alf, y=y_alf, z=z_alf) d_alf, l_alf, b_alf, s_alf = mst.get_stats() _hist_alf = hmst.get_hist(d_alf, l_alf, b_alf, s_alf) hist_alf_group = hmst.end_group() pmst = mist.PlotHistMST() pmst.read_mst(hist_lf, label='Levy Flight') pmst.read_mst(hist_alf_group, label='Adjusted Levy Flight') pmst.plot(usecomp=True, plt_output='close')
def test_PlotHistMST_plot_comparison(): x_lf, y_lf, z_lf = mist.get_levy_flight(5000) x_alf, y_alf, z_alf = mist.get_adjusted_levy_flight(5000) mst = mist.GetMST(x=x_lf, y=y_lf, z=z_lf) d_lf, l_lf, b_lf, s_lf = mst.get_stats() mst = mist.GetMST(x=x_alf, y=y_alf, z=z_alf) d_alf, l_alf, b_alf, s_alf = mst.get_stats() hmst = mist.HistMST() hmst.setup(uselog=True) hist_lf = hmst.get_hist(d_lf, l_lf, b_lf, s_lf) x_alf, y_alf, z_alf = mist.get_adjusted_levy_flight(5000) mst = mist.GetMST(x=x_alf, y=y_alf, z=z_alf) d_alf, l_alf, b_alf, s_alf = mst.get_stats() hist_alf = hmst.get_hist(d_alf, l_alf, b_alf, s_alf) pmst = mist.PlotHistMST() pmst.read_mst(hist_lf, label='Levy Flight') pmst.read_mst(hist_alf, label='Adjusted Levy Flight') pmst.plot(usecomp=True, plt_output='close') pmst = mist.PlotHistMST() pmst.read_mst(hist_lf, label='Levy Flight') pmst.read_mst(hist_alf, label='Adjusted Levy Flight') pmst.plot(usebox=False, usecomp=True, plt_output='close')
def test_PlotHistMST_read_mst_uselog(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) d, l, b, s = mst.get_stats() hmst = mist.HistMST() hmst.setup(uselog=True) mst_hist = hmst.get_hist(d, l, b, s) pmst = mist.PlotHistMST() pmst.read_mst(mst_hist, color='dodgerblue', linewidth=1., linestyle=':', alpha=0.5, label='check', alpha_envelope=0.5) assert pmst.colors[0] == 'dodgerblue' assert pmst.linewidths[0] == 1. assert pmst.linestyles[0] == ':' assert pmst.alphas[0] == 0.5 assert pmst.labels[0] == 'check' assert pmst.alphas_envelope[0] == 0.5 assert pmst.need_envelopes[0] == False assert pmst.use_sqrt_s == True
def plotMSTandSTATS(self, mst, local_x, local_y): plt.figure(figsize=(8., 5.)) d, l, b, s, l_index, b_index = mst.get_stats(include_index=True) # plotting nodes: plt.scatter(local_x, local_y, s=10) # plotting branches: for i in range(0, len(b_index)): plt.plot([ local_x[l_index[0][b_index[i][0]]], local_x[l_index[1][b_index[i][0]]] ], [ local_y[l_index[0][b_index[i][0]]], local_y[l_index[1][b_index[i][0]]] ], color='C0', linestyle=':') plt.plot([ local_x[l_index[0][b_index[i][1:-1]]], local_x[l_index[1][b_index[i][1:-1]]] ], [ local_y[l_index[0][b_index[i][1:-1]]], local_y[l_index[1][b_index[i][1:-1]]] ], color='C0') plt.plot([ local_x[l_index[0][b_index[i][-1]]], local_x[l_index[1][b_index[i][-1]]] ], [ local_y[l_index[0][b_index[i][-1]]], local_y[l_index[1][b_index[i][-1]]] ], color='C0', linestyle=':') # ploting MST edges: plt.plot([local_x[l_index[0]], local_x[l_index[1]]], [local_y[l_index[0]], local_y[l_index[1]]], color='grey', linewidth=2, alpha=0.25) plt.plot([], [], color='C0', label=r'$Branch$ $Mid$') plt.plot([], [], color='C0', label=r'$Branch$ $End$', linestyle=':') plt.plot([], [], color='grey', alpha=0.25, label=r'$MST$ $Edges$') plt.xlabel(r'$X$', size=16) plt.ylabel(r'$Y$', size=16) plt.legend(loc='best') plt.tight_layout() plt.show() # begins by binning the data and storing this in a dictionary. hmst = mist.HistMST() hmst.setup() mst_dict = hmst.get_hist(d, l, b, s) # plotting which takes as input the dictionary created before. pmst = mist.PlotHistMST() pmst.read_mst(mst_dict) pmst.plot()
def test_start_group(): hmst = mist.HistMST() hmst.setup() hmst.start_group() assert hmst.group_mode == True