Python, number, unique

Asked 2 years ago, Updated 2 years ago, 56 views

I wonder how out[indices] reconstructs the original value.

python numpy unique

2022-09-22 18:26

1 Answers

class NPArrayLike:
    def __init__(self, list):
        self._list = list 

    def __getitem__(self, indices):
        return [self._list[idx] for idx in indices];

if __name__ == "__main__":
    out = NPArrayLike([1,2,3,4,6])
    indices = [0,1,4,3,1,2,1]
    print(out[indices]) # [1, 2, 6, 4, 2, 3, 2]

Wouldn't it be like this if you emulate it?


2022-09-22 18:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.