funi
Find UNIque float array rows.
numpy.unique is an awesome function that alleviates headaches, fast.
Haven't you wished that it'd be applicable for 2D float arrays?
funi
is here to help!
There are two available methods: axis
and lexicographic
.
axis
will first project each array to an axis to sort, where as
lexicographic
sorts given array in lexicographical manner.
Install
pip install funi
Quick Start
import funi
import numpy as np
arr = np.random.random((10000, 3))
arr = np.vstack((arr, arr, arr))
np.random.shuffle(arr)
unique_data, unique_ids, inverse = funi.unique_rows(
arr,
tolerance=1e-11,
sorted_index=True,
method="axis",
)
assert np.allclose(unique_data, arr[unique_ids])
assert np.allclose(arr, unique_data[inverse])
assert np.alltrue(np.sort(unique_ids) == unique_ids)