(pids_array, if_reture_dict=False)
| 805 | |
| 806 | |
| 807 | def relabel_numpy(pids_array, if_reture_dict=False): |
| 808 | assert len( |
| 809 | pids_array.shape) == 1, f'The shape of np_array is {pids_array.shape}!' |
| 810 | pids_np_array = copy.deepcopy(pids_array) |
| 811 | label_dict = {} |
| 812 | for i, original_label in enumerate(np.unique(pids_np_array)): |
| 813 | label_dict[original_label] = i |
| 814 | |
| 815 | new_pids = np.array([label_dict[original_label] |
| 816 | for original_label in pids_np_array]) |
| 817 | if if_reture_dict: |
| 818 | return new_pids, label_dict |
| 819 | else: |
| 820 | return new_pids |
| 821 | |
| 822 | |
| 823 |
no outgoing calls
no test coverage detected