funi 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- funi-0.0.0/LICENSE +21 -0
- funi-0.0.0/PKG-INFO +66 -0
- funi-0.0.0/README.md +44 -0
- funi-0.0.0/funi.egg-info/PKG-INFO +66 -0
- funi-0.0.0/funi.egg-info/SOURCES.txt +12 -0
- funi-0.0.0/funi.egg-info/dependency_links.txt +1 -0
- funi-0.0.0/funi.egg-info/not-zip-safe +1 -0
- funi-0.0.0/funi.egg-info/requires.txt +1 -0
- funi-0.0.0/funi.egg-info/top_level.txt +1 -0
- funi-0.0.0/pyproject.toml +18 -0
- funi-0.0.0/setup.cfg +4 -0
- funi-0.0.0/setup.py +49 -0
- funi-0.0.0/src/pyfuni.cpp +10 -0
- funi-0.0.0/tests/test_funi.py +80 -0
funi-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 tataratat
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
funi-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: funi
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Find unique float arrays
|
|
5
|
+
Home-page: https://github.com/tataratat/funi
|
|
6
|
+
Author: Jaewook Lee
|
|
7
|
+
Author-email: jaewooklee042@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# funi
|
|
24
|
+
Find UNIque float array rows.
|
|
25
|
+
[numpy.unique](https://numpy.org/doc/stable/reference/generated/numpy.unique.html) is an awesome function that alleviates headaches, fast.
|
|
26
|
+
Haven you wished that it'd be applicable for 2D float arrays?
|
|
27
|
+
`funi` is here to help!
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
```bash
|
|
31
|
+
pip install funi
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
```python
|
|
36
|
+
import funi
|
|
37
|
+
import numpy as np
|
|
38
|
+
|
|
39
|
+
# create a random array with duplicating entries
|
|
40
|
+
arr = np.random.random((10000, 3))
|
|
41
|
+
arr = np.vstack((arr, arr, arr))
|
|
42
|
+
np.random.shuffle(arr)
|
|
43
|
+
|
|
44
|
+
# specify tolerance and
|
|
45
|
+
# tolerance is used to compare entries in column-wise.
|
|
46
|
+
# consider it as bounding-box edge length for duplicate identification
|
|
47
|
+
# with stable_sort + sorted_index unique_id will start from 0
|
|
48
|
+
unique_data, unique_ids, inverse = funi.unique_rows(
|
|
49
|
+
arr,
|
|
50
|
+
tolerance=1e-11,
|
|
51
|
+
return_unique=True,
|
|
52
|
+
return_index=True,
|
|
53
|
+
sorted_index=True,
|
|
54
|
+
return_inverse=True,
|
|
55
|
+
stable_sort=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# use ids to extract unique_data from the original array
|
|
59
|
+
assert np.allclose(unique_data, arr[unique_ids])
|
|
60
|
+
|
|
61
|
+
# use inverse to map unique_data back to the original array
|
|
62
|
+
assert np.allclose(arr, unique_data[inverse])
|
|
63
|
+
|
|
64
|
+
# sorted_index=True gives you sorted unique_ids and corresponding inverse
|
|
65
|
+
assert np.alltrue(np.sort(unique_ids) == unique_ids)
|
|
66
|
+
```
|
funi-0.0.0/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# funi
|
|
2
|
+
Find UNIque float array rows.
|
|
3
|
+
[numpy.unique](https://numpy.org/doc/stable/reference/generated/numpy.unique.html) is an awesome function that alleviates headaches, fast.
|
|
4
|
+
Haven you wished that it'd be applicable for 2D float arrays?
|
|
5
|
+
`funi` is here to help!
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
```bash
|
|
9
|
+
pip install funi
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
```python
|
|
14
|
+
import funi
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
# create a random array with duplicating entries
|
|
18
|
+
arr = np.random.random((10000, 3))
|
|
19
|
+
arr = np.vstack((arr, arr, arr))
|
|
20
|
+
np.random.shuffle(arr)
|
|
21
|
+
|
|
22
|
+
# specify tolerance and
|
|
23
|
+
# tolerance is used to compare entries in column-wise.
|
|
24
|
+
# consider it as bounding-box edge length for duplicate identification
|
|
25
|
+
# with stable_sort + sorted_index unique_id will start from 0
|
|
26
|
+
unique_data, unique_ids, inverse = funi.unique_rows(
|
|
27
|
+
arr,
|
|
28
|
+
tolerance=1e-11,
|
|
29
|
+
return_unique=True,
|
|
30
|
+
return_index=True,
|
|
31
|
+
sorted_index=True,
|
|
32
|
+
return_inverse=True,
|
|
33
|
+
stable_sort=True,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# use ids to extract unique_data from the original array
|
|
37
|
+
assert np.allclose(unique_data, arr[unique_ids])
|
|
38
|
+
|
|
39
|
+
# use inverse to map unique_data back to the original array
|
|
40
|
+
assert np.allclose(arr, unique_data[inverse])
|
|
41
|
+
|
|
42
|
+
# sorted_index=True gives you sorted unique_ids and corresponding inverse
|
|
43
|
+
assert np.alltrue(np.sort(unique_ids) == unique_ids)
|
|
44
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: funi
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Find unique float arrays
|
|
5
|
+
Home-page: https://github.com/tataratat/funi
|
|
6
|
+
Author: Jaewook Lee
|
|
7
|
+
Author-email: jaewooklee042@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# funi
|
|
24
|
+
Find UNIque float array rows.
|
|
25
|
+
[numpy.unique](https://numpy.org/doc/stable/reference/generated/numpy.unique.html) is an awesome function that alleviates headaches, fast.
|
|
26
|
+
Haven you wished that it'd be applicable for 2D float arrays?
|
|
27
|
+
`funi` is here to help!
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
```bash
|
|
31
|
+
pip install funi
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
```python
|
|
36
|
+
import funi
|
|
37
|
+
import numpy as np
|
|
38
|
+
|
|
39
|
+
# create a random array with duplicating entries
|
|
40
|
+
arr = np.random.random((10000, 3))
|
|
41
|
+
arr = np.vstack((arr, arr, arr))
|
|
42
|
+
np.random.shuffle(arr)
|
|
43
|
+
|
|
44
|
+
# specify tolerance and
|
|
45
|
+
# tolerance is used to compare entries in column-wise.
|
|
46
|
+
# consider it as bounding-box edge length for duplicate identification
|
|
47
|
+
# with stable_sort + sorted_index unique_id will start from 0
|
|
48
|
+
unique_data, unique_ids, inverse = funi.unique_rows(
|
|
49
|
+
arr,
|
|
50
|
+
tolerance=1e-11,
|
|
51
|
+
return_unique=True,
|
|
52
|
+
return_index=True,
|
|
53
|
+
sorted_index=True,
|
|
54
|
+
return_inverse=True,
|
|
55
|
+
stable_sort=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# use ids to extract unique_data from the original array
|
|
59
|
+
assert np.allclose(unique_data, arr[unique_ids])
|
|
60
|
+
|
|
61
|
+
# use inverse to map unique_data back to the original array
|
|
62
|
+
assert np.allclose(arr, unique_data[inverse])
|
|
63
|
+
|
|
64
|
+
# sorted_index=True gives you sorted unique_ids and corresponding inverse
|
|
65
|
+
assert np.alltrue(np.sort(unique_ids) == unique_ids)
|
|
66
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
funi.egg-info/PKG-INFO
|
|
6
|
+
funi.egg-info/SOURCES.txt
|
|
7
|
+
funi.egg-info/dependency_links.txt
|
|
8
|
+
funi.egg-info/not-zip-safe
|
|
9
|
+
funi.egg-info/requires.txt
|
|
10
|
+
funi.egg-info/top_level.txt
|
|
11
|
+
src/pyfuni.cpp
|
|
12
|
+
tests/test_funi.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
numpy
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
funi
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=42",
|
|
4
|
+
"wheel",
|
|
5
|
+
"pybind11",
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
build-backend = "setuptools.build_meta"
|
|
9
|
+
|
|
10
|
+
[tool.cibuildwheel]
|
|
11
|
+
test-command = "python {project}/tests/test_funi.py"
|
|
12
|
+
|
|
13
|
+
[tool.cibuildwheel.macos]
|
|
14
|
+
archs = ["x86_64", "arm64"]
|
|
15
|
+
test-skip = ["*arm64"]
|
|
16
|
+
|
|
17
|
+
[tool.cibuildwheel.windows]
|
|
18
|
+
skip = "pp*"
|
funi-0.0.0/setup.cfg
ADDED
funi-0.0.0/setup.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
with open("README.md") as f:
|
|
5
|
+
readme = f.read()
|
|
6
|
+
|
|
7
|
+
__version__ = "0.0.0"
|
|
8
|
+
|
|
9
|
+
ext_modules = [
|
|
10
|
+
Pybind11Extension(
|
|
11
|
+
"funi",
|
|
12
|
+
["src/pyfuni.cpp"],
|
|
13
|
+
include_dirs=["src"],
|
|
14
|
+
extra_compile_args=["-O3"],
|
|
15
|
+
cxx_std=17,
|
|
16
|
+
)
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
setup(
|
|
20
|
+
name="funi",
|
|
21
|
+
version=__version__,
|
|
22
|
+
description="Find unique float arrays",
|
|
23
|
+
long_description=readme,
|
|
24
|
+
long_description_content_type="text/markdown",
|
|
25
|
+
author="Jaewook Lee",
|
|
26
|
+
author_email="jaewooklee042@gmail.com",
|
|
27
|
+
url="https://github.com/tataratat/funi",
|
|
28
|
+
ext_modules=ext_modules,
|
|
29
|
+
cmdclass={"build_ext": build_ext},
|
|
30
|
+
package_data={"src": ["*.hpp"]},
|
|
31
|
+
classifiers=[
|
|
32
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Programming Language :: Python",
|
|
35
|
+
"Programming Language :: Python :: 3.6",
|
|
36
|
+
"Programming Language :: Python :: 3.7",
|
|
37
|
+
"Programming Language :: Python :: 3.8",
|
|
38
|
+
"Programming Language :: Python :: 3.9",
|
|
39
|
+
"Programming Language :: Python :: 3.10",
|
|
40
|
+
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Natural Language :: English",
|
|
42
|
+
"Topic :: Scientific/Engineering",
|
|
43
|
+
],
|
|
44
|
+
install_requires=[
|
|
45
|
+
"numpy",
|
|
46
|
+
],
|
|
47
|
+
zip_safe=False,
|
|
48
|
+
license="MIT",
|
|
49
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#include <pybind11/numpy.h>
|
|
2
|
+
#include <pybind11/pybind11.h>
|
|
3
|
+
|
|
4
|
+
#include <pyfuni.hpp>
|
|
5
|
+
|
|
6
|
+
PYBIND11_MODULE(funi, m) {
|
|
7
|
+
m.def("unique_float32", &funi::Unique<float>);
|
|
8
|
+
m.def("unique_float64", &funi::Unique<double>);
|
|
9
|
+
m.def("unique_rows", &funi::UniqueRows);
|
|
10
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
import funi
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FuniTest(unittest.TestCase):
|
|
9
|
+
def setUp(self):
|
|
10
|
+
# stack 100 x 3 arrays 3 times then shuffle
|
|
11
|
+
q = np.random.rand(100, 3)
|
|
12
|
+
self.q = np.vstack((q, q, q))
|
|
13
|
+
np.random.shuffle(self.q)
|
|
14
|
+
|
|
15
|
+
def test_all_return(self):
|
|
16
|
+
tol = 1e-10
|
|
17
|
+
|
|
18
|
+
# sorted indices
|
|
19
|
+
unique_s, ids_s, inv_s = funi.unique_float64(
|
|
20
|
+
self.q, tol, True, True, True, True, True
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# mapping check
|
|
24
|
+
assert np.allclose(self.q[ids_s], unique_s)
|
|
25
|
+
assert np.allclose(self.q, unique_s[inv_s])
|
|
26
|
+
|
|
27
|
+
# sortedness check
|
|
28
|
+
assert ~np.all(np.diff(ids_s) < 0)
|
|
29
|
+
|
|
30
|
+
# not sorted
|
|
31
|
+
# sorted indices
|
|
32
|
+
unique_ns, ids_ns, inv_ns = funi.unique_float64(
|
|
33
|
+
self.q, tol, True, True, False, True, True
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# mapping check
|
|
37
|
+
assert np.allclose(self.q[ids_ns], unique_ns)
|
|
38
|
+
assert np.allclose(self.q, unique_ns[inv_ns])
|
|
39
|
+
|
|
40
|
+
# no unique return - sorted
|
|
41
|
+
unique, ids, inv = funi.unique_float64(
|
|
42
|
+
self.q, tol, False, True, True, True, True
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
assert unique.size == 0
|
|
46
|
+
assert np.allclose(self.q, self.q[ids][inv])
|
|
47
|
+
assert np.allclose(ids, ids_s)
|
|
48
|
+
assert np.allclose(inv, inv_s)
|
|
49
|
+
|
|
50
|
+
# no unique return - not sorted
|
|
51
|
+
unique, ids, inv = funi.unique_float64(
|
|
52
|
+
self.q, tol, False, True, False, True, True
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
assert unique.size == 0
|
|
56
|
+
assert np.allclose(self.q, self.q[ids][inv])
|
|
57
|
+
assert np.allclose(ids, ids_ns)
|
|
58
|
+
assert np.allclose(inv, inv_ns)
|
|
59
|
+
|
|
60
|
+
# no inverse - sorted
|
|
61
|
+
unique, ids, inv = funi.unique_float64(
|
|
62
|
+
self.q, tol, True, True, True, False, True
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
assert inv.size == 0
|
|
66
|
+
assert np.allclose(unique, self.q[ids])
|
|
67
|
+
assert np.allclose(ids, ids_s)
|
|
68
|
+
|
|
69
|
+
# no invese - not sorted
|
|
70
|
+
unique, ids, inv = funi.unique_float64(
|
|
71
|
+
self.q, tol, True, True, False, False, True
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
assert inv.size == 0
|
|
75
|
+
assert np.allclose(unique, self.q[ids])
|
|
76
|
+
assert np.allclose(ids, ids_ns)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
unittest.main()
|