From 0d36bc1f3b52ded4d5bf5b636f8c0e1ebcf6abd0 Mon Sep 17 00:00:00 2001 From: Brendan Collins Date: Tue, 23 Jun 2026 05:14:48 -0700 Subject: [PATCH] perlin: document name param, float-dtype requirement, and ValueError The perlin() docstring listed only agg, freq, and seed in Parameters, omitting the name parameter. It also said nothing about the float-dtype requirement that the function enforces, nor the ValueError it raises on integer input (guarded by test_perlin_rejects_integer_dtype, regression from #1232). Documents name, notes the float-dtype requirement on agg, and adds a Raises section. Docstring-only; no behavior change. Records the documentation sweep state for perlin. --- .claude/sweep-documentation-state.csv | 2 ++ xrspatial/perlin.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 .claude/sweep-documentation-state.csv diff --git a/.claude/sweep-documentation-state.csv b/.claude/sweep-documentation-state.csv new file mode 100644 index 000000000..7c342d626 --- /dev/null +++ b/.claude/sweep-documentation-state.csv @@ -0,0 +1,2 @@ +module,last_inspected,issue,severity_max,categories_found,notes,doc_coverage +perlin,2026-06-23,,MEDIUM,2;5,"name param undocumented (Cat2) + float-dtype requirement/ValueError undocumented, no Raises section (Cat5); fixed in deep-sweep-documentation-perlin-2026-06-23; repo has issues disabled so no issue number; example runs and output matches; 1 public func (perlin) listed in reference/surface.rst",1/1 diff --git a/xrspatial/perlin.py b/xrspatial/perlin.py index fe08cff8c..5beebb2ff 100644 --- a/xrspatial/perlin.py +++ b/xrspatial/perlin.py @@ -294,16 +294,28 @@ def perlin(agg: xr.DataArray, agg : xr.DataArray 2D array of size width x height, will be used to determine height/ width and which platform to use for calculation. + Must have a floating-point dtype (float32 or float64); integer + input is rejected (see Raises). freq : tuple, default=(1,1) (x, y) frequency multipliers. seed : int, default=5 Seed for random number generator. + name : str, default='perlin' + Name assigned to the output DataArray. Returns ------- perlin_agg : xarray.DataArray 2D array of perlin noise values. + Raises + ------ + ValueError + If `agg` does not have a floating-point dtype. The noise is + written into `agg` in place and then normalized; an integer + buffer would truncate the float values to zero and corrupt the + result, so non-float input is rejected up front. + References ---------- - Paul Panzer: https://stackoverflow.com/questions/42147776/producing-2d-perlin-noise-with-numpy # noqa