pointpca2 0.2.2__tar.gz → 0.3.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.
@@ -277,7 +277,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc"
277
277
  dependencies = [
278
278
  "proc-macro2",
279
279
  "quote",
280
- "syn 2.0.70",
280
+ "syn 2.0.71",
281
281
  ]
282
282
 
283
283
  [[package]]
@@ -450,18 +450,18 @@ dependencies = [
450
450
 
451
451
  [[package]]
452
452
  name = "pointpca2"
453
- version = "0.2.2"
453
+ version = "0.3.0"
454
454
  dependencies = [
455
455
  "nalgebra",
456
456
  "numpy",
457
- "pointpca2-rust",
457
+ "pointpca2-rs",
458
458
  "pyo3",
459
459
  ]
460
460
 
461
461
  [[package]]
462
- name = "pointpca2-rust"
463
- version = "0.1.0"
464
- source = "git+https://github.com/akaTsunemori/pointpca2-rs.git?tag=v1.2.2#353164ef997439d0ae825551f442a8c23d844dce"
462
+ name = "pointpca2-rs"
463
+ version = "1.3.0"
464
+ source = "git+https://github.com/akaTsunemori/pointpca2-rs.git?tag=v1.3.0#18d4d6534f8503d4e9ce7c6e178c3e3a425b4c94"
465
465
  dependencies = [
466
466
  "kd-tree",
467
467
  "libm",
@@ -659,7 +659,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
659
659
  dependencies = [
660
660
  "proc-macro2",
661
661
  "quote",
662
- "syn 2.0.70",
662
+ "syn 2.0.71",
663
663
  ]
664
664
 
665
665
  [[package]]
@@ -720,9 +720,9 @@ dependencies = [
720
720
 
721
721
  [[package]]
722
722
  name = "syn"
723
- version = "2.0.70"
723
+ version = "2.0.71"
724
724
  source = "registry+https://github.com/rust-lang/crates.io-index"
725
- checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16"
725
+ checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462"
726
726
  dependencies = [
727
727
  "proc-macro2",
728
728
  "quote",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "pointpca2"
3
- version = "0.2.2"
3
+ version = "0.3.0"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -11,9 +11,9 @@ crate-type = ["cdylib"]
11
11
  nalgebra = "0.32.5"
12
12
  numpy = "0.15"
13
13
 
14
- [dependencies.pointpca2-rust]
14
+ [dependencies.pointpca2-rs]
15
15
  git = "https://github.com/akaTsunemori/pointpca2-rs.git"
16
- tag = "v1.2.2"
16
+ tag = "v1.3.0"
17
17
 
18
18
  [dependencies.pyo3]
19
19
  version = "0.15.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pointpca2
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Requires-Dist: numpy >=1.26
5
5
  Requires-Dist: toml ==0.10.0
6
6
  License-File: LICENSE
@@ -0,0 +1,53 @@
1
+ extern crate nalgebra as na;
2
+ extern crate numpy;
3
+ extern crate pointpca2_rs;
4
+
5
+ use na::DMatrix;
6
+ use numpy::PyArray1;
7
+ use numpy::PyReadonlyArray2;
8
+ use pyo3::prelude::*;
9
+ use pyo3::wrap_pyfunction;
10
+
11
+ fn as_dmatrix<'a, T>(x: &'a PyReadonlyArray2<T>) -> DMatrix<T>
12
+ where
13
+ T: numpy::Element + na::Scalar,
14
+ {
15
+ let data: Vec<T> = x.as_array().iter().cloned().collect();
16
+ DMatrix::from_row_slice(x.shape()[0], x.shape()[1], &data)
17
+ }
18
+
19
+ #[pyfunction]
20
+ fn compute_pointpca2<'py>(
21
+ _py: Python<'py>,
22
+ points_a: PyReadonlyArray2<'py, f64>,
23
+ colors_a: PyReadonlyArray2<'py, u8>,
24
+ points_b: PyReadonlyArray2<'py, f64>,
25
+ colors_b: PyReadonlyArray2<'py, u8>,
26
+ search_size: usize,
27
+ verbose: bool,
28
+ ) -> &'py PyArray1<f64> {
29
+ let (points_a, colors_a, points_b, colors_b) = {
30
+ (
31
+ as_dmatrix(&points_a),
32
+ as_dmatrix(&colors_a),
33
+ as_dmatrix(&points_b),
34
+ as_dmatrix(&colors_b),
35
+ )
36
+ };
37
+ let pooled_predictors = pointpca2_rs::compute_pointpca2(
38
+ points_a,
39
+ colors_a,
40
+ points_b,
41
+ colors_b,
42
+ search_size,
43
+ verbose,
44
+ );
45
+ let py_array = PyArray1::from_iter(_py, pooled_predictors.iter().cloned());
46
+ py_array
47
+ }
48
+
49
+ #[pymodule]
50
+ fn pointpca2(_py: Python, m: &PyModule) -> PyResult<()> {
51
+ m.add_function(wrap_pyfunction!(compute_pointpca2, m)?)?;
52
+ Ok(())
53
+ }
@@ -1,73 +0,0 @@
1
- extern crate nalgebra as na;
2
- extern crate numpy;
3
- extern crate pointpca2_rust;
4
-
5
- use na::DMatrix;
6
- use numpy::PyArray1;
7
- use numpy::PyReadonlyArray2;
8
- use pointpca2_rust::features;
9
- use pointpca2_rust::knn_search;
10
- use pointpca2_rust::pooling;
11
- use pointpca2_rust::predictors;
12
- use pointpca2_rust::preprocessing;
13
- use pyo3::prelude::*;
14
- use pyo3::wrap_pyfunction;
15
-
16
- fn print_if_verbose<'a>(string: &'a str, verbose: &'a bool) {
17
- if *verbose {
18
- println!("{}", string);
19
- }
20
- }
21
-
22
- fn as_dmatrix<'a, T>(x: &'a PyReadonlyArray2<T>) -> DMatrix<T>
23
- where
24
- T: numpy::Element + na::Scalar,
25
- {
26
- let data: Vec<T> = x.as_array().iter().cloned().collect();
27
- DMatrix::from_row_slice(x.shape()[0], x.shape()[1], &data)
28
- }
29
-
30
- #[pyfunction]
31
- fn compute_pointpca2<'py>(
32
- _py: Python<'py>,
33
- points_a: PyReadonlyArray2<'py, f64>,
34
- colors_a: PyReadonlyArray2<'py, u8>,
35
- points_b: PyReadonlyArray2<'py, f64>,
36
- colors_b: PyReadonlyArray2<'py, u8>,
37
- search_size: usize,
38
- verbose: bool,
39
- ) -> &'py PyArray1<f64> {
40
- let points_a = as_dmatrix(&points_a);
41
- let colors_a = as_dmatrix(&colors_a);
42
- let points_b = as_dmatrix(&points_b);
43
- let colors_b = as_dmatrix(&colors_b);
44
- print_if_verbose("Preprocessing", &verbose);
45
- let (points_a, colors_a) = preprocessing::preprocess_point_cloud(&points_a, &colors_a);
46
- let (points_b, colors_b) = preprocessing::preprocess_point_cloud(&points_b, &colors_b);
47
- print_if_verbose("Performing knn search", &verbose);
48
- let knn_indices_a = knn_search::knn_search(&points_a, &points_a, search_size);
49
- let knn_indices_b = knn_search::knn_search(&points_b, &points_a, search_size);
50
- print_if_verbose("Computing local features", &verbose);
51
- let local_features = features::compute_features(
52
- points_a,
53
- colors_a,
54
- points_b,
55
- colors_b,
56
- knn_indices_a,
57
- knn_indices_b,
58
- search_size,
59
- );
60
- print_if_verbose("Computing predictors", &verbose);
61
- let predictors_result = predictors::compute_predictors(local_features);
62
- print_if_verbose("Pooling predictors", &verbose);
63
- let pooled_predictors = pooling::mean_pooling(predictors_result);
64
- print_if_verbose("Done", &verbose);
65
- let py_array = PyArray1::from_iter(_py, pooled_predictors.iter().cloned());
66
- py_array
67
- }
68
-
69
- #[pymodule]
70
- fn pointpca2(_py: Python, m: &PyModule) -> PyResult<()> {
71
- m.add_function(wrap_pyfunction!(compute_pointpca2, m)?)?;
72
- Ok(())
73
- }
File without changes
File without changes
File without changes
File without changes
File without changes