Skip to content

Commit 4b24d6a

Browse files
authored
Merge pull request #9 from agfianf/docs/complete-docstring
Docs/complete docstring
2 parents 149e1f5 + f5cccb9 commit 4b24d6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+750
-269
lines changed

.github/workflows/docs.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,29 @@ jobs:
1818
id-token: write
1919
actions: read
2020
steps:
21-
- name: Clone repository
21+
- name: 🗃️ Clone repository
2222
uses: actions/checkout@v4
2323

24-
- name: Install uv and set the python version
24+
- name: 🐍 Install uv and set the python version
2525
uses: astral-sh/setup-uv@v5
2626
with:
2727
version: "0.5.24"
2828
enable-cache: true
2929
cache-dependency-glob: "uv.lock"
3030
python-version: 3.12
3131

32-
33-
- name: Install dependencies
32+
- name: 📦 Install dependencies
3433
run: |
3534
uv sync --only-group docs
3635
37-
- name: Build MkDocs site
36+
- name: 🏗️ Build MkDocs site
3837
run: |
3938
mkdocs build
4039
41-
- name: Setup Pages
40+
- name: 🔧 Setup Pages
4241
uses: actions/configure-pages@v3
4342

44-
- name: Upload artifact
43+
- name: 📤 Upload artifact
4544
uses: actions/upload-pages-artifact@v3
4645
with:
4746
path: ./site
@@ -61,6 +60,6 @@ jobs:
6160
url: ${{ steps.deployment.outputs.page_url }}
6261

6362
steps:
64-
- name: Deploy to GitHub Pages
63+
- name: 🚀 Deploy to GitHub Pages
6564
id: deployment
6665
uses: actions/deploy-pages@v4

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ on:
55
branches: [ main ]
66
paths-ignore:
77
- '**.md'
8+
- '*.md'
9+
- '**.js'
10+
- '**.html'
11+
- '**.css'
812
- 'docs/**'
913
- 'LICENSE'
1014
- '.gitignore'
1115
- '.pre-commit-config.yaml'
1216
- 'mkdocs.yml'
13-
- 'docs_requirements.txt'
17+
- 'CHANGELOG.md'
1418

1519
jobs:
1620
test:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v0.0.1-rc1] - 2025-02-10
4+
**Release Candidate with Full Feature Set and Documentation**
5+
- Add docs page build with mkdocs-material. Read more [https://agfianf.github.io/color-correction/](https://agfianf.github.io/color-correction/)
6+
- Complete docstrings for all classes and methods
7+
38
## [v0.0.1b3] - 2025-02-06
49
**Add Analyzer Report and Bug Fixes**
510

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ log:
1919

2020
update-uv-lock:
2121
uv lock
22+
23+
list-installed:
24+
uv pip list
25+
26+
sync-docs:
27+
uv sync --only-group={docs,dev}
28+
29+
sync-all:
30+
uv sync --all-groups --no-group dev-model

color_correction/core/correction/polynomial.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class Polynomial(BaseComputeCorrection):
2020
----------
2121
**kwargs : dict, optional
2222
Keyword arguments. Recognized keyword:
23-
degree : int, optional, default 2
24-
Degree of the polynomial.
23+
24+
- `degree` : int, optional, default 2
25+
Degree of the polynomial.
2526
"""
2627

2728
def __init__(self, **kwargs: dict) -> None:
@@ -60,17 +61,15 @@ def fit(
6061
Reference image patches.
6162
**kwargs : dict
6263
Additional keyword arguments. Recognized keyword:
63-
degree : int, optional
64-
Degree of the polynomial.
64+
65+
- `degree` : int, optional
66+
Degree of the polynomial.
6567
6668
Returns
6769
-------
6870
np.ndarray
6971
Fitted model pipeline.
7072
71-
Notes
72-
-----
73-
The execution time for model fitting is printed.
7473
"""
7574
start_time = time.perf_counter()
7675
degree = kwargs.get("degree", self.degree)

color_correction/schemas/__init__.py

Whitespace-only changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""
2+
Images Schema Module
3+
--------------------
4+
This module defines type annotations for image processing.
5+
6+
Attributes
7+
----------
8+
ColorPatchType : numpy.typing.NDArray[np.uint8]
9+
Represents a color patch extracted from an image. Usually a mean of a region patch.
10+
11+
Example
12+
-------
13+
```python
14+
np.array(
15+
[
16+
[68, 82, 115], # 1. Dark skin
17+
[128, 149, 195], # 2. Light skin
18+
[157, 123, 93], # 3. Blue sky
19+
[65, 108, 91], # 4. Foliage
20+
[175, 129, 130], # 5. Blue flower
21+
[171, 191, 99], # 6. Bluish green
22+
[46, 123, 220], # 7. Orange
23+
[168, 92, 72], # 8. Purplish blue
24+
[97, 84, 194], # 9. Moderate red
25+
[104, 59, 91], # 10. Purple
26+
[62, 189, 161], # 11. Yellow green
27+
[40, 161, 229], # 12. Orange yellow
28+
[147, 63, 42], # 13. Blue
29+
[72, 149, 72], # 14. Green
30+
[57, 50, 175], # 15. Red
31+
[22, 200, 238], # 16. Yellow
32+
[150, 84, 188], # 17. Magenta
33+
[166, 137, 0], # 18. Cyan
34+
[240, 245, 245], # 19. White 9.5
35+
[201, 202, 201], # 20. Neutral 8
36+
[162, 162, 161], # 21. Neutral 6.5
37+
[121, 121, 120], # 22. Neutral 5
38+
[85, 85, 83], # 23. Neutral 3.5
39+
[51, 50, 50], # 24. Black 2
40+
],
41+
)
42+
```
43+
ImageType : numpy.typing.NDArray[np.uint8]
44+
Represents an image 3D array with shape (H, W, C) in uint8 format.
45+
ImageBGR : numpy.typing.NDArray[np.uint8]
46+
Represents an image in BGR format (OpenCV default).
47+
ImageRGB : numpy.typing.NDArray[np.uint8]
48+
Represents an image in RGB format.
49+
50+
"""
51+
52+
from typing import Literal
53+
54+
import numpy as np
55+
from numpy.typing import NDArray
56+
57+
LiteralModelCorrection = Literal[
58+
"least_squares",
59+
"polynomial",
60+
"linear_reg",
61+
"affine_reg",
62+
]
63+
64+
LiteralModelDetection = Literal["yolov8"]
65+
66+
ColorPatchType = NDArray[np.uint8]
67+
ImageType = NDArray[np.uint8]
68+
ImageBGR = NDArray[np.uint8]
69+
ImageRGB = NDArray[np.uint8]
70+
ImageGray = NDArray[np.uint8]

color_correction/schemas/det_yv8.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
Module for detection result schema using Pydantic.
3+
4+
Provides the DetectionResult model that contains detection boxes, scores, and class ids,
5+
and a helper method to draw these detections on an image.
6+
"""
7+
18
import numpy as np
29
from pydantic import BaseModel
310

@@ -7,6 +14,38 @@
714

815

916
class DetectionResult(BaseModel):
17+
"""
18+
Detection result model for YOLOv8 card and color patches detection.
19+
20+
A data model that encapsulates YOLOv8 detection results for a standardized color
21+
card and its color patches. The model handles two distinct classes:
22+
patches (label 0) and card (label 1). In a typical detection scenario,
23+
the model captures one color calibration card and 24 color patches.
24+
25+
26+
Notes
27+
-----
28+
The detection typically yields 25 objects:
29+
30+
- 1 calibration card (class_id: 1)
31+
- 24 color patches (class_id: 0)
32+
33+
Attributes
34+
----------
35+
boxes : list[tuple[int, int, int, int]]
36+
List of bounding boxes as (x1, y1, x2, y2).
37+
Representing the top-left and bottom-right corners of the detection.
38+
Class identifiers for each detected object where:
39+
40+
- 0: represents color patches
41+
- 1: represents the calibration card
42+
43+
scores : list[float]
44+
List of confidence scores for each detection.
45+
class_ids : list[int]
46+
List of class IDs corresponding to each detection.
47+
"""
48+
1049
boxes: list[BoundingBox]
1150
scores: list[float]
1251
class_ids: list[int]
@@ -15,5 +54,17 @@ def draw_detections(
1554
self,
1655
image: np.ndarray,
1756
) -> np.ndarray:
18-
"""Draw detection boxes on image."""
57+
"""
58+
Draw detection boxes on the provided image.
59+
60+
Parameters
61+
----------
62+
image : numpy.ndarray
63+
The image on which the detection boxes will be drawn.
64+
65+
Returns
66+
-------
67+
numpy.ndarray
68+
The image with the drawn detection boxes.
69+
"""
1970
return draw_detections(image, self.boxes, self.scores, self.class_ids)

color_correction/schemas/device.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ class CPUArchitecture(str, Enum):
1919

2020

2121
class DeviceSpecs(BaseModel):
22-
"""Device specifications schema."""
22+
"""
23+
Device specifications schema.
24+
25+
Attributes
26+
----------
27+
os_name : str
28+
Operating system name.
29+
cpu_arch : CPUArchitecture
30+
CPU architecture.
31+
gpu_type : GPUType
32+
GPU type.
33+
is_apple_silicon : bool
34+
Whether the device is Apple Silicon.
35+
"""
2336

2437
os_name: str = Field(..., description="Operating system name")
2538
cpu_arch: CPUArchitecture = Field(

color_correction/schemas/images.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)