name: review-transform description: Run the full shared Codex review checklist against a transform. Use when the user asks to review, audit, or check a transform for correctness, performance, or API consistency.
Review Transform
Run these checks in order. Report issues with severity: ๐ด Critical, ๐ก Important, ๐ข Suggestion.
1. Dead Code (๐ด Critical)
- Any methods defined but never called within the class or externally
- Unused imports at the top of the file
- Unreachable branches (
if False:, conditions that can never be true)
2. Correctness
- Mathematical/logical errors in the transform
- Off-by-one errors in coordinate handling
- Incorrect dtype preservation (uint8 in โ uint8 out, float32 in โ float32 out)
- BBox/keypoint coordinate correctness after spatial transforms
- Do not request 2D grayscale compatibility for Compose paths: images and volumes are channel-last with explicit channels
(
(H,W,C),(N,H,W,C),(D,H,W,C),(N,D,H,W,C)), and grayscale is(H,W,1). - Never auto-detect bbox type from column count โ type comes from
BboxParams.bbox_type - For OBB: never use raw
cv2.minAreaRectoutput; usecv2.boxPointsthenpolygons_to_obb
3. API Consistency (๐ด Critical)
- No "Random" prefix in class name
- Range params use
_rangesuffix:brightness_range, notbrightness_limit -
fillnotfill_value,fill_masknotfill_mask_value -
border_modenotmodeorpad_mode - No default values in
InitSchema(except Pydantic discriminator fields) - No default values in
apply_*method args (other thanself,**params) - All
InitSchemafields useAnnotated[...]validators where applicable - No
get_transform_init_args_names()override โ the base class auto-detects from__init__via MRO
4. Random Number Generation (๐ด Critical)
- All randomness lives in
get_paramsorget_params_dependent_on_data, NOT inapply_* - Uses
self.py_randomfor simple ops (faster) - Uses
self.random_generatoronly when numpy arrays are needed - No
np.random.*orrandom.*module-level calls anywhere in the class
5. Type Safety (๐ด Critical)
- All methods have complete type hints
-
ImageTypeused for image/mask/volume params and return types (notnp.ndarray) -
np.ndarrayused for bboxes and keypoints only - No unsafe type conversions or missing dtype handling
6. Performance (๐ก Important)
Priority order to check:
cv2.LUTused for pixel lookup operations (fastest)albucore.resizenotcv2.resizefor image resizing (handles 5+ channels, INTER_AREA, etc.)cv2over numpy for image ops where applicable- Vectorized numpy instead of Python loops
- In-place ops where safe (avoid unnecessary
.copy()) - No repeated array allocations in tight loops
- Expensive computations cached in
get_params/get_params_dependent_on_data
Batch Optimization Checks
- Custom
apply_to_imagesif expensive setup (kernels, LUTs, gradient maps) can be computed once per batch - No redundant
ndim == 4checks on images โ they're always 4D in batch context - No 2D grayscale branches in Compose functional paths โ grayscale images are
(H,W,1) - No reshape trick: Do NOT reshape
(N,H,W,1)to(H,W,N)for cv2 โ 2โ4ร slower due to non-contiguous copy + sequential channel processing
Flag any violations with a concrete speedup suggestion.
7. Documentation (๐ก Important)
- Docstring has
Args,Targets,Image typessections -
Examplessection present (plural, not "Example") - Examples follow the standard pattern with image, mask, bboxes, keypoints
- Examples use
A.ComposewithBboxParamsandKeypointParams - No
---sequences in docstring (pre-commit will catch this but check anyway)
8. Test Coverage (๐ก Important)
- Transform appears in
get_dual_transforms()orget_image_only_transforms()intests/utils.py - Tested with uint8 and float32
- Tested with 1, 3, and N channels (if applicable)
- Edge cases covered (empty bboxes, zero-area regions, etc.)
- Tests use
seed=137(not 42) - Tests use
np.testingassertions (not plainassert)
9. Code Quality (๐ข Suggestion)
- No unused imports
- No overly complex logic that could be simplified
- Relative parameters (fractions) preferred over fixed pixel values
- Consistent style with similar existing transforms
Reporting Format
## Review: <TransformName>
### ๐ด Critical
- **Dead code**: `_unused_method` is never called (line 42)
- **API**: Parameter `fill_value` should be `fill`
### ๐ก Important
- **Performance**: Use `cv2.LUT` instead of numpy indexing for pixel mapping (5-10x faster)
- **Docs**: Missing `Examples` section in docstring
### ๐ข Suggestions
- Consider using relative `noise_range` instead of absolute pixel values