def generateTestData(size, poly_num=10, max_point_num=4): x = [] for i in range(size): polys = polys2data(getData(index=5)) # polys=generatePolygon(poly_num,max_point_num) polys = polys.T x.append(polys) x = np.array(x) np.save('test{}_{}_{}'.format(size, poly_num, max_point_num), x)
def exportDataset(index, export_name): data = [] vectors = [] polys = getData(index) data.append(polys) vector = [] for poly in polys: vector.append(vectorFunc(poly, cut_nums=128).vector) vectors.append(vector) data = np.array(data) vectors = np.array(vectors) np.save('{}_xy'.format(export_name), data) np.save('{}'.format(export_name), vectors)
def showPolys(self): '''展示全部形状以及边框''' for poly in self.polys: PltFunc.addPolygon(poly) PltFunc.addPolygonColor([[0, 0], [self.cur_length, 0], [self.cur_length, self.width], [0, self.width]]) PltFunc.showPlt(width=1000, height=1000) def outputWarning(self, _str): '''输出红色字体''' print("\033[0;31m", _str, "\033[0m") def outputAttention(self, _str): '''输出绿色字体''' print("\033[0;32m", _str, "\033[0m") def outputInfo(self, _str): '''输出浅黄色字体''' print("\033[0;33m", _str, "\033[0m") if __name__ == '__main__': polys = getData() GSMPD(760, polys) # for i in range(100): # permutation = np.arange(10) # np.random.shuffle(permutation) # print(permutation)