Skip to content

Commit 3dc9dba

Browse files
committed
Update docstrings in colour.recovery package.
1 parent 6abab4f commit 3dc9dba

File tree

8 files changed

+43
-38
lines changed

8 files changed

+43
-38
lines changed

colour/recovery/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def XYZ_to_sd(
119119
**kwargs: Any,
120120
) -> SpectralDistribution:
121121
"""
122-
Recover the spectral distribution of given *CIE XYZ* tristimulus
123-
values using given method.
122+
Recover the spectral distribution of specified *CIE XYZ* tristimulus
123+
values using specified method.
124124
125125
Parameters
126126
----------
@@ -186,7 +186,7 @@ def XYZ_to_sd(
186186
| ``XYZ`` | [0, 1] | [0, 1] |
187187
+------------+-----------------------+---------------+
188188
189-
- *Smits (1999)* method will internally convert given *CIE XYZ*
189+
- *Smits (1999)* method will internally convert specified *CIE XYZ*
190190
tristimulus values to *sRGB* colourspace array assuming equal energy
191191
illuminant *E*.
192192

colour/recovery/datasets/otsu2018.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,6 @@
13201320
]
13211321
)
13221322
"""
1323-
Array describing how to select the appropriate cluster for given *CIE xy*
1323+
Array describing how to select the appropriate cluster for specified *CIE xy*
13241324
chromaticity coordinates.
13251325
"""

colour/recovery/jakob2019.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def sd_Jakob2019(
142142
coefficients: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019
143143
) -> SpectralDistribution:
144144
"""
145-
Return a spectral distribution following the spectral model given by
145+
Generate a spectral distribution following the spectral model specified by
146146
*Jakob and Hanika (2019)*.
147147
148148
Parameters
@@ -241,7 +241,7 @@ def error_function(
241241
):
242242
"""
243243
Compute :math:`\\Delta E_{76}` between the target colour and the colour
244-
defined by given spectral model, along with its gradient.
244+
defined by specified spectral model, along with its gradient.
245245
246246
Parameters
247247
----------
@@ -340,7 +340,7 @@ def dimensionalise_coefficients(
340340
coefficients: ArrayLike, shape: SpectralShape
341341
) -> NDArrayFloat:
342342
"""
343-
Rescale the dimensionless coefficients to given spectral shape.
343+
Rescale the dimensionless coefficients to specified spectral shape.
344344
345345
A dimensionless form of the reflectance spectral model is used in the
346346
optimisation process. Instead of the usual spectral shape, specified in
@@ -437,7 +437,7 @@ def find_coefficients_Jakob2019(
437437
Returns
438438
-------
439439
:class:`tuple`
440-
Tuple of computed coefficients that best fit the given colour and
440+
Tuple of computed coefficients that best fit the specified colour and
441441
:math:`\\Delta E_{76}` between the target colour and the colour
442442
corresponding to the computed coefficients.
443443
@@ -555,8 +555,8 @@ def XYZ_to_sd_Jakob2019(
555555
additional_data: bool = False,
556556
) -> Tuple[SpectralDistribution, float] | SpectralDistribution:
557557
"""
558-
Recover the spectral distribution of given *CIE XYZ* tristimulus values
559-
using *Jakob and Hanika (2019)* method.
558+
Recover the spectral distribution of specified *CIE XYZ* tristimulus
559+
values using *Jakob and Hanika (2019)* method.
560560
561561
Parameters
562562
----------
@@ -873,8 +873,8 @@ def generate(
873873
print_callable: Callable = print,
874874
) -> None:
875875
"""
876-
Generate the lookup table data for given *RGB* colourspace, colour
877-
matching functions, illuminant and given size.
876+
Generate the lookup table data for specified *RGB* colourspace, colour
877+
matching functions, illuminant and specified size.
878878
879879
Parameters
880880
----------
@@ -1023,7 +1023,7 @@ def optimize(
10231023

10241024
def RGB_to_coefficients(self, RGB: ArrayLike) -> NDArrayFloat:
10251025
"""
1026-
Look up a given *RGB* colourspace array and return corresponding
1026+
Look up a specified *RGB* colourspace array and return corresponding
10271027
coefficients. Interpolation is used for colours not on the table grid.
10281028
10291029
Parameters
@@ -1083,7 +1083,7 @@ def RGB_to_sd(
10831083
self, RGB: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019
10841084
) -> SpectralDistribution:
10851085
"""
1086-
Look up a given *RGB* colourspace array and return the corresponding
1086+
Look up a specified *RGB* colourspace array and return the corresponding
10871087
spectral distribution.
10881088
10891089
Parameters

colour/recovery/jiang2013.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def PCA_Jiang2013(
100100
| Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat]
101101
):
102102
"""
103-
Perform the *Principal Component Analysis* (PCA) on given camera *RGB*
103+
Perform the *Principal Component Analysis* (PCA) on specified camera *RGB*
104104
sensitivities.
105105
106106
Parameters
@@ -138,7 +138,7 @@ def PCA_Jiang2013(
138138
def normalised_sensitivity(
139139
msds: MultiSpectralDistributions, channel: str
140140
) -> NDArrayFloat:
141-
"""Return a normalised camera *RGB* sensitivity."""
141+
"""Generate a normalised camera *RGB* sensitivity."""
142142

143143
sensitivity = cast(SpectralDistribution, msds.signals[channel].copy())
144144

@@ -176,7 +176,7 @@ def RGB_to_sd_camera_sensitivity_Jiang2013(
176176
shape: SpectralShape | None = None,
177177
) -> SpectralDistribution:
178178
"""
179-
Recover a single camera *RGB* sensitivity for given camera *RGB* values
179+
Recover a single camera *RGB* sensitivity for specified camera *RGB* values
180180
using *Jiang et al. (2013)* method.
181181
182182
Parameters
@@ -308,8 +308,8 @@ def RGB_to_msds_camera_sensitivities_Jiang2013(
308308
shape: SpectralShape | None = None,
309309
) -> MultiSpectralDistributions:
310310
"""
311-
Recover the camera *RGB* sensitivities for given camera *RGB* values using
312-
*Jiang et al. (2013)* method.
311+
Recover the camera *RGB* sensitivities for specified camera *RGB* values
312+
using *Jiang et al. (2013)* method.
313313
314314
Parameters
315315
----------

colour/recovery/mallett2019.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def spectral_primary_decomposition_Mallett2019(
5959
) -> MultiSpectralDistributions:
6060
"""
6161
Perform the spectral primary decomposition as described in *Mallett and
62-
Yuksel (2019)* for given *RGB* colourspace.
62+
Yuksel (2019)* for specified *RGB* colourspace.
6363
6464
Parameters
6565
----------
@@ -86,7 +86,7 @@ def spectral_primary_decomposition_Mallett2019(
8686
Returns
8787
-------
8888
:class:`colour.MultiSpectralDistributions`
89-
Basis functions for given *RGB* colourspace.
89+
Basis functions for specified *RGB* colourspace.
9090
9191
References
9292
----------
@@ -222,7 +222,7 @@ def RGB_to_sd_Mallett2019(
222222
basis_functions: MultiSpectralDistributions = MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019,
223223
) -> SpectralDistribution:
224224
"""
225-
Recover the spectral distribution of given *RGB* colourspace array using
225+
Recover the spectral distribution of specified *RGB* colourspace array using
226226
*Mallett and Yuksel (2019)* method.
227227
228228
Parameters

colour/recovery/meng2015.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def XYZ_to_sd_Meng2015(
6161
optimisation_kwargs: dict | None = None,
6262
) -> SpectralDistribution:
6363
"""
64-
Recover the spectral distribution of given *CIE XYZ* tristimulus values
64+
Recover the spectral distribution of specified *CIE XYZ* tristimulus values
6565
using *Meng et al. (2015)* method.
6666
6767
Parameters
@@ -85,6 +85,11 @@ def XYZ_to_sd_Meng2015(
8585
:class:`colour.SpectralDistribution`
8686
Recovered spectral distribution.
8787
88+
Raises
89+
------
90+
RuntimeError
91+
If the optimisation failed.
92+
8893
Notes
8994
-----
9095
+------------+-----------------------+---------------+

colour/recovery/otsu2018.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def __str__(self) -> str:
251251

252252
def select(self, xy: ArrayLike) -> int:
253253
"""
254-
Return the cluster index appropriate for the given *CIE xy*
254+
Determine the cluster index appropriate for the specified *CIE xy*
255255
coordinates.
256256
257257
Parameters
@@ -294,7 +294,7 @@ def select(self, xy: ArrayLike) -> int:
294294

295295
def cluster(self, xy: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]:
296296
"""
297-
Return the basis functions and dataset mean for the given *CIE xy*
297+
Retrieve the basis functions and dataset mean for the specified *CIE xy*
298298
coordinates.
299299
300300
Parameters
@@ -367,7 +367,7 @@ def read(self, path: str | PathLike) -> None:
367367

368368
def write(self, path: str | PathLike) -> None:
369369
"""
370-
Write the dataset to an *.npz* file at given path.
370+
Write the dataset to an *.npz* file at specified path.
371371
372372
Parameters
373373
----------
@@ -444,7 +444,7 @@ def XYZ_to_sd_Otsu2018(
444444
clip: bool = True,
445445
) -> SpectralDistribution:
446446
"""
447-
Recover the spectral distribution of given *CIE XYZ* tristimulus values
447+
Recover the spectral distribution of specified *CIE XYZ* tristimulus values
448448
using *Otsu et al. (2018)* method.
449449
450450
Parameters
@@ -786,7 +786,7 @@ def __str__(self) -> str:
786786

787787
def __len__(self) -> int:
788788
"""
789-
Return the number of colours in the data.
789+
Determine the number of colours in the data.
790790
791791
Returns
792792
-------
@@ -798,8 +798,8 @@ def __len__(self) -> int:
798798

799799
def origin(self, i: int, direction: int) -> float:
800800
"""
801-
Return the origin *CIE x* or *CIE y* chromaticity coordinate for given
802-
index and direction.
801+
Retrieve the origin *CIE x* or *CIE y* chromaticity coordinate for
802+
specified index and direction.
803803
804804
Parameters
805805
----------
@@ -828,7 +828,7 @@ def origin(self, i: int, direction: int) -> float:
828828

829829
def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]:
830830
"""
831-
Partition the data using given partition axis.
831+
Partition the data using specified partition axis.
832832
833833
Parameters
834834
----------
@@ -904,7 +904,7 @@ def PCA(self) -> None:
904904

905905
def reconstruct(self, XYZ: ArrayLike) -> SpectralDistribution:
906906
"""
907-
Reconstruct the reflectance for the given *CIE XYZ* tristimulus
907+
Reconstruct the reflectance for the specified *CIE XYZ* tristimulus
908908
values.
909909
910910
Parameters
@@ -947,7 +947,7 @@ def reconstruct(self, XYZ: ArrayLike) -> SpectralDistribution:
947947

948948
def reconstruction_error(self) -> float:
949949
"""
950-
Return the reconstruction error of the data. The error is computed by
950+
Compute the reconstruction error of the data. The error is computed by
951951
reconstructing the reflectances for the reference *CIE XYZ* tristimulus
952952
values using PCA and, comparing the reconstructed reflectances against
953953
the reference reflectances.
@@ -1076,7 +1076,7 @@ def row(self) -> Tuple[float, float, Self, Self]:
10761076

10771077
def split(self, children: Sequence[Self], axis: PartitionAxis) -> None:
10781078
"""
1079-
Convert the leaf node into an inner node using given children and
1079+
Convert the leaf node into an inner node using specified children and
10801080
partition axis.
10811081
10821082
Parameters
@@ -1110,7 +1110,7 @@ def minimise(
11101110
Returns
11111111
-------
11121112
:class:`tuple`
1113-
Tuple of tuple of nodes created by splitting a node with a given
1113+
Tuple of tuple of nodes created by splitting a node with a specified
11141114
partition, partition axis, i.e., the horizontal or vertical line,
11151115
partitioning the 2D space in two half-planes and partition error.
11161116
"""
@@ -1172,7 +1172,7 @@ def minimise(
11721172

11731173
def leaf_reconstruction_error(self) -> float:
11741174
"""
1175-
Return the reconstruction error of the node data. The error is
1175+
Compute the reconstruction error of the node data. The error is
11761176
computed by reconstructing the reflectances for the data reference
11771177
*CIE XYZ* tristimulus values using PCA and, comparing the reconstructed
11781178
reflectances against the data reference reflectances.
@@ -1584,7 +1584,7 @@ def to_dataset(self) -> Dataset_Otsu2018:
15841584
else:
15851585

15861586
def add_rows(node: Node_Otsu2018, data: dict | None = None) -> dict | None:
1587-
"""Add rows for given node and its children."""
1587+
"""Add rows for specified node and its children."""
15881588

15891589
data = optional(data, {"rows": [], "node_to_leaf_id": {}, "leaf_id": 0})
15901590

colour/recovery/smits1999.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def XYZ_to_RGB_Smits1999(XYZ: ArrayLike) -> NDArrayFloat:
9494

9595
def RGB_to_sd_Smits1999(RGB: ArrayLike) -> SpectralDistribution:
9696
"""
97-
Recover the spectral distribution of given *RGB* colourspace array using
97+
Recover the spectral distribution of specified *RGB* colourspace array using
9898
*Smits (1999)* method.
9999
100100
Parameters

0 commit comments

Comments
 (0)