def produceTrainingSequences(self): warnings.filterwarnings("ignore", category=DeprecationWarning) datasetOfGraphSequences = [] clusters = self.generateClusters(self.number_of_generations) for point_cluster in clusters: x, y = self.getXandYCoordinatesOfClusterAsNumpyArrays( point_cluster) cluster_points, hull_base = self.fillCoordinateArrayAndIndexedPointarrayWithCoordinates( x, y) mst = mist.GetMST(x, y) roots = self.defineRootIndexedPoints(hull_base) self.createMSTandSTATS(mst, x, y) edges = self.buildMSTEdgesIndexedPointArray(mst, cluster_points) rootSortedEdges = self.sortEdgesFromHullpointRootsAndReturnAsArray( roots, edges) datasetOfGraphSequences.append( self. consolidateAllSequencesToOneDataSetFromAllSortedEdgesOfGraph( rootSortedEdges)) return datasetOfGraphSequences
def test_get_branch_index_sub_divide_3d_no_box_size(): x = np.random.random_sample(50) y = np.random.random_sample(50) z = np.random.random_sample(50) mst = mist.GetMST(x=x, y=y, z=z) mst.construct_mst() mst.get_degree() mst.get_degree_for_edges() branch_index, branch_index_rej = mist.get_branch_index(mst.edge_index, mst.edge_degree) branch_index_sub, branch_index_sub_rej = mist.get_branch_index_sub_divide(2, mst.edge_index, mst.edge_degree, edge_x=mst.edge_x, edge_y=mst.edge_y, edge_z=mst.edge_z) assert len(branch_index_sub_rej) == 0 count = 0 for i in range(0, len(branch_index)): for j in range(0, len(branch_index_sub)): if np.array_equal(np.array(sorted(branch_index[i])), np.array(sorted(branch_index_sub[j]))) == True: count += 1 else: pass assert count == len(branch_index)
def test_GetMST_init(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) assert mst._mode == '2D' z = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y, z=z) assert mst._mode == '3D' mst = mist.GetMST(phi=x, theta=y) assert mst._mode == 'tomographic' mst = mist.GetMST(phi=x, theta=y, r=z) assert mst._mode == 'spherical polar' mst = mist.GetMST(ra=x, dec=y) assert mst._mode == 'tomographic celestial' mst = mist.GetMST(ra=x, dec=y, r=z) assert mst._mode == 'spherical polar celestial'
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 test_GetMST_scal_cut(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) mst.scale_cut(0.2) assert mst.scale_cut_length == 0.2
def test_GetMST_branch_edge_count(): mst = mist.GetMST() mst.branch_index = [[1, 2, 3], [1, 2], [3, 4, 5, 6, 6]] mst.get_branch_edge_count() condition = np.where(mst.branch_edge_count == np.array([3, 2, 5]))[0] assert len(condition) == 3
def test_GetMST_knn(): x = np.random.random_sample(100) y = np.random.random_sample(100) mst = mist.GetMST(x=x, y=y) mst.define_k_neighbours(10) assert mst.k_neighbours == 10
t = data[:, 3] xmin = x > 6000 xmax = x < 9000 ymin = y > -6000 ymax = y < -3000 zmin = z > 1500 zmax = z < 5000 selection = zmin * zmax * ymin * ymax * xmin * xmax xcut = x[selection] ycut = y[selection] zcut = z[selection] tcut = t[selection] mst = mist.GetMST(x=xcut, y=ycut, z=zcut) d, l, b, s = mst.get_stats() l_index = mst.edge_index b_index = mst.branch_index fig = plt.figure(figsize=(7., 7.)) ax1 = fig.add_subplot(111, projection='3d') # plotting nodes: ax1.scatter(xcut, ycut, zcut, s=10, color='r') # plotting branches: ''' for i in range(len(b_index)):