def test_contigify_ids_2(): inp = np.array([2, 0, 10, 2, 2, 10], dtype=np.intp) ref = np.array([0, 1, 2, 0, 0, 2], dtype=np.intp) out, mapping = contigify_ids(inp) assert np.all(out == ref) # it's inplace, so they should be equal now assert np.all(inp == out) assert mapping == {2: 0, 0: 1, 10: 2}
def test_contigify_ids_1(): inp = np.array([0, 10, 10, 20, 20, 21]) ref = np.array([0, 1, 1, 2, 2, 3]) out, mapping = contigify_ids(inp) assert np.all(out == ref) # it's inplace, so they should be equal now assert np.all(inp == out) assert mapping == {0:0, 10:1, 20:2, 21:3}
def test_contigify_ids_2(): inp = np.array([2, 0, 10, 2, 2, 10]) ref = np.array([0, 1, 2, 0, 0, 2]) out, mapping = contigify_ids(inp) assert np.all(out == ref) # it's inplace, so they should be equal now assert np.all(inp == out) assert mapping == {2:0, 0:1, 10:2}
def test_contigify_ids_1(): inp = np.array([0, 10, 10, 20, 20, 21]) ref = np.array([0, 1, 1, 2, 2, 3]) out, mapping = contigify_ids(inp) assert np.all(out == ref) # it's inplace, so they should be equal now assert np.all(inp == out) assert mapping == {0: 0, 10: 1, 20: 2, 21: 3}