Giter Club home page Giter Club logo

fnntw's Introduction

This crate has been abandoned in favor of bosque โ€” a super fast in-place kD-Tree library.

FNNTW: Fastest Nearest Neighbor (in the) West

Fastest Neighbor Nearest Neighbor (in the) West is an in-development kD-tree library that aims to be one of the most, if not the most, performant parallel kNN libraries that exist.

There are several key components of the building and querying process of the kD-trees that allows for its performance.

1. Building The Tree

Many kD-Tree build implementations are not parallel despite being very easy to parallelize. Here we discuss parallelization strategies for individual subtrees and across subtrees.

a. Using Quickselect

By using the quickselect in the form of select_nth_unstable_by in Rust's core::slice instead of an average or even some other median algorithm, we get the left and right subsets for free in the same O(N) algorithm instead of having to do yet another O(N) comparisons to obtain the left and right bins. As such, the build is still O(N log(N)), but removes a whole O(N) operation that is found in many other libraries during each splitting. For trees with >=100,000 nodes, a homemade parallel approximate median finder is used to find the split point for the subtrees. This speeds up the building of large trees tremendously, as โ‰ˆ95% of a sequential tree build is spent finding medians.

b. Parallel build

Every subtree of a kD-tree is an independent kD-tree, so at each splitting one could build each subtree in parallel up to some minimum subtree size. This is done here with the user-specified par_split_level, which is the tree depth at which the parallelism begins. See note in Benchmark Against Other Codes about recommended values.

2. Unsafe Accesses

Because we know the shape of all arrays (i.e. the dimension of the tree) at compile time, and we know the tree size and topology post-build at run time, the unsafe methods get_unchecked and get_unchecked_mut are used liberally throughout the code. This means virtually no bounds checks are done.

3. Allocators

We tested many allocators, including the default allocator, jemalloc, tcmalloc, snmalloc, mimalloc, rpmalloc, and found the best performance with tcmalloc.

Benchmark Against Other Codes

This library is intended to be used by the author to calculate summary statistics in cosmology. As such, the parameters of the benchmark chosen are close to those that would be used in analyzing the output of a cosmological simulation. In such an application, often many subsamples or simulation boxes are used. So, the combined build + query time is important since many different trees may be constructed in an analysis. We use

  • A mock dataset of 100,000 uniform random points in the unit cube.
  • A query set of 1,000,000 uniform random points in the unit cube.

Over 100 realizations of the datasets and query points, the following results are obtained for the average build (serial) and 1NN query times on an AMD EPYC 7502P using 48 threads. The results are sorted by the combined build and query time.

Code Build (ms) Query (ms) Total (ms)
FNNTW 12 22 34
pykdtree (python) 12 35 47
nabo-rs (rust) 25 30 55
Scipy's cKDTree (python) 31 38 69
kiddo (rust) 26 84 110

With FNNTW's parallel build capability, the build time can go as low as 5 ms on the AMD EPYC 7502P (at split_level = 2) (and under 5 ms at single precision). Since the overhead of the parallelism and atomic operations slows down the build when the number of datapoints is small, both a parallel build and non_parallel build are available via Tree:new(..) and Tree::new_parallel(..). The latter takes the aforementioned parameter par_split_level, which is the split depth after which the parallelism stops. Although for our applications of O(1e5) points we see the biggest improvement for par_split_level = 2, we expect that the optimal par_split_level will increase with the size of the dataset. For tree sizes of O(1e8) points, for example, we see peak performance at par_split_level = 4 (16 threads).

fnntw's People

Contributors

cavemanloverboy avatar

Stargazers

Schrodinger ZHU Yifan avatar  avatar RaisCui avatar Aaron Ouellette avatar Jack McPherson avatar  avatar Marche avatar Stephan Gerhard avatar Philipp Schlegel avatar axionbuster avatar Etch avatar nana avatar Rohan Kapur avatar James Li avatar > avatar

Watchers

 avatar

fnntw's Issues

[Feature Request] Can FNNTW support the periodic boundary for triclinic box?

Hi,
FNNTW now supports periodic boundary conditions for a rectangular box, where the angles between the two line vectors are 90 degrees. Is it possible to make it more generalizable for a triclinic box? This feature proves useful in certain simulation domains. Let's consider the box below, where each row represents a box vector:

box = np.array([[a1, a2, a3], [b1, b2, b3], [c1, c2, c3]])

The rectangular box is like below:

box = np.array([[a, 0, 0], [0, b, 0], [0, 0, c]])

A distance vector rij = np.array([x, y, z]) can be wrapped as below:

def pbc(rij, box):
      nz = rij[2] / box[2][2]
      ny = (rij[1] - nz * box[2][1]) / box[1][1]
      nx = (rij[0] - ny * box[1][0] - nz * box[2][0]) / box[0][0]
      n =[nx, ny, nz]
      for i in range(3):
            if n[i] > 0.5:
                n[i] -= 1
            elif n[i] < -0.5:
                n[i] += 1
      return n[0] * box[0] + n[1] * box[1] + n[2] * box[2]

Maybe change the distance equation in codes can achieve this?
Thank you very much!

Cannot install pyfnntw==0.4.1 on Fedora

Hello,

Cannot taste the speed, so to say:

$ cargo -V
cargo 1.64.0 (387270bc7 2022-09-16)
$ python3 -V
Python 3.10.11

Error during the installation:

$ pip3 install pyfnntw

Defaulting to user installation because normal site-packages is not writeable
Collecting pyfnntw
  Using cached pyfnntw-0.4.1.tar.gz (69 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyfnntw
  Building wheel for pyfnntw (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpzb2vislq
       cwd: /tmp/pip-install-8i90cdvq/pyfnntw_cd52bbf6d78f4029ae509b1dd8405027
  Complete output (116 lines):
  Running `maturin pep517 build-wheel -i /usr/bin/python3 --compatibility off`
  ๐Ÿ”— Found pyo3 bindings
  ๐Ÿ Found CPython 3.10 at /usr/bin/python3
     Compiling autocfg v1.1.0
     Compiling proc-macro2 v1.0.66
     Compiling unicode-ident v1.0.3
     Compiling libc v0.2.132
     Compiling thiserror v1.0.47
     Compiling target-lexicon v0.12.4
     Compiling cfg-if v1.0.0
     Compiling crossbeam-utils v0.8.16
     Compiling scopeguard v1.1.0
     Compiling syn v1.0.99
     Compiling version_check v0.9.4
     Compiling ucd-trie v0.1.6
     Compiling once_cell v1.13.1
     Compiling rayon-core v1.11.0
     Compiling parking_lot_core v0.9.3
     Compiling either v1.9.0
     Compiling const_fn v0.4.9
     Compiling smallvec v1.9.0
     Compiling arrayvec v0.4.12
     Compiling nodrop v0.1.14
     Compiling Inflector v0.11.4
     Compiling rawpointer v0.2.1
     Compiling aliasable v0.1.3
     Compiling itoa v0.4.8
     Compiling indoc v1.0.7
     Compiling unindent v0.1.10
     Compiling sync-unsafe-cell v0.1.1
     Compiling permutation v0.4.1
     Compiling proc-macro-error-attr v1.0.4
     Compiling proc-macro-error v1.0.4
     Compiling memoffset v0.9.0
     Compiling crossbeam-epoch v0.9.15
     Compiling num-traits v0.2.15
     Compiling lock_api v0.4.7
     Compiling num-integer v0.1.45
     Compiling matrixmultiply v0.3.7
     Compiling crossbeam-channel v0.5.8
     Compiling num-format v0.4.0
     Compiling quote v1.0.33
     Compiling pyo3-build-config v0.16.5
     Compiling num_cpus v1.16.0
     Compiling crossbeam-deque v0.8.3
     Compiling syn v2.0.29
     Compiling parking_lot v0.12.1
     Compiling num-complex v0.4.4
     Compiling ordered-float v3.0.0
     Compiling rayon v1.7.0
     Compiling pyo3-ffi v0.16.5
     Compiling pyo3 v0.16.5
     Compiling ndarray v0.15.6
     Compiling pyo3-macros-backend v0.16.5
     Compiling thiserror-impl v1.0.47
     Compiling concat-idents v1.1.5
     Compiling ouroboros_macro v0.15.6
     Compiling pest v2.7.2
     Compiling pyo3-macros v0.16.5
     Compiling ouroboros v0.15.6
     Compiling semver-parser v0.10.2
     Compiling semver v0.11.0
     Compiling rustc_version v0.3.3
     Compiling likely_stable v0.1.2
     Compiling fnntw v0.4.1 (/tmp/pip-install-8i90cdvq/pyfnntw_cd52bbf6d78f4029ae509b1dd8405027/local_dependencies/fnntw)
  error: could not compile `fnntw` due to 5 previous errors
  warning: build failed, waiting for other jobs to finish...
  ๐Ÿ’ฅ maturin failed
    Caused by: Failed to build a native library through cargo
    Caused by: Cargo build finished with "exit status: 101": `PYO3_ENVIRONMENT_SIGNATURE="cpython-3.10-64bit" PYO3_PYTHON="/usr/bin/python3" PYTHON_SYS_EXECUTABLE="/usr/bin/python3" "cargo" "rustc" "--release" "--manifest-path" "/tmp/pip-install-8i90cdvq/pyfnntw_cd52bbf6d78f4029ae509b1dd8405027/Cargo.toml" "--message-format" "json" "--lib"`
  error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
    --> local_dependencies/fnntw/src/query.rs:19:33
     |
  19 |             Ok(process_result::<'t, T, D>(
     |                                 ^^
     |
  note: the late bound lifetime parameter is introduced here
    --> local_dependencies/fnntw/src/utils.rs:96:30
     |
  96 | pub(crate) fn process_result<'t, T: Float, const D: usize>(
     |                              ^^


  error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
    --> local_dependencies/fnntw/src/query.rs:24:33
     |
  24 |             Ok(process_result::<'t, T, D>(
     |                                 ^^
     |
  note: the late bound lifetime parameter is introduced here
    --> local_dependencies/fnntw/src/utils.rs:96:30
     |
  96 | pub(crate) fn process_result<'t, T: Float, const D: usize>(
     |                              ^^


  error[E0599]: no method named `ilog2` found for type `usize` in the current scope
     --> local_dependencies/fnntw/src/lib.rs:153:40
      |
  153 |             let height_hint = data_len.ilog2() as usize;
      |                                        ^^^^^ help: there is an associated function with a similar name: `log`


  error[E0599]: no method named `ilog2` found for type `usize` in the current scope
     --> local_dependencies/fnntw/src/lib.rs:474:40
      |
  474 |             let height_hint = data_len.ilog2() as usize;
      |                                        ^^^^^ help: there is an associated function with a similar name: `log`


  error: aborting due to 4 previous errors


  For more information about this error, try `rustc --explain E0599`.

  Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/bin/python3', '--compatibility', 'off'] returned non-zero exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyfnntw
Failed to build pyfnntw
ERROR: Could not build wheels for pyfnntw, which is required to install pyproject.toml-based projects
[matteo@tuxedo ~]$ pip3 install pyfnntw > out
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpnz61h27j
       cwd: /tmp/pip-install-a8ggre83/pyfnntw_164096346079481d864472fc48146814
  Complete output (116 lines):
  Running `maturin pep517 build-wheel -i /usr/bin/python3 --compatibility off`
  ๐Ÿ”— Found pyo3 bindings
  ๐Ÿ Found CPython 3.10 at /usr/bin/python3
     Compiling autocfg v1.1.0
     Compiling proc-macro2 v1.0.66
     Compiling unicode-ident v1.0.3
     Compiling libc v0.2.132
     Compiling cfg-if v1.0.0
     Compiling thiserror v1.0.47
     Compiling target-lexicon v0.12.4
     Compiling crossbeam-utils v0.8.16
     Compiling syn v1.0.99
     Compiling scopeguard v1.1.0
     Compiling version_check v0.9.4
     Compiling ucd-trie v0.1.6
     Compiling once_cell v1.13.1
     Compiling rayon-core v1.11.0
     Compiling parking_lot_core v0.9.3
     Compiling const_fn v0.4.9
     Compiling arrayvec v0.4.12
     Compiling smallvec v1.9.0
     Compiling either v1.9.0
     Compiling rawpointer v0.2.1
     Compiling Inflector v0.11.4
     Compiling nodrop v0.1.14
     Compiling indoc v1.0.7
     Compiling itoa v0.4.8
     Compiling aliasable v0.1.3
     Compiling unindent v0.1.10
     Compiling permutation v0.4.1
     Compiling sync-unsafe-cell v0.1.1
     Compiling proc-macro-error-attr v1.0.4
     Compiling proc-macro-error v1.0.4
     Compiling memoffset v0.9.0
     Compiling num-traits v0.2.15
     Compiling crossbeam-epoch v0.9.15
     Compiling lock_api v0.4.7
     Compiling num-integer v0.1.45
     Compiling matrixmultiply v0.3.7
     Compiling crossbeam-channel v0.5.8
     Compiling num-format v0.4.0
     Compiling quote v1.0.33
     Compiling num_cpus v1.16.0
     Compiling pyo3-build-config v0.16.5
     Compiling syn v2.0.29
     Compiling crossbeam-deque v0.8.3
     Compiling parking_lot v0.12.1
     Compiling num-complex v0.4.4
     Compiling ordered-float v3.0.0
     Compiling rayon v1.7.0
     Compiling pyo3-ffi v0.16.5
     Compiling pyo3 v0.16.5
     Compiling ndarray v0.15.6
     Compiling pyo3-macros-backend v0.16.5
     Compiling thiserror-impl v1.0.47
     Compiling concat-idents v1.1.5
     Compiling ouroboros_macro v0.15.6
     Compiling pest v2.7.2
     Compiling pyo3-macros v0.16.5
     Compiling ouroboros v0.15.6
     Compiling semver-parser v0.10.2
     Compiling semver v0.11.0
     Compiling rustc_version v0.3.3
     Compiling likely_stable v0.1.2
     Compiling fnntw v0.4.1 (/tmp/pip-install-a8ggre83/pyfnntw_164096346079481d864472fc48146814/local_dependencies/fnntw)
  error: could not compile `fnntw` due to 5 previous errors
  warning: build failed, waiting for other jobs to finish...
  ๐Ÿ’ฅ maturin failed
    Caused by: Failed to build a native library through cargo
    Caused by: Cargo build finished with "exit status: 101": `PYO3_ENVIRONMENT_SIGNATURE="cpython-3.10-64bit" PYO3_PYTHON="/usr/bin/python3" PYTHON_SYS_EXECUTABLE="/usr/bin/python3" "cargo" "rustc" "--release" "--manifest-path" "/tmp/pip-install-a8ggre83/pyfnntw_164096346079481d864472fc48146814/Cargo.toml" "--message-format" "json" "--lib"`
  error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
    --> local_dependencies/fnntw/src/query.rs:19:33
     |
  19 |             Ok(process_result::<'t, T, D>(
     |                                 ^^
     |
  note: the late bound lifetime parameter is introduced here
    --> local_dependencies/fnntw/src/utils.rs:96:30
     |
  96 | pub(crate) fn process_result<'t, T: Float, const D: usize>(
     |                              ^^


  error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
    --> local_dependencies/fnntw/src/query.rs:24:33
     |
  24 |             Ok(process_result::<'t, T, D>(
     |                                 ^^
     |
  note: the late bound lifetime parameter is introduced here
    --> local_dependencies/fnntw/src/utils.rs:96:30
     |
  96 | pub(crate) fn process_result<'t, T: Float, const D: usize>(
     |                              ^^


  error[E0599]: no method named `ilog2` found for type `usize` in the current scope
     --> local_dependencies/fnntw/src/lib.rs:153:40
      |
  153 |             let height_hint = data_len.ilog2() as usize;
      |                                        ^^^^^ help: there is an associated function with a similar name: `log`


  error[E0599]: no method named `ilog2` found for type `usize` in the current scope
     --> local_dependencies/fnntw/src/lib.rs:474:40
      |
  474 |             let height_hint = data_len.ilog2() as usize;
      |                                        ^^^^^ help: there is an associated function with a similar name: `log`


  error: aborting due to 4 previous errors


  For more information about this error, try `rustc --explain E0599`.

  Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/bin/python3', '--compatibility', 'off'] returned non-zero exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyfnntw
ERROR: Could not build wheels for pyfnntw, which is required to install pyproject.toml-based projects

Help greatly appreciated!

Best wishes,
Matteo Lacki

Candidate Containers

Presently, FNNTW uses a BinaryHeap to store nearest neighbor candidates and stems that must be checked. A feature vec-container was added which attempts to build something akin to a max heap, but it's strictly slower than BinaryHeap. It would be good to explore other candidate containers to see if there is a better, faster one.

Installation error on pyfnntw==0.4.0

I install pyfnntw by:

pip install pyfnntw==0.4.0

I use Conda environment and the PYTHON version is 3.11.0 (as required in pyproject.toml) ans OS is windows10.
The output is as below:

Collecting pyfnntw==0.4.0
  Downloading pyfnntw-0.4.0.tar.gz (71 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 71.1/71.1 kB 647.0 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyfnntw
  Building wheel for pyfnntw (pyproject.toml) ... error
  error: subprocess-exited-with-error

  ร— Building wheel for pyfnntw (pyproject.toml) did not run successfully.
  โ”‚ exit code: 1
  โ•ฐโ”€> [84 lines of output]
      Running `maturin pep517 build-wheel -i D:\Anaconda\envs\py311\python.exe --compatibility off`
      ้ฆƒๆ•† Found pyo3 bindings
      ้ฆƒๆ‚• Found CPython 3.11 at D:\Anaconda\envs\py311\python.exe
         Compiling autocfg v1.1.0
         Compiling proc-macro2 v1.0.51
         Compiling quote v1.0.21
         Compiling unicode-ident v1.0.3
         Compiling syn v1.0.109
         Compiling thiserror v1.0.39
         Compiling cfg-if v1.0.0
         Compiling target-lexicon v0.12.4
         Compiling scopeguard v1.1.0
         Compiling crossbeam-utils v0.8.15
         Compiling version_check v0.9.4
         Compiling once_cell v1.13.1
         Compiling ucd-trie v0.1.5
         Compiling windows_x86_64_msvc v0.36.1
         Compiling rayon-core v1.11.0
         Compiling num_cpus v1.15.0
         Compiling libc v0.2.132
         Compiling parking_lot_core v0.9.3
         Compiling const_fn v0.4.9
         Compiling tcmalloc-sys v0.3.0
         Compiling either v1.8.1
         Compiling arrayvec v0.4.12
         Compiling smallvec v1.9.0
         Compiling Inflector v0.11.4
         Compiling rawpointer v0.2.1
         Compiling nodrop v0.1.14
         Compiling itoa v0.4.8
         Compiling unindent v0.1.10
         Compiling aliasable v0.1.3
         Compiling indoc v1.0.7
         Compiling permutation v0.4.1
         Compiling sync-unsafe-cell v0.1.0
         Compiling matrixmultiply v0.3.2
         Compiling memoffset v0.8.0
         Compiling num-traits v0.2.15
         Compiling crossbeam-epoch v0.9.14
         Compiling lock_api v0.4.7
         Compiling num-integer v0.1.45
         Compiling proc-macro-error-attr v1.0.4
         Compiling proc-macro-error v1.0.4
         Compiling windows-sys v0.36.1
         Compiling tcmalloc v0.3.0
         Compiling num-format v0.4.0
         Compiling pyo3-build-config v0.16.5
         Compiling crossbeam-channel v0.5.7
         Compiling crossbeam-deque v0.8.3
         Compiling num-complex v0.4.3
         Compiling ordered-float v3.0.0
         Compiling rayon v1.7.0
         Compiling parking_lot v0.12.1
         Compiling pyo3-ffi v0.16.5
         Compiling pyo3 v0.16.5
         Compiling ndarray v0.15.6
         Compiling pyo3-macros-backend v0.16.5
         Compiling thiserror-impl v1.0.39
         Compiling ouroboros_macro v0.15.6
         Compiling concat-idents v1.1.4
         Compiling pest v2.5.6
         Compiling ouroboros v0.15.6
         Compiling pyo3-macros v0.16.5
         Compiling semver-parser v0.10.2
         Compiling semver v0.11.0
         Compiling rustc_version v0.3.3
         Compiling likely_stable v0.1.2
         Compiling fnntw v0.4.0 (C:\Users\Administrator\AppData\Local\Temp\pip-install-uv8o5oyw\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\local_dependencies\fnntw)
         Compiling numpy v0.16.2
         Compiling pyfnntw v0.4.0 (C:\Users\Administrator\AppData\Local\Temp\pip-install-uv8o5oyw\pyfnntw_89a06f849e7240068ea92b3e9ceaee94)
      error: could not compile `pyfnntw` due to 2 previous errors
      ้ฆƒๆŒœ maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--release" "--manifest-path" "C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-uv8o5oyw\\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\\Cargo.toml" "--message-format" "json" "--lib"`
      error: linking with `link.exe` failed: exit code: 1181
        |
        = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustc25OP3V\\lib.def" "/NOLOGO" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustc25OP3V\\symbols.o" "C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-uv8o5oyw\\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\\target\\release\\deps\\pyfnntw.pyfnntw.5efcba88-cgu.0.rcgu.o" "/LIBPATH:C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-uv8o5oyw\\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\\target\\release\\deps" "/LIBPATH:C:\\Users\\Administrator\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\windows_x86_64_msvc-0.36.1\\lib" "/LIBPATH:D:\\Anaconda\\envs\\py311\\libs" "/LIBPATH:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-3f0eed38bcc54ffc.rlib" "windows.lib" "python311.lib" "legacy_stdio_definitions.lib" "tcmalloc.lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-uv8o5oyw\\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\\target\\release\\deps\\pyfnntw.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-uv8o5oyw\\pyfnntw_89a06f849e7240068ea92b3e9ceaee94\\target\\release\\deps\\pyfnntw.dll.lib" "/DEBUG" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
        = note: Non-UTF-8 output: LINK : fatal error LNK1181: \xce\xde\xb7\xa8\xb4\xf2\xbf\xaa\xca\xe4\xc8\xeb\xce\xc4\xbc\xfe\xa1\xb0tcmalloc.lib\xa1\xb1\r\n


      error: aborting due to previous error


      Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'D:\\Anaconda\\envs\\py311\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyfnntw
Failed to build pyfnntw
ERROR: Could not build wheels for pyfnntw, which is required to install pyproject.toml-based projects
NativeCommandExitException: Program "pip.exe" ended with non-zero exit code: 1.

In my WSL, the error seems to be related to tcmalloc-sys v0.3.0.
Can you tell me how to solve it?
BTW., why the PYTHON version is required larger than 3.11.0? It would be helpful to change it to >=3.7.0.

Duplicate Data

The use of the HashMap to calculate the indices is fine for most applications. However, if there is some application where there is some metadata attached to the items in the tree and there are two items that have the same position, then only one such item will be returned. That is, if both points are k-nearest neighbors, then the returned value with include a duplicate of one of them instead of both unique elements.

Add comparison against kd-tree

The somewhat older kd_tree crate has mentioned optimisations as well (it uses quickselect, as well as has parallel build via par_build_by_ordered_float) so it could be interesting to compare its performance to this implementation, but I noticed it's currently missing in README.

Add documentation for python package!

I wanted to find a library that was fast for neighbourhood search and supported periodic boundary conditions and stumbled across this library. I gave it a quick try and I found it really powerful, but I'm not sure if the library is still being updated. I have two questions.

  1. update the documentation of the python library, otherwise it will be difficult to use and promote it back.
  2. I found that there is no parallelisation when building the Tree, which led to a speed similar to that of the KDTree in scipy when I tested it. The code is as follows.
import pyfnntw
from scipy.spatial import KDTree
import numpy as np

N = 500000
pos = np.random.random((N, 3))

kdt = KDTree(pos, leafsize=32, boxsize=[1.0, 1.0, 1.0])
_, ind = kdt.query(pos, 5, workers=-1)

rkdt = pyfnntw.Tree(pos, 32, np.array([1.0, 1.0, 1.0]))
_, rind = rkdt.query(pos, 5)

By the way, many thanks to the author for developing this library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.