martin-g commented on code in PR #97:
URL: https://github.com/apache/sedona-db/pull/97#discussion_r2464752604


##########
python/sedonadb/python/sedonadb/testing.py:
##########
@@ -29,6 +29,85 @@
     import sedonadb
 
 
+def random_geometry(
+    n: int = 1024,
+    geometry_type: Literal[
+        "Point",
+        "LineString",
+        "Polygon",
+        "MultiPoint",
+        "MultiLineString",
+        "MultiPolygon",
+        "GeometryCollection",
+    ] = "Point",
+    *,
+    num_vertices: Union[int, Tuple[int, int]] = 4,
+    num_parts: Union[int, Tuple[int, int]] = (1, 3),
+    size: Union[float, Tuple[float, float]] = (5.0, 20.0),
+    bounds: Iterable[float] = (-170, -80, 170, 80),
+    hole_rate: float = 0.0,
+    empty_rate: float = 0.0,
+    null_rate: float = 0.0,
+    seed: Optional[int] = None,
+) -> "sedonadb.dataframe.DataFrame":

Review Comment:
   nit: Missing docstring



##########
python/sedonadb/python/sedonadb/testing.py:
##########
@@ -29,6 +29,85 @@
     import sedonadb
 
 
+def random_geometry(
+    n: int = 1024,
+    geometry_type: Literal[
+        "Point",
+        "LineString",
+        "Polygon",
+        "MultiPoint",
+        "MultiLineString",
+        "MultiPolygon",
+        "GeometryCollection",
+    ] = "Point",
+    *,
+    num_vertices: Union[int, Tuple[int, int]] = 4,
+    num_parts: Union[int, Tuple[int, int]] = (1, 3),
+    size: Union[float, Tuple[float, float]] = (5.0, 20.0),
+    bounds: Iterable[float] = (-170, -80, 170, 80),
+    hole_rate: float = 0.0,
+    empty_rate: float = 0.0,
+    null_rate: float = 0.0,
+    seed: Optional[int] = None,
+) -> "sedonadb.dataframe.DataFrame":
+    import json
+    import time
+
+    import sedonadb
+
+    if isinstance(num_vertices, tuple):
+        num_vertices_min, num_vertices_max = num_vertices
+    else:
+        num_vertices_min = num_vertices_max = num_vertices
+
+    if isinstance(num_parts, tuple):
+        num_parts_min, num_parts_max = num_parts
+    else:
+        num_parts_min = num_parts_max = num_parts
+
+    if isinstance(size, tuple):
+        size_min, size_max = size
+    else:
+        size_min = size
+        size_max = size + size / 1e3
+
+    if num_vertices_min > num_vertices_max:
+        raise ValueError("num_vertices_min > num_vertices_max")
+    if num_parts_min > num_parts_max:
+        raise ValueError("num_parts_min > num_parts_max")
+    if size_min > size_max:
+        raise ValueError("size_min > size_max")
+
+    bounds = [float(b) for b in bounds]
+    if len(bounds) != 4:
+        raise ValueError(
+            f"Expected bounds as [xmin, ymin, xmax, ymax] but got {bounds}"
+        )
+
+    width = bounds[2] - bounds[0]
+    height = bounds[3] - bounds[1]
+    if size_min > width or size_min > height:
+        raise ValueError("size > height / 2 or width / 2 of bounds")

Review Comment:
   The error message does not match the check. The error message talks about 
halfs.



##########
python/sedonadb/python/sedonadb/testing.py:
##########
@@ -29,6 +29,85 @@
     import sedonadb
 
 
+def random_geometry(
+    n: int = 1024,
+    geometry_type: Literal[
+        "Point",
+        "LineString",
+        "Polygon",
+        "MultiPoint",
+        "MultiLineString",
+        "MultiPolygon",
+        "GeometryCollection",
+    ] = "Point",
+    *,
+    num_vertices: Union[int, Tuple[int, int]] = 4,
+    num_parts: Union[int, Tuple[int, int]] = (1, 3),
+    size: Union[float, Tuple[float, float]] = (5.0, 20.0),
+    bounds: Iterable[float] = (-170, -80, 170, 80),
+    hole_rate: float = 0.0,
+    empty_rate: float = 0.0,
+    null_rate: float = 0.0,
+    seed: Optional[int] = None,
+) -> "sedonadb.dataframe.DataFrame":
+    import json
+    import time
+
+    import sedonadb
+
+    if isinstance(num_vertices, tuple):
+        num_vertices_min, num_vertices_max = num_vertices
+    else:
+        num_vertices_min = num_vertices_max = num_vertices
+
+    if isinstance(num_parts, tuple):
+        num_parts_min, num_parts_max = num_parts
+    else:
+        num_parts_min = num_parts_max = num_parts
+
+    if isinstance(size, tuple):
+        size_min, size_max = size
+    else:
+        size_min = size
+        size_max = size + size / 1e3
+
+    if num_vertices_min > num_vertices_max:
+        raise ValueError("num_vertices_min > num_vertices_max")
+    if num_parts_min > num_parts_max:
+        raise ValueError("num_parts_min > num_parts_max")
+    if size_min > size_max:
+        raise ValueError("size_min > size_max")
+
+    bounds = [float(b) for b in bounds]
+    if len(bounds) != 4:
+        raise ValueError(
+            f"Expected bounds as [xmin, ymin, xmax, ymax] but got {bounds}"
+        )
+
+    width = bounds[2] - bounds[0]

Review Comment:
   Should there be checks that xmin is smaller than xmax ?
   Same for the `y` bounds below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to