-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements unit tests for colour.models.ipt module
- Loading branch information
1 parent
621467f
commit 4eb03a4
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Defines unit tests for :mod:`colour.models.ipt` 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_IPT, IPT_to_XYZ, IPT_hue_angle | ||
|
||
__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_IPT', | ||
'TestIPT_to_XYZ', | ||
'TestIPT_hue_angle'] | ||
|
||
|
||
class TestXYZ_to_IPT(unittest.TestCase): | ||
""" | ||
Defines :func:`colour.models.ipt.TestXYZ_to_IPT` definition unit tests | ||
methods. | ||
""" | ||
|
||
def test_XYZ_to_IPT(self): | ||
""" | ||
Tests :func:`colour.models.ipt.XYZ_to_IPT` definition. | ||
""" | ||
|
||
np.testing.assert_almost_equal( | ||
XYZ_to_IPT(np.array([0.5, 0.5, 0.5])), | ||
np.array([0.738192, 0.0536732, 0.0359856]), | ||
decimal=7) | ||
|
||
|
||
class TestIPT_to_XYZ(unittest.TestCase): | ||
""" | ||
Defines :func:`colour.models.ipt.IPT_to_XYZ` definition unit tests | ||
methods. | ||
""" | ||
|
||
def test_IPT_to_XYZ(self): | ||
""" | ||
Tests :func:`colour.models.ipt.IPT_to_XYZ` definition. | ||
""" | ||
|
||
np.testing.assert_almost_equal( | ||
IPT_to_XYZ(np.array([0.5, 0.5, 0.5])), | ||
np.array([0.4497109, 0.2694691, 0.0196303]), | ||
decimal=7) | ||
|
||
|
||
class TestIPT_hue_angle(unittest.TestCase): | ||
""" | ||
Defines :func:`colour.models.ipt.IPT_hue_angle` definition unit tests | ||
methods. | ||
""" | ||
|
||
def test_IPT_hue_angle(self): | ||
""" | ||
Tests :func:`colour.models.ipt.IPT_hue_angle` definition. | ||
""" | ||
|
||
np.testing.assert_almost_equal( | ||
IPT_hue_angle(np.array([0.5, 0.5, 0.5])), | ||
0.78539812, | ||
decimal=7) |