code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def corner_label_and_text(label: str, text: str, ha: str, va: str) -> None:
"""Draw a label and text in specified corner."""
x = -1.45 if ha == "left" else 1.45
y = 1.45 if va == "top" else -1.45
y_text = -15 if va == "top" else 15
axes.annotate(
text,
x... | Draw a label and text in specified corner. | corner_label_and_text | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def plot_16_bin_bars(
values: ArrayLike,
label_template: str,
x_ticker: bool = False,
label_orientation: Literal["Horizontal", "Vertical"] | str = "Vertical",
**kwargs: Any,
) -> Tuple[Figure, Axes]:
"""
Plot the 16 bin bars for specified values according to
*ANSI/IES TM-30-18 Colour Ren... |
Plot the 16 bin bars for specified values according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
values
Values to generate the bin bars for.
label_template
Template to format the labels.
x_ticker
Whether to show the *X* axis ticker and the a... | plot_16_bin_bars | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def plot_local_chroma_shifts(
specification: ColourQuality_Specification_ANSIIESTM3018,
x_ticker: bool = False,
**kwargs: Any,
) -> Tuple[Figure, Axes]:
"""
Plot the local chroma shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
... |
Plot the local chroma shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*ANSI/IES TM-30-18 Colour Rendition Report* specification.
x_ticker
Whether to show the *X* axis ticker and the associated label.
Other Parameters
... | plot_local_chroma_shifts | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def plot_local_hue_shifts(
specification: ColourQuality_Specification_ANSIIESTM3018,
x_ticker: bool = False,
**kwargs: Any,
) -> Tuple[Figure, Axes]:
"""
Plot the local hue shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*... |
Plot the local hue shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*ANSI/IES TM-30-18 Colour Rendition Report* specification.
x_ticker
Whether to show the *X* axis ticker and the associated label.
Other Parameters
--... | plot_local_hue_shifts | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def plot_local_colour_fidelities(
specification: ColourQuality_Specification_ANSIIESTM3018,
x_ticker: bool = False,
**kwargs: Any,
) -> Tuple[Figure, Axes]:
"""
Plot the local colour fidelities according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specifica... |
Plot the local colour fidelities according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*ANSI/IES TM-30-18 Colour Rendition Report* specification.
x_ticker
Whether to show the *X* axis ticker and the associated label.
Other Parameters... | plot_local_colour_fidelities | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def plot_colour_fidelity_indexes(
specification: ColourQuality_Specification_ANSIIESTM3018, **kwargs: Any
) -> Tuple[Figure, Axes]:
"""
Plot the local chroma shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*ANSI/IES TM-30-18 Colou... |
Plot the local chroma shifts according to
*ANSI/IES TM-30-18 Colour Rendition Report*.
Parameters
----------
specification
*ANSI/IES TM-30-18 Colour Rendition Report* specification.
Other Parameters
----------------
kwargs
{:func:`colour.plotting.artist`, :func:`colour... | plot_colour_fidelity_indexes | python | colour-science/colour | colour/plotting/tm3018/components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/components.py | BSD-3-Clause |
def _plot_report_header(axes: Axes) -> Axes:
"""
Plot the report header, i.e., the title, on specified axes.
Parameters
----------
axes
Axes to add the report header to.
Returns
-------
:class:`matplotlib.axes._axes.Axes`
Axes the report header was added to.
"""
... |
Plot the report header, i.e., the title, on specified axes.
Parameters
----------
axes
Axes to add the report header to.
Returns
-------
:class:`matplotlib.axes._axes.Axes`
Axes the report header was added to.
| _plot_report_header | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def _plot_report_footer(axes: Axes) -> Axes:
"""
Plot the report footer on specified axes.
Parameters
----------
axes
Axes to add the report footer to.
Returns
-------
:class:`matplotlib.axes._axes.Axes`
Axes the report footer was added to.
"""
try:
des... |
Plot the report footer on specified axes.
Parameters
----------
axes
Axes to add the report footer to.
Returns
-------
:class:`matplotlib.axes._axes.Axes`
Axes the report footer was added to.
| _plot_report_footer | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def plot_single_sd_colour_rendition_report_full(
sd: SpectralDistribution,
source: str | None = None,
date: str | None = None,
manufacturer: str | None = None,
model: str | None = None,
notes: str | None = None,
report_size: tuple[float, float] = CONSTANT_REPORT_SIZE_FULL,
report_row_hei... |
Generate the full *ANSI/IES TM-30-18 Colour Rendition Report* for specified
spectral distribution.
Parameters
----------
sd
Spectral distribution of the emission source to generate the report
for.
source
Emission source name, defaults to
`colour.SpectralDistribu... | plot_single_sd_colour_rendition_report_full | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def plot_single_sd_colour_rendition_report_intermediate(
sd: SpectralDistribution,
report_size: tuple[float, float] = CONSTANT_REPORT_SIZE_INTERMEDIATE,
report_row_height_ratios: tuple = (CONSTANT_REPORT_ROW_HEIGHT_RATIOS_INTERMEDIATE),
report_box_padding: dict | None = None,
**kwargs: Any,
) -> Tup... |
Generate the intermediate *ANSI/IES TM-30-18 Colour Rendition Report* for
specified spectral distribution.
Parameters
----------
sd
Spectral distribution of the emission source to generate the report
for.
report_size
Report size, default to A4 paper size in inches.
... | plot_single_sd_colour_rendition_report_intermediate | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def plot_single_sd_colour_rendition_report_simple(
sd: SpectralDistribution,
report_size: tuple[float, float] = CONSTANT_REPORT_SIZE_SIMPLE,
report_row_height_ratios: tuple = CONSTANT_REPORT_ROW_HEIGHT_RATIOS_SIMPLE,
report_box_padding: dict | None = None,
**kwargs: Any,
) -> Tuple[Figure, Axes]:
... |
Generate the simple *ANSI/IES TM-30-18 Colour Rendition Report* for specified
spectral distribution.
Parameters
----------
sd
Spectral distribution of the emission source to generate the report
for.
report_size
Report size, default to A4 paper size in inches.
report... | plot_single_sd_colour_rendition_report_simple | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def plot_single_sd_colour_rendition_report(
sd: SpectralDistribution,
method: Literal["Full", "Intermediate", "Simple"] | str = "Full",
**kwargs: Any,
) -> Tuple[Figure, Axes]:
"""
Generate the *ANSI/IES TM-30-18 Colour Rendition Report* for specified
spectral distribution according to specified... |
Generate the *ANSI/IES TM-30-18 Colour Rendition Report* for specified
spectral distribution according to specified method.
Parameters
----------
sd
Spectral distribution of the emission source to generate the report
for.
method
Report plotting method.
Other Parame... | plot_single_sd_colour_rendition_report | python | colour-science/colour | colour/plotting/tm3018/report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/report.py | BSD-3-Clause |
def test_plot_spectra_ANSIIESTM3018(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_spectra_ANSIIESTM3018` definition.
"""
figure, axes = plot_spectra_ANSIIESTM3018(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isinstance(... |
Test :func:`colour.plotting.tm3018.components.plot_spectra_ANSIIESTM3018` definition.
| test_plot_spectra_ANSIIESTM3018 | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_colour_vector_graphic(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_colour_vector_graphic` definition.
"""
figure, axes = plot_colour_vector_graphic(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isinstance(... |
Test :func:`colour.plotting.tm3018.components.plot_colour_vector_graphic` definition.
| test_plot_colour_vector_graphic | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_16_bin_bars(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.plot_16_bin_bars`
definition.
"""
figure, axes = plot_16_bin_bars(range(16), "{0}")
assert isinstance(figure, Figure)
assert isinstance(axes, Axes) |
Test :func:`colour.plotting.tm3018.components.plot_16_bin_bars`
definition.
| test_plot_16_bin_bars | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_local_chroma_shifts(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_local_chroma_shifts` definition.
"""
figure, axes = plot_local_chroma_shifts(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isinstance(axes, ... |
Test :func:`colour.plotting.tm3018.components.plot_local_chroma_shifts` definition.
| test_plot_local_chroma_shifts | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_local_hue_shifts(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_local_hue_shifts` definition.
"""
figure, axes = plot_local_hue_shifts(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isinstance(axes, Axes) |
Test :func:`colour.plotting.tm3018.components.plot_local_hue_shifts` definition.
| test_plot_local_hue_shifts | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_local_colour_fidelities(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_local_colour_fidelities` definition.
"""
figure, axes = plot_local_colour_fidelities(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isins... |
Test :func:`colour.plotting.tm3018.components.plot_local_colour_fidelities` definition.
| test_plot_local_colour_fidelities | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_colour_fidelity_indexes(self) -> None:
"""
Test :func:`colour.plotting.tm3018.components.\
plot_colour_fidelity_indexes` definition.
"""
figure, axes = plot_colour_fidelity_indexes(SPECIFICATION_ANSIIESTM3018)
assert isinstance(figure, Figure)
assert isins... |
Test :func:`colour.plotting.tm3018.components.plot_colour_fidelity_indexes` definition.
| test_plot_colour_fidelity_indexes | python | colour-science/colour | colour/plotting/tm3018/tests/test_components.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_components.py | BSD-3-Clause |
def test_plot_single_sd_colour_rendition_report_full(self) -> None:
"""
Test :func:`colour.plotting.tm3018.report.\
plot_single_sd_colour_rendition_report_full` definition.
"""
figure, axes = plot_single_sd_colour_rendition_report_full(
SDS_ILLUMINANTS["FL2"]
)
... |
Test :func:`colour.plotting.tm3018.report.plot_single_sd_colour_rendition_report_full` definition.
| test_plot_single_sd_colour_rendition_report_full | python | colour-science/colour | colour/plotting/tm3018/tests/test_report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_report.py | BSD-3-Clause |
def test_plot_single_sd_colour_rendition_report_intermediate(self) -> None:
"""
Test :func:`colour.plotting.tm3018.report.\
plot_single_sd_colour_rendition_report_intermediate` definition.
"""
figure, axes = plot_single_sd_colour_rendition_report_intermediate(
SDS_ILLUMINANT... |
Test :func:`colour.plotting.tm3018.report.plot_single_sd_colour_rendition_report_intermediate` definition.
| test_plot_single_sd_colour_rendition_report_intermediate | python | colour-science/colour | colour/plotting/tm3018/tests/test_report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_report.py | BSD-3-Clause |
def test_plot_color_vector_graphic(self) -> None:
"""
Test :func:`colour.plotting.tm3018.report.\
plot_single_sd_colour_rendition_report_simple` definition.
"""
figure, axes = plot_single_sd_colour_rendition_report_simple(
SDS_ILLUMINANTS["FL2"]
)
assert isi... |
Test :func:`colour.plotting.tm3018.report.plot_single_sd_colour_rendition_report_simple` definition.
| test_plot_color_vector_graphic | python | colour-science/colour | colour/plotting/tm3018/tests/test_report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_report.py | BSD-3-Clause |
def test_plot_single_sd_colour_rendition_report(self) -> None:
"""
Test :func:`colour.plotting.tm3018.report.\
plot_single_sd_colour_rendition_report` definition.
"""
figure, axes = plot_single_sd_colour_rendition_report(SDS_ILLUMINANTS["FL2"])
assert isinstance(figure, Figure)... |
Test :func:`colour.plotting.tm3018.report.plot_single_sd_colour_rendition_report` definition.
| test_plot_single_sd_colour_rendition_report | python | colour-science/colour | colour/plotting/tm3018/tests/test_report.py | https://github.com/colour-science/colour/blob/master/colour/plotting/tm3018/tests/test_report.py | BSD-3-Clause |
def colour_fidelity_index_CIE2017(
sd_test: SpectralDistribution, additional_data: bool = False
) -> float | ColourRendering_Specification_CIE2017:
"""
Compute the *CIE 2017 Colour Fidelity Index* (CFI) :math:`R_f` of specified
spectral distribution.
Parameters
----------
sd_test
Te... |
Compute the *CIE 2017 Colour Fidelity Index* (CFI) :math:`R_f` of specified
spectral distribution.
Parameters
----------
sd_test
Test spectral distribution.
additional_data
Whether to output additional data.
Returns
-------
:class:`float` or :class:`colour.quality.... | colour_fidelity_index_CIE2017 | python | colour-science/colour | colour/quality/cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/cfi2017.py | BSD-3-Clause |
def load_TCS_CIE2017(shape: SpectralShape) -> MultiSpectralDistributions:
"""
Load the *CIE 2017 Test Colour Samples* dataset appropriate for the specified
spectral shape.
The datasets are cached and won't be loaded again on subsequent calls to
this definition.
Parameters
----------
sh... |
Load the *CIE 2017 Test Colour Samples* dataset appropriate for the specified
spectral shape.
The datasets are cached and won't be loaded again on subsequent calls to
this definition.
Parameters
----------
shape
Spectral shape of the tested illuminant.
Returns
-------
... | load_TCS_CIE2017 | python | colour-science/colour | colour/quality/cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/cfi2017.py | BSD-3-Clause |
def CCT_reference_illuminant(sd: SpectralDistribution) -> NDArrayFloat:
"""
Compute the reference illuminant correlated colour temperature
:math:`T_{cp}` and :math:`\\Delta_{uv}` for specified test spectral
distribution using *Ohno (2013)* method.
Parameters
----------
sd
Test spect... |
Compute the reference illuminant correlated colour temperature
:math:`T_{cp}` and :math:`\Delta_{uv}` for specified test spectral
distribution using *Ohno (2013)* method.
Parameters
----------
sd
Test spectral distribution.
Returns
-------
:class:`numpy.ndarray`
Co... | CCT_reference_illuminant | python | colour-science/colour | colour/quality/cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/cfi2017.py | BSD-3-Clause |
def sd_reference_illuminant(CCT: float, shape: SpectralShape) -> SpectralDistribution:
"""
Compute the reference illuminant for a specified correlated colour temperature
:math:`T_{cp}` for use in *CIE 2017 Colour Fidelity Index* (CFI)
computation.
Parameters
----------
CCT
Correlate... |
Compute the reference illuminant for a specified correlated colour temperature
:math:`T_{cp}` for use in *CIE 2017 Colour Fidelity Index* (CFI)
computation.
Parameters
----------
CCT
Correlated colour temperature :math:`T_{cp}`.
shape
Desired shape of the returned spectral ... | sd_reference_illuminant | python | colour-science/colour | colour/quality/cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/cfi2017.py | BSD-3-Clause |
def delta_E_to_R_f(delta_E: ArrayLike) -> NDArrayFloat:
"""
Convert from colour-appearance difference to
*CIE 2017 Colour Fidelity Index* (CFI) :math:`R_f` value.
Parameters
----------
delta_E
Euclidean distance between two colours in *CAM02-UCS* colourspace.
Returns
-------
... |
Convert from colour-appearance difference to
*CIE 2017 Colour Fidelity Index* (CFI) :math:`R_f` value.
Parameters
----------
delta_E
Euclidean distance between two colours in *CAM02-UCS* colourspace.
Returns
-------
:class:`numpy.ndarray`
Corresponding *CIE 2017 Colour... | delta_E_to_R_f | python | colour-science/colour | colour/quality/cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/cfi2017.py | BSD-3-Clause |
def colour_quality_scale(
sd_test: SpectralDistribution,
additional_data: bool = False,
method: Literal["NIST CQS 7.4", "NIST CQS 9.0"] | str = "NIST CQS 9.0",
) -> float | ColourRendering_Specification_CQS:
"""
Compute the *Colour Quality Scale* (CQS) of specified spectral distribution
using sp... |
Compute the *Colour Quality Scale* (CQS) of specified spectral distribution
using specified method.
Parameters
----------
sd_test
Test spectral distribution.
additional_data
Whether to output additional data.
method
Computation method.
Returns
-------
:... | colour_quality_scale | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def gamut_area(Lab: ArrayLike) -> float:
"""
Compute the gamut area :math:`G` covered by specified *CIE L\\*a\\*b\\**
matrices.
Parameters
----------
Lab
*CIE L\\*a\\*b\\** colourspace matrices.
Returns
-------
:class:`float`
Gamut area :math:`G`.
Examples
... |
Compute the gamut area :math:`G` covered by specified *CIE L\*a\*b\**
matrices.
Parameters
----------
Lab
*CIE L\*a\*b\** colourspace matrices.
Returns
-------
:class:`float`
Gamut area :math:`G`.
Examples
--------
>>> Lab = [
... np.array([39.9499... | gamut_area | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def vs_colorimetry_data(
sd_test: SpectralDistribution,
sd_reference: SpectralDistribution,
sds_vs: Dict[str, SpectralDistribution],
cmfs: MultiSpectralDistributions,
chromatic_adaptation: bool = False,
) -> Tuple[DataColorimetry_VS, ...]:
"""
Compute the *VS test colour samples* colorimetry... |
Compute the *VS test colour samples* colorimetry data.
Parameters
----------
sd_test
Test spectral distribution.
sd_reference
Reference spectral distribution.
sds_vs
*VS test colour samples* spectral reflectance distributions.
cmfs
Standard observer colour m... | vs_colorimetry_data | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def CCT_factor(
reference_data: Tuple[DataColorimetry_VS, ...], XYZ_r: ArrayLike
) -> float:
"""
Compute the correlated colour temperature factor penalizing lamps with
extremely low correlated colour temperatures.
Parameters
----------
reference_data
Reference colorimetry data.
... |
Compute the correlated colour temperature factor penalizing lamps with
extremely low correlated colour temperatures.
Parameters
----------
reference_data
Reference colorimetry data.
XYZ_r
*CIE XYZ* tristimulus values for reference.
Returns
-------
:class:`float`
... | CCT_factor | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def delta_E_RMS(
CQS_data: Dict[int, DataColourQualityScale_VS], attribute: str
) -> float:
"""
Compute the root-mean-square average for specified *Colour Quality Scale*
(CQS) data.
Parameters
----------
CQS_data
*Colour Quality Scale* (CQS) data.
attribute
Colorimetry d... |
Compute the root-mean-square average for specified *Colour Quality Scale*
(CQS) data.
Parameters
----------
CQS_data
*Colour Quality Scale* (CQS) data.
attribute
Colorimetry data attribute to use to compute the root-mean-square
average.
Returns
-------
:cla... | delta_E_RMS | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def colour_quality_scales(
test_data: Tuple[DataColorimetry_VS, ...],
reference_data: Tuple[DataColorimetry_VS, ...],
scaling_f: float,
CCT_f: float,
) -> Dict[int, DataColourQualityScale_VS]:
"""
Compute the *VS test colour samples* rendering scales.
Parameters
----------
test_data... |
Compute the *VS test colour samples* rendering scales.
Parameters
----------
test_data
Test data.
reference_data
Reference data.
scaling_f
Scaling factor constant.
CCT_f
Factor penalizing lamps with extremely low correlated colour
temperatures.
... | colour_quality_scales | python | colour-science/colour | colour/quality/cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/cqs.py | BSD-3-Clause |
def colour_rendering_index(
sd_test: SpectralDistribution,
additional_data: bool = False,
method: Literal["CIE 1995", "CIE 2024"] | str = "CIE 1995",
) -> float | ColourRendering_Specification_CRI:
"""
Compute the *Colour Rendering Index* (CRI) :math:`Q_a` of specified spectral
distribution.
... |
Compute the *Colour Rendering Index* (CRI) :math:`Q_a` of specified spectral
distribution.
Parameters
----------
sd_test
Test spectral distribution.
additional_data
Whether to output additional data.
method
Computation method.
Returns
-------
:class:`fl... | colour_rendering_index | python | colour-science/colour | colour/quality/cri.py | https://github.com/colour-science/colour/blob/master/colour/quality/cri.py | BSD-3-Clause |
def tcs_colorimetry_data(
sd_t: SpectralDistribution,
sd_r: SpectralDistribution,
sds_tcs: Dict[str, SpectralDistribution],
cmfs: MultiSpectralDistributions,
chromatic_adaptation: bool = False,
method: Literal["CIE 1995", "CIE 2024"] | str = "CIE 1995",
) -> Tuple[DataColorimetry_TCS, ...]:
... |
Compute the *test colour samples* colorimetry data.
Parameters
----------
sd_t
Test spectral distribution.
sd_r
Reference spectral distribution.
sds_tcs
*Test colour samples* spectral reflectance distributions.
cmfs
Standard observer colour matching function... | tcs_colorimetry_data | python | colour-science/colour | colour/quality/cri.py | https://github.com/colour-science/colour/blob/master/colour/quality/cri.py | BSD-3-Clause |
def colour_rendering_indexes(
test_data: Tuple[DataColorimetry_TCS, ...],
reference_data: Tuple[DataColorimetry_TCS, ...],
) -> Dict[int, DataColourQualityScale_TCS]:
"""
Compute the *test colour samples* rendering indexes :math:`Q_a`.
Parameters
----------
test_data
Test data.
... |
Compute the *test colour samples* rendering indexes :math:`Q_a`.
Parameters
----------
test_data
Test data.
reference_data
Reference data.
Returns
-------
:class:`dict`
*Test colour samples* *Colour Rendering Index* (CRI).
| colour_rendering_indexes | python | colour-science/colour | colour/quality/cri.py | https://github.com/colour-science/colour/blob/master/colour/quality/cri.py | BSD-3-Clause |
def spectral_similarity_index(
sd_test: SpectralDistribution,
sd_reference: SpectralDistribution,
round_result: bool = True,
) -> NDArrayFloat:
"""
Compute the *Academy Spectral Similarity Index* (SSI) of specified test
spectral distribution with specified reference spectral distribution.
P... |
Compute the *Academy Spectral Similarity Index* (SSI) of specified test
spectral distribution with specified reference spectral distribution.
Parameters
----------
sd_test
Test spectral distribution.
sd_reference
Reference spectral distribution.
round_result
Whether... | spectral_similarity_index | python | colour-science/colour | colour/quality/ssi.py | https://github.com/colour-science/colour/blob/master/colour/quality/ssi.py | BSD-3-Clause |
def colour_fidelity_index_ANSIIESTM3018(
sd_test: SpectralDistribution, additional_data: bool = False
) -> float | ColourQuality_Specification_ANSIIESTM3018:
"""
Compute the *ANSI/IES TM-30-18 Colour Fidelity Index* (CFI) :math:`R_f`
of specified spectral distribution.
Parameters
----------
... |
Compute the *ANSI/IES TM-30-18 Colour Fidelity Index* (CFI) :math:`R_f`
of specified spectral distribution.
Parameters
----------
sd_test
Test spectral distribution.
additional_data
Whether to output additional data.
Returns
-------
:class:`float` or :class:`colour... | colour_fidelity_index_ANSIIESTM3018 | python | colour-science/colour | colour/quality/tm3018.py | https://github.com/colour-science/colour/blob/master/colour/quality/tm3018.py | BSD-3-Clause |
def averages_area(averages: ArrayLike) -> float:
"""
Compute the area of the polygon formed by the hue bin averages.
Parameters
----------
averages
Hue bin averages.
Returns
-------
:class:`float`
Area of the polygon.
"""
averages = as_float_array(averages)
... |
Compute the area of the polygon formed by the hue bin averages.
Parameters
----------
averages
Hue bin averages.
Returns
-------
:class:`float`
Area of the polygon.
| averages_area | python | colour-science/colour | colour/quality/tm3018.py | https://github.com/colour-science/colour/blob/master/colour/quality/tm3018.py | BSD-3-Clause |
def colour_fidelity_index(
sd_test: SpectralDistribution,
additional_data: bool = False,
method: Literal["CIE 2017", "ANSI/IES TM-30-18"] | str = "CIE 2017",
) -> (
float
| ColourRendering_Specification_CIE2017
| ColourQuality_Specification_ANSIIESTM3018
):
"""
Compute the *Colour Fideli... |
Compute the *Colour Fidelity Index* (CFI) :math:`R_f` of specified
spectral distribution using specified method.
Parameters
----------
sd_test
Test spectral distribution.
additional_data
Whether to output additional data.
method
Computation method.
Returns
... | colour_fidelity_index | python | colour-science/colour | colour/quality/__init__.py | https://github.com/colour-science/colour/blob/master/colour/quality/__init__.py | BSD-3-Clause |
def test_raise_exception_colour_fidelity_index_CFI2017(self) -> None:
"""
Test :func:`colour.quality.CIE2017.colour_fidelity_index_CFI2017`
definition raised exception.
"""
sd = reshape_sd(SDS_ILLUMINANTS["FL2"], SpectralShape(400, 700, 5))
pytest.warns(ColourUsageWarnin... |
Test :func:`colour.quality.CIE2017.colour_fidelity_index_CFI2017`
definition raised exception.
| test_raise_exception_colour_fidelity_index_CFI2017 | python | colour-science/colour | colour/quality/tests/test_cfi2017.py | https://github.com/colour-science/colour/blob/master/colour/quality/tests/test_cfi2017.py | BSD-3-Clause |
def test_colour_quality_scale(self) -> None:
"""Test :func:`colour.quality.cqs.colour_quality_scale` definition."""
np.testing.assert_allclose(
colour_quality_scale(SDS_ILLUMINANTS["FL1"], additional_data=False),
74.982585798279914,
atol=TOLERANCE_ABSOLUTE_TESTS,
... | Test :func:`colour.quality.cqs.colour_quality_scale` definition. | test_colour_quality_scale | python | colour-science/colour | colour/quality/tests/test_cqs.py | https://github.com/colour-science/colour/blob/master/colour/quality/tests/test_cqs.py | BSD-3-Clause |
def test_colour_rendering_index(self) -> None:
"""Test :func:`colour.quality.cri.colour_rendering_index` definition."""
np.testing.assert_allclose(
colour_rendering_index(SDS_ILLUMINANTS["FL1"], additional_data=False),
75.852827992149358,
atol=TOLERANCE_ABSOLUTE_TEST... | Test :func:`colour.quality.cri.colour_rendering_index` definition. | test_colour_rendering_index | python | colour-science/colour | colour/quality/tests/test_cri.py | https://github.com/colour-science/colour/blob/master/colour/quality/tests/test_cri.py | BSD-3-Clause |
def test_spectral_similarity_index(self) -> None:
"""Test :func:`colour.quality.ssi.spectral_similarity_index` definition."""
assert (
spectral_similarity_index(SDS_ILLUMINANTS["C"], SDS_ILLUMINANTS["D65"])
== 94.0
)
assert (
spectral_similarity_index... | Test :func:`colour.quality.ssi.spectral_similarity_index` definition. | test_spectral_similarity_index | python | colour-science/colour | colour/quality/tests/test_ssi.py | https://github.com/colour-science/colour/blob/master/colour/quality/tests/test_ssi.py | BSD-3-Clause |
def test_spectral_similarity_rounding(self) -> None:
"""
Test :func:`colour.quality.ssi.spectral_similarity_index` for
producing continuous values.
"""
# Test values were computed at ed2e90
np.testing.assert_allclose(
spectral_similarity_index(
... |
Test :func:`colour.quality.ssi.spectral_similarity_index` for
producing continuous values.
| test_spectral_similarity_rounding | python | colour-science/colour | colour/quality/tests/test_ssi.py | https://github.com/colour-science/colour/blob/master/colour/quality/tests/test_ssi.py | BSD-3-Clause |
def sd_Jakob2019(
coefficients: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019
) -> SpectralDistribution:
"""
Generate a spectral distribution following the spectral model specified by
*Jakob and Hanika (2019)*.
Parameters
----------
coefficients
Dimensionless coefficien... |
Generate a spectral distribution following the spectral model specified by
*Jakob and Hanika (2019)*.
Parameters
----------
coefficients
Dimensionless coefficients for *Jakob and Hanika (2019)* reflectance
spectral model.
shape
Shape used by the spectral distribution.
... | sd_Jakob2019 | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def error_function(
coefficients: ArrayLike,
target: ArrayLike,
cmfs: MultiSpectralDistributions,
illuminant: SpectralDistribution,
max_error: float | None = None,
additional_data: bool = False,
) -> (
Tuple[float, NDArrayFloat]
| Tuple[float, NDArrayFloat, NDArrayFloat, NDArrayFloat, ND... |
Compute :math:`\Delta E_{76}` between the target colour and the colour
defined by specified spectral model, along with its gradient.
Parameters
----------
coefficients
Dimensionless coefficients for *Jakob and Hanika (2019)* reflectance
spectral model.
target
*CIE L\*a\... | error_function | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def intermediate_XYZ_to_Lab(
XYZ_i: NDArrayFloat, offset: float | None = 16
) -> NDArrayFloat:
"""
Return the final intermediate value for the *CIE Lab* to *CIE XYZ*
conversion.
"""
return np.array(
[
116 * XYZ_i[1] - offset,
... |
Return the final intermediate value for the *CIE Lab* to *CIE XYZ*
conversion.
| intermediate_XYZ_to_Lab | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def dimensionalise_coefficients(
coefficients: ArrayLike, shape: SpectralShape
) -> NDArrayFloat:
"""
Rescale the dimensionless coefficients to specified spectral shape.
A dimensionless form of the reflectance spectral model is used in the
optimisation process. Instead of the usual spectral shape, ... |
Rescale the dimensionless coefficients to specified spectral shape.
A dimensionless form of the reflectance spectral model is used in the
optimisation process. Instead of the usual spectral shape, specified in
nanometers, it is normalised to the [0, 1] range. A side effect is that
computed coeffic... | dimensionalise_coefficients | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def find_coefficients_Jakob2019(
XYZ: ArrayLike,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
coefficients_0: ArrayLike = (0, 0, 0),
max_error: float = JND_CIE1976 / 100,
dimensionalise: bool = True,
) -> Tuple[NDArrayFloat, float]:
"""
... |
Compute the coefficients for *Jakob and Hanika (2019)* reflectance
spectral model.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to find the coefficients for.
cmfs
Standard observer colour matching functions, default to the
*CIE 1931 2 Degree Standard Observer*... | find_coefficients_Jakob2019 | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def optimize(
target_o: NDArrayFloat, coefficients_0_o: NDArrayFloat
) -> Tuple[NDArrayFloat, float | np.float64]:
"""Minimise the error function using *L-BFGS-B* method."""
try:
result = minimize(
error_function,
coefficients_0_o,
... | Minimise the error function using *L-BFGS-B* method. | optimize | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def XYZ_to_sd_Jakob2019(
XYZ: ArrayLike,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
optimisation_kwargs: dict | None = None,
additional_data: bool = False,
) -> Tuple[SpectralDistribution, float] | SpectralDistribution:
"""
Recover the spe... |
Recover the spectral distribution of specified *CIE XYZ* tristimulus
values using *Jakob and Hanika (2019)* method.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to recover the spectral distribution from.
cmfs
Standard observer colour matching functions, default to the... | XYZ_to_sd_Jakob2019 | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def _create_interpolator(self) -> None:
"""
Create a :class:`scipy.interpolate.RegularGridInterpolator` class
instance for read or generated coefficients.
"""
samples = np.linspace(0, 1, self._size)
axes = ([0, 1, 2], self._lightness_scale, samples, samples)
sel... |
Create a :class:`scipy.interpolate.RegularGridInterpolator` class
instance for read or generated coefficients.
| _create_interpolator | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def generate(
self,
colourspace: RGB_Colourspace,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
size: int = 64,
print_callable: Callable = print,
) -> None:
"""
Generate the lookup table data for specif... |
Generate the lookup table data for specified *RGB* colourspace, colour
matching functions, illuminant and specified size.
Parameters
----------
colourspace
The *RGB* colourspace to create a lookup table for.
cmfs
Standard observer colour matching... | generate | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def optimize(
ijkL: ArrayLike, coefficients_0: ArrayLike, chroma: NDArrayFloat
) -> NDArrayFloat:
"""
Solve for a specific lightness and stores the result in the
appropriate cell.
"""
i, j, k, L = tsplit(ijkL, dtype=DTYPE_INT_DEFAULT)
... |
Solve for a specific lightness and stores the result in the
appropriate cell.
| optimize | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def RGB_to_coefficients(self, RGB: ArrayLike) -> NDArrayFloat:
"""
Look up a specified *RGB* colourspace array and return corresponding
coefficients. Interpolation is used for colours not on the table grid.
Parameters
----------
RGB
*RGB* colourspace array.
... |
Look up a specified *RGB* colourspace array and return corresponding
coefficients. Interpolation is used for colours not on the table grid.
Parameters
----------
RGB
*RGB* colourspace array.
Returns
-------
:class:`numpy.ndarray`
... | RGB_to_coefficients | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def RGB_to_sd(
self, RGB: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019
) -> SpectralDistribution:
"""
Look up a specified *RGB* colourspace array and return the corresponding
spectral distribution.
Parameters
----------
RGB
*RGB* col... |
Look up a specified *RGB* colourspace array and return the corresponding
spectral distribution.
Parameters
----------
RGB
*RGB* colourspace array.
shape
Shape used by the spectral distribution.
Returns
-------
:class:`col... | RGB_to_sd | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def read(self, path: str | PathLike) -> LUT3D_Jakob2019:
"""
Load a lookup table from a *\\*.coeff* file.
Parameters
----------
path
Path to the file.
Returns
-------
LUT3D_Jakob2019
*Jakob and Hanika (2019)* lookup table.
... |
Load a lookup table from a *\*.coeff* file.
Parameters
----------
path
Path to the file.
Returns
-------
LUT3D_Jakob2019
*Jakob and Hanika (2019)* lookup table.
Examples
--------
>>> import os
>>> import ... | read | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def write(self, path: str | PathLike) -> bool:
"""
Write the lookup table to a *\\*.coeff* file.
Parameters
----------
path
Path to the file.
Returns
-------
:class:`bool`
Definition success.
Examples
--------
... |
Write the lookup table to a *\*.coeff* file.
Parameters
----------
path
Path to the file.
Returns
-------
:class:`bool`
Definition success.
Examples
--------
>>> import os
>>> import colour
>>> fr... | write | python | colour-science/colour | colour/recovery/jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jakob2019.py | BSD-3-Clause |
def PCA_Jiang2013(
msds_camera_sensitivities: Mapping[str, MultiSpectralDistributions],
eigen_w_v_count: int | None = None,
additional_data: bool = False,
) -> (
Tuple[
Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat],
Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat],
]
| Tuple[NDA... |
Perform the *Principal Component Analysis* (PCA) on specified camera *RGB*
sensitivities.
Parameters
----------
msds_camera_sensitivities
Camera *RGB* sensitivities.
eigen_w_v_count
Eigen-values :math:`w` and eigen-vectors :math:`v` count.
additional_data
Whether t... | PCA_Jiang2013 | python | colour-science/colour | colour/recovery/jiang2013.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jiang2013.py | BSD-3-Clause |
def RGB_to_sd_camera_sensitivity_Jiang2013(
RGB: ArrayLike,
illuminant: SpectralDistribution,
reflectances: MultiSpectralDistributions,
eigen_w: ArrayLike,
shape: SpectralShape | None = None,
) -> SpectralDistribution:
"""
Recover a single camera *RGB* sensitivity for specified camera *RGB* ... |
Recover a single camera *RGB* sensitivity for specified camera *RGB* values
using *Jiang et al. (2013)* method.
Parameters
----------
RGB
Camera *RGB* values corresponding with ``reflectances``.
illuminant
Illuminant spectral distribution used to produce the camera *RGB*
... | RGB_to_sd_camera_sensitivity_Jiang2013 | python | colour-science/colour | colour/recovery/jiang2013.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jiang2013.py | BSD-3-Clause |
def RGB_to_msds_camera_sensitivities_Jiang2013(
RGB: ArrayLike,
illuminant: SpectralDistribution,
reflectances: MultiSpectralDistributions,
basis_functions: ArrayLike = BASIS_FUNCTIONS_DYER2017,
shape: SpectralShape | None = None,
) -> MultiSpectralDistributions:
"""
Recover the camera *RGB*... |
Recover the camera *RGB* sensitivities for specified camera *RGB* values
using *Jiang et al. (2013)* method.
Parameters
----------
RGB
Camera *RGB* values corresponding with ``reflectances``.
illuminant
Illuminant spectral distribution used to produce the camera *RGB*
v... | RGB_to_msds_camera_sensitivities_Jiang2013 | python | colour-science/colour | colour/recovery/jiang2013.py | https://github.com/colour-science/colour/blob/master/colour/recovery/jiang2013.py | BSD-3-Clause |
def spectral_primary_decomposition_Mallett2019(
colourspace: RGB_Colourspace,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
metric: Callable = np.linalg.norm,
metric_args: tuple = (),
optimisation_kwargs: dict | None = None,
) -> MultiSpectralDis... |
Perform the spectral primary decomposition as described in *Mallett and
Yuksel (2019)* for specified *RGB* colourspace.
Parameters
----------
colourspace
*RGB* colourspace.
cmfs
Standard observer colour matching functions, default to the
*CIE 1931 2 Degree Standard Obse... | spectral_primary_decomposition_Mallett2019 | python | colour-science/colour | colour/recovery/mallett2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/mallett2019.py | BSD-3-Clause |
def RGB_to_sd_Mallett2019(
RGB: ArrayLike,
basis_functions: MultiSpectralDistributions = MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019,
) -> SpectralDistribution:
"""
Recover the spectral distribution of specified *RGB* colourspace array using
*Mallett and Yuksel (2019)* method.
Parameters
--------... |
Recover the spectral distribution of specified *RGB* colourspace array using
*Mallett and Yuksel (2019)* method.
Parameters
----------
RGB
*RGB* colourspace array.
basis_functions
Basis functions for the method. The default is to use the built-in
*sRGB* basis functions,... | RGB_to_sd_Mallett2019 | python | colour-science/colour | colour/recovery/mallett2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/mallett2019.py | BSD-3-Clause |
def XYZ_to_sd_Meng2015(
XYZ: ArrayLike,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
optimisation_kwargs: dict | None = None,
) -> SpectralDistribution:
"""
Recover the spectral distribution of specified *CIE XYZ* tristimulus values
using *M... |
Recover the spectral distribution of specified *CIE XYZ* tristimulus values
using *Meng et al. (2015)* method.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to recover the spectral distribution from.
cmfs
Standard observer colour matching functions. The wavelength
... | XYZ_to_sd_Meng2015 | python | colour-science/colour | colour/recovery/meng2015.py | https://github.com/colour-science/colour/blob/master/colour/recovery/meng2015.py | BSD-3-Clause |
def __str__(self) -> str:
"""
Return a formatted string representation of the dataset.
Returns
-------
:class:`str`
Formatted string representation.
"""
if self._basis_functions is not None:
return (
f"{self.__class__.__na... |
Return a formatted string representation of the dataset.
Returns
-------
:class:`str`
Formatted string representation.
| __str__ | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def select(self, xy: ArrayLike) -> int:
"""
Determine the cluster index appropriate for the specified *CIE xy*
coordinates.
Parameters
----------
xy
*CIE xy* chromaticity coordinates.
Returns
-------
:class:`int`
Cluster i... |
Determine the cluster index appropriate for the specified *CIE xy*
coordinates.
Parameters
----------
xy
*CIE xy* chromaticity coordinates.
Returns
-------
:class:`int`
Cluster index.
Raises
------
ValueE... | select | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def cluster(self, xy: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]:
"""
Retrieve the basis functions and dataset mean for the specified *CIE xy*
coordinates.
Parameters
----------
xy
*CIE xy* chromaticity coordinates.
Returns
-------
... |
Retrieve the basis functions and dataset mean for the specified *CIE xy*
coordinates.
Parameters
----------
xy
*CIE xy* chromaticity coordinates.
Returns
-------
:class:`tuple`
Tuple of three basis functions and dataset mean.
... | cluster | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def read(self, path: str | PathLike) -> None:
"""
Read and loads a dataset from an *.npz* file.
Parameters
----------
path
Path to the file.
Examples
--------
>>> import os
>>> import colour
>>> from colour.characterisation im... |
Read and loads a dataset from an *.npz* file.
Parameters
----------
path
Path to the file.
Examples
--------
>>> import os
>>> import colour
>>> from colour.characterisation import SDS_COLOURCHECKERS
>>> from colour.colorimet... | read | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def write(self, path: str | PathLike) -> None:
"""
Write the dataset to an *.npz* file at specified path.
Parameters
----------
path
Path to the file.
Raises
------
ValueError
If the shape is undefined.
Examples
-... |
Write the dataset to an *.npz* file at specified path.
Parameters
----------
path
Path to the file.
Raises
------
ValueError
If the shape is undefined.
Examples
--------
>>> import os
>>> import colour
... | write | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def XYZ_to_sd_Otsu2018(
XYZ: ArrayLike,
cmfs: MultiSpectralDistributions | None = None,
illuminant: SpectralDistribution | None = None,
dataset: Dataset_Otsu2018 = DATASET_REFERENCE_OTSU2018,
clip: bool = True,
) -> SpectralDistribution:
"""
Recover the spectral distribution of specified *CI... |
Recover the spectral distribution of specified *CIE XYZ* tristimulus values
using *Otsu et al. (2018)* method.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to recover the spectral distribution from.
cmfs
Standard observer colour matching functions, default to the
... | XYZ_to_sd_Otsu2018 | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def __str__(self) -> str:
"""
Return a formatted string representation of the partition axis.
Returns
-------
:class:`str`
Formatted string representation.
"""
return (
f"{self.__class__.__name__}"
f"({'horizontal' if self.dir... |
Return a formatted string representation of the partition axis.
Returns
-------
:class:`str`
Formatted string representation.
| __str__ | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def reflectances(self, value: ArrayLike | None) -> None:
"""Setter for the **self.reflectances** property."""
if value is not None:
self._reflectances = as_float_array(value)
self._XYZ = (
msds_to_XYZ_integration(
self._reflectances,
... | Setter for the **self.reflectances** property. | reflectances | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def origin(self, i: int, direction: int) -> float:
"""
Retrieve the origin *CIE x* or *CIE y* chromaticity coordinate for
specified index and direction.
Parameters
----------
i
Origin index.
direction
Origin direction.
Returns
... |
Retrieve the origin *CIE x* or *CIE y* chromaticity coordinate for
specified index and direction.
Parameters
----------
i
Origin index.
direction
Origin direction.
Returns
-------
:class:`float`
Origin *CIE x*... | origin | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]:
"""
Partition the data using specified partition axis.
Parameters
----------
axis
Partition axis used to partition the data.
Returns
-------
:class:`tuple`
... |
Partition the data using specified partition axis.
Parameters
----------
axis
Partition axis used to partition the data.
Returns
-------
:class:`tuple`
Tuple of left or lower part and right or upper part.
Raises
------
... | partition | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def PCA(self) -> None:
"""
Perform the *Principal Component Analysis* (PCA) on the data and sets
the relevant attributes accordingly.
"""
if self._M is None and self._reflectances is not None:
settings: Dict[str, Any] = {
"cmfs": self._cmfs,
... |
Perform the *Principal Component Analysis* (PCA) on the data and sets
the relevant attributes accordingly.
| PCA | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def reconstruct(self, XYZ: ArrayLike) -> SpectralDistribution:
"""
Reconstruct the reflectance for the specified *CIE XYZ* tristimulus
values.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to recover the spectral distribution
from.
... |
Reconstruct the reflectance for the specified *CIE XYZ* tristimulus
values.
Parameters
----------
XYZ
*CIE XYZ* tristimulus values to recover the spectral distribution
from.
Returns
-------
:class:`colour.SpectralDistribution`
... | reconstruct | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def reconstruction_error(self) -> float:
"""
Compute the reconstruction error of the data. The error is computed by
reconstructing the reflectances for the reference *CIE XYZ* tristimulus
values using PCA and, comparing the reconstructed reflectances against
the reference reflect... |
Compute the reconstruction error of the data. The error is computed by
reconstructing the reflectances for the reference *CIE XYZ* tristimulus
values using PCA and, comparing the reconstructed reflectances against
the reference reflectances.
Returns
-------
:cla... | reconstruction_error | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def row(self) -> Tuple[float, float, Self, Self]:
"""
Getter property for the node row for the selector array.
Returns
-------
:class:`tuple`
Node row for the selector array.
Raises
------
ValueError
If the partition axis is undef... |
Getter property for the node row for the selector array.
Returns
-------
:class:`tuple`
Node row for the selector array.
Raises
------
ValueError
If the partition axis is undefined.
| row | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def split(self, children: Sequence[Self], axis: PartitionAxis) -> None:
"""
Convert the leaf node into an inner node using specified children and
partition axis.
Parameters
----------
children
Tuple of two :class:`colour.recovery.otsu2018.Node` class
... |
Convert the leaf node into an inner node using specified children and
partition axis.
Parameters
----------
children
Tuple of two :class:`colour.recovery.otsu2018.Node` class
instances.
axis
Partition axis.
| split | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def minimise(
self, minimum_cluster_size: int
) -> Tuple[Sequence[Node_Otsu2018], PartitionAxis, float]:
"""
Find the best partition for the node that minimises the leaf
reconstruction error.
Parameters
----------
minimum_cluster_size
Smallest acc... |
Find the best partition for the node that minimises the leaf
reconstruction error.
Parameters
----------
minimum_cluster_size
Smallest acceptable cluster size. It must be at least 3 or the
*Principal Component Analysis* (PCA) is not possible.
Re... | minimise | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def branch_reconstruction_error(self) -> float:
"""
Compute the reconstruction error for all the leaves data connected to
the node or its children, i.e., the reconstruction errors summation for
all the leaves in the branch.
Returns
-------
:class:`float`
... |
Compute the reconstruction error for all the leaves data connected to
the node or its children, i.e., the reconstruction errors summation for
all the leaves in the branch.
Returns
-------
:class:`float`
Reconstruction errors summation for all the leaves' dat... | branch_reconstruction_error | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def optimise(
self,
iterations: int = 8,
minimum_cluster_size: int | None = None,
print_callable: Callable = print,
) -> None:
"""
Optimise the tree by repeatedly performing optimal partitioning of the
nodes, creating a tree that minimises the total reconstruc... |
Optimise the tree by repeatedly performing optimal partitioning of the
nodes, creating a tree that minimises the total reconstruction error.
Parameters
----------
iterations
Maximum number of splits. If the dataset is too small, this number
might not be ... | optimise | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def to_dataset(self) -> Dataset_Otsu2018:
"""
Create a :class:`colour.recovery.Dataset_Otsu2018` class instance
based on data stored in the tree.
The dataset can then be saved to disk or used to recover reflectance
with :func:`colour.recovery.XYZ_to_sd_Otsu2018` definition.
... |
Create a :class:`colour.recovery.Dataset_Otsu2018` class instance
based on data stored in the tree.
The dataset can then be saved to disk or used to recover reflectance
with :func:`colour.recovery.XYZ_to_sd_Otsu2018` definition.
Returns
-------
:class:`colour.r... | to_dataset | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def add_rows(node: Node_Otsu2018, data: dict | None = None) -> dict | None:
"""Add rows for specified node and its children."""
data = optional(data, {"rows": [], "node_to_leaf_id": {}, "leaf_id": 0})
if node.is_leaf():
data["node_to_leaf_id"][node] ... | Add rows for specified node and its children. | add_rows | python | colour-science/colour | colour/recovery/otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/otsu2018.py | BSD-3-Clause |
def test_intermediates(self) -> None:
"""
Test intermediate results of
:func:`colour.recovery.jakob2019.error_function` with
:func:`colour.sd_to_XYZ`, :func:`colour.XYZ_to_Lab` and checks if the
error is computed correctly by comparing it with
:func:`colour.difference.del... |
Test intermediate results of
:func:`colour.recovery.jakob2019.error_function` with
:func:`colour.sd_to_XYZ`, :func:`colour.XYZ_to_Lab` and checks if the
error is computed correctly by comparing it with
:func:`colour.difference.delta_E_CIE1976`.
| test_intermediates | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def test_derivatives(self) -> None:
"""
Test the gradients computed using closed-form expressions of the
derivatives with finite difference approximations.
"""
samples = np.linspace(-10, 10, 1000)
ds = samples[1] - samples[0]
# Vary one coefficient at a time, ke... |
Test the gradients computed using closed-form expressions of the
derivatives with finite difference approximations.
| test_derivatives | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def test_domain_range_scale_XYZ_to_sd_Jakob2019(self) -> None:
"""
Test :func:`colour.recovery.jakob2019.XYZ_to_sd_Jakob2019` definition
domain and range scale support.
"""
XYZ_i = np.array([0.20654008, 0.12197225, 0.05136952])
XYZ_o = sd_to_XYZ(
XYZ_to_sd_Ja... |
Test :func:`colour.recovery.jakob2019.XYZ_to_sd_Jakob2019` definition
domain and range scale support.
| test_domain_range_scale_XYZ_to_sd_Jakob2019 | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def generate_LUT(cls: Type[TestLUT3D_Jakob2019]) -> LUT3D_Jakob2019:
"""
Generate the *LUT* used for the unit tests.
Notes
-----
- This method is used to define the slow common tests attributes once
rather than using the typical :meth:`unittest.TestCase.setUp` that... |
Generate the *LUT* used for the unit tests.
Notes
-----
- This method is used to define the slow common tests attributes once
rather than using the typical :meth:`unittest.TestCase.setUp` that
is invoked once per-test.
| generate_LUT | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def test_LUT3D_Jakob2019(self) -> None:
"""
Test the entirety of the
:class:`colour.recovery.jakob2019.LUT3D_Jakob2019`class.
"""
LUT = TestLUT3D_Jakob2019.generate_LUT()
temporary_directory = tempfile.mkdtemp()
path = os.path.join(temporary_directory, "Test_Jak... |
Test the entirety of the
:class:`colour.recovery.jakob2019.LUT3D_Jakob2019`class.
| test_LUT3D_Jakob2019 | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def test_raise_exception_RGB_to_coefficients(self) -> None:
"""
Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.\
RGB_to_coefficients` method raised exception.
"""
LUT = LUT3D_Jakob2019()
pytest.raises(RuntimeError, LUT.RGB_to_coefficients, np.array([1, 2, 3, 4])) |
Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.RGB_to_coefficients` method raised exception.
| test_raise_exception_RGB_to_coefficients | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def test_raise_exception_read(self) -> None:
"""
Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.read` method
raised exception.
"""
LUT = LUT3D_Jakob2019()
pytest.raises(ValueError, LUT.read, __file__) |
Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.read` method
raised exception.
| test_raise_exception_read | python | colour-science/colour | colour/recovery/tests/test_jakob2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_jakob2019.py | BSD-3-Clause |
def check_basis_functions(self) -> None:
"""
Test :func:`colour.recovery.RGB_to_sd_Mallett2019` definition or the
more specialised :func:`colour.recovery.RGB_to_sd_Mallett2019`
definition.
"""
# Make sure the white point is reconstructed as a perfectly flat
# spe... |
Test :func:`colour.recovery.RGB_to_sd_Mallett2019` definition or the
more specialised :func:`colour.recovery.RGB_to_sd_Mallett2019`
definition.
| check_basis_functions | python | colour-science/colour | colour/recovery/tests/test_mallett2019.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_mallett2019.py | BSD-3-Clause |
def test_raise_exception_XYZ_to_sd_Meng2015(self) -> None:
"""
Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015`
definition raised exception.
"""
pytest.raises(
RuntimeError,
XYZ_to_sd_Meng2015,
np.array([0.0, 0.0, 1.0]),
op... |
Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015`
definition raised exception.
| test_raise_exception_XYZ_to_sd_Meng2015 | python | colour-science/colour | colour/recovery/tests/test_meng2015.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_meng2015.py | BSD-3-Clause |
def test_domain_range_scale_XYZ_to_sd_Meng2015(self) -> None:
"""
Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition
domain and range scale support.
"""
XYZ_i = np.array([0.20654008, 0.12197225, 0.05136952])
XYZ_o = sd_to_XYZ_integration(
XYZ... |
Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition
domain and range scale support.
| test_domain_range_scale_XYZ_to_sd_Meng2015 | python | colour-science/colour | colour/recovery/tests/test_meng2015.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_meng2015.py | BSD-3-Clause |
def test_means(self) -> None:
"""
Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.means`
property.
"""
assert self._dataset.means is not None
assert self._dataset.means.shape == (8, 36) |
Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.means`
property.
| test_means | python | colour-science/colour | colour/recovery/tests/test_otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_otsu2018.py | BSD-3-Clause |
def test_cluster(self) -> None:
"""Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.cluster` method."""
basis_functions, means = self._dataset.cluster(self._xy)
assert basis_functions.shape == (3, 36)
assert means.shape == (36,) | Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.cluster` method. | test_cluster | python | colour-science/colour | colour/recovery/tests/test_otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_otsu2018.py | BSD-3-Clause |
def test_read(self) -> None:
"""Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.read` method."""
dataset = Dataset_Otsu2018()
dataset.read(self._path)
assert dataset.shape == SPECTRAL_SHAPE_OTSU2018
assert dataset.basis_functions is not None
assert dataset.basis_f... | Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.read` method. | test_read | python | colour-science/colour | colour/recovery/tests/test_otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_otsu2018.py | BSD-3-Clause |
def test_write(self) -> None:
"""Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.write` method."""
self._dataset.write(self._path)
dataset = Dataset_Otsu2018()
dataset.read(self._path)
assert dataset.shape == SPECTRAL_SHAPE_OTSU2018
assert dataset.basis_functions... | Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.write` method. | test_write | python | colour-science/colour | colour/recovery/tests/test_otsu2018.py | https://github.com/colour-science/colour/blob/master/colour/recovery/tests/test_otsu2018.py | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.