From 61e0151026d7ba0873aea8fd6765565370b41d1a Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Tue, 4 Jul 2017 20:58:09 +1200 Subject: [PATCH] Format "colour_demosaicing" package. --- colour_demosaicing/__init__.py | 15 +- .../bayer/demosaicing/__init__.py | 5 +- .../bayer/demosaicing/bilinear.py | 15 +- .../bayer/demosaicing/malvar2004.py | 17 +-- .../bayer/demosaicing/menon2007.py | 130 +++++++++--------- colour_demosaicing/bayer/masks.py | 1 - colour_demosaicing/bayer/mosaicing.py | 1 - .../tests/tests_demosaicing/tests_bilinear.py | 22 ++- .../tests_demosaicing/tests_malvar2004.py | 23 ++-- .../tests_demosaicing/tests_menon2007.py | 34 ++--- colour_demosaicing/bayer/tests/tests_masks.py | 13 +- .../bayer/tests/tests_mosaicing.py | 14 +- docs/conf.py | 37 ++--- setup.py | 69 +++++----- 14 files changed, 169 insertions(+), 227 deletions(-) diff --git a/colour_demosaicing/__init__.py b/colour_demosaicing/__init__.py index 55b15c6..41d4efd 100644 --- a/colour_demosaicing/__init__.py +++ b/colour_demosaicing/__init__.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Colour - Demosaicing ==================== @@ -29,18 +28,18 @@ __all__ = [] __all__ += bayer.__all__ -RESOURCES_DIRECTORY = os.path.join( - os.path.dirname(__file__), 'resources') +RESOURCES_DIRECTORY = os.path.join(os.path.dirname(__file__), 'resources') EXAMPLES_RESOURCES_DIRECTORY = os.path.join( RESOURCES_DIRECTORY, 'colour-demosaicing-examples-dataset') -TESTS_RESOURCES_DIRECTORY = os.path.join( - RESOURCES_DIRECTORY, 'colour-demosaicing-tests-dataset') +TESTS_RESOURCES_DIRECTORY = os.path.join(RESOURCES_DIRECTORY, + 'colour-demosaicing-tests-dataset') __application_name__ = 'Colour - Demosaicing' __major_version__ = '0' __minor_version__ = '1' __change_version__ = '2' -__version__ = '.'.join((__major_version__, - __minor_version__, - __change_version__)) +__version__ = '.'.join( + (__major_version__, + __minor_version__, + __change_version__)) # yapf: disable diff --git a/colour_demosaicing/bayer/demosaicing/__init__.py b/colour_demosaicing/bayer/demosaicing/__init__.py index b662e4f..76468b5 100644 --- a/colour_demosaicing/bayer/demosaicing/__init__.py +++ b/colour_demosaicing/bayer/demosaicing/__init__.py @@ -5,9 +5,8 @@ from .bilinear import demosaicing_CFA_Bayer_bilinear from .malvar2004 import demosaicing_CFA_Bayer_Malvar2004 -from .menon2007 import ( - demosaicing_CFA_Bayer_DDFAPD, - demosaicing_CFA_Bayer_Menon2007) +from .menon2007 import (demosaicing_CFA_Bayer_DDFAPD, + demosaicing_CFA_Bayer_Menon2007) __all__ = [] __all__ += ['demosaicing_CFA_Bayer_bilinear'] diff --git a/colour_demosaicing/bayer/demosaicing/bilinear.py b/colour_demosaicing/bayer/demosaicing/bilinear.py index 7626756..99110e1 100644 --- a/colour_demosaicing/bayer/demosaicing/bilinear.py +++ b/colour_demosaicing/bayer/demosaicing/bilinear.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Bilinear Bayer CFA Demosaicing ============================== @@ -61,8 +60,9 @@ def demosaicing_CFA_Bayer_bilinear(CFA, pattern='RGGB'): Examples -------- - >>> CFA = np.array([[0.30980393, 0.36078432, 0.30588236, 0.3764706], - ... [0.35686275, 0.39607844, 0.36078432, 0.40000001]]) + >>> CFA = np.array( + ... [[0.30980393, 0.36078432, 0.30588236, 0.3764706], + ... [0.35686275, 0.39607844, 0.36078432, 0.40000001]]) >>> demosaicing_CFA_Bayer_bilinear(CFA) array([[[ 0.69705884, 0.17941177, 0.09901961], [ 0.46176472, 0.4509804 , 0.19803922], @@ -73,8 +73,9 @@ def demosaicing_CFA_Bayer_bilinear(CFA, pattern='RGGB'): [ 0.15392157, 0.26960785, 0.59411766], [ 0.15294118, 0.4509804 , 0.59705884], [ 0.07647059, 0.18431373, 0.90000002]]]) - >>> CFA = np.array([[0.3764706, 0.360784320, 0.40784314, 0.3764706], - ... [0.35686275, 0.30980393, 0.36078432, 0.29803923]]) + >>> CFA = np.array( + ... [[0.3764706, 0.360784320, 0.40784314, 0.3764706], + ... [0.35686275, 0.30980393, 0.36078432, 0.29803923]]) >>> demosaicing_CFA_Bayer_bilinear(CFA, 'BGGR') array([[[ 0.07745098, 0.17941177, 0.84705885], [ 0.15490197, 0.4509804 , 0.5882353 ], @@ -93,12 +94,12 @@ def demosaicing_CFA_Bayer_bilinear(CFA, pattern='RGGB'): H_G = np.asarray( [[0, 1, 0], [1, 4, 1], - [0, 1, 0]]) / 4 + [0, 1, 0]]) / 4 # yapf: disable H_RB = np.asarray( [[1, 2, 1], [2, 4, 2], - [1, 2, 1]]) / 4 + [1, 2, 1]]) / 4 # yapf: disable R = convolve(CFA * R_m, H_RB) G = convolve(CFA * G_m, H_G) diff --git a/colour_demosaicing/bayer/demosaicing/malvar2004.py b/colour_demosaicing/bayer/demosaicing/malvar2004.py index 5cbc2c7..9058a35 100644 --- a/colour_demosaicing/bayer/demosaicing/malvar2004.py +++ b/colour_demosaicing/bayer/demosaicing/malvar2004.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Malvar (2004) Bayer CFA Demosaicing =================================== @@ -64,8 +63,9 @@ def demosaicing_CFA_Bayer_Malvar2004(CFA, pattern='RGGB'): Examples -------- - >>> CFA = np.array([[0.30980393, 0.36078432, 0.30588236, 0.3764706], - ... [0.35686275, 0.39607844, 0.36078432, 0.40000001]]) + >>> CFA = np.array( + ... [[0.30980393, 0.36078432, 0.30588236, 0.3764706], + ... [0.35686275, 0.39607844, 0.36078432, 0.40000001]]) >>> demosaicing_CFA_Bayer_Malvar2004(CFA) array([[[ 0.30980393, 0.31666668, 0.32941177], [ 0.33039216, 0.36078432, 0.38112746], @@ -76,8 +76,9 @@ def demosaicing_CFA_Bayer_Malvar2004(CFA, pattern='RGGB'): [ 0.35318628, 0.38186275, 0.39607844], [ 0.3379902 , 0.36078432, 0.3754902 ], [ 0.37769609, 0.39558825, 0.40000001]]]) - >>> CFA = np.array([[0.3764706, 0.360784320, 0.40784314, 0.3764706], - ... [0.35686275, 0.30980393, 0.36078432, 0.29803923]]) + >>> CFA = np.array( + ... [[0.3764706, 0.360784320, 0.40784314, 0.3764706], + ... [0.35686275, 0.30980393, 0.36078432, 0.29803923]]) >>> demosaicing_CFA_Bayer_Malvar2004(CFA, 'BGGR') array([[[ 0.35539217, 0.37058825, 0.3764706 ], [ 0.34264707, 0.36078432, 0.37450981], @@ -98,14 +99,14 @@ def demosaicing_CFA_Bayer_Malvar2004(CFA, pattern='RGGB'): [0, 0, 2, 0, 0], [-1, 2, 4, 2, -1], [0, 0, 2, 0, 0], - [0, 0, -1, 0, 0]]) / 8 + [0, 0, -1, 0, 0]]) / 8 # yapf: disable Rg_RB_Bg_BR = np.asarray( [[0, 0, 0.5, 0, 0], [0, -1, 0, -1, 0], [-1, 4, 5, 4, - 1], [0, -1, 0, -1, 0], - [0, 0, 0.5, 0, 0]]) / 8 + [0, 0, 0.5, 0, 0]]) / 8 # yapf: disable Rg_BR_Bg_RB = np.transpose(Rg_RB_Bg_BR) @@ -114,7 +115,7 @@ def demosaicing_CFA_Bayer_Malvar2004(CFA, pattern='RGGB'): [0, 2, 0, 2, 0], [-1.5, 0, 6, 0, -1.5], [0, 2, 0, 2, 0], - [0, 0, -1.5, 0, 0]]) / 8 + [0, 0, -1.5, 0, 0]]) / 8 # yapf: disable R = CFA * R_m G = CFA * G_m diff --git a/colour_demosaicing/bayer/demosaicing/menon2007.py b/colour_demosaicing/bayer/demosaicing/menon2007.py index 41cddd1..7db6c10 100644 --- a/colour_demosaicing/bayer/demosaicing/menon2007.py +++ b/colour_demosaicing/bayer/demosaicing/menon2007.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - - """ DDFAPD - Menon (2007) Bayer CFA Demosaicing =========================================== @@ -31,9 +29,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['demosaicing_CFA_Bayer_Menon2007', - 'demosaicing_CFA_Bayer_DDFAPD', - 'refining_step_Menon2007'] +__all__ = [ + 'demosaicing_CFA_Bayer_Menon2007', 'demosaicing_CFA_Bayer_DDFAPD', + 'refining_step_Menon2007' +] def _cnv_h(x, y): @@ -83,8 +82,9 @@ def demosaicing_CFA_Bayer_Menon2007(CFA, pattern='RGGB', refining_step=True): Examples -------- - >>> CFA = np.array([[ 0.30980393, 0.36078432, 0.30588236, 0.3764706 ], - ... [ 0.35686275, 0.39607844, 0.36078432, 0.40000001]]) + >>> CFA = np.array( + ... [[ 0.30980393, 0.36078432, 0.30588236, 0.3764706 ], + ... [ 0.35686275, 0.39607844, 0.36078432, 0.40000001]]) >>> demosaicing_CFA_Bayer_Menon2007(CFA) array([[[ 0.30980393, 0.35686275, 0.39215687], [ 0.30980393, 0.36078432, 0.39607844], @@ -95,8 +95,9 @@ def demosaicing_CFA_Bayer_Menon2007(CFA, pattern='RGGB', refining_step=True): [ 0.30980393, 0.36078432, 0.39607844], [ 0.30588236, 0.36078432, 0.39019609], [ 0.32156864, 0.3764706 , 0.40000001]]]) - >>> CFA = np.array([[ 0.3764706 , 0.36078432, 0.40784314, 0.3764706 ], - ... [ 0.35686275, 0.30980393, 0.36078432, 0.29803923]]) + >>> CFA = np.array( + ... [[ 0.3764706 , 0.36078432, 0.40784314, 0.3764706 ], + ... [ 0.35686275, 0.30980393, 0.36078432, 0.29803923]]) >>> demosaicing_CFA_Bayer_Menon2007(CFA, 'BGGR') array([[[ 0.30588236, 0.35686275, 0.3764706 ], [ 0.30980393, 0.36078432, 0.39411766], @@ -128,17 +129,17 @@ def demosaicing_CFA_Bayer_Menon2007(CFA, pattern='RGGB', refining_step=True): C_V = np.where(R_m == 1, R - G_V, 0) C_V = np.where(B_m == 1, B - G_V, C_V) - D_H = np.abs(C_H - - np.pad(C_H, ((0, 0), (0, 2)), mode=str('reflect'))[:, 2:]) - D_V = np.abs(C_V - - np.pad(C_V, ((0, 2), (0, 0)), mode=str('reflect'))[2:, :]) + D_H = np.abs(C_H - np.pad(C_H, ((0, 0), (0, 2)), + mode=str('reflect'))[:, 2:]) + D_V = np.abs(C_V - np.pad(C_V, ((0, 2), (0, 0)), + mode=str('reflect'))[2:, :]) k = np.array( [[0, 0, 1, 0, 1], [0, 0, 0, 1, 0], [0, 0, 3, 0, 3], [0, 0, 0, 1, 0], - [0, 0, 1, 0, 1]]) + [0, 0, 1, 0, 1]]) # yapf: disable d_H = convolve(D_H, k, mode='constant') d_V = convolve(D_V, np.transpose(k), mode='constant') @@ -154,33 +155,31 @@ def demosaicing_CFA_Bayer_Menon2007(CFA, pattern='RGGB', refining_step=True): k_b = np.array([0.5, 0, 0.5]) - R = np.where(np.logical_and(G_m == 1, R_r == 1), - G + _cnv_h(R, k_b) - _cnv_h(G, k_b), - R) + R = np.where( + np.logical_and(G_m == 1, R_r == 1), + G + _cnv_h(R, k_b) - _cnv_h(G, k_b), R) - R = np.where(np.logical_and(G_m == 1, B_r == 1) == 1, - G + _cnv_v(R, k_b) - _cnv_v(G, k_b), - R) + R = np.where( + np.logical_and(G_m == 1, B_r == 1) == 1, + G + _cnv_v(R, k_b) - _cnv_v(G, k_b), R) - B = np.where(np.logical_and(G_m == 1, B_r == 1), - G + _cnv_h(B, k_b) - _cnv_h(G, k_b), - B) + B = np.where( + np.logical_and(G_m == 1, B_r == 1), + G + _cnv_h(B, k_b) - _cnv_h(G, k_b), B) - B = np.where(np.logical_and(G_m == 1, R_r == 1) == 1, - G + _cnv_v(B, k_b) - _cnv_v(G, k_b), - B) + B = np.where( + np.logical_and(G_m == 1, R_r == 1) == 1, + G + _cnv_v(B, k_b) - _cnv_v(G, k_b), B) - R = np.where(np.logical_and(B_r == 1, B_m == 1), - np.where(M == 1, - B + _cnv_h(R, k_b) - _cnv_h(B, k_b), - B + _cnv_v(R, k_b) - _cnv_v(B, k_b)), - R) + R = np.where( + np.logical_and(B_r == 1, B_m == 1), + np.where(M == 1, B + _cnv_h(R, k_b) - _cnv_h(B, k_b), + B + _cnv_v(R, k_b) - _cnv_v(B, k_b)), R) - B = np.where(np.logical_and(R_r == 1, R_m == 1), - np.where(M == 1, - R + _cnv_h(B, k_b) - _cnv_h(R, k_b), - R + _cnv_v(B, k_b) - _cnv_v(R, k_b)), - B) + B = np.where( + np.logical_and(R_r == 1, R_m == 1), + np.where(M == 1, R + _cnv_h(B, k_b) - _cnv_h(R, k_b), + R + _cnv_v(B, k_b) - _cnv_v(R, k_b)), B) RGB = tstack((R, G, B)) @@ -213,24 +212,27 @@ def refining_step_Menon2007(RGB, RGB_m, M): Examples -------- - >>> RGB = np.array([[[0.30588236, 0.35686275, 0.3764706], - ... [0.30980393, 0.36078432, 0.39411766], - ... [0.29607844, 0.36078432, 0.40784314], - ... [0.29803923, 0.37647060, 0.42352942]], - ... [[0.30588236, 0.35686275, 0.3764706], - ... [0.30980393, 0.36078432, 0.39411766], - ... [0.29607844, 0.36078432, 0.40784314], - ... [0.29803923, 0.37647060, 0.42352942]]]) - >>> RGB_m = np.array([[[0, 0, 1], - ... [0, 1, 0], - ... [0, 0, 1], - ... [0, 1, 0]], - ... [[0, 1, 0], - ... [1, 0, 0], - ... [0, 1, 0], - ... [1, 0, 0]]]) - >>> M = np.array([[0, 1, 0, 1], - ... [1, 0, 1, 0]]) + >>> RGB = np.array( + ... [[[0.30588236, 0.35686275, 0.3764706], + ... [0.30980393, 0.36078432, 0.39411766], + ... [0.29607844, 0.36078432, 0.40784314], + ... [0.29803923, 0.37647060, 0.42352942]], + ... [[0.30588236, 0.35686275, 0.3764706], + ... [0.30980393, 0.36078432, 0.39411766], + ... [0.29607844, 0.36078432, 0.40784314], + ... [0.29803923, 0.37647060, 0.42352942]]]) + >>> RGB_m = np.array( + ... [[[0, 0, 1], + ... [0, 1, 0], + ... [0, 0, 1], + ... [0, 1, 0]], + ... [[0, 1, 0], + ... [1, 0, 0], + ... [0, 1, 0], + ... [1, 0, 0]]]) + >>> M = np.array( + ... [[0, 1, 0, 1], + ... [1, 0, 1, 0]]) >>> refining_step_Menon2007(RGB, RGB_m, M) array([[[ 0.30588236, 0.35686275, 0.3764706 ], [ 0.30980393, 0.36078432, 0.39411765], @@ -276,22 +278,18 @@ def refining_step_Menon2007(RGB, RGB_m, M): k_b = np.array([0.5, 0, 0.5]) - R_G_m = np.where(np.logical_and(G_m == 1, B_r == 1), - _cnv_v(R_G, k_b), - R_G_m) + R_G_m = np.where( + np.logical_and(G_m == 1, B_r == 1), _cnv_v(R_G, k_b), R_G_m) R = np.where(np.logical_and(G_m == 1, B_r == 1), G + R_G_m, R) - R_G_m = np.where(np.logical_and(G_m == 1, B_c == 1), - _cnv_h(R_G, k_b), - R_G_m) + R_G_m = np.where( + np.logical_and(G_m == 1, B_c == 1), _cnv_h(R_G, k_b), R_G_m) R = np.where(np.logical_and(G_m == 1, B_c == 1), G + R_G_m, R) - B_G_m = np.where(np.logical_and(G_m == 1, R_r == 1), - _cnv_v(B_G, k_b), - B_G_m) + B_G_m = np.where( + np.logical_and(G_m == 1, R_r == 1), _cnv_v(B_G, k_b), B_G_m) B = np.where(np.logical_and(G_m == 1, R_r == 1), G + B_G_m, B) - B_G_m = np.where(np.logical_and(G_m == 1, R_c == 1), - _cnv_h(B_G, k_b), - B_G_m) + B_G_m = np.where( + np.logical_and(G_m == 1, R_c == 1), _cnv_h(B_G, k_b), B_G_m) B = np.where(np.logical_and(G_m == 1, R_c == 1), G + B_G_m, B) # Updating of the red (blue) component in the blue (red) locations. diff --git a/colour_demosaicing/bayer/masks.py b/colour_demosaicing/bayer/masks.py index 9b67135..89c9c10 100644 --- a/colour_demosaicing/bayer/masks.py +++ b/colour_demosaicing/bayer/masks.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Bayer CFA Masks =============== diff --git a/colour_demosaicing/bayer/mosaicing.py b/colour_demosaicing/bayer/mosaicing.py index 855bd35..8e40f86 100644 --- a/colour_demosaicing/bayer/mosaicing.py +++ b/colour_demosaicing/bayer/mosaicing.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Bayer CFA Mosaicing =================== diff --git a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_bilinear.py b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_bilinear.py index aa50077..50113c3 100644 --- a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_bilinear.py +++ b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_bilinear.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- - """ Defines unit tests for :mod:`colour_demosaicing.bayer.demosaicing.bilinear` module. @@ -24,11 +23,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['BAYER_DIRECTORY', - 'TestDemosaicing_CFA_Bayer_bilinear'] +__all__ = ['BAYER_DIRECTORY', 'TestDemosaicing_CFA_Bayer_bilinear'] -BAYER_DIRECTORY = os.path.join( - TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', 'bayer') +BAYER_DIRECTORY = os.path.join(TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', + 'bayer') class TestDemosaicing_CFA_Bayer_bilinear(unittest.TestCase): @@ -44,17 +42,13 @@ def test_demosaicing_CFA_Bayer_bilinear(self): """ for pattern in ('RGGB', 'BGGR', 'GRBG', 'GBRG'): + CFA = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr') + RGB = os.path.join(BAYER_DIRECTORY, 'Lighthouse_Bilinear_{0}.exr') + np.testing.assert_almost_equal( demosaicing_CFA_Bayer_bilinear( - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_CFA_{0}.exr'.format(pattern)))), - pattern), - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_Bilinear_{0}.exr'.format(pattern)))), + colour.read_image(str(CFA.format(pattern))), pattern), + colour.read_image(str(RGB.format(pattern))), decimal=7) diff --git a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_malvar2004.py b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_malvar2004.py index 5a6b366..7da3e8e 100644 --- a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_malvar2004.py +++ b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_malvar2004.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- - """ Defines unit tests for :mod:`colour_demosaicing.bayer.demosaicing.malvar2004` module. @@ -24,11 +23,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['BAYER_DIRECTORY', - 'TestDemosaicing_CFA_Bayer_Malvar2004'] +__all__ = ['BAYER_DIRECTORY', 'TestDemosaicing_CFA_Bayer_Malvar2004'] -BAYER_DIRECTORY = os.path.join( - TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', 'bayer') +BAYER_DIRECTORY = os.path.join(TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', + 'bayer') class TestDemosaicing_CFA_Bayer_Malvar2004(unittest.TestCase): @@ -44,17 +42,14 @@ def test_demosaicing_CFA_Bayer_Malvar2004(self): """ for pattern in ('RGGB', 'BGGR', 'GRBG', 'GBRG'): + CFA = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr') + RGB = os.path.join(BAYER_DIRECTORY, + 'Lighthouse_Malvar2004_{0}.exr') + np.testing.assert_almost_equal( demosaicing_CFA_Bayer_Malvar2004( - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_CFA_{0}.exr'.format(pattern)))), - pattern), - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_Malvar2004_{0}.exr'.format(pattern)))), + colour.read_image(str(CFA.format(pattern))), pattern), + colour.read_image(str(RGB.format(pattern))), decimal=7) diff --git a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_menon2007.py b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_menon2007.py index 1e4755f..52aeda6 100644 --- a/colour_demosaicing/bayer/tests/tests_demosaicing/tests_menon2007.py +++ b/colour_demosaicing/bayer/tests/tests_demosaicing/tests_menon2007.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- - """ Defines unit tests for :mod:`colour_demosaicing.bayer.demosaicing.menon2007` module. @@ -24,11 +23,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['BAYER_DIRECTORY', - 'TestDemosaicing_CFA_Bayer_Menon2007'] +__all__ = ['BAYER_DIRECTORY', 'TestDemosaicing_CFA_Bayer_Menon2007'] -BAYER_DIRECTORY = os.path.join( - TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', 'bayer') +BAYER_DIRECTORY = os.path.join(TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', + 'bayer') class TestDemosaicing_CFA_Bayer_Menon2007(unittest.TestCase): @@ -44,31 +42,23 @@ def test_demosaicing_CFA_Bayer_Menon2007(self): """ for pattern in ('RGGB', 'BGGR', 'GRBG', 'GBRG'): + CFA = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr') + RGB = os.path.join(BAYER_DIRECTORY, 'Lighthouse_Menon2007_{0}.exr') + np.testing.assert_almost_equal( demosaicing_CFA_Bayer_Menon2007( - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_CFA_{0}.exr'.format(pattern)))), - pattern), - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_Menon2007_{0}.exr'.format(pattern)))), + colour.read_image(str(CFA.format(pattern))), pattern), + colour.read_image(str(RGB.format(pattern))), decimal=7) + RGB = os.path.join(BAYER_DIRECTORY, + 'Lighthouse_Menon2007_NR_{0}.exr') np.testing.assert_almost_equal( demosaicing_CFA_Bayer_Menon2007( - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_CFA_{0}.exr'.format(pattern)))), + colour.read_image(str(CFA.format(pattern))), pattern, refining_step=False), - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_Menon2007_NR_{0}.exr'.format(pattern)))), + colour.read_image(str(RGB.format(pattern))), decimal=7) diff --git a/colour_demosaicing/bayer/tests/tests_masks.py b/colour_demosaicing/bayer/tests/tests_masks.py index cc81dea..cc3b110 100644 --- a/colour_demosaicing/bayer/tests/tests_masks.py +++ b/colour_demosaicing/bayer/tests/tests_masks.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- - """ Defines unit tests for :mod:`colour_demosaicing.bayer.masks` module. """ @@ -23,11 +22,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['BAYER_DIRECTORY', - 'TestMasks_CFA_Bayer'] +__all__ = ['BAYER_DIRECTORY', 'TestMasks_CFA_Bayer'] -BAYER_DIRECTORY = os.path.join( - TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', 'bayer') +BAYER_DIRECTORY = os.path.join(TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', + 'bayer') class TestMasks_CFA_Bayer(unittest.TestCase): @@ -43,11 +41,10 @@ def test_masks_CFA_Bayer(self): """ for pattern in ('RGGB', 'BGGR', 'GRBG', 'GBRG'): + mask = os.path.join(BAYER_DIRECTORY, '{0}_Masks.exr') np.testing.assert_almost_equal( colour.tstack(masks_CFA_Bayer((8, 8), pattern)), - colour.read_image( - str(os.path.join(BAYER_DIRECTORY, - '{0}_Masks.exr'.format(pattern)))), + colour.read_image(str(mask.format(pattern))), decimal=7) diff --git a/colour_demosaicing/bayer/tests/tests_mosaicing.py b/colour_demosaicing/bayer/tests/tests_mosaicing.py index 7d9f57b..289cd0a 100644 --- a/colour_demosaicing/bayer/tests/tests_mosaicing.py +++ b/colour_demosaicing/bayer/tests/tests_mosaicing.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- - """ Defines unit tests for :mod:`colour_demosaicing.bayer.mosaicing` module. """ @@ -23,11 +22,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['BAYER_DIRECTORY', - 'TestMosaicing_CFA_Bayer'] +__all__ = ['BAYER_DIRECTORY', 'TestMosaicing_CFA_Bayer'] -BAYER_DIRECTORY = os.path.join( - TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', 'bayer') +BAYER_DIRECTORY = os.path.join(TESTS_RESOURCES_DIRECTORY, 'colour_demosaicing', + 'bayer') class TestMosaicing_CFA_Bayer(unittest.TestCase): @@ -46,12 +44,10 @@ def test_mosaicing_CFA_Bayer(self): str(os.path.join(BAYER_DIRECTORY, 'Lighthouse.exr'))) for pattern in ('RGGB', 'BGGR', 'GRBG', 'GBRG'): + CFA = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr') np.testing.assert_almost_equal( mosaicing_CFA_Bayer(image, pattern), - colour.read_image( - str(os.path.join( - BAYER_DIRECTORY, - 'Lighthouse_CFA_{0}.exr'.format(pattern)))), + colour.read_image(str(CFA.format(pattern))), decimal=7) diff --git a/docs/conf.py b/docs/conf.py index f64f7ab..e5b890f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,10 +20,7 @@ import mock # Mock modules for *readthedocs.org*. -MOCK_MODULES = ( - 'scipy', - 'scipy.ndimage', - 'scipy.ndimage.filters') +MOCK_MODULES = ('scipy', 'scipy.ndimage', 'scipy.ndimage.filters') for module in MOCK_MODULES: sys.modules[module] = mock.Mock() @@ -46,15 +43,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', - 'sphinx.ext.autosummary', - 'sphinx.ext.napoleon', - 'sphinx.ext.mathjax'] + 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', + 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', + 'sphinx.ext.autosummary', 'sphinx.ext.napoleon', 'sphinx.ext.mathjax' +] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -119,7 +111,6 @@ # If true, keep warnings as 'system message' paragraphs in the built documents. # keep_warnings = False - # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -247,20 +238,17 @@ # If false, no module index is generated. # latex_domain_indices = True - # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'Colour_Demosaicing', u'Colour - Demosaicing Documentation', - [u'Colour Developers'], 1) -] +man_pages = [('index', 'Colour_Demosaicing', + u'Colour - Demosaicing Documentation', [u'Colour Developers'], + 1)] # If true, show URL addresses after external links. # man_show_urls = False - # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples @@ -284,7 +272,6 @@ # If true, do not generate a @detailmenu in the 'Top' node's menu. # texinfo_no_detailmenu = False - # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. @@ -358,7 +345,6 @@ intersphinx_mapping = {'python': ('https://docs.python.org/3.5', None)} - # def _autodoc_process_docstring(app, # what, # name, @@ -393,12 +379,7 @@ # offset[0] += len(references) -def _autodoc_process_docstring(app, - what, - name, - obj, - options, - lines): +def _autodoc_process_docstring(app, what, name, obj, options, lines): """ Process the docstrings to remove the *# noqa* *flake8* pragma. """ diff --git a/setup.py b/setup.py index 72dd762..5bd242e 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """ Pypi Setup ========== @@ -20,11 +19,10 @@ __email__ = 'colour-science@googlegroups.com' __status__ = 'Production' -__all__ = ['SHORT_DESCRIPTION', - 'LONG_DESCRIPTION', - 'INSTALLATION_REQUIREMENTS', - 'DOCS_REQUIREMENTS', - 'TESTS_REQUIREMENTS'] +__all__ = [ + 'SHORT_DESCRIPTION', 'LONG_DESCRIPTION', 'INSTALLATION_REQUIREMENTS', + 'DOCS_REQUIREMENTS', 'TESTS_REQUIREMENTS' +] SHORT_DESCRIPTION = 'Colour - Demosaicing' @@ -34,37 +32,32 @@ DOCS_REQUIREMENTS = ['sphinx>=1.2.2'] -TESTS_REQUIREMENTS = ['coverage>=3.7.1', - 'flake8>=2.1.0', - 'nose>=1.3.4'] +TESTS_REQUIREMENTS = ['coverage>=3.7.1', 'flake8>=2.1.0', 'nose>=1.3.4'] if os.environ.get('READTHEDOCS') == 'True': - INSTALLATION_REQUIREMENTS = ['colour-science>=0.3.8', - 'mock==1.0.1'] - -setup(name='colour-demosaicing', - version='0.1.2', - author=__author__, - author_email=__email__, - include_package_data=True, - packages=find_packages(), - scripts=[], - url='http://github.com/colour-science/colour-demosaicing', - license='', - description=SHORT_DESCRIPTION, - long_description=LONG_DESCRIPTION, - install_requires=INSTALLATION_REQUIREMENTS, - extras_require={ - 'docs': DOCS_REQUIREMENTS, - 'tests': TESTS_REQUIREMENTS}, - classifiers=['Development Status :: 3 - Alpha', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Topic :: Software Development']) + INSTALLATION_REQUIREMENTS = ['colour-science>=0.3.8', 'mock==1.0.1'] + +setup( + name='colour-demosaicing', + version='0.1.2', + author=__author__, + author_email=__email__, + include_package_data=True, + packages=find_packages(), + scripts=[], + url='http://github.com/colour-science/colour-demosaicing', + license='', + description=SHORT_DESCRIPTION, + long_description=LONG_DESCRIPTION, + install_requires=INSTALLATION_REQUIREMENTS, + extras_require={'docs': DOCS_REQUIREMENTS, + 'tests': TESTS_REQUIREMENTS}, + classifiers=[ + 'Development Status :: 3 - Alpha', 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', 'License :: OSI Approved', + 'Natural Language :: English', 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Topic :: Scientific/Engineering', 'Topic :: Software Development' + ])