Skip to content

Commit

Permalink
Use np.testing.assert_allclose definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 17, 2023
1 parent e4dc3f9 commit 915b316
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import numpy as np
from colour import read_image
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

from colour_demosaicing import ROOT_RESOURCES_TESTS
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_bilinear
Expand Down Expand Up @@ -52,12 +53,12 @@ def test_demosaicing_CFA_Bayer_bilinear(self):
ROOT_RESOURCES_BAYER, f"Lighthouse_Bilinear_{pattern}.exr"
)

np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
demosaicing_CFA_Bayer_bilinear(
read_image(str(CFA))[..., 0], pattern
),
read_image(str(RGB)),
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)


Expand Down
5 changes: 3 additions & 2 deletions colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import numpy as np
from colour import read_image
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

from colour_demosaicing import ROOT_RESOURCES_TESTS
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_Malvar2004
Expand Down Expand Up @@ -52,12 +53,12 @@ def test_demosaicing_CFA_Bayer_Malvar2004(self):
ROOT_RESOURCES_BAYER, f"Lighthouse_Malvar2004_{pattern}.exr"
)

np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
demosaicing_CFA_Bayer_Malvar2004(
read_image(str(CFA))[..., 0], pattern
),
read_image(str(RGB)),
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)


Expand Down
9 changes: 5 additions & 4 deletions colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import numpy as np
from colour import read_image
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

from colour_demosaicing import ROOT_RESOURCES_TESTS
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_Menon2007
Expand Down Expand Up @@ -52,25 +53,25 @@ def test_demosaicing_CFA_Bayer_Menon2007(self):
ROOT_RESOURCES_BAYER, f"Lighthouse_Menon2007_{pattern}.exr"
)

np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
demosaicing_CFA_Bayer_Menon2007(
read_image(str(CFA))[..., 0], pattern
),
read_image(str(RGB)),
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)

RGB = os.path.join(
ROOT_RESOURCES_BAYER, f"Lighthouse_Menon2007_NR_{pattern}.exr"
)
np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
demosaicing_CFA_Bayer_Menon2007(
read_image(str(CFA))[..., 0],
pattern,
refining_step=False,
),
read_image(str(RGB)),
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)


Expand Down
5 changes: 3 additions & 2 deletions colour_demosaicing/bayer/tests/test_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import numpy as np
from colour import read_image
from colour.constants import TOLERANCE_ABSOLUTE_TESTS
from colour.utilities import tstack

from colour_demosaicing import ROOT_RESOURCES_TESTS
Expand Down Expand Up @@ -44,10 +45,10 @@ def test_masks_CFA_Bayer(self):

for pattern in ("RGGB", "BGGR", "GRBG", "GBRG"):
mask = os.path.join(ROOT_RESOURCES_BAYER, f"{pattern}_Masks.exr")
np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
tstack(masks_CFA_Bayer((8, 8), pattern)),
read_image(str(mask)),
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)


Expand Down
5 changes: 3 additions & 2 deletions colour_demosaicing/bayer/tests/test_mosaicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import numpy as np
from colour import read_image
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

from colour_demosaicing import ROOT_RESOURCES_TESTS
from colour_demosaicing.bayer import mosaicing_CFA_Bayer
Expand Down Expand Up @@ -52,10 +53,10 @@ def test_mosaicing_CFA_Bayer(self):
CFA = os.path.join(
ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr"
)
np.testing.assert_array_almost_equal(
np.testing.assert_allclose(
mosaicing_CFA_Bayer(image, pattern),
read_image(str(CFA))[..., 0],
decimal=7,
atol=TOLERANCE_ABSOLUTE_TESTS,
)


Expand Down

0 comments on commit 915b316

Please sign in to comment.