gridr 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.
gridr-0.0.0/Cargo.toml ADDED
@@ -0,0 +1,35 @@
1
+ # Cargo.toml
2
+ [package]
3
+ name = "pyo3-cookie-cutter"
4
+ version = "0.1.0"
5
+ edition = "2021"
6
+
7
+ [features]
8
+ extension-module = ["pyo3/extension-module"]
9
+ default = []
10
+
11
+ [dependencies]
12
+ pyo3 = { version = "0.21.2", features = ["extension-module", "experimental-declarative-modules"]}
13
+ #pyo3 = "^0.22.0"
14
+ #pyo3 = "*"
15
+ numpy = "0.21.0"
16
+ ndarray = { version = "0.15.6", features = ["approx", "rayon"] }
17
+ #ndarray = "^0.15.6"
18
+ #numpy = "^0.21.0"
19
+ #numpy = "*"
20
+
21
+ #rand = "0.8.5" # Specific for this example
22
+ #ordered-float = "2.10.0" # Specific for this example
23
+
24
+ [build-dependencies]
25
+ pyo3-build-config = "0.22.0"
26
+
27
+ [lib]
28
+ name = "_mylib" # private module to be nested into Python package,
29
+ # needs to match the name of the function with the `[#pymodule]` attribute
30
+ path = "rust/lib.rs"
31
+ crate-type = ["cdylib"] # required for shared library for Python to import from.
32
+
33
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
34
+ # See also PyO3 docs on writing Cargo.toml files at https://pyo3.rs
35
+
@@ -0,0 +1,4 @@
1
+ # MANIFEST.in
2
+ include Cargo.toml
3
+ recursive-include rust *.rs
4
+
gridr-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: gridr
3
+ Version: 0.0.0
4
+ Summary: Geometric and Radiometric Image Data Resampling
5
+ Author-email: Arnaud Kelbert <arnaud.kelbert@cnes.fr>
6
+ Classifier: Programming Language :: Python
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Rust
10
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
11
+ Classifier: Topic :: Software Development :: Libraries
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: numpy>=1.24.4
16
+
17
+ # GRIDR - Geometric and Radiometric Image Data Resampling
18
+ A python/rust library for image resampling. In progress...
gridr-0.0.0/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # GRIDR - Geometric and Radiometric Image Data Resampling
2
+ A python/rust library for image resampling. In progress...
@@ -0,0 +1,37 @@
1
+ # pyproject.toml
2
+ [build-system]
3
+ requires = ["setuptools", "setuptools-rust"]
4
+ build-backend = "setuptools.build_meta"
5
+
6
+ [project]
7
+ name = "gridr"
8
+ version = "0.0.0"
9
+ description = "Geometric and Radiometric Image Data Resampling"
10
+ authors = [ {name="Arnaud Kelbert", email="arnaud.kelbert@cnes.fr"} ]
11
+ readme = "README.md"
12
+ #license = {file = "LICENSE"}
13
+ classifiers = [
14
+ "Programming Language :: Python",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.8",
17
+ "Programming Language :: Rust",
18
+ "Topic :: Scientific/Engineering :: Image Processing",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Topic :: Software Development :: Libraries :: Python Modules",
21
+ "License :: OSI Approved :: Apache Software License"
22
+ ]
23
+ dependencies = [
24
+ "numpy>=1.24.4",
25
+ ]
26
+
27
+
28
+ [tool.setuptools.packages]
29
+ # Pure Python packages/modules
30
+ find = { where = ["python"] }
31
+
32
+ [[tool.setuptools-rust.ext-modules]]
33
+ # Private Rust extension module to be nested into the Python package
34
+ target = "mylib._mylib" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml,
35
+ # but you can add a prefix to nest it inside of a Python package.
36
+ path = "Cargo.toml" # Default value, can be omitted
37
+ binding = "PyO3" # Default value, can be omitted
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: gridr
3
+ Version: 0.0.0
4
+ Summary: Geometric and Radiometric Image Data Resampling
5
+ Author-email: Arnaud Kelbert <arnaud.kelbert@cnes.fr>
6
+ Classifier: Programming Language :: Python
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Rust
10
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
11
+ Classifier: Topic :: Software Development :: Libraries
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: numpy>=1.24.4
16
+
17
+ # GRIDR - Geometric and Radiometric Image Data Resampling
18
+ A python/rust library for image resampling. In progress...
@@ -0,0 +1,13 @@
1
+ Cargo.toml
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ python/gridr.egg-info/PKG-INFO
6
+ python/gridr.egg-info/SOURCES.txt
7
+ python/gridr.egg-info/dependency_links.txt
8
+ python/gridr.egg-info/requires.txt
9
+ python/gridr.egg-info/top_level.txt
10
+ python/mylib/__init__.py
11
+ rust/lib.rs
12
+ rust/lib_core.rs
13
+ rust/lib_py.rs
@@ -0,0 +1 @@
1
+ numpy>=1.24.4
@@ -0,0 +1 @@
1
+ mylib
@@ -0,0 +1,7 @@
1
+ from ._mylib import sum_as_string, array_func
2
+
3
+ __all__ = ["sum_as_string", "array_func"]
4
+
5
+ # It is a common practice in Python packaging to keep the extension modules
6
+ # private and use Pure Python modules to wrap them.
7
+ # This allows you to have a very fine control over the public API.
@@ -0,0 +1,24 @@
1
+ #![warn(missing_docs)]
2
+ //! Crate doc
3
+ mod lib_core;
4
+ mod lib_py;
5
+
6
+ // Instead of declaring "mod lib_py" from another file you can also directly
7
+ // define the pymodule here ; see bellow.
8
+ //use pyo3::prelude::*;
9
+ //
10
+ // /// A Python module implemented in Rust. The name of this function must match
11
+ // /// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
12
+ // /// import the module.
13
+ //#[pymodule]
14
+ //mod _mylib {
15
+ // use pyo3::prelude::*;
16
+ // use crate::lib_core::mymodule as core_mymodule;
17
+ //
18
+ // /// Formats the sum of two numbers as string.
19
+ // #[pyfunction]
20
+ // fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
21
+ // core_mymodule::sum_a_b_str(a as f64,b as f64)
22
+ // //Ok((a + b).to_string())
23
+ // }
24
+ //}
@@ -0,0 +1,33 @@
1
+ #![warn(missing_docs)]
2
+ //! Crate doc
3
+ //use ndarray as nd;
4
+ /// Add python binding in the scope
5
+
6
+ /// Current module
7
+ pub mod mymodule {
8
+ use ndarray::prelude::*;
9
+ use ndarray::{ArrayViewD, ArrayViewMutD};
10
+ //use numpy::ndarray::{ArrayViewD, ArrayViewMutD};
11
+
12
+ /// Function sum_a_b_str
13
+ pub fn sum_a_b_str<E>(a: f64, b: f64) -> Result<String, E> {
14
+ let s = a + b;
15
+ //s.to_string()?
16
+ Ok(s.to_string())
17
+ }
18
+
19
+ pub fn an_array_func(
20
+ an_imut_array: &ArrayViewD<'_, f64>,
21
+ a_mut_array: &mut ArrayViewMutD<'_, f64>) -> i32 {
22
+
23
+ if a_mut_array.len() != an_imut_array.len() {
24
+ panic!("both arrays must share same length")
25
+ }
26
+ a_mut_array.slice_mut(s![..]).assign(&(&an_imut_array.slice(s![..]) * 2.0));
27
+ //a_mut_array[0] = an_imut_array[0] * 2.0;
28
+ //a_mut_array[1] = an_imut_array[1] * 2.0;
29
+ let ret = 1;
30
+ ret
31
+ }
32
+ }
33
+
@@ -0,0 +1,63 @@
1
+ #![warn(missing_docs)]
2
+ //! Crate doc
3
+ use pyo3::prelude::*;
4
+ use crate::lib_core::mymodule as core_mymodule;
5
+ use ndarray;
6
+ use numpy::{IntoPyArray, PyArray1, PyArray2, PyArrayDyn, PyReadonlyArrayDyn, PyArrayMethods};
7
+
8
+ /// We tell here what module/functions we use from the pure rust library (lib.rs)
9
+ //use crate::lib_core::*;
10
+
11
+ /// A Python module implemented in Rust. The name of this function must match
12
+ /// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
13
+ /// import the module.
14
+ //#[pymodule]
15
+ //mod _mylib {
16
+ #[pymodule]
17
+ fn _mylib(m: &Bound<'_, PyModule>) -> PyResult<()> {
18
+ m.add_function(wrap_pyfunction!(array_func,m)?)?;
19
+ m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
20
+ Ok(())
21
+ }
22
+
23
+ /// A numpy imut/mut function
24
+ #[pyfunction]
25
+ #[allow(clippy::too_many_arguments)]
26
+ fn array_func(
27
+ read_arr: &Bound<'_, PyArrayDyn<f64>>,
28
+ write_arr: &Bound<'_, PyArrayDyn<f64>>
29
+ ) -> Result<(), PyErr> {
30
+
31
+ // Convert the read only array into ndarray
32
+ let read_arr = read_arr.readonly();
33
+ let read_arr = read_arr.as_array(); //.expect("read_arr is not contiguous");
34
+
35
+ // Make the write_arr mutable
36
+ let mut write_arr = write_arr.readwrite();
37
+ let mut write_arr = write_arr.as_array_mut();
38
+
39
+ //println!("Before function call...");
40
+ //println!("{}", read_arr[0].to_string());
41
+ //println!("{}", read_arr.len().to_string());
42
+ //println!("{}", write_arr.len().to_string());
43
+ core_mymodule::an_array_func(&read_arr.view(), &mut write_arr.view_mut());
44
+ Ok(())
45
+ /* match core_mymodule::an_array_func(&read_arr, &write_arr) {
46
+ Ok(()) => {
47
+ println!("Computation ok");
48
+ Ok(())
49
+ },
50
+ _ => {
51
+ println!("Computation not ok");
52
+ Ok(())
53
+ }
54
+ } */
55
+ }
56
+
57
+ /// Formats the sum of two numbers as string.
58
+ #[pyfunction]
59
+ fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
60
+ core_mymodule::sum_a_b_str(a as f64,b as f64)
61
+ //Ok((a + b).to_string()
62
+ }
63
+
gridr-0.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+