(data, store_root, split_num=8, shuffle=True)
| 66 | |
| 67 | # 功能:将一个list文件分成多份,存储在store_root中 |
| 68 | def func_split_list_data(data, store_root, split_num=8, shuffle=True): |
| 69 | if not os.path.exists(store_root): |
| 70 | os.makedirs(store_root) |
| 71 | |
| 72 | if shuffle: |
| 73 | data = func_shuffle_list_data(data) |
| 74 | |
| 75 | subset_number = math.ceil(len(data)/split_num) |
| 76 | for ii in range(split_num): |
| 77 | sub_data = data[ii*subset_number:(ii+1)*subset_number] |
| 78 | |
| 79 | save_path = os.path.join(store_root, f'split-{ii}.npy') |
| 80 | np.save(save_path, sub_data) |
| 81 | |
| 82 | |
| 83 | # 功能2:读取key值对应的 name2key [因为可能存在多个values,所以返回的values都变成list格式了] |
nothing calls this directly
no test coverage detected