<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Colour Quality Scale
====================

Defines *colour quality scale* computation objects:

-   :func:`colour_quality_scale`

See Also
--------
`Colour Quality Scale IPython Notebook
<http://nbviewer.ipython.org/github/colour-science/colour-ipython/blob/master/notebooks/quality/cqs.ipynb>`_  # noqa

References
----------
.. [1]  **<NAME>., & <NAME>. (2010)**, *Color Quality Scale*,
        *Optical Engineering, 49(3), 033602-033602*,
        DOI: 10.1117/1.3360335

.. [2]  http://cie2.nist.gov/TC1-69/NIST%20CQS%20simulation%207.4.xls
        (Last accessed 18 September 2014)
"""

from __future__ import division, unicode_literals

import math
import numpy as np
from collections import namedtuple

from colour.colorimetry import STANDARD_OBSERVERS_CMFS
from colour.colorimetry import (
    D_illuminant_relative_spd,
    blackbody_spd,
    spectral_to_XYZ)
from colour.quality.dataset.vs import VS_SPDS, VS_INDEXES_TO_NAMES
from colour.models import (
    UCS_to_uv,
    XYZ_to_UCS,
    XYZ_to_xy,
    XYZ_to_Lab,
    Lab_to_LCHab)
from colour.temperature import CCT_to_xy_illuminant_D, uv_to_CCT_robertson1968
from colour.adaptation import chromatic_adaptation as xyz_chromatic_adaptation

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2013 - 2014 - Colour Developers'
__license__ = 'New BSD License - http://opensource.org/licenses/BSD-3-Clause'
__maintainer__ = 'Colour Developers'
__email__ = '<EMAIL>'
__status__ = 'Production'

__all__ = ['VsColorimetryData',
           'colour_quality_scale']


class VsColorimetryData(namedtuple('VsColorimetryData_nXYZLabC',
                                   ('name', 'XYZ', 'Lab', 'C'))):
    """
    Defines the the class holding *VS test colour samples* colorimetry data.
    """


def _vs_colorimetry_data(test_spd,
                         reference_spd,
                         vs_spds,
                         cmfs,
                         chromatic_adaptation=False):
    """
    Returns the *VS test colour samples* colorimetry data.

    Parameters
    ----------
    test_spd : SpectralPowerDistribution
        Test spectral power distribution.
    reference_spd : SpectralPowerDistribution
        Reference spectral power distribution.
    vs_spds : dict
        VS Test colour samples.
    cmfs : XYZ_ColourMatchingFunctions
        Standard observer colour matching functions.
    chromatic_adaptation : bool, optional
        Perform chromatic adaptation.<commit_msg>Fix incorrect "colour.quality.cqs.VsColorimetryData" namedtuple name.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Colour Quality Scale
====================

Defines *colour quality scale* computation objects:

-   :func:`colour_quality_scale`

See Also
--------
`Colour Quality Scale IPython Notebook
<http://nbviewer.ipython.org/github/colour-science/colour-ipython/blob/master/notebooks/quality/cqs.ipynb>`_  # noqa

References
----------
.. [1]  **<NAME>., & <NAME>. (2010)**, *Color Quality Scale*,
        *Optical Engineering, 49(3), 033602-033602*,
        DOI: 10.1117/1.3360335

.. [2]  http://cie2.nist.gov/TC1-69/NIST%20CQS%20simulation%207.4.xls
        (Last accessed 18 September 2014)
"""

from __future__ import division, unicode_literals

import math
import numpy as np
from collections import namedtuple

from colour.colorimetry import STANDARD_OBSERVERS_CMFS
from colour.colorimetry import (
    D_illuminant_relative_spd,
    blackbody_spd,
    spectral_to_XYZ)
from colour.quality.dataset.vs import VS_SPDS, VS_INDEXES_TO_NAMES
from colour.models import (
    UCS_to_uv,
    XYZ_to_UCS,
    XYZ_to_xy,
    XYZ_to_Lab,
    Lab_to_LCHab)
from colour.temperature import CCT_to_xy_illuminant_D, uv_to_CCT_robertson1968
from colour.adaptation import chromatic_adaptation as xyz_chromatic_adaptation

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2013 - 2014 - Colour Developers'
__license__ = 'New BSD License - http://opensource.org/licenses/BSD-3-Clause'
__maintainer__ = 'Colour Developers'
__email__ = '<EMAIL>'
__status__ = 'Production'

__all__ = ['VsColorimetryData',
           'colour_quality_scale']


class VsColorimetryData(namedtuple('VsColorimetryData',
                                   ('name', 'XYZ', 'Lab', 'C'))):
    """
    Defines the the class holding *VS test colour samples* colorimetry data.
    """


def _vs_colorimetry_data(test_spd,
                         reference_spd,
                         vs_spds,
                         cmfs,
                         chromatic_adaptation=False):
    """
    Returns the *VS test colour samples* colorimetry data.

    Parameters
    ----------
    test_spd : SpectralPowerDistribution
        Test spectral power distribution.
    reference_spd : SpectralPowerDistribution
        Reference spectral power distribution.
    vs_spds : dict
        VS Test colour samples.
    cmfs : XYZ_ColourMatchingFunctions
        Standard observer colour matching functions.
    chromatic_adaptation : bool, optional
        Perform chromatic adaptation.
{'fraction_non_alphanumeric': 0.10707981957246519, 'fraction_numerical': 0.026279662678956657, 'mean_word_length': 3.07673860911271, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2058357', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1572, 'n_words': 365}