MCPcopy Create free account
hub / github.com/TPCD/DCCL / relabel_numpy

Function relabel_numpy

project_utils/visualization_utils.py:807–820  ·  view source on GitHub ↗
(pids_array, if_reture_dict=False)

Source from the content-addressed store, hash-verified

805
806
807def 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

Callers 3

visualizeFunction · 0.85
visualize2Function · 0.85
visualize3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected