// Bounding box conversion: COCO [x, y, w, h] -> [x1, y1, x2, y2]
STATICMETHOD coco_bbox_to_corner_bbox(bbox):
// Case 1: single 4-element list [x, y, w, h]
IF is_list(bbox) AND length(bbox) == 4 AND all_elements_are_numbers(bbox):
x, y, w, h <- bbox
RETURN [x, y, x + w, y + h]
text
// Case 2: nested list with first element a 4-element list
IF is_list(bbox) AND length(bbox) > 0 AND is_list(bbox[0]) AND length(bbox[0]) == 4:
x, y, w, h <- bbox[0]
RETURN [x, y, x + w, y + h]
// Fallback (not expected by tests)
RETURN []
Notes:
download(data_dir) must be callable as COCODetection.download("test").
The test expectations: curl commands exactly as "curl {url} -o {target_dir}/{filename}" for each URL (order unconstrained); ZipFile constructed with "test/{filename}" for each URL (order unconstrained).
Use only standard library: pathlib.Path, zipfile.ZipFile, subprocess.call, etc.
Do not perform IO beyond the described actions; tests patch Path.mkdir, Path.unlink, ZipFile, and subprocess.call.