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

"""
Defines unit tests for :mod:`colour.models.common` module.
"""

from __future__ import division, unicode_literals

import numpy as np
import sys

if sys.version_info[:2] <= (2, 6):
    import unittest2 as unittest
else:
    import unittest

from colour.models import XYZ_to_sRGB

__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__ = 'colour-science@googlegroups.com'
__status__ = 'Production'

__all__ = ['TestXYZ_to_sRGB']


class TestXYZ_to_sRGB(unittest.TestCase):
    """
    Defines :func:`colour.models.common.XYZ_to_sRGB` definition unit tests
    methods.
    """

    def test_XYZ_to_RGB(self):
        """
        Tests :func:`colour.models.common.XYZ_to_sRGB` definition.
        """

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0.1180583421, 0.1034, 0.0515089229])),
            np.array([0.48224885, 0.31651974, 0.22070513]),
            decimal=7)

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0.21341854, 0.19387471, 0.16653476])),
            np.array([0.59313312, 0.44141487, 0.42141429]),
            decimal=7)

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0, 0, 0]),
                        (0.34567, 0.35850)),
            np.array([0., 0., 0.]),
            decimal=7)

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0.1180583421, 0.1034, 0.0515089229]),
                        illuminant=(0.32168, 0.33767)),
            np.array([0.47572655, 0.31766531, 0.23306098]),
            decimal=7)

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0.1180583421, 0.1034, 0.0515089229]),
                        chromatic_adaptation_method='Bradford'),
            np.array([0.48224885, 0.31651974, 0.22070513]),
            decimal=7)

        np.testing.assert_almost_equal(
            XYZ_to_sRGB(np.array([0.1180583421, 0.1034, 0.0515089229]),
                        transfer_function=False),
            np.array([0.19797725, 0.08168657, 0.03992654]),
            decimal=7)


if __name__ == '__main__':
    unittest.main()

@@ -991,40 +991,36 @@
 (%5B0.
-1180583421
+07049534
 , 0.10
-34
+08
 , 0.0
-515089229
+9558313
 %5D)),
@@ -1048,40 +1048,40 @@
 (%5B0.
-48224885, 0.31651974, 0.22070513
+17501358, 0.38818795, 0.32161955
 %5D),%0A
@@ -1184,101 +1184,94 @@
 (%5B0.
-21341854, 0.19387471, 0.16653476%5D)),%0A            np.array(%5B0.59313312, 0.44141487, 0.42141429
+4709771, 0.3495, 0.11301649%5D)),%0A            np.array(%5B0.96984378, 0.4888342, 0.3022906
 %5D),%0A
@@ -1410,22 +1410,22 @@
  (0.
-3456
+4475
 7, 0.
-35850
+40745
 )),%0A
@@ -1624,36 +1624,25 @@
     
-illuminant=(0.32168
+(0.31271
 , 0.3
-3767
+2902
 )),%0A
@@ -1670,39 +1670,39 @@
 %5B0.4
-757265
+822488
 5, 0.31
-766531, 0.23306098
+651974, 0.22070513
 %5D),%0A
@@ -1805,40 +1805,36 @@
 (%5B0.
-1180583421
+07049534
 , 0.10
-34
+08
 , 0.0
-515089229
+9558313
 %5D),%0A
@@ -1926,40 +1926,40 @@
 (%5B0.
-48224885, 0.31651974, 0.22070513
+17501358, 0.38818795, 0.32161955
 %5D),%0A
@@ -2062,40 +2062,36 @@
 (%5B0.
-1180583421
+07049534
 , 0.10
-34
+08
 , 0.0
-515089229
+9558313
 %5D),%0A
@@ -2168,40 +2168,39 @@
 (%5B0.
-19797725, 0.08168657, 0.03992654
+02584654, 0.12473983, 0.0844036
 %5D),%0A

Use consistent data in "colour.models.tests.tests_common" module unit tests.