Repository: zonebuilders/zonebuilder-py (language: python)

Issue:
Documentation and preparing for release
Hello,

Since the bindings are done, I thought we'd want to have this package easily available for download from `pip` which means uploading to pypi.org. Might be a good idea to have a few issues sorted out before that:
1. Documentation: At the moment it's just about dev stuff, is it a good idea to copy over images and descriptions from `zonebuilder-rust/README.md`?
2. Adding a test for the `clockboard` function? Any suggestions for a test case or just use the output from `zonebuilder-rust/examples/clockboard-example.rs` written to a json file and compared against a local run?
3. License? Author order convention?
4. Any other points?


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 0813365..dec42c0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,8 +3,6 @@ name = "zonebuilder-py"
 version = "0.1.0"
 edition = "2021"
 
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
 [dependencies]
 # zonebuilder = "0.1.0"
 zonebuilder = { git = "https://github.com/zonebuilders/zonebuilder-rust/" }
@@ -12,7 +10,7 @@ geojson = "0.22.2"
 geo = "0.17.1"
 
 [lib]
-name = "zonebuilder_py"
+name = "zonebuilder"
 crate-type = ["cdylib"]
 
 [dependencies.pyo3]
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..4ef91c8
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["maturin>=0.12,<0.13"]
+build-backend = "maturin"
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 09695a5..9fde6b7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -74,7 +74,7 @@ fn kwargsparse(kwargs: Option<&PyDict>) -> PyResult<Pyparams> {
     Ok(params)
 }
 
-#[pyfunction]
+#[pyfunction(kwargs = "**")]
 fn clockboard(center: [f64; 2], kwargs: Option<&PyDict>) -> PyResult<String> {
     let center_point = Point::new(center[0], center[1]);
     let params = kwargsparse(kwargs)?;
@@ -83,7 +83,7 @@ fn clockboard(center: [f64; 2], kwargs: Option<&PyDict>) -> PyResult<String> {
 }
 
 #[pymodule]
-fn zonebuilder_py(_py: Python, m: &PyModule) -> PyResult<()> {
+fn zonebuilder(_py: Python, m: &PyModule) -> PyResult<()> {
     m.add_function(wrap_pyfunction!(triangular_sequence, m)?)?;
     m.add_function(wrap_pyfunction!(clockboard, m)?)?;
     Ok(())


Test patch:
diff --git a/tests/test_clockboard.py b/tests/test_clockboard.py
new file mode 100644
index 0000000..6ee8607
--- /dev/null
+++ b/tests/test_clockboard.py
@@ -0,0 +1,34 @@
+from zonebuilder import clockboard, triangular_sequence
+import geojson, pytest
+
+
+def test_default():
+    featurecollection = geojson.loads(clockboard([0, 0]))
+    assert len(featurecollection["features"]) == 49
+
+
+@pytest.mark.parametrize(
+    "test_io",
+    [
+        # case 1
+        {"num_segments": 11, "distances": triangular_sequence(10)},
+        # case 2
+        {"num_segments": 1, "distances": triangular_sequence(3)},
+        # case 3
+        {"num_segments": 4, "distances": triangular_sequence(1)},
+    ],
+)
+def test_n_polygons(test_io):
+    featurecollection = geojson.loads(
+        clockboard(
+            [0, 0], num_segments=test_io["num_segments"], distances=test_io["distances"]
+        )
+    )
+    if test_io["num_segments"] > 1:
+        assert len(featurecollection["features"]) == (
+            test_io["num_segments"] * (len(test_io["distances"]) - 1) + 1
+        )
+    else:
+        assert len(featurecollection["features"]) == (
+            test_io["num_segments"] * len(test_io["distances"])
+        )
diff --git a/tests/test_triangular.py b/tests/test_triangular.py
index 24e4f31..193fc9b 100644
--- a/tests/test_triangular.py
+++ b/tests/test_triangular.py
@@ -1,4 +1,4 @@
-import zonebuilder_py
+import zonebuilder
 import pytest
 
 
@@ -16,5 +16,5 @@
     ],
 )
 def test_triangle(test_io):
-    output = zonebuilder_py.triangular_sequence(test_io["input"])
+    output = zonebuilder.triangular_sequence(test_io["input"])
     assert test_io["output"] == output