Complete worked example
python
import numpy as np
def inspect_example(values, chunk_size):
if type(chunk_size) is not int or chunk_size < 1:
raise ValueError("expected a positive chunk size")
total = 0.0
largest = 0
for start in range(0, len(values), chunk_size):
block = np.asarray(values[start:start + chunk_size], dtype=np.float64)
if block.ndim != 1 or not np.isfinite(block).all():
raise ValueError("expected finite scalar observations")
total += float(np.dot(block, block))
largest = max(largest, int(block.nbytes))
return {"result": total, "largestBlockBytes": largest}- Reasoning
- The worked loop constructs a float64 block for one slice, checks finite values, and adds its dot product with itself to a scalar accumulator. That computes a sum of squares without retaining a complete array of every squared value. The report includes the largest actual numerical block nbytes encountered, letting the tests verify the declared workspace boundary on small fixtures. The final short block must be processed as well as complete blocks. An empty input has a sum of squares of zero and a largest block size of zero. The explicit empty convention belongs to the sum contract; a later mean-based task needs its own denominator policy.