From 14b79166ee9ff9a9346a741b83560317127ef58f Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Sat, 15 Aug 2020 11:13:40 +0200 Subject: [PATCH 01/17] Convert CAM test to unit tests. --- colour/appearance/tests/test_atd95.py | 6 ++++-- colour/appearance/tests/test_cam16.py | 7 +++++-- colour/appearance/tests/test_ciecam02.py | 7 +++++-- colour/appearance/tests/test_hunt.py | 3 ++- colour/appearance/tests/test_llab.py | 4 +++- colour/appearance/tests/test_nayatani95.py | 6 ++++-- colour/appearance/tests/test_rlab.py | 6 ++++-- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index 9486f36612..2077e59a89 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -6,8 +6,10 @@ from __future__ import division, unicode_literals -import numpy as np from itertools import permutations +from unittest import TestCase + +import numpy as np from colour.appearance import XYZ_to_ATD95 from colour.appearance.tests.common import ColourAppearanceModelTest @@ -23,7 +25,7 @@ __all__ = ['TestATD95ColourAppearanceModel'] -class TestATD95ColourAppearanceModel(ColourAppearanceModelTest): +class TestATD95ColourAppearanceModel(ColourAppearanceModelTest, TestCase): """ Defines :mod:`colour.appearance.atd95` module unit tests methods for *ATD (1995)* colour vision model. diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index 61cfb127e6..7df8f33a13 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -6,8 +6,10 @@ from __future__ import division, unicode_literals -import numpy as np from itertools import permutations +from unittest import TestCase + +import numpy as np from colour.appearance import (VIEWING_CONDITIONS_CAM16, InductionFactors_CAM16, CAM_Specification_CAM16, @@ -29,7 +31,8 @@ ] -class TestCAM16ColourAppearanceModelForward(ColourAppearanceModelTest): +class TestCAM16ColourAppearanceModelForward(ColourAppearanceModelTest, + TestCase): """ Defines :mod:`colour.appearance.cam16` module units tests methods for *CAM16* colour appearance model forward implementation. diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index e03fc24b2f..7ac6d40d00 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -6,8 +6,10 @@ from __future__ import division, unicode_literals -import numpy as np from itertools import permutations +from unittest import TestCase + +import numpy as np from colour.appearance import ( VIEWING_CONDITIONS_CIECAM02, InductionFactors_CIECAM02, @@ -29,7 +31,8 @@ ] -class TestCIECAM02ColourAppearanceModelForward(ColourAppearanceModelTest): +class TestCIECAM02ColourAppearanceModelForward(ColourAppearanceModelTest, + TestCase): """ Defines :mod:`colour.appearance.ciecam02` module units tests methods for *CIECAM02* colour appearance model forward implementation. diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index ba9a3693dd..000ee95f9e 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -8,6 +8,7 @@ import numpy as np from itertools import permutations +from unittest import TestCase from colour.appearance import (VIEWING_CONDITIONS_HUNT, InductionFactors_Hunt, XYZ_to_Hunt) @@ -24,7 +25,7 @@ __all__ = ['TestHuntColourAppearanceModel'] -class TestHuntColourAppearanceModel(ColourAppearanceModelTest): +class TestHuntColourAppearanceModel(ColourAppearanceModelTest, TestCase): """ Defines :mod:`colour.appearance.hunt` module unit tests methods for *Hunt* colour appearance model. diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 0ed13d25a2..50125278bf 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -13,7 +13,9 @@ from unittest import mock except ImportError: # pragma: no cover import mock + from itertools import permutations +from unittest import TestCase from colour.appearance import (VIEWING_CONDITIONS_LLAB, InductionFactors_LLAB, XYZ_to_LLAB, llab) @@ -30,7 +32,7 @@ __all__ = ['TestLLABColourAppearanceModel'] -class TestLLABColourAppearanceModel(ColourAppearanceModelTest): +class TestLLABColourAppearanceModel(ColourAppearanceModelTest, TestCase): """ Defines :mod:`colour.appearance.llab` module unit tests methods for *LLAB(l:c)* colour appearance model. diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index 406e1de6bd..35643d987e 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -6,8 +6,10 @@ from __future__ import division, unicode_literals -import numpy as np from itertools import permutations +from unittest import TestCase + +import numpy as np from colour.appearance import XYZ_to_Nayatani95 from colour.appearance.tests.common import ColourAppearanceModelTest @@ -23,7 +25,7 @@ __all__ = ['TestNayatani95ColourAppearanceModel'] -class TestNayatani95ColourAppearanceModel(ColourAppearanceModelTest): +class TestNayatani95ColourAppearanceModel(ColourAppearanceModelTest, TestCase): """ Defines :mod:`colour.appearance.nayatani95` module unit tests methods for *Nayatani (1995)* colour appearance model. diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index 34f37ec4b3..6303c95812 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -6,8 +6,10 @@ from __future__ import division, unicode_literals -import numpy as np from itertools import permutations +from unittest import TestCase + +import numpy as np from colour.appearance import (D_FACTOR_RLAB, VIEWING_CONDITIONS_RLAB, XYZ_to_RLAB) @@ -24,7 +26,7 @@ __all__ = ['TestRLABColourAppearanceModel'] -class TestRLABColourAppearanceModel(ColourAppearanceModelTest): +class TestRLABColourAppearanceModel(ColourAppearanceModelTest, TestCase): """ Defines :mod:`colour.appearance.rlab` module unit tests methods for *RLAB* colour appearance model. From 69f8d3bf443ad4ee149068301ecc12db424b0f1b Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Wed, 8 Jul 2020 21:58:54 +1200 Subject: [PATCH 02/17] Investigate n-dimensional array backend change. --- colour/__init__.py | 2 +- colour/adaptation/__init__.py | 2 +- colour/adaptation/cie1994.py | 2 +- colour/adaptation/cmccat2000.py | 2 +- colour/adaptation/datasets/cat.py | 2 +- colour/adaptation/fairchild1990.py | 2 +- colour/adaptation/tests/test__init__.py | 2 +- colour/adaptation/tests/test_cie1994.py | 2 +- colour/adaptation/tests/test_cmccat2000.py | 2 +- colour/adaptation/tests/test_fairchild1990.py | 2 +- colour/adaptation/tests/test_vonkries.py | 2 +- colour/adaptation/vonkries.py | 2 +- colour/algebra/common.py | 2 +- .../coordinates/tests/test_transformations.py | 2 +- colour/algebra/coordinates/transformations.py | 2 +- colour/algebra/extrapolation.py | 2 +- colour/algebra/geometry.py | 2 +- colour/algebra/interpolation.py | 14 ++- colour/algebra/matrix.py | 2 +- colour/algebra/random.py | 2 +- colour/algebra/regression.py | 2 +- colour/algebra/tests/test_common.py | 2 +- colour/algebra/tests/test_extrapolation.py | 2 +- colour/algebra/tests/test_geometry.py | 2 +- colour/algebra/tests/test_interpolation.py | 2 +- colour/algebra/tests/test_matrix.py | 2 +- colour/algebra/tests/test_random.py | 2 +- colour/algebra/tests/test_regression.py | 2 +- colour/appearance/atd95.py | 2 +- colour/appearance/cam16.py | 2 +- colour/appearance/ciecam02.py | 2 +- colour/appearance/hunt.py | 2 +- colour/appearance/llab.py | 2 +- colour/appearance/nayatani95.py | 2 +- colour/appearance/rlab.py | 2 +- colour/appearance/tests/common.py | 2 +- colour/appearance/tests/test_atd95.py | 3 +- colour/appearance/tests/test_cam16.py | 3 +- colour/appearance/tests/test_ciecam02.py | 2 +- colour/appearance/tests/test_hunt.py | 2 +- colour/appearance/tests/test_llab.py | 2 +- colour/appearance/tests/test_nayatani95.py | 2 +- colour/appearance/tests/test_rlab.py | 2 +- .../tests/test_michaelis_menten.py | 2 +- colour/blindness/datasets/machado2010.py | 2 +- colour/blindness/machado2009.py | 2 +- colour/blindness/tests/test_machado2009.py | 2 +- colour/characterisation/aces_it.py | 2 +- colour/characterisation/correction.py | 2 +- .../chromaticity_coordinates.py | 2 +- colour/characterisation/tests/test_aces_it.py | 2 +- .../characterisation/tests/test_correction.py | 2 +- colour/colorimetry/blackbody.py | 2 +- colour/colorimetry/correction.py | 2 +- .../illuminants/chromaticity_coordinates.py | 2 +- .../datasets/illuminants/hunterlab.py | 2 +- .../light_sources/chromaticity_coordinates.py | 2 +- colour/colorimetry/dominant.py | 2 +- colour/colorimetry/generation.py | 2 +- colour/colorimetry/illuminants.py | 2 +- colour/colorimetry/lightness.py | 2 +- colour/colorimetry/luminance.py | 2 +- colour/colorimetry/photometry.py | 2 +- colour/colorimetry/spectrum.py | 2 +- colour/colorimetry/tests/test_blackbody.py | 2 +- colour/colorimetry/tests/test_correction.py | 2 +- colour/colorimetry/tests/test_dominant.py | 2 +- colour/colorimetry/tests/test_generation.py | 2 +- colour/colorimetry/tests/test_illuminants.py | 2 +- colour/colorimetry/tests/test_lefs.py | 2 +- colour/colorimetry/tests/test_lightness.py | 2 +- colour/colorimetry/tests/test_luminance.py | 2 +- colour/colorimetry/tests/test_spectrum.py | 2 +- .../colorimetry/tests/test_transformations.py | 2 +- colour/colorimetry/tests/test_tristimulus.py | 2 +- colour/colorimetry/tests/test_whiteness.py | 2 +- colour/colorimetry/tests/test_yellowness.py | 2 +- colour/colorimetry/transformations.py | 2 +- colour/colorimetry/tristimulus.py | 2 +- colour/colorimetry/whiteness.py | 14 +-- colour/colorimetry/yellowness.py | 6 +- colour/constants/common.py | 2 +- colour/continuous/abstract.py | 2 +- colour/continuous/multi_signals.py | 2 +- colour/continuous/signal.py | 3 +- colour/continuous/tests/test_multi_signal.py | 2 +- colour/continuous/tests/test_signal.py | 2 +- colour/contrast/barten1999.py | 2 +- colour/contrast/tests/test_barten1999.py | 2 +- colour/corresponding/datasets/breneman1987.py | 2 +- colour/corresponding/prediction.py | 2 +- colour/corresponding/tests/test_prediction.py | 2 +- colour/difference/__init__.py | 2 +- colour/difference/cam02_ucs.py | 2 +- colour/difference/delta_e.py | 2 +- colour/difference/din99.py | 2 +- colour/difference/tests/test__init__.py | 2 +- colour/difference/tests/test_cam02_ucs.py | 2 +- colour/difference/tests/test_delta_e.py | 2 +- colour/difference/tests/test_din99.py | 2 +- .../examples/adaptation/examples_cie1994.py | 2 +- .../adaptation/examples_cmccat2000.py | 2 +- .../adaptation/examples_fairchild1990.py | 2 +- .../examples/adaptation/examples_vonkries.py | 2 +- .../algebra/examples_interpolation.py | 2 +- colour/examples/appearance/examples_atd95.py | 2 +- colour/examples/appearance/examples_cam16.py | 2 +- .../examples/appearance/examples_ciecam02.py | 2 +- colour/examples/appearance/examples_hunt.py | 2 +- colour/examples/appearance/examples_llab.py | 2 +- .../appearance/examples_nayatani95.py | 2 +- colour/examples/appearance/examples_rlab.py | 2 +- .../blindness/examples_machado2009.py | 2 +- .../examples_colour_checkers.py | 2 +- .../characterisation/examples_correction.py | 2 +- .../colorimetry/examples_correction.py | 2 +- .../examples/colorimetry/examples_dominant.py | 2 +- .../colorimetry/examples_lightness.py | 2 +- .../examples/colorimetry/examples_spectrum.py | 2 +- .../colorimetry/examples_tristimulus.py | 2 +- .../colorimetry/examples_whiteness.py | 2 +- .../colorimetry/examples_yellowness.py | 2 +- colour/examples/contrast/examples_contrast.py | 2 +- .../examples/difference/examples_delta_e.py | 2 +- colour/examples/examples_colour.py | 2 +- colour/examples/geometry/examples_geometry.py | 2 +- colour/examples/graph/examples_graph.py | 2 +- colour/examples/io/examples_luts.py | 2 +- colour/examples/models/examples_cmyk.py | 2 +- .../examples/models/examples_cylindrical.py | 2 +- colour/examples/models/examples_derivation.py | 2 +- colour/examples/models/examples_ictcp.py | 2 +- colour/examples/models/examples_models.py | 2 +- colour/examples/models/examples_prismatic.py | 2 +- colour/examples/models/examples_rgb.py | 2 +- colour/examples/models/examples_ycbcr.py | 2 +- colour/examples/models/examples_ycocg.py | 2 +- .../examples/notation/examples_hexadecimal.py | 2 +- colour/examples/notation/examples_munsell.py | 2 +- .../examples/plotting/examples_blindness.py | 2 +- .../plotting/examples_models_plots.py | 2 +- .../plotting/examples_volume_plots.py | 2 +- colour/examples/recovery/examples_meng2015.py | 2 +- .../examples/recovery/examples_smits1999.py | 2 +- colour/geometry/primitives.py | 2 +- colour/geometry/tests/test_primitives.py | 2 +- colour/geometry/tests/test_vertices.py | 2 +- colour/geometry/vertices.py | 2 +- colour/graph/conversion.py | 2 +- colour/graph/tests/test_conversion.py | 2 +- colour/io/image.py | 2 +- colour/io/luts/__init__.py | 2 +- colour/io/luts/cinespace_csp.py | 2 +- colour/io/luts/iridas_cube.py | 2 +- colour/io/luts/lut.py | 2 +- colour/io/luts/resolve_cube.py | 2 +- colour/io/luts/sony_spi1d.py | 2 +- colour/io/luts/sony_spi3d.py | 2 +- colour/io/luts/tests/test__init__.py | 2 +- colour/io/luts/tests/test_cinespace_csp.py | 2 +- colour/io/luts/tests/test_iridas_cube.py | 2 +- colour/io/luts/tests/test_lut.py | 2 +- colour/io/luts/tests/test_resolve_cube.py | 2 +- colour/io/luts/tests/test_sony_spi1d.py | 2 +- colour/io/luts/tests/test_sony_spi3d.py | 2 +- colour/io/tests/test_ies_tm2714.py | 2 +- colour/io/tests/test_image.py | 2 +- colour/io/tests/test_tabular.py | 2 +- colour/models/cam02_ucs.py | 2 +- colour/models/cie_lab.py | 8 +- colour/models/cie_luv.py | 16 +-- colour/models/cie_ucs.py | 12 +- colour/models/cie_uvw.py | 4 +- colour/models/cie_xyy.py | 2 +- colour/models/common.py | 4 +- colour/models/datasets/macadam_ellipses.py | 2 +- colour/models/datasets/pointer_gamut.py | 2 +- colour/models/din99.py | 6 +- colour/models/hdr_cie_lab.py | 2 +- colour/models/hdr_ipt.py | 2 +- colour/models/hunter_lab.py | 2 +- colour/models/hunter_rdab.py | 4 +- colour/models/ipt.py | 2 +- colour/models/jzazbz.py | 2 +- colour/models/osa_ucs.py | 6 +- colour/models/rgb/cmyk.py | 2 +- colour/models/rgb/common.py | 4 +- colour/models/rgb/cylindrical.py | 2 +- colour/models/rgb/datasets/aces.py | 2 +- colour/models/rgb/datasets/adobe_rgb_1998.py | 2 +- .../rgb/datasets/adobe_wide_gamut_rgb.py | 2 +- colour/models/rgb/datasets/apple_rgb.py | 2 +- .../rgb/datasets/arri_alexa_wide_gamut.py | 2 +- colour/models/rgb/datasets/best_rgb.py | 2 +- colour/models/rgb/datasets/beta_rgb.py | 2 +- .../models/rgb/datasets/canon_cinema_gamut.py | 2 +- colour/models/rgb/datasets/cie_rgb.py | 2 +- colour/models/rgb/datasets/color_match_rgb.py | 2 +- colour/models/rgb/datasets/dcdm_xyz.py | 2 +- colour/models/rgb/datasets/dci_p3.py | 2 +- colour/models/rgb/datasets/display_p3.py | 2 +- colour/models/rgb/datasets/dji_dgamut.py | 2 +- colour/models/rgb/datasets/don_rgb_4.py | 2 +- colour/models/rgb/datasets/eci_rgb_v2.py | 2 +- colour/models/rgb/datasets/ekta_space_ps5.py | 2 +- .../models/rgb/datasets/filmlight_egamut.py | 2 +- .../models/rgb/datasets/fujifilm_f_gamut.py | 2 +- colour/models/rgb/datasets/gopro.py | 2 +- colour/models/rgb/datasets/itur_bt_2020.py | 2 +- colour/models/rgb/datasets/itur_bt_470.py | 2 +- colour/models/rgb/datasets/itur_bt_709.py | 2 +- colour/models/rgb/datasets/max_rgb.py | 2 +- colour/models/rgb/datasets/p3_d65.py | 2 +- .../models/rgb/datasets/panasonic_v_gamut.py | 2 +- colour/models/rgb/datasets/red.py | 2 +- colour/models/rgb/datasets/rimm_romm_rgb.py | 2 +- colour/models/rgb/datasets/russell_rgb.py | 2 +- colour/models/rgb/datasets/sharp.py | 2 +- colour/models/rgb/datasets/smpte_240m.py | 2 +- colour/models/rgb/datasets/smpte_c.py | 2 +- colour/models/rgb/datasets/sony.py | 2 +- colour/models/rgb/datasets/srgb.py | 2 +- colour/models/rgb/datasets/xtreme_rgb.py | 2 +- colour/models/rgb/derivation.py | 2 +- colour/models/rgb/ictcp.py | 2 +- colour/models/rgb/prismatic.py | 2 +- colour/models/rgb/rgb_colourspace.py | 2 +- colour/models/rgb/tests/test_cmyk.py | 2 +- colour/models/rgb/tests/test_common.py | 2 +- colour/models/rgb/tests/test_cylindrical.py | 2 +- colour/models/rgb/tests/test_derivation.py | 2 +- colour/models/rgb/tests/test_ictcp.py | 2 +- colour/models/rgb/tests/test_prismatic.py | 2 +- .../models/rgb/tests/test_rgb_colourspace.py | 2 +- colour/models/rgb/tests/test_ycbcr.py | 2 +- colour/models/rgb/tests/test_ycocg.py | 2 +- colour/models/rgb/transfer_functions/aces.py | 2 +- .../rgb/transfer_functions/arib_std_b67.py | 2 +- .../transfer_functions/arri_alexa_log_c.py | 2 +- .../rgb/transfer_functions/canon_log.py | 2 +- .../models/rgb/transfer_functions/cineon.py | 2 +- .../models/rgb/transfer_functions/common.py | 2 +- colour/models/rgb/transfer_functions/dcdm.py | 2 +- .../rgb/transfer_functions/dicom_gsdf.py | 2 +- .../models/rgb/transfer_functions/dji_dlog.py | 2 +- .../models/rgb/transfer_functions/exponent.py | 2 +- .../rgb/transfer_functions/filmic_pro.py | 2 +- .../rgb/transfer_functions/filmlight_tlog.py | 2 +- .../rgb/transfer_functions/fujifilm_flog.py | 2 +- colour/models/rgb/transfer_functions/gamma.py | 2 +- colour/models/rgb/transfer_functions/gopro.py | 2 +- .../rgb/transfer_functions/itur_bt_1886.py | 2 +- .../rgb/transfer_functions/itur_bt_2020.py | 2 +- .../rgb/transfer_functions/itur_bt_2100.py | 2 +- .../rgb/transfer_functions/itur_bt_601.py | 2 +- colour/models/rgb/transfer_functions/log.py | 6 +- .../models/rgb/transfer_functions/panalog.py | 2 +- .../rgb/transfer_functions/panasonic_vlog.py | 2 +- .../rgb/transfer_functions/pivoted_log.py | 2 +- .../models/rgb/transfer_functions/red_log.py | 2 +- .../rgb/transfer_functions/rimm_romm_rgb.py | 2 +- .../rgb/transfer_functions/smpte_240m.py | 2 +- .../rgb/transfer_functions/sony_slog.py | 2 +- colour/models/rgb/transfer_functions/srgb.py | 2 +- .../models/rgb/transfer_functions/st_2084.py | 2 +- .../transfer_functions/tests/test__init__.py | 2 +- .../rgb/transfer_functions/tests/test_aces.py | 2 +- .../tests/test_arib_std_b67.py | 2 +- .../tests/test_arri_alexa_log_c.py | 2 +- .../tests/test_canon_log.py | 2 +- .../transfer_functions/tests/test_cineon.py | 2 +- .../transfer_functions/tests/test_common.py | 2 +- .../rgb/transfer_functions/tests/test_dcdm.py | 2 +- .../tests/test_dicom_gsdf.py | 2 +- .../transfer_functions/tests/test_dji_dlog.py | 2 +- .../transfer_functions/tests/test_exponent.py | 2 +- .../tests/test_filmic_pro.py | 2 +- .../tests/test_filmlight_tlog.py | 2 +- .../tests/test_fujifilm_flog.py | 2 +- .../transfer_functions/tests/test_gamma.py | 2 +- .../transfer_functions/tests/test_gopro.py | 2 +- .../tests/test_itur_bt_1886.py | 2 +- .../tests/test_itur_bt_2020.py | 2 +- .../tests/test_itur_bt_2100.py | 2 +- .../tests/test_itur_bt_601.py | 2 +- .../tests/test_itur_bt_709.py | 2 +- .../transfer_functions/tests/test_linear.py | 2 +- .../rgb/transfer_functions/tests/test_log.py | 2 +- .../transfer_functions/tests/test_panalog.py | 2 +- .../tests/test_panasonic_vlog.py | 2 +- .../tests/test_pivoted_log.py | 2 +- .../transfer_functions/tests/test_red_log.py | 2 +- .../tests/test_rimm_romm_rgb.py | 2 +- .../tests/test_smpte_240m.py | 2 +- .../tests/test_sony_slog.py | 2 +- .../rgb/transfer_functions/tests/test_srgb.py | 2 +- .../transfer_functions/tests/test_st_2084.py | 2 +- .../tests/test_viper_log.py | 2 +- .../rgb/transfer_functions/viper_log.py | 2 +- colour/models/rgb/ycbcr.py | 2 +- colour/models/rgb/ycocg.py | 2 +- colour/models/tests/test_cam02_ucs.py | 2 +- colour/models/tests/test_cie_lab.py | 2 +- colour/models/tests/test_cie_luv.py | 2 +- colour/models/tests/test_cie_ucs.py | 2 +- colour/models/tests/test_cie_uvw.py | 2 +- colour/models/tests/test_cie_xyy.py | 2 +- colour/models/tests/test_common.py | 2 +- colour/models/tests/test_din99.py | 2 +- colour/models/tests/test_hdr_cie_lab.py | 2 +- colour/models/tests/test_hdr_ipt.py | 2 +- colour/models/tests/test_hunter_lab.py | 2 +- colour/models/tests/test_hunter_rdab.py | 2 +- colour/models/tests/test_ipt.py | 2 +- colour/models/tests/test_jzazbz.py | 2 +- colour/models/tests/test_osa_ucs.py | 2 +- colour/ndarray/__init__.py | 17 +++ colour/ndarray/backend.py | 115 ++++++++++++++++++ colour/notation/datasets/munsell/all.py | 2 +- .../notation/datasets/munsell/experimental.py | 2 +- colour/notation/datasets/munsell/real.py | 2 +- colour/notation/hexadecimal.py | 2 +- colour/notation/munsell.py | 2 +- colour/notation/tests/test_hexadecimal.py | 2 +- colour/notation/tests/test_munsell.py | 2 +- colour/phenomena/rayleigh.py | 2 +- colour/phenomena/tests/test_rayleigh.py | 2 +- colour/plotting/blindness.py | 2 +- colour/plotting/characterisation.py | 2 +- colour/plotting/colorimetry.py | 2 +- colour/plotting/common.py | 4 +- colour/plotting/diagrams.py | 2 +- colour/plotting/models.py | 2 +- colour/plotting/notation.py | 2 +- colour/plotting/quality.py | 2 +- colour/plotting/temperature.py | 2 +- colour/plotting/tests/test_blindness.py | 2 +- colour/plotting/tests/test_common.py | 2 +- colour/plotting/tests/test_models.py | 2 +- colour/plotting/tests/test_volume.py | 2 +- colour/plotting/volume.py | 2 +- colour/quality/cqs.py | 2 +- colour/quality/cri.py | 2 +- colour/quality/ssi.py | 2 +- colour/quality/tests/test_cqs.py | 2 +- colour/quality/tests/test_cri.py | 2 +- colour/recovery/__init__.py | 2 +- colour/recovery/meng2015.py | 2 +- colour/recovery/smits1999.py | 2 +- colour/recovery/tests/test__init__.py | 2 +- colour/recovery/tests/test_meng2015.py | 2 +- colour/recovery/tests/test_smits1999.py | 2 +- colour/temperature/__init__.py | 6 +- colour/temperature/cie_d.py | 2 +- colour/temperature/hernandez1999.py | 2 +- colour/temperature/kang2002.py | 2 +- colour/temperature/krystek1985.py | 2 +- colour/temperature/mccamy1992.py | 4 +- colour/temperature/ohno2013.py | 2 +- colour/temperature/robertson1968.py | 2 +- colour/temperature/tests/test_cie_d.py | 2 +- .../temperature/tests/test_hernandez1999.py | 2 +- colour/temperature/tests/test_kang2002.py | 2 +- colour/temperature/tests/test_krystek1985.py | 2 +- colour/temperature/tests/test_mccamy1992.py | 2 +- colour/temperature/tests/test_ohno2013.py | 2 +- .../temperature/tests/test_robertson1968.py | 2 +- colour/utilities/array.py | 2 +- colour/utilities/common.py | 2 +- colour/utilities/metrics.py | 2 +- colour/utilities/tests/test_array.py | 2 +- colour/utilities/tests/test_common.py | 2 +- .../utilities/tests/test_data_structures.py | 2 +- colour/utilities/tests/test_metrics.py | 2 +- colour/utilities/verbose.py | 2 +- .../volume/datasets/optimal_colour_stimuli.py | 2 +- colour/volume/macadam_limits.py | 2 +- colour/volume/mesh.py | 2 +- colour/volume/pointer_gamut.py | 2 +- colour/volume/rgb.py | 2 +- colour/volume/spectrum.py | 4 +- colour/volume/tests/test_macadam_limits.py | 2 +- colour/volume/tests/test_mesh.py | 2 +- colour/volume/tests/test_pointer_gamut.py | 2 +- colour/volume/tests/test_rgb.py | 2 +- colour/volume/tests/test_spectrum.py | 2 +- et --hard HEAD@{5} | 76 ++++++++++++ pyproject.toml | 5 +- utilities/generate_plots.py | 2 +- 389 files changed, 645 insertions(+), 429 deletions(-) create mode 100644 colour/ndarray/__init__.py create mode 100644 colour/ndarray/backend.py create mode 100644 et --hard HEAD@{5} diff --git a/colour/__init__.py b/colour/__init__.py index c611225505..51b7661187 100644 --- a/colour/__init__.py +++ b/colour/__init__.py @@ -46,7 +46,7 @@ from __future__ import absolute_import -import numpy as np +import colour.ndarray as np import sys from .utilities.deprecation import ModuleAPI, build_API_changes diff --git a/colour/adaptation/__init__.py b/colour/adaptation/__init__.py index 1fffd174e6..35087b55e5 100644 --- a/colour/adaptation/__init__.py +++ b/colour/adaptation/__init__.py @@ -171,7 +171,7 @@ def chromatic_adaptation(XYZ, XYZ_w, XYZ_wr, method='Von Kries', **kwargs): *Von Kries* chromatic adaptation: - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_w = np.array([0.95045593, 1.00000000, 1.08905775]) >>> XYZ_wr = np.array([0.96429568, 1.00000000, 0.82510460]) diff --git a/colour/adaptation/cie1994.py b/colour/adaptation/cie1994.py index f5b89acc1a..2998af7ebf 100644 --- a/colour/adaptation/cie1994.py +++ b/colour/adaptation/cie1994.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.adaptation import CAT_VON_KRIES diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index b9f9868f22..47b849d30d 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.adaptation import CAT_CMCCAT2000 diff --git a/colour/adaptation/datasets/cat.py b/colour/adaptation/datasets/cat.py index ac6f052ea6..0221688081 100644 --- a/colour/adaptation/datasets/cat.py +++ b/colour/adaptation/datasets/cat.py @@ -68,7 +68,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/adaptation/fairchild1990.py b/colour/adaptation/fairchild1990.py index 3704b1847f..ef02cc9d62 100644 --- a/colour/adaptation/fairchild1990.py +++ b/colour/adaptation/fairchild1990.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.adaptation import CAT_VON_KRIES diff --git a/colour/adaptation/tests/test__init__.py b/colour/adaptation/tests/test__init__.py index 06eb2acf6c..825697cc0a 100644 --- a/colour/adaptation/tests/test__init__.py +++ b/colour/adaptation/tests/test__init__.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from six.moves import zip diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py index d20f228c14..83b5fb084b 100644 --- a/colour/adaptation/tests/test_cie1994.py +++ b/colour/adaptation/tests/test_cie1994.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py index 775f566474..c1081a6a10 100644 --- a/colour/adaptation/tests/test_cmccat2000.py +++ b/colour/adaptation/tests/test_cmccat2000.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py index 3c8302d3a9..4f52bf4556 100644 --- a/colour/adaptation/tests/test_fairchild1990.py +++ b/colour/adaptation/tests/test_fairchild1990.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py index a58cc652bf..3f80eb3ed7 100644 --- a/colour/adaptation/tests/test_vonkries.py +++ b/colour/adaptation/tests/test_vonkries.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations from functools import partial diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index dbac8e5c9e..da73fbe852 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS from colour.utilities import (dot_matrix, dot_vector, from_range_1, diff --git a/colour/algebra/common.py b/colour/algebra/common.py index 9898e723ed..8683bc9544 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -14,7 +14,7 @@ from __future__ import division, unicode_literals import functools -import numpy as np +import colour.ndarray as np from colour.utilities import as_float_array, as_float diff --git a/colour/algebra/coordinates/tests/test_transformations.py b/colour/algebra/coordinates/tests/test_transformations.py index c7515eaf08..d895aeb6da 100644 --- a/colour/algebra/coordinates/tests/test_transformations.py +++ b/colour/algebra/coordinates/tests/test_transformations.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/algebra/coordinates/transformations.py b/colour/algebra/coordinates/transformations.py index 22473f4602..3043830638 100644 --- a/colour/algebra/coordinates/transformations.py +++ b/colour/algebra/coordinates/transformations.py @@ -31,7 +31,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float_array, tsplit, tstack diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 0e076e1224..261abe6e7d 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_FLOAT_DTYPE from colour.utilities import as_float, is_numeric, is_string diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py index 7f32407107..5e3197229e 100644 --- a/colour/algebra/geometry.py +++ b/colour/algebra/geometry.py @@ -37,7 +37,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.utilities import (CaseInsensitiveMapping, as_float_array, ones, diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index ada73ab8d3..9547599927 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -61,7 +61,7 @@ from __future__ import division, unicode_literals import itertools -import numpy as np +import colour.ndarray as np import scipy.interpolate from six.moves import reduce from collections import OrderedDict @@ -1078,7 +1078,11 @@ def x(self, value): xp3 = value[-1] + value_interval xp4 = value[-1] + value_interval * 2 - self._xp = np.concatenate(((xp1, xp2), value, (xp3, xp4))) + self._xp = np.concatenate([ + np.array([xp1, xp2]), + value, + np.array([xp3, xp4]), + ]) self._x = value @@ -1131,7 +1135,11 @@ def y(self, value): (np.dot(self.SPRAGUE_C_COEFFICIENTS[3], np.array(value[-6:]).reshape([6, 1]))) / 209)[0] - self._yp = np.concatenate(((yp1, yp2), value, (yp3, yp4))) + self._yp = np.concatenate([ + np.array([yp1, yp2]), + value, + np.array([yp3, yp4]), + ]) self._y = value diff --git a/colour/algebra/matrix.py b/colour/algebra/matrix.py index 666bd9a065..11ec5f4e93 100644 --- a/colour/algebra/matrix.py +++ b/colour/algebra/matrix.py @@ -8,7 +8,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/algebra/random.py b/colour/algebra/random.py index 866fcb9da4..6ce304141d 100644 --- a/colour/algebra/random.py +++ b/colour/algebra/random.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_INT_DTYPE from colour.utilities import runtime_warning, tstack diff --git a/colour/algebra/regression.py b/colour/algebra/regression.py index 29e9faa083..afbc7c9c63 100644 --- a/colour/algebra/regression.py +++ b/colour/algebra/regression.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py index a56ca2555f..88e5b8266d 100644 --- a/colour/algebra/tests/test_common.py +++ b/colour/algebra/tests/test_common.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.algebra import (is_spow_enabled, set_spow_enable, spow_enable, diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py index d339c376db..af75d52797 100644 --- a/colour/algebra/tests/test_extrapolation.py +++ b/colour/algebra/tests/test_extrapolation.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/algebra/tests/test_geometry.py b/colour/algebra/tests/test_geometry.py index ac1b180de9..81862a06d3 100644 --- a/colour/algebra/tests/test_geometry.py +++ b/colour/algebra/tests/test_geometry.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index 3dec64d53e..c64b3d0c34 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import unittest from itertools import permutations diff --git a/colour/algebra/tests/test_matrix.py b/colour/algebra/tests/test_matrix.py index 15ff9de6a0..16723581fc 100644 --- a/colour/algebra/tests/test_matrix.py +++ b/colour/algebra/tests/test_matrix.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.algebra import is_identity diff --git a/colour/algebra/tests/test_random.py b/colour/algebra/tests/test_random.py index ed58a99a89..75f62f2c98 100644 --- a/colour/algebra/tests/test_random.py +++ b/colour/algebra/tests/test_random.py @@ -12,7 +12,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.algebra import random_triplet_generator diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py index 910ad0f481..f9b1f9ff36 100644 --- a/colour/algebra/tests/test_regression.py +++ b/colour/algebra/tests/test_regression.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.algebra import least_square_mapping_MoorePenrose diff --git a/colour/appearance/atd95.py b/colour/appearance/atd95.py index b9ab06b36f..3a4a7f5d84 100644 --- a/colour/appearance/atd95.py +++ b/colour/appearance/atd95.py @@ -27,7 +27,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/cam16.py b/colour/appearance/cam16.py index 62e88bf683..6f7ed9c8f3 100644 --- a/colour/appearance/cam16.py +++ b/colour/appearance/cam16.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 277a49883f..70e52aeeca 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -28,7 +28,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 2b58ed7f5e..e3005bb63b 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index 819072b602..adf2b8e7cc 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -28,7 +28,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import polar_to_cartesian, spow diff --git a/colour/appearance/nayatani95.py b/colour/appearance/nayatani95.py index 913ae0fb22..8bdaed18ac 100644 --- a/colour/appearance/nayatani95.py +++ b/colour/appearance/nayatani95.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/rlab.py b/colour/appearance/rlab.py index 72d5021bb0..b7a772e999 100644 --- a/colour/appearance/rlab.py +++ b/colour/appearance/rlab.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import spow diff --git a/colour/appearance/tests/common.py b/colour/appearance/tests/common.py index 102c7df3d7..dadf18bc56 100644 --- a/colour/appearance/tests/common.py +++ b/colour/appearance/tests/common.py @@ -7,7 +7,7 @@ from __future__ import division, unicode_literals import csv -import numpy as np +import colour.ndarray as np import os from abc import ABCMeta, abstractmethod from collections import defaultdict diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index 2077e59a89..d7a0c1b60e 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -6,11 +6,10 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from itertools import permutations from unittest import TestCase -import numpy as np - from colour.appearance import XYZ_to_ATD95 from colour.appearance.tests.common import ColourAppearanceModelTest from colour.utilities import domain_range_scale, ignore_numpy_errors, tstack diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index 7df8f33a13..10bde7fdee 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -6,11 +6,10 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from itertools import permutations from unittest import TestCase -import numpy as np - from colour.appearance import (VIEWING_CONDITIONS_CAM16, InductionFactors_CAM16, CAM_Specification_CAM16, XYZ_to_CAM16, CAM16_to_XYZ) diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index 7ac6d40d00..1ee270b560 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -6,10 +6,10 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from itertools import permutations from unittest import TestCase -import numpy as np from colour.appearance import ( VIEWING_CONDITIONS_CIECAM02, InductionFactors_CIECAM02, diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index 000ee95f9e..3451ca644a 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from itertools import permutations from unittest import TestCase diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 50125278bf..67385c5607 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -7,7 +7,7 @@ from __future__ import division, unicode_literals from colour.utilities.array import tstack -import numpy as np +import colour.ndarray as np try: from unittest import mock diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index 35643d987e..1638f3434a 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -6,10 +6,10 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from itertools import permutations from unittest import TestCase -import numpy as np from colour.appearance import XYZ_to_Nayatani95 from colour.appearance.tests.common import ColourAppearanceModelTest diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index 6303c95812..b5870e527c 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -6,10 +6,10 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from itertools import permutations from unittest import TestCase -import numpy as np from colour.appearance import (D_FACTOR_RLAB, VIEWING_CONDITIONS_RLAB, XYZ_to_RLAB) diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py index 1398fbca8b..9f39ae7a37 100644 --- a/colour/biochemistry/tests/test_michaelis_menten.py +++ b/colour/biochemistry/tests/test_michaelis_menten.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/blindness/datasets/machado2010.py b/colour/blindness/datasets/machado2010.py index 5ea3d77db7..cd686ef918 100644 --- a/colour/blindness/datasets/machado2010.py +++ b/colour/blindness/datasets/machado2010.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index 7f9cf5fb68..c5ba22d435 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -29,7 +29,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.blindness import CVD_MATRICES_MACHADO2010 from colour.colorimetry import SpectralShape diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py index 2901b54832..39eb109e28 100644 --- a/colour/blindness/tests/test_machado2009.py +++ b/colour/blindness/tests/test_machado2009.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.blindness import (CVD_MATRICES_MACHADO2010, cvd_matrix_Machado2009, diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 5bbe76c6a0..4d320f773b 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -49,7 +49,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os from scipy.optimize import minimize diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 634a54224d..09337bad25 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -59,7 +59,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import least_square_mapping_MoorePenrose from colour.utilities import (CaseInsensitiveMapping, as_float_array, as_int, diff --git a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py index 1a61f19969..cd8a2fd51f 100644 --- a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py +++ b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py @@ -46,7 +46,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import OrderedDict, namedtuple from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py index 412f91e094..125acbdbed 100644 --- a/colour/characterisation/tests/test_aces_it.py +++ b/colour/characterisation/tests/test_aces_it.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import unittest diff --git a/colour/characterisation/tests/test_correction.py b/colour/characterisation/tests/test_correction.py index b1677c35b4..f0ef488f8c 100644 --- a/colour/characterisation/tests/test_correction.py +++ b/colour/characterisation/tests/test_correction.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations from numpy.linalg import LinAlgError diff --git a/colour/colorimetry/blackbody.py b/colour/colorimetry/blackbody.py index 0226a305a8..22ae466e8b 100644 --- a/colour/colorimetry/blackbody.py +++ b/colour/colorimetry/blackbody.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, SpectralDistribution) from colour.utilities import as_float_array, usage_warning diff --git a/colour/colorimetry/correction.py b/colour/colorimetry/correction.py index 2ed325bbad..a8183bcb03 100644 --- a/colour/colorimetry/correction.py +++ b/colour/colorimetry/correction.py @@ -27,7 +27,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/colorimetry/datasets/illuminants/chromaticity_coordinates.py b/colour/colorimetry/datasets/illuminants/chromaticity_coordinates.py index 2cfe6ace28..d3110bb757 100644 --- a/colour/colorimetry/datasets/illuminants/chromaticity_coordinates.py +++ b/colour/colorimetry/datasets/illuminants/chromaticity_coordinates.py @@ -75,7 +75,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/colorimetry/datasets/illuminants/hunterlab.py b/colour/colorimetry/datasets/illuminants/hunterlab.py index 89281f82e9..6057b5fee1 100644 --- a/colour/colorimetry/datasets/illuminants/hunterlab.py +++ b/colour/colorimetry/datasets/illuminants/hunterlab.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.utilities import CaseInsensitiveMapping diff --git a/colour/colorimetry/datasets/light_sources/chromaticity_coordinates.py b/colour/colorimetry/datasets/light_sources/chromaticity_coordinates.py index 2758872ce1..da1ce3f0d4 100644 --- a/colour/colorimetry/datasets/light_sources/chromaticity_coordinates.py +++ b/colour/colorimetry/datasets/light_sources/chromaticity_coordinates.py @@ -45,7 +45,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index 990fb2a61f..29724af3a2 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import scipy.spatial.distance from colour.algebra import (euclidean_distance, extend_line_segment, diff --git a/colour/colorimetry/generation.py b/colour/colorimetry/generation.py index 03f51ce0ed..a0cfaaa454 100644 --- a/colour/colorimetry/generation.py +++ b/colour/colorimetry/generation.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_FLOAT_DTYPE from colour.colorimetry import ( diff --git a/colour/colorimetry/illuminants.py b/colour/colorimetry/illuminants.py index 089647c5a3..508cd3f478 100644 --- a/colour/colorimetry/illuminants.py +++ b/colour/colorimetry/illuminants.py @@ -27,7 +27,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import LinearInterpolator from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, diff --git a/colour/colorimetry/lightness.py b/colour/colorimetry/lightness.py index 40bb4285d2..3e94c6bc83 100644 --- a/colour/colorimetry/lightness.py +++ b/colour/colorimetry/lightness.py @@ -57,7 +57,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.biochemistry import reaction_rate_MichealisMenten diff --git a/colour/colorimetry/luminance.py b/colour/colorimetry/luminance.py index b53af43488..2b2d254b0b 100644 --- a/colour/colorimetry/luminance.py +++ b/colour/colorimetry/luminance.py @@ -58,7 +58,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.biochemistry import substrate_concentration_MichealisMenten from colour.utilities import (CaseInsensitiveMapping, as_float_array, as_float, diff --git a/colour/colorimetry/photometry.py b/colour/colorimetry/photometry.py index 318b824e05..ae9671417c 100644 --- a/colour/colorimetry/photometry.py +++ b/colour/colorimetry/photometry.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import SDS_LEFS_PHOTOPIC from colour.constants import CONSTANT_K_M diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 02878aa26d..12c839e1b9 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from six.moves import zip from colour.algebra import (Extrapolator, CubicSplineInterpolator, diff --git a/colour/colorimetry/tests/test_blackbody.py b/colour/colorimetry/tests/test_blackbody.py index e549bf6307..ba267c9636 100644 --- a/colour/colorimetry/tests/test_blackbody.py +++ b/colour/colorimetry/tests/test_blackbody.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index 791f000db7..5a2bf031e3 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import (SpectralDistribution, diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index 8543e46606..a2dc1848b0 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/colorimetry/tests/test_generation.py b/colour/colorimetry/tests/test_generation.py index be4744195e..fd43d87b38 100644 --- a/colour/colorimetry/tests/test_generation.py +++ b/colour/colorimetry/tests/test_generation.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry.generation import ( diff --git a/colour/colorimetry/tests/test_illuminants.py b/colour/colorimetry/tests/test_illuminants.py index 4c3a68f834..efe3bd33f2 100644 --- a/colour/colorimetry/tests/test_illuminants.py +++ b/colour/colorimetry/tests/test_illuminants.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import ( diff --git a/colour/colorimetry/tests/test_lefs.py b/colour/colorimetry/tests/test_lefs.py index d2cef74b07..af367b8873 100644 --- a/colour/colorimetry/tests/test_lefs.py +++ b/colour/colorimetry/tests/test_lefs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import (mesopic_weighting_function, diff --git a/colour/colorimetry/tests/test_lightness.py b/colour/colorimetry/tests/test_lightness.py index 0946091a1a..5c0ab6dd8c 100644 --- a/colour/colorimetry/tests/test_lightness.py +++ b/colour/colorimetry/tests/test_lightness.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import (lightness_Glasser1958, lightness_Wyszecki1963, diff --git a/colour/colorimetry/tests/test_luminance.py b/colour/colorimetry/tests/test_luminance.py index 69ad92979c..3a9bb855df 100644 --- a/colour/colorimetry/tests/test_luminance.py +++ b/colour/colorimetry/tests/test_luminance.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import ( diff --git a/colour/colorimetry/tests/test_spectrum.py b/colour/colorimetry/tests/test_spectrum.py index 706642dad8..66c43b9deb 100644 --- a/colour/colorimetry/tests/test_spectrum.py +++ b/colour/colorimetry/tests/test_spectrum.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest import scipy from distutils.version import LooseVersion diff --git a/colour/colorimetry/tests/test_transformations.py b/colour/colorimetry/tests/test_transformations.py index c582955241..9bf4b84d10 100644 --- a/colour/colorimetry/tests/test_transformations.py +++ b/colour/colorimetry/tests/test_transformations.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import (MSDS_CMFS, diff --git a/colour/colorimetry/tests/test_tristimulus.py b/colour/colorimetry/tests/test_tristimulus.py index 0a58174a2a..97e9f66a16 100644 --- a/colour/colorimetry/tests/test_tristimulus.py +++ b/colour/colorimetry/tests/test_tristimulus.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.algebra import LinearInterpolator diff --git a/colour/colorimetry/tests/test_whiteness.py b/colour/colorimetry/tests/test_whiteness.py index ca08fd1d64..d80af794e2 100644 --- a/colour/colorimetry/tests/test_whiteness.py +++ b/colour/colorimetry/tests/test_whiteness.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index 742cdec7e6..632852d365 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/colorimetry/transformations.py b/colour/colorimetry/transformations.py index c8d1d8c2d0..dd3111b871 100644 --- a/colour/colorimetry/transformations.py +++ b/colour/colorimetry/transformations.py @@ -33,7 +33,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import MSDS_CMFS_LMS, MSDS_CMFS_RGB, SDS_LEFS_PHOTOPIC from colour.utilities import dot_vector, tstack diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 7d56b8f6d5..4e1548ad4f 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import lagrange_coefficients from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index 7e4ddd36fa..30c9c12ed3 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -106,7 +106,7 @@ def whiteness_Berger1959(XYZ, XYZ_0): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> XYZ_0 = np.array([94.80966767, 100.00000000, 107.30513595]) >>> whiteness_Berger1959(XYZ, XYZ_0) # doctest: +ELLIPSIS @@ -164,7 +164,7 @@ def whiteness_Taube1960(XYZ, XYZ_0): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> XYZ_0 = np.array([94.80966767, 100.00000000, 107.30513595]) >>> whiteness_Taube1960(XYZ, XYZ_0) # doctest: +ELLIPSIS @@ -222,7 +222,7 @@ def whiteness_Stensby1968(Lab): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab = np.array([100.00000000, -2.46875131, -16.72486654]) >>> whiteness_Stensby1968(Lab) # doctest: +ELLIPSIS 142.7683456... @@ -271,7 +271,7 @@ def whiteness_ASTME313(XYZ): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> whiteness_ASTME313(XYZ) # doctest: +ELLIPSIS 55.7400000... @@ -333,7 +333,7 @@ def whiteness_Ganz1979(xy, Y): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy = np.array([0.3167, 0.3334]) >>> whiteness_Ganz1979(xy, 100) # doctest: +ELLIPSIS array([ 85.6003766..., 0.6789003...]) @@ -412,7 +412,7 @@ def whiteness_CIE2004(xy, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy = np.array([0.3167, 0.3334]) >>> xy_n = np.array([0.3139, 0.3311]) >>> whiteness_CIE2004(xy, 100, xy_n) # doctest: +ELLIPSIS @@ -511,7 +511,7 @@ def whiteness(XYZ, XYZ_0, method='CIE 2004', **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> from colour.models import xyY_to_XYZ >>> XYZ = xyY_to_XYZ(np.array([0.3167, 0.3334, 100])) >>> XYZ_0 = xyY_to_XYZ(np.array([0.3139, 0.3311, 100])) diff --git a/colour/colorimetry/yellowness.py b/colour/colorimetry/yellowness.py index 0658e72144..23f46040ef 100644 --- a/colour/colorimetry/yellowness.py +++ b/colour/colorimetry/yellowness.py @@ -84,7 +84,7 @@ def yellowness_ASTMD1925(XYZ): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> yellowness_ASTMD1925(XYZ) # doctest: +ELLIPSIS 10.2999999... @@ -136,7 +136,7 @@ def yellowness_ASTME313(XYZ): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> yellowness_ASTME313(XYZ) # doctest: +ELLIPSIS 11.0650000... @@ -203,7 +203,7 @@ def yellowness(XYZ, method='ASTM E313'): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000]) >>> yellowness(XYZ) # doctest: +ELLIPSIS 11.0650000... diff --git a/colour/constants/common.py b/colour/constants/common.py index 966febdc77..b7b3bd85b8 100644 --- a/colour/constants/common.py +++ b/colour/constants/common.py @@ -9,7 +9,7 @@ from __future__ import division, unicode_literals import os -import numpy as np +import colour.ndarray as np from colour.utilities.documentation import (DocstringFloat, is_documentation_building) diff --git a/colour/continuous/abstract.py b/colour/continuous/abstract.py index 184121dd44..fa11f09026 100644 --- a/colour/continuous/abstract.py +++ b/colour/continuous/abstract.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from abc import ABCMeta, abstractmethod, abstractproperty from copy import deepcopy diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 04f245899d..9347222e18 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -10,7 +10,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np # Python 3 compatibility. try: diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 8c5902be46..e26f0b4d5c 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -10,7 +10,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from operator import add, mul, pow, sub, iadd, imul, ipow, isub # Python 3 compatibility. @@ -296,6 +296,7 @@ def domain(self, value): 'unpredictable results may occur!'.format( self.name, value)) + value value = np.copy(value).astype(self.dtype) if self._range is not None: diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index ac4839e9ef..ebdcba69d3 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import operator import unittest import re diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index 7f6e6c89a8..b98670e43b 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest import re import textwrap diff --git a/colour/contrast/barten1999.py b/colour/contrast/barten1999.py index 17f768248d..a06beffb4e 100644 --- a/colour/contrast/barten1999.py +++ b/colour/contrast/barten1999.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float_array, as_float diff --git a/colour/contrast/tests/test_barten1999.py b/colour/contrast/tests/test_barten1999.py index 40e3be6c2a..9b7affd5cf 100644 --- a/colour/contrast/tests/test_barten1999.py +++ b/colour/contrast/tests/test_barten1999.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index 56121e82c5..4ee585b4a9 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index 3c9806ec86..e34a3a10d8 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -36,7 +36,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.adaptation import ( diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index 0b4c26d5a1..e58a39ee63 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.corresponding.prediction import ( diff --git a/colour/difference/__init__.py b/colour/difference/__init__.py index d0225b16ec..9869e323df 100644 --- a/colour/difference/__init__.py +++ b/colour/difference/__init__.py @@ -132,7 +132,7 @@ def delta_E(a, b, method='CIE 2000', **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> a = np.array([100.00000000, 21.57210357, 272.22819350]) >>> b = np.array([100.00000000, 426.67945353, 72.39590835]) >>> delta_E(a, b) # doctest: +ELLIPSIS diff --git a/colour/difference/cam02_ucs.py b/colour/difference/cam02_ucs.py index 4124542e46..61fa774ee9 100644 --- a/colour/difference/cam02_ucs.py +++ b/colour/difference/cam02_ucs.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import tsplit from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006 diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 5f4a3cc5b1..06e439a6c3 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import euclidean_distance from colour.utilities import to_domain_100, tsplit diff --git a/colour/difference/din99.py b/colour/difference/din99.py index 757097c1e2..43ed40ade6 100644 --- a/colour/difference/din99.py +++ b/colour/difference/din99.py @@ -73,7 +73,7 @@ def delta_E_DIN99(Lab_1, Lab_2, textiles=False): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab_1 = np.array([60.2574, -34.0099, 36.2677]) >>> Lab_2 = np.array([60.4626, -34.1751, 39.4387]) >>> delta_E_DIN99(Lab_1, Lab_2) # doctest: +ELLIPSIS diff --git a/colour/difference/tests/test__init__.py b/colour/difference/tests/test__init__.py index 69943d323e..df052db4b7 100644 --- a/colour/difference/tests/test__init__.py +++ b/colour/difference/tests/test__init__.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.difference import delta_E diff --git a/colour/difference/tests/test_cam02_ucs.py b/colour/difference/tests/test_cam02_ucs.py index e2ad97c9d1..0486482988 100644 --- a/colour/difference/tests/test_cam02_ucs.py +++ b/colour/difference/tests/test_cam02_ucs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py index f40c14c47f..e12e6d84a1 100644 --- a/colour/difference/tests/test_delta_e.py +++ b/colour/difference/tests/test_delta_e.py @@ -12,7 +12,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/difference/tests/test_din99.py b/colour/difference/tests/test_din99.py index da3ec872cc..5f4bb3d926 100644 --- a/colour/difference/tests/test_din99.py +++ b/colour/difference/tests/test_din99.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/examples/adaptation/examples_cie1994.py b/colour/examples/adaptation/examples_cie1994.py index 38012b36ba..9398d9303b 100644 --- a/colour/examples/adaptation/examples_cie1994.py +++ b/colour/examples/adaptation/examples_cie1994.py @@ -3,7 +3,7 @@ Showcases *CIE 1994* chromatic adaptation model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/adaptation/examples_cmccat2000.py b/colour/examples/adaptation/examples_cmccat2000.py index f2cd73a24e..54dec6b7b2 100644 --- a/colour/examples/adaptation/examples_cmccat2000.py +++ b/colour/examples/adaptation/examples_cmccat2000.py @@ -3,7 +3,7 @@ Showcases *CMCCAT2000* chromatic adaptation model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/adaptation/examples_fairchild1990.py b/colour/examples/adaptation/examples_fairchild1990.py index 55dbc077c8..82c8e845ec 100644 --- a/colour/examples/adaptation/examples_fairchild1990.py +++ b/colour/examples/adaptation/examples_fairchild1990.py @@ -3,7 +3,7 @@ Showcases *Fairchild (1990)* chromatic adaptation model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/adaptation/examples_vonkries.py b/colour/examples/adaptation/examples_vonkries.py index c68c785355..031a7fb8a9 100644 --- a/colour/examples/adaptation/examples_vonkries.py +++ b/colour/examples/adaptation/examples_vonkries.py @@ -3,7 +3,7 @@ Showcases *Von Kries* chromatic adaptation model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/algebra/examples_interpolation.py b/colour/examples/algebra/examples_interpolation.py index 9f289180aa..77648b877b 100644 --- a/colour/examples/algebra/examples_interpolation.py +++ b/colour/examples/algebra/examples_interpolation.py @@ -4,7 +4,7 @@ """ import matplotlib.pyplot as plt -import numpy as np +import colour.ndarray as np import os import colour diff --git a/colour/examples/appearance/examples_atd95.py b/colour/examples/appearance/examples_atd95.py index 675a254109..8cc75ed4d9 100644 --- a/colour/examples/appearance/examples_atd95.py +++ b/colour/examples/appearance/examples_atd95.py @@ -3,7 +3,7 @@ Showcases *ATD (1995)* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.appearance.atd95 import CAM_ReferenceSpecification_ATD95 diff --git a/colour/examples/appearance/examples_cam16.py b/colour/examples/appearance/examples_cam16.py index 627ed239f1..2e2d8f5be4 100644 --- a/colour/examples/appearance/examples_cam16.py +++ b/colour/examples/appearance/examples_cam16.py @@ -3,7 +3,7 @@ Showcases *CAM16* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/appearance/examples_ciecam02.py b/colour/examples/appearance/examples_ciecam02.py index dc9946123f..1c814891fd 100644 --- a/colour/examples/appearance/examples_ciecam02.py +++ b/colour/examples/appearance/examples_ciecam02.py @@ -3,7 +3,7 @@ Showcases *CIECAM02* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/appearance/examples_hunt.py b/colour/examples/appearance/examples_hunt.py index ef5f32d20b..eb77babb3a 100644 --- a/colour/examples/appearance/examples_hunt.py +++ b/colour/examples/appearance/examples_hunt.py @@ -3,7 +3,7 @@ Showcases *Hunt* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.appearance.hunt import CAM_ReferenceSpecification_Hunt diff --git a/colour/examples/appearance/examples_llab.py b/colour/examples/appearance/examples_llab.py index 403ebde66a..a6e9695aca 100644 --- a/colour/examples/appearance/examples_llab.py +++ b/colour/examples/appearance/examples_llab.py @@ -3,7 +3,7 @@ Showcases *LLAB(l:c)* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.appearance.llab import CAM_ReferenceSpecification_LLAB diff --git a/colour/examples/appearance/examples_nayatani95.py b/colour/examples/appearance/examples_nayatani95.py index 541da563df..e88c292d6a 100644 --- a/colour/examples/appearance/examples_nayatani95.py +++ b/colour/examples/appearance/examples_nayatani95.py @@ -3,7 +3,7 @@ Showcases *Nayatani (1995)* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.appearance.nayatani95 import CAM_ReferenceSpecification_Nayatani95 diff --git a/colour/examples/appearance/examples_rlab.py b/colour/examples/appearance/examples_rlab.py index cee22dc214..27d1216ffe 100644 --- a/colour/examples/appearance/examples_rlab.py +++ b/colour/examples/appearance/examples_rlab.py @@ -3,7 +3,7 @@ Showcases *RLAB* colour appearance model computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.appearance.rlab import CAM_ReferenceSpecification_RLAB diff --git a/colour/examples/blindness/examples_machado2009.py b/colour/examples/blindness/examples_machado2009.py index 7747ea6b5a..54523f3e4b 100644 --- a/colour/examples/blindness/examples_machado2009.py +++ b/colour/examples/blindness/examples_machado2009.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import colour from colour.utilities.verbose import message_box diff --git a/colour/examples/characterisation/examples_colour_checkers.py b/colour/examples/characterisation/examples_colour_checkers.py index a7db82610f..0e785068fc 100644 --- a/colour/examples/characterisation/examples_colour_checkers.py +++ b/colour/examples/characterisation/examples_colour_checkers.py @@ -3,7 +3,7 @@ Showcases colour rendition charts computations. """ -import numpy as np +import colour.ndarray as np from pprint import pprint import colour diff --git a/colour/examples/characterisation/examples_correction.py b/colour/examples/characterisation/examples_correction.py index 323eb62598..45ef3af1c2 100644 --- a/colour/examples/characterisation/examples_correction.py +++ b/colour/examples/characterisation/examples_correction.py @@ -3,7 +3,7 @@ Showcases colour correction computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_correction.py b/colour/examples/colorimetry/examples_correction.py index 4f481fd9b0..48c335d8da 100644 --- a/colour/examples/colorimetry/examples_correction.py +++ b/colour/examples/colorimetry/examples_correction.py @@ -3,7 +3,7 @@ Showcases colour spectral bandpass dependence correction computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_dominant.py b/colour/examples/colorimetry/examples_dominant.py index 5da9ac9929..1ce9094027 100644 --- a/colour/examples/colorimetry/examples_dominant.py +++ b/colour/examples/colorimetry/examples_dominant.py @@ -3,7 +3,7 @@ Showcases dominant wavelength and purity of a colour computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_lightness.py b/colour/examples/colorimetry/examples_lightness.py index cfb96b0d6c..5cb22d976b 100644 --- a/colour/examples/colorimetry/examples_lightness.py +++ b/colour/examples/colorimetry/examples_lightness.py @@ -3,7 +3,7 @@ Showcases *Lightness* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_spectrum.py b/colour/examples/colorimetry/examples_spectrum.py index 4775715294..5d10a11312 100644 --- a/colour/examples/colorimetry/examples_spectrum.py +++ b/colour/examples/colorimetry/examples_spectrum.py @@ -3,7 +3,7 @@ Showcases colour spectrum computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_tristimulus.py b/colour/examples/colorimetry/examples_tristimulus.py index 5520677298..28d0be763a 100644 --- a/colour/examples/colorimetry/examples_tristimulus.py +++ b/colour/examples/colorimetry/examples_tristimulus.py @@ -3,7 +3,7 @@ Showcases *CIE XYZ* tristimulus values computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_whiteness.py b/colour/examples/colorimetry/examples_whiteness.py index 76b8eb08ec..79d7d7c136 100644 --- a/colour/examples/colorimetry/examples_whiteness.py +++ b/colour/examples/colorimetry/examples_whiteness.py @@ -3,7 +3,7 @@ Showcases *whiteness* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/colorimetry/examples_yellowness.py b/colour/examples/colorimetry/examples_yellowness.py index 8674aa0396..b1ed47fe69 100644 --- a/colour/examples/colorimetry/examples_yellowness.py +++ b/colour/examples/colorimetry/examples_yellowness.py @@ -3,7 +3,7 @@ Showcases *yellowness* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/contrast/examples_contrast.py b/colour/examples/contrast/examples_contrast.py index 02f0c8a95e..bd8981250e 100644 --- a/colour/examples/contrast/examples_contrast.py +++ b/colour/examples/contrast/examples_contrast.py @@ -5,7 +5,7 @@ from pprint import pprint -import numpy as np +import colour.ndarray as np from scipy.optimize import fmin import colour diff --git a/colour/examples/difference/examples_delta_e.py b/colour/examples/difference/examples_delta_e.py index 04002f5890..b27d4bc8fd 100644 --- a/colour/examples/difference/examples_delta_e.py +++ b/colour/examples/difference/examples_delta_e.py @@ -3,7 +3,7 @@ Showcases *Delta E* colour difference computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/examples_colour.py b/colour/examples/examples_colour.py index e1bb0b5660..151cc925c9 100644 --- a/colour/examples/examples_colour.py +++ b/colour/examples/examples_colour.py @@ -3,7 +3,7 @@ Showcases overall *Colour* examples. """ -import numpy as np +import colour.ndarray as np import warnings import colour diff --git a/colour/examples/geometry/examples_geometry.py b/colour/examples/geometry/examples_geometry.py index 4b2bcdccc2..6c0f1ee975 100644 --- a/colour/examples/geometry/examples_geometry.py +++ b/colour/examples/geometry/examples_geometry.py @@ -3,7 +3,7 @@ Showcases geometry primitives generation examples. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/graph/examples_graph.py b/colour/examples/graph/examples_graph.py index e3d9f8b9cd..b161397059 100644 --- a/colour/examples/graph/examples_graph.py +++ b/colour/examples/graph/examples_graph.py @@ -3,7 +3,7 @@ Showcases *Automatic Colour Conversion Graph* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/io/examples_luts.py b/colour/examples/io/examples_luts.py index f393190575..a1098792f6 100644 --- a/colour/examples/io/examples_luts.py +++ b/colour/examples/io/examples_luts.py @@ -3,7 +3,7 @@ Showcases Look Up Table (LUT) data related examples. """ -import numpy as np +import colour.ndarray as np import os import colour diff --git a/colour/examples/models/examples_cmyk.py b/colour/examples/models/examples_cmyk.py index 6c1cfe5b79..b0b1536e0f 100644 --- a/colour/examples/models/examples_cmyk.py +++ b/colour/examples/models/examples_cmyk.py @@ -3,7 +3,7 @@ Showcases Cyan-Magenta-Yellow (Black) (CMY(K)) colour transformations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_cylindrical.py b/colour/examples/models/examples_cylindrical.py index 39f815b116..5f6eb259d2 100644 --- a/colour/examples/models/examples_cylindrical.py +++ b/colour/examples/models/examples_cylindrical.py @@ -3,7 +3,7 @@ Showcases cylindrical and spherical colour models computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_derivation.py b/colour/examples/models/examples_derivation.py index 8cc3b40a5a..c5d60b149b 100644 --- a/colour/examples/models/examples_derivation.py +++ b/colour/examples/models/examples_derivation.py @@ -3,7 +3,7 @@ Showcases *RGB* colourspace derivation. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_ictcp.py b/colour/examples/models/examples_ictcp.py index 6b13e6f646..ff21564656 100644 --- a/colour/examples/models/examples_ictcp.py +++ b/colour/examples/models/examples_ictcp.py @@ -3,7 +3,7 @@ Showcases *ICTCP* *colour encoding* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_models.py b/colour/examples/models/examples_models.py index 0ea0571e5e..e549b6d334 100644 --- a/colour/examples/models/examples_models.py +++ b/colour/examples/models/examples_models.py @@ -3,7 +3,7 @@ Showcases colour models computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_prismatic.py b/colour/examples/models/examples_prismatic.py index 7403365e1d..44cad58b4c 100644 --- a/colour/examples/models/examples_prismatic.py +++ b/colour/examples/models/examples_prismatic.py @@ -3,7 +3,7 @@ Showcases *Prismatic* colourspace computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_rgb.py b/colour/examples/models/examples_rgb.py index 7dad73b717..c21d73bd3d 100644 --- a/colour/examples/models/examples_rgb.py +++ b/colour/examples/models/examples_rgb.py @@ -3,7 +3,7 @@ Showcases *RGB* *colourspaces* computations. """ -import numpy as np +import colour.ndarray as np from pprint import pprint import colour diff --git a/colour/examples/models/examples_ycbcr.py b/colour/examples/models/examples_ycbcr.py index 048a9a1e3e..b20c157b8d 100644 --- a/colour/examples/models/examples_ycbcr.py +++ b/colour/examples/models/examples_ycbcr.py @@ -3,7 +3,7 @@ Showcases *Y'CbCr* *colour encoding* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/models/examples_ycocg.py b/colour/examples/models/examples_ycocg.py index 92261f3437..9cb6cc3684 100644 --- a/colour/examples/models/examples_ycocg.py +++ b/colour/examples/models/examples_ycocg.py @@ -3,7 +3,7 @@ Showcases *YCoCg* *colour encoding* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/notation/examples_hexadecimal.py b/colour/examples/notation/examples_hexadecimal.py index 56cc0298fd..0893821836 100644 --- a/colour/examples/notation/examples_hexadecimal.py +++ b/colour/examples/notation/examples_hexadecimal.py @@ -3,7 +3,7 @@ Showcases hexadecimal computations. """ -import numpy as np +import colour.ndarray as np import colour.notation.hexadecimal from colour.utilities import message_box diff --git a/colour/examples/notation/examples_munsell.py b/colour/examples/notation/examples_munsell.py index ecc20d3c03..35cd589a98 100644 --- a/colour/examples/notation/examples_munsell.py +++ b/colour/examples/notation/examples_munsell.py @@ -3,7 +3,7 @@ Showcases *Munsell Renotation System* computations. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/plotting/examples_blindness.py b/colour/examples/plotting/examples_blindness.py index 07fd1bf64e..b1fb36d0d3 100644 --- a/colour/examples/plotting/examples_blindness.py +++ b/colour/examples/plotting/examples_blindness.py @@ -3,7 +3,7 @@ Showcases corresponding colour blindness plotting examples. """ -import numpy as np +import colour.ndarray as np import os import colour diff --git a/colour/examples/plotting/examples_models_plots.py b/colour/examples/plotting/examples_models_plots.py index 95e449b540..7751fbe2a6 100644 --- a/colour/examples/plotting/examples_models_plots.py +++ b/colour/examples/plotting/examples_models_plots.py @@ -3,7 +3,7 @@ Showcases colour models plotting examples. """ -import numpy as np +import colour.ndarray as np from pprint import pprint import colour diff --git a/colour/examples/plotting/examples_volume_plots.py b/colour/examples/plotting/examples_volume_plots.py index fa042291b6..8bb116da45 100644 --- a/colour/examples/plotting/examples_volume_plots.py +++ b/colour/examples/plotting/examples_volume_plots.py @@ -3,7 +3,7 @@ Showcases colour models volume and gamut plotting examples. """ -import numpy as np +import colour.ndarray as np from colour.plotting import (plot_RGB_colourspaces_gamuts, plot_RGB_scatter, colour_style) diff --git a/colour/examples/recovery/examples_meng2015.py b/colour/examples/recovery/examples_meng2015.py index cf436fc6e4..43880bd6e0 100644 --- a/colour/examples/recovery/examples_meng2015.py +++ b/colour/examples/recovery/examples_meng2015.py @@ -3,7 +3,7 @@ Showcases reflectance recovery computations using *Meng et al. (2015)* method. """ -import numpy as np +import colour.ndarray as np import colour from colour.utilities import message_box diff --git a/colour/examples/recovery/examples_smits1999.py b/colour/examples/recovery/examples_smits1999.py index 4b578f31fc..33343de122 100644 --- a/colour/examples/recovery/examples_smits1999.py +++ b/colour/examples/recovery/examples_smits1999.py @@ -3,7 +3,7 @@ Showcases reflectance recovery computations using *Smits (1999)* method. """ -import numpy as np +import colour.ndarray as np import colour from colour.recovery.smits1999 import XYZ_to_RGB_Smits1999 diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index 1bde0458d5..fb22d6d3ac 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_INT_DTYPE, DEFAULT_FLOAT_DTYPE from colour.utilities import CaseInsensitiveMapping, filter_kwargs, ones, zeros diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index 98aa45b490..5a77549e96 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.geometry import (PLANE_TO_AXIS_MAPPING, primitive_grid, diff --git a/colour/geometry/tests/test_vertices.py b/colour/geometry/tests/test_vertices.py index 51cc345e15..4b5431fb5b 100644 --- a/colour/geometry/tests/test_vertices.py +++ b/colour/geometry/tests/test_vertices.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.geometry import ( diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 2b2d02461d..f526ffee38 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spherical_to_cartesian from colour.geometry import PLANE_TO_AXIS_MAPPING diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index 848809f4f7..409f27c470 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -12,7 +12,7 @@ from __future__ import division, print_function, unicode_literals import inspect -import numpy as np +import colour.ndarray as np import textwrap from collections import namedtuple from copy import copy diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 7f9050d7b4..8840219a77 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import six import unittest diff --git a/colour/io/image.py b/colour/io/image.py index f94adf8118..0765d3cd28 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -8,7 +8,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import platform from collections import namedtuple from six import string_types diff --git a/colour/io/luts/__init__.py b/colour/io/luts/__init__.py index 049d42396f..68e5753c1c 100644 --- a/colour/io/luts/__init__.py +++ b/colour/io/luts/__init__.py @@ -207,7 +207,7 @@ def write_LUT(LUT, path, decimals=7, method=None, **kwargs): -------- Writing a 3x1D *Iridas* *.cube* *LUT*: - >>> import numpy as np + >>> import colour.ndarray as np >>> from colour.algebra import spow >>> domain = np.array([[-0.1, -0.2, -0.4], [1.5, 3.0, 6.0]]) >>> LUT = LUT3x1D( diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 6c2ffc5f4b..bcf3c1bb16 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.io.luts import LUT1D, LUT3x1D, LUT3D, LUTSequence from colour.utilities import tsplit, tstack, as_float_array, as_int_array diff --git a/colour/io/luts/iridas_cube.py b/colour/io/luts/iridas_cube.py index 44f60ab919..b40045ead1 100644 --- a/colour/io/luts/iridas_cube.py +++ b/colour/io/luts/iridas_cube.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_INT_DTYPE from colour.io.luts import LUT1D, LUT3x1D, LUT3D, LUTSequence diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 788c609705..cb03db94fb 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -14,7 +14,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import re from abc import ABCMeta, abstractmethod try: diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index 7e826db14b..b2b08a623a 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.io.luts import LUT1D, LUT3x1D, LUT3D, LUTSequence from colour.io.luts.common import path_to_title diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index ad7edf3b40..838948f40e 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_INT_DTYPE from colour.io.luts import LUT1D, LUT3x1D, LUTSequence diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 2fbbe24d55..05cb27429b 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_INT_DTYPE from colour.io.luts import LUT3D, LUTSequence diff --git a/colour/io/luts/tests/test__init__.py b/colour/io/luts/tests/test__init__.py index 0645797a20..9aaf7884d0 100644 --- a/colour/io/luts/tests/test__init__.py +++ b/colour/io/luts/tests/test__init__.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import tempfile diff --git a/colour/io/luts/tests/test_cinespace_csp.py b/colour/io/luts/tests/test_cinespace_csp.py index 110cb7d08e..ea07c0aa20 100644 --- a/colour/io/luts/tests/test_cinespace_csp.py +++ b/colour/io/luts/tests/test_cinespace_csp.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import unittest import shutil diff --git a/colour/io/luts/tests/test_iridas_cube.py b/colour/io/luts/tests/test_iridas_cube.py index 88ff16899d..c3f9f89fc7 100644 --- a/colour/io/luts/tests/test_iridas_cube.py +++ b/colour/io/luts/tests/test_iridas_cube.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import unittest import shutil diff --git a/colour/io/luts/tests/test_lut.py b/colour/io/luts/tests/test_lut.py index b5ba91d073..658d2629f3 100644 --- a/colour/io/luts/tests/test_lut.py +++ b/colour/io/luts/tests/test_lut.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import textwrap import unittest diff --git a/colour/io/luts/tests/test_resolve_cube.py b/colour/io/luts/tests/test_resolve_cube.py index 67f6aa45cf..d511f62d9e 100644 --- a/colour/io/luts/tests/test_resolve_cube.py +++ b/colour/io/luts/tests/test_resolve_cube.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import unittest import shutil diff --git a/colour/io/luts/tests/test_sony_spi1d.py b/colour/io/luts/tests/test_sony_spi1d.py index cba89aab33..8026364269 100644 --- a/colour/io/luts/tests/test_sony_spi1d.py +++ b/colour/io/luts/tests/test_sony_spi1d.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import tempfile diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index ff68886d4d..7f0fb6393b 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import tempfile diff --git a/colour/io/tests/test_ies_tm2714.py b/colour/io/tests/test_ies_tm2714.py index 9c8db30f18..fe8e2f8540 100644 --- a/colour/io/tests/test_ies_tm2714.py +++ b/colour/io/tests/test_ies_tm2714.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import unittest diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index f2dc54aae7..437170f3d9 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import platform import shutil diff --git a/colour/io/tests/test_tabular.py b/colour/io/tests/test_tabular.py index 53062e3283..3193906b00 100644 --- a/colour/io/tests/test_tabular.py +++ b/colour/io/tests/test_tabular.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import unittest diff --git a/colour/models/cam02_ucs.py b/colour/models/cam02_ucs.py index 31654d23a3..e0eff8d181 100644 --- a/colour/models/cam02_ucs.py +++ b/colour/models/cam02_ucs.py @@ -22,7 +22,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import cartesian_to_polar, polar_to_cartesian diff --git a/colour/models/cie_lab.py b/colour/models/cie_lab.py index f1e4fcf427..2b2fb287df 100644 --- a/colour/models/cie_lab.py +++ b/colour/models/cie_lab.py @@ -83,7 +83,7 @@ def XYZ_to_Lab(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_to_Lab(XYZ) # doctest: +ELLIPSIS array([ 41.5278752..., 52.6385830..., 26.9231792...]) @@ -153,7 +153,7 @@ def Lab_to_XYZ(Lab, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_XYZ(Lab) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) @@ -220,7 +220,7 @@ def Lab_to_LCHab(Lab): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_LCHab(Lab) # doctest: +ELLIPSIS array([ 41.5278752..., 59.1242590..., 27.0884878...]) @@ -273,7 +273,7 @@ def LCHab_to_Lab(LCHab): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> LCHab = np.array([41.52787529, 59.12425901, 27.08848784]) >>> LCHab_to_Lab(LCHab) # doctest: +ELLIPSIS array([ 41.5278752..., 52.6385830..., 26.9231792...]) diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index 245242b2e2..c95f81b1d7 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -97,7 +97,7 @@ def XYZ_to_Luv(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_to_Luv(XYZ) # doctest: +ELLIPSIS array([ 41.5278752..., 96.8362605..., 17.7521014...]) @@ -168,7 +168,7 @@ def Luv_to_XYZ(Luv, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) @@ -237,7 +237,7 @@ def Luv_to_uv(Luv, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_uv(Luv) # doctest: +ELLIPSIS array([ 0.3772021..., 0.5012026...]) @@ -301,7 +301,7 @@ def uv_to_Luv(uv, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> uv = np.array([0.37720213, 0.50120264]) >>> uv_to_Luv(uv) # doctest: +ELLIPSIS array([ 100. , 233.1837603..., 42.7474385...]) @@ -338,7 +338,7 @@ def Luv_uv_to_xy(uv): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> uv = np.array([0.37720213, 0.50120264]) >>> Luv_uv_to_xy(uv) # doctest: +ELLIPSIS array([ 0.5436955..., 0.3210794...]) @@ -373,7 +373,7 @@ def xy_to_Luv_uv(xy): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy = np.array([0.54369558, 0.32107944]) >>> xy_to_Luv_uv(xy) # doctest: +ELLIPSIS array([ 0.3772021..., 0.5012026...]) @@ -431,7 +431,7 @@ def Luv_to_LCHuv(Luv): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_LCHuv(Luv) # doctest: +ELLIPSIS array([ 41.5278752..., 98.4499795..., 10.3881634...]) @@ -484,7 +484,7 @@ def LCHuv_to_Luv(LCHuv): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> LCHuv = np.array([41.52787529, 98.44997950, 10.38816348]) >>> LCHuv_to_Luv(LCHuv) # doctest: +ELLIPSIS array([ 41.5278752..., 96.8362605..., 17.7521014...]) diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index b1313fc9df..4ac808bfd0 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -73,7 +73,7 @@ def XYZ_to_UCS(XYZ): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_to_UCS(XYZ) # doctest: +ELLIPSIS array([ 0.1376933..., 0.1219722..., 0.1053731...]) @@ -121,7 +121,7 @@ def UCS_to_XYZ(UVW): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> UVW = np.array([0.13769339, 0.12197225, 0.10537310]) >>> UCS_to_XYZ(UVW) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) @@ -164,7 +164,7 @@ def UCS_to_uv(UVW): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> UVW = np.array([0.13769339, 0.12197225, 0.10537310]) >>> UCS_to_uv(UVW) # doctest: +ELLIPSIS array([ 0.3772021..., 0.3341350...]) @@ -204,7 +204,7 @@ def uv_to_UCS(uv, V=1): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> uv = np.array([0.37720213, 0.33413508]) >>> uv_to_UCS(uv) # doctest: +ELLIPSIS array([ 1.1288911..., 1. , 0.8639104...]) @@ -242,7 +242,7 @@ def UCS_uv_to_xy(uv): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> uv = np.array([0.37720213, 0.33413508]) >>> UCS_uv_to_xy(uv) # doctest: +ELLIPSIS array([ 0.5436955..., 0.3210794...]) @@ -277,7 +277,7 @@ def xy_to_UCS_uv(xy): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy = np.array([0.54369555, 0.32107941]) >>> xy_to_UCS_uv(xy) # doctest: +ELLIPSIS array([ 0.3772021..., 0.3341350...]) diff --git a/colour/models/cie_uvw.py b/colour/models/cie_uvw.py index d5a7e1c0f3..cc4bfed6d9 100644 --- a/colour/models/cie_uvw.py +++ b/colour/models/cie_uvw.py @@ -84,7 +84,7 @@ def XYZ_to_UVW(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) * 100 >>> XYZ_to_UVW(XYZ) # doctest: +ELLIPSIS array([ 94.5503572..., 11.5553652..., 40.5475740...]) @@ -159,7 +159,7 @@ def UVW_to_XYZ(UVW, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> UVW = np.array([94.55035725, 11.55536523, 40.54757405]) >>> UVW_to_XYZ(UVW) array([ 20.654008, 12.197225, 5.136952]) diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index fa85c05355..7f90031f4b 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.utilities import (as_float_array, from_range_1, full, to_domain_1, diff --git a/colour/models/common.py b/colour/models/common.py index c06de8be46..2db3107f09 100644 --- a/colour/models/common.py +++ b/colour/models/common.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import cartesian_to_polar, polar_to_cartesian from colour.utilities import (domain_range_scale, from_range_degrees, @@ -234,7 +234,7 @@ def XYZ_to_colourspace_model(XYZ, illuminant, model, **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> W = np.array([0.31270, 0.32900]) >>> XYZ_to_colourspace_model( # doctest: +ELLIPSIS diff --git a/colour/models/datasets/macadam_ellipses.py b/colour/models/datasets/macadam_ellipses.py index b33e9b05c3..7cf265d6a7 100644 --- a/colour/models/datasets/macadam_ellipses.py +++ b/colour/models/datasets/macadam_ellipses.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/models/datasets/pointer_gamut.py b/colour/models/datasets/pointer_gamut.py index 7e4127c390..194d24f4aa 100644 --- a/colour/models/datasets/pointer_gamut.py +++ b/colour/models/datasets/pointer_gamut.py @@ -13,7 +13,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_LIGHT_SOURCES diff --git a/colour/models/din99.py b/colour/models/din99.py index 26f7079607..da12216eea 100644 --- a/colour/models/din99.py +++ b/colour/models/din99.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import from_range_100, tsplit, tstack, to_domain_100 @@ -82,7 +82,7 @@ def Lab_to_DIN99(Lab, k_E=1, k_CH=1): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_DIN99(Lab) # doctest: +ELLIPSIS array([ 53.2282198..., 28.4163465..., 3.8983955...]) @@ -159,7 +159,7 @@ def DIN99_to_Lab(Lab_99, k_E=1, k_CH=1): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Lab_99 = np.array([53.22821988, 28.41634656, 3.89839552]) >>> DIN99_to_Lab(Lab_99) # doctest: +ELLIPSIS array([ 41.5278752..., 52.6385830..., 26.9231792...]) diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 4ca655ae4d..1823d693fb 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import ( CCS_ILLUMINANTS, lightness_Fairchild2010, lightness_Fairchild2011, diff --git a/colour/models/hdr_ipt.py b/colour/models/hdr_ipt.py index 5b6186ebcc..a6979ad5bf 100644 --- a/colour/models/hdr_ipt.py +++ b/colour/models/hdr_ipt.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import ( lightness_Fairchild2010, lightness_Fairchild2011, luminance_Fairchild2010, diff --git a/colour/models/hunter_lab.py b/colour/models/hunter_lab.py index 65750778be..7d55d0b83b 100644 --- a/colour/models/hunter_lab.py +++ b/colour/models/hunter_lab.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import TVS_ILLUMINANT_HUNTERLAB from colour.utilities import from_range_100, to_domain_100, tsplit, tstack diff --git a/colour/models/hunter_rdab.py b/colour/models/hunter_rdab.py index 20752d1466..553e9fe415 100644 --- a/colour/models/hunter_rdab.py +++ b/colour/models/hunter_rdab.py @@ -83,7 +83,7 @@ def XYZ_to_Hunter_Rdab(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) * 100 >>> D65 = TVS_ILLUMINANT_HUNTERLAB[ ... 'CIE 1931 2 Degree Standard Observer']['D65'] @@ -160,7 +160,7 @@ def Hunter_Rdab_to_XYZ(R_d_ab, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> R_d_ab = np.array([12.19722500, 57.12537874, 17.46241341]) >>> D65 = TVS_ILLUMINANT_HUNTERLAB[ ... 'CIE 1931 2 Degree Standard Observer']['D65'] diff --git a/colour/models/ipt.py b/colour/models/ipt.py index 49026e41a4..9193b1aa4a 100644 --- a/colour/models/ipt.py +++ b/colour/models/ipt.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (from_range_1, from_range_degrees, to_domain_1, diff --git a/colour/models/jzazbz.py b/colour/models/jzazbz.py index 69e42526b3..ab2c9ee865 100644 --- a/colour/models/jzazbz.py +++ b/colour/models/jzazbz.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import (eotf_inverse_ST2084, eotf_ST2084) diff --git a/colour/models/osa_ucs.py b/colour/models/osa_ucs.py index 33197d1e1d..1babf42514 100644 --- a/colour/models/osa_ucs.py +++ b/colour/models/osa_ucs.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import fmin from colour.algebra import spow @@ -99,7 +99,7 @@ def XYZ_to_OSA_UCS(XYZ): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) * 100 >>> XYZ_to_OSA_UCS(XYZ) # doctest: +ELLIPSIS array([-3.0049979..., 2.9971369..., -9.6678423...]) @@ -188,7 +188,7 @@ def OSA_UCS_to_XYZ(Ljg, optimisation_kwargs=None, **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> Ljg = np.array([-3.00499790, 2.99713697, -9.66784231]) >>> OSA_UCS_to_XYZ(Ljg) # doctest: +ELLIPSIS array([ 20.6540240..., 12.1972369..., 5.1369372...]) diff --git a/colour/models/rgb/cmyk.py b/colour/models/rgb/cmyk.py index 578f5bcd8f..f84200a1a1 100644 --- a/colour/models/rgb/cmyk.py +++ b/colour/models/rgb/cmyk.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import (as_float_array, from_range_1, to_domain_1, tsplit, tstack) diff --git a/colour/models/rgb/common.py b/colour/models/rgb/common.py index 091d703c49..c677a39815 100644 --- a/colour/models/rgb/common.py +++ b/colour/models/rgb/common.py @@ -73,7 +73,7 @@ def XYZ_to_sRGB(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_to_sRGB(XYZ) # doctest: +ELLIPSIS array([ 0.7057393..., 0.1924826..., 0.2235416...]) @@ -146,7 +146,7 @@ def sRGB_to_XYZ(RGB, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> RGB = np.array([0.70573936, 0.19248266, 0.22354169]) >>> sRGB_to_XYZ(RGB) # doctest: +ELLIPSIS array([ 0.2065429..., 0.1219794..., 0.0513714...]) diff --git a/colour/models/rgb/cylindrical.py b/colour/models/rgb/cylindrical.py index facb2aeeaf..e8dd48fa32 100644 --- a/colour/models/rgb/cylindrical.py +++ b/colour/models/rgb/cylindrical.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import (as_float_array, from_range_1, to_domain_1, tsplit, tstack) diff --git a/colour/models/rgb/datasets/aces.py b/colour/models/rgb/datasets/aces.py index 63e3fbea88..f5da245771 100644 --- a/colour/models/rgb/datasets/aces.py +++ b/colour/models/rgb/datasets/aces.py @@ -54,7 +54,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import ( diff --git a/colour/models/rgb/datasets/adobe_rgb_1998.py b/colour/models/rgb/datasets/adobe_rgb_1998.py index 7e285c7f30..87baa2f976 100644 --- a/colour/models/rgb/datasets/adobe_rgb_1998.py +++ b/colour/models/rgb/datasets/adobe_rgb_1998.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py index 225b227196..df667fad8c 100644 --- a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py +++ b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/apple_rgb.py b/colour/models/rgb/datasets/apple_rgb.py index fd95acb9c3..90749b664a 100644 --- a/colour/models/rgb/datasets/apple_rgb.py +++ b/colour/models/rgb/datasets/apple_rgb.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/arri_alexa_wide_gamut.py b/colour/models/rgb/datasets/arri_alexa_wide_gamut.py index 7a699b74ec..f13320e0aa 100644 --- a/colour/models/rgb/datasets/arri_alexa_wide_gamut.py +++ b/colour/models/rgb/datasets/arri_alexa_wide_gamut.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_ALEXALogC, diff --git a/colour/models/rgb/datasets/best_rgb.py b/colour/models/rgb/datasets/best_rgb.py index 91c37fa475..d06ff31e54 100644 --- a/colour/models/rgb/datasets/best_rgb.py +++ b/colour/models/rgb/datasets/best_rgb.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/beta_rgb.py b/colour/models/rgb/datasets/beta_rgb.py index 886edbb701..c19f95047b 100644 --- a/colour/models/rgb/datasets/beta_rgb.py +++ b/colour/models/rgb/datasets/beta_rgb.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/canon_cinema_gamut.py b/colour/models/rgb/datasets/canon_cinema_gamut.py index 378ad4fe02..a235cbd8f2 100644 --- a/colour/models/rgb/datasets/canon_cinema_gamut.py +++ b/colour/models/rgb/datasets/canon_cinema_gamut.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/cie_rgb.py b/colour/models/rgb/datasets/cie_rgb.py index 78fdc3b1f8..b6d8d0452e 100644 --- a/colour/models/rgb/datasets/cie_rgb.py +++ b/colour/models/rgb/datasets/cie_rgb.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/color_match_rgb.py b/colour/models/rgb/datasets/color_match_rgb.py index 9219113588..18398d5480 100644 --- a/colour/models/rgb/datasets/color_match_rgb.py +++ b/colour/models/rgb/datasets/color_match_rgb.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/dcdm_xyz.py b/colour/models/rgb/datasets/dcdm_xyz.py index 725262788d..21483f3483 100644 --- a/colour/models/rgb/datasets/dcdm_xyz.py +++ b/colour/models/rgb/datasets/dcdm_xyz.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, eotf_DCDM, diff --git a/colour/models/rgb/datasets/dci_p3.py b/colour/models/rgb/datasets/dci_p3.py index 346bb49e9f..2f97de12c7 100644 --- a/colour/models/rgb/datasets/dci_p3.py +++ b/colour/models/rgb/datasets/dci_p3.py @@ -27,7 +27,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/display_p3.py b/colour/models/rgb/datasets/display_p3.py index c761faaadb..0d8877c568 100644 --- a/colour/models/rgb/datasets/display_p3.py +++ b/colour/models/rgb/datasets/display_p3.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, eotf_inverse_sRGB, eotf_sRGB, diff --git a/colour/models/rgb/datasets/dji_dgamut.py b/colour/models/rgb/datasets/dji_dgamut.py index acf8e63909..3794df7c2a 100644 --- a/colour/models/rgb/datasets/dji_dgamut.py +++ b/colour/models/rgb/datasets/dji_dgamut.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_DJIDLog, diff --git a/colour/models/rgb/datasets/don_rgb_4.py b/colour/models/rgb/datasets/don_rgb_4.py index d21cacb5be..74135f4a75 100644 --- a/colour/models/rgb/datasets/don_rgb_4.py +++ b/colour/models/rgb/datasets/don_rgb_4.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/eci_rgb_v2.py b/colour/models/rgb/datasets/eci_rgb_v2.py index 00e6bfce91..07900a4009 100644 --- a/colour/models/rgb/datasets/eci_rgb_v2.py +++ b/colour/models/rgb/datasets/eci_rgb_v2.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import (CCS_ILLUMINANTS, lightness_CIE1976, diff --git a/colour/models/rgb/datasets/ekta_space_ps5.py b/colour/models/rgb/datasets/ekta_space_ps5.py index b2a5096fed..8bed9d3752 100644 --- a/colour/models/rgb/datasets/ekta_space_ps5.py +++ b/colour/models/rgb/datasets/ekta_space_ps5.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/filmlight_egamut.py b/colour/models/rgb/datasets/filmlight_egamut.py index 2ba9b3d967..f248ca27bb 100755 --- a/colour/models/rgb/datasets/filmlight_egamut.py +++ b/colour/models/rgb/datasets/filmlight_egamut.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_FilmLightTLog, diff --git a/colour/models/rgb/datasets/fujifilm_f_gamut.py b/colour/models/rgb/datasets/fujifilm_f_gamut.py index 8329f00241..3825268855 100644 --- a/colour/models/rgb/datasets/fujifilm_f_gamut.py +++ b/colour/models/rgb/datasets/fujifilm_f_gamut.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_FLog, diff --git a/colour/models/rgb/datasets/gopro.py b/colour/models/rgb/datasets/gopro.py index 56affbe632..dbf27594d2 100644 --- a/colour/models/rgb/datasets/gopro.py +++ b/colour/models/rgb/datasets/gopro.py @@ -27,7 +27,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_decoding_Protune, diff --git a/colour/models/rgb/datasets/itur_bt_2020.py b/colour/models/rgb/datasets/itur_bt_2020.py index 3fa3092bff..b6f244867f 100644 --- a/colour/models/rgb/datasets/itur_bt_2020.py +++ b/colour/models/rgb/datasets/itur_bt_2020.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, normalised_primary_matrix, diff --git a/colour/models/rgb/datasets/itur_bt_470.py b/colour/models/rgb/datasets/itur_bt_470.py index be05a5bbb3..982786956c 100644 --- a/colour/models/rgb/datasets/itur_bt_470.py +++ b/colour/models/rgb/datasets/itur_bt_470.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/itur_bt_709.py b/colour/models/rgb/datasets/itur_bt_709.py index ae6f40f88f..04cde2d292 100644 --- a/colour/models/rgb/datasets/itur_bt_709.py +++ b/colour/models/rgb/datasets/itur_bt_709.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, oetf_BT709, oetf_inverse_BT709, diff --git a/colour/models/rgb/datasets/max_rgb.py b/colour/models/rgb/datasets/max_rgb.py index 59279f7686..69482416fc 100644 --- a/colour/models/rgb/datasets/max_rgb.py +++ b/colour/models/rgb/datasets/max_rgb.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/p3_d65.py b/colour/models/rgb/datasets/p3_d65.py index 497a222c5a..d4d6940058 100644 --- a/colour/models/rgb/datasets/p3_d65.py +++ b/colour/models/rgb/datasets/p3_d65.py @@ -10,7 +10,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/panasonic_v_gamut.py b/colour/models/rgb/datasets/panasonic_v_gamut.py index ba7aa4cbc3..65b360d797 100644 --- a/colour/models/rgb/datasets/panasonic_v_gamut.py +++ b/colour/models/rgb/datasets/panasonic_v_gamut.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_VLog, diff --git a/colour/models/rgb/datasets/red.py b/colour/models/rgb/datasets/red.py index 52102a78e0..302997b1ef 100644 --- a/colour/models/rgb/datasets/red.py +++ b/colour/models/rgb/datasets/red.py @@ -28,7 +28,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import ( diff --git a/colour/models/rgb/datasets/rimm_romm_rgb.py b/colour/models/rgb/datasets/rimm_romm_rgb.py index ad38e8c577..a294d2b4ad 100644 --- a/colour/models/rgb/datasets/rimm_romm_rgb.py +++ b/colour/models/rgb/datasets/rimm_romm_rgb.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import ( diff --git a/colour/models/rgb/datasets/russell_rgb.py b/colour/models/rgb/datasets/russell_rgb.py index 653ece177f..83f14ccd7d 100644 --- a/colour/models/rgb/datasets/russell_rgb.py +++ b/colour/models/rgb/datasets/russell_rgb.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry.datasets import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/sharp.py b/colour/models/rgb/datasets/sharp.py index 2963c786e0..a9d58dfe7d 100644 --- a/colour/models/rgb/datasets/sharp.py +++ b/colour/models/rgb/datasets/sharp.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/smpte_240m.py b/colour/models/rgb/datasets/smpte_240m.py index 85b32dfedf..86ce6dd683 100644 --- a/colour/models/rgb/datasets/smpte_240m.py +++ b/colour/models/rgb/datasets/smpte_240m.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, normalised_primary_matrix, diff --git a/colour/models/rgb/datasets/smpte_c.py b/colour/models/rgb/datasets/smpte_c.py index 09a4079828..bd00b89034 100644 --- a/colour/models/rgb/datasets/smpte_c.py +++ b/colour/models/rgb/datasets/smpte_c.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/datasets/sony.py b/colour/models/rgb/datasets/sony.py index ed1b14ee73..9e8d2be80f 100644 --- a/colour/models/rgb/datasets/sony.py +++ b/colour/models/rgb/datasets/sony.py @@ -46,7 +46,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import (RGB_Colourspace, log_encoding_SLog2, diff --git a/colour/models/rgb/datasets/srgb.py b/colour/models/rgb/datasets/srgb.py index 6ac9d2e23e..2d4231990e 100644 --- a/colour/models/rgb/datasets/srgb.py +++ b/colour/models/rgb/datasets/srgb.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models.rgb import RGB_Colourspace, eotf_inverse_sRGB, eotf_sRGB diff --git a/colour/models/rgb/datasets/xtreme_rgb.py b/colour/models/rgb/datasets/xtreme_rgb.py index 3790279fd3..74ef8961df 100644 --- a/colour/models/rgb/datasets/xtreme_rgb.py +++ b/colour/models/rgb/datasets/xtreme_rgb.py @@ -15,7 +15,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from functools import partial from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index d27be5a5f6..1f3bed53f8 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.adaptation import chromatic_adaptation_VonKries from colour.models import XYZ_to_xy, XYZ_to_xyY, xy_to_XYZ diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 503d6f7fb7..18054705ba 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import (eotf_inverse_ST2084, eotf_ST2084) diff --git a/colour/models/rgb/prismatic.py b/colour/models/rgb/prismatic.py index 83d2899d23..6a101d1077 100644 --- a/colour/models/rgb/prismatic.py +++ b/colour/models/rgb/prismatic.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1, tsplit, tstack diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index c9a948fb01..19a81778e9 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from copy import deepcopy from colour.models import xy_to_XYZ, xy_to_xyY, xyY_to_XYZ diff --git a/colour/models/rgb/tests/test_cmyk.py b/colour/models/rgb/tests/test_cmyk.py index d6b9901e99..1084139a9f 100644 --- a/colour/models/rgb/tests/test_cmyk.py +++ b/colour/models/rgb/tests/test_cmyk.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_common.py b/colour/models/rgb/tests/test_common.py index 8e16b58085..fa15f79d69 100644 --- a/colour/models/rgb/tests/test_common.py +++ b/colour/models/rgb/tests/test_common.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models import XYZ_to_sRGB, sRGB_to_XYZ diff --git a/colour/models/rgb/tests/test_cylindrical.py b/colour/models/rgb/tests/test_cylindrical.py index 81b4662802..0ce648c4d6 100644 --- a/colour/models/rgb/tests/test_cylindrical.py +++ b/colour/models/rgb/tests/test_cylindrical.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_derivation.py b/colour/models/rgb/tests/test_derivation.py index ddf6fcffff..9881943c9c 100644 --- a/colour/models/rgb/tests/test_derivation.py +++ b/colour/models/rgb/tests/test_derivation.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import re import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_ictcp.py b/colour/models/rgb/tests/test_ictcp.py index 0a9218c9df..2d319167ff 100644 --- a/colour/models/rgb/tests/test_ictcp.py +++ b/colour/models/rgb/tests/test_ictcp.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_prismatic.py b/colour/models/rgb/tests/test_prismatic.py index e7d3c7cc58..c5b7edbf37 100644 --- a/colour/models/rgb/tests/test_prismatic.py +++ b/colour/models/rgb/tests/test_prismatic.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_rgb_colourspace.py b/colour/models/rgb/tests/test_rgb_colourspace.py index 444af2f291..969439d0f2 100644 --- a/colour/models/rgb/tests/test_rgb_colourspace.py +++ b/colour/models/rgb/tests/test_rgb_colourspace.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import pickle import re import six diff --git a/colour/models/rgb/tests/test_ycbcr.py b/colour/models/rgb/tests/test_ycbcr.py index 9a6435aaba..0ceaf8d476 100644 --- a/colour/models/rgb/tests/test_ycbcr.py +++ b/colour/models/rgb/tests/test_ycbcr.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/tests/test_ycocg.py b/colour/models/rgb/tests/test_ycocg.py index 6bb8fefd7d..c55446fc71 100644 --- a/colour/models/rgb/tests/test_ycocg.py +++ b/colour/models/rgb/tests/test_ycocg.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index dc8d9dbc99..425eb8eca0 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -50,7 +50,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import (Structure, as_float, as_int, from_range_1, to_domain_1) diff --git a/colour/models/rgb/transfer_functions/arib_std_b67.py b/colour/models/rgb/transfer_functions/arib_std_b67.py index 408b2f279d..84a9125aff 100644 --- a/colour/models/rgb/transfer_functions/arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/arib_std_b67.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import gamma_function from colour.utilities import (Structure, as_float, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/arri_alexa_log_c.py b/colour/models/rgb/transfer_functions/arri_alexa_log_c.py index 2454b5d1f8..a600668699 100644 --- a/colour/models/rgb/transfer_functions/arri_alexa_log_c.py +++ b/colour/models/rgb/transfer_functions/arri_alexa_log_c.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import (CaseInsensitiveMapping, as_float, from_range_1, to_domain_1) diff --git a/colour/models/rgb/transfer_functions/canon_log.py b/colour/models/rgb/transfer_functions/canon_log.py index d7cc91c072..b57b856cdb 100644 --- a/colour/models/rgb/transfer_functions/canon_log.py +++ b/colour/models/rgb/transfer_functions/canon_log.py @@ -31,7 +31,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import (as_float, domain_range_scale, from_range_1, diff --git a/colour/models/rgb/transfer_functions/cineon.py b/colour/models/rgb/transfer_functions/cineon.py index df743d6347..215492eba8 100644 --- a/colour/models/rgb/transfer_functions/cineon.py +++ b/colour/models/rgb/transfer_functions/cineon.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/common.py b/colour/models/rgb/transfer_functions/common.py index de0e51d76e..0d80787365 100644 --- a/colour/models/rgb/transfer_functions/common.py +++ b/colour/models/rgb/transfer_functions/common.py @@ -8,7 +8,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_FLOAT_DTYPE, DEFAULT_INT_DTYPE from colour.utilities import as_float_array diff --git a/colour/models/rgb/transfer_functions/dcdm.py b/colour/models/rgb/transfer_functions/dcdm.py index 49ec3b5a03..be1b971b76 100644 --- a/colour/models/rgb/transfer_functions/dcdm.py +++ b/colour/models/rgb/transfer_functions/dcdm.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.constants import DEFAULT_INT_DTYPE diff --git a/colour/models/rgb/transfer_functions/dicom_gsdf.py b/colour/models/rgb/transfer_functions/dicom_gsdf.py index 156bbb54b6..368c06d276 100644 --- a/colour/models/rgb/transfer_functions/dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/dicom_gsdf.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import (Structure, as_float, as_int, from_range_1, to_domain_1) diff --git a/colour/models/rgb/transfer_functions/dji_dlog.py b/colour/models/rgb/transfer_functions/dji_dlog.py index faba3530bf..f9fd81477b 100644 --- a/colour/models/rgb/transfer_functions/dji_dlog.py +++ b/colour/models/rgb/transfer_functions/dji_dlog.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/exponent.py b/colour/models/rgb/transfer_functions/exponent.py index 4e0a2c4f7a..e10468894f 100644 --- a/colour/models/rgb/transfer_functions/exponent.py +++ b/colour/models/rgb/transfer_functions/exponent.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float, as_float_array, suppress_warnings diff --git a/colour/models/rgb/transfer_functions/filmic_pro.py b/colour/models/rgb/transfer_functions/filmic_pro.py index 2c89c7b16a..751e917546 100644 --- a/colour/models/rgb/transfer_functions/filmic_pro.py +++ b/colour/models/rgb/transfer_functions/filmic_pro.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import Extrapolator, LinearInterpolator from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/filmlight_tlog.py b/colour/models/rgb/transfer_functions/filmlight_tlog.py index f30de04a7e..e76f43d451 100644 --- a/colour/models/rgb/transfer_functions/filmlight_tlog.py +++ b/colour/models/rgb/transfer_functions/filmlight_tlog.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/fujifilm_flog.py b/colour/models/rgb/transfer_functions/fujifilm_flog.py index 1770a73695..24ddedca15 100644 --- a/colour/models/rgb/transfer_functions/fujifilm_flog.py +++ b/colour/models/rgb/transfer_functions/fujifilm_flog.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index f32e4797a2..121a30da66 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import as_float_array, as_float diff --git a/colour/models/rgb/transfer_functions/gopro.py b/colour/models/rgb/transfer_functions/gopro.py index 1b8bae1950..fbfc556ec7 100644 --- a/colour/models/rgb/transfer_functions/gopro.py +++ b/colour/models/rgb/transfer_functions/gopro.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/itur_bt_1886.py b/colour/models/rgb/transfer_functions/itur_bt_1886.py index fe9253d17d..86ac3b5b8c 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1886.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/itur_bt_2020.py b/colour/models/rgb/transfer_functions/itur_bt_2020.py index b46a7fd64c..efb4c8686b 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2020.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (Structure, as_float, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 6aac9bf052..a34df0899e 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -54,7 +54,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/itur_bt_601.py b/colour/models/rgb/transfer_functions/itur_bt_601.py index abf0b3d184..6e97aee309 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/itur_bt_601.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (as_float, domain_range_scale, from_range_1, diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index f9a8cc0564..76935577a2 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -38,10 +38,8 @@ from __future__ import division, unicode_literals -import numpy as np - -from colour.utilities import (as_float, as_float_array, from_range_1, - to_domain_1) +import colour.ndarray as np +from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/models/rgb/transfer_functions/panalog.py b/colour/models/rgb/transfer_functions/panalog.py index 3d9f0931f7..90910d0f0c 100644 --- a/colour/models/rgb/transfer_functions/panalog.py +++ b/colour/models/rgb/transfer_functions/panalog.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/panasonic_vlog.py b/colour/models/rgb/transfer_functions/panasonic_vlog.py index e37fe55a81..e222000590 100644 --- a/colour/models/rgb/transfer_functions/panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/panasonic_vlog.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/pivoted_log.py b/colour/models/rgb/transfer_functions/pivoted_log.py index 79aa9a37a4..f930a874ce 100644 --- a/colour/models/rgb/transfer_functions/pivoted_log.py +++ b/colour/models/rgb/transfer_functions/pivoted_log.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/red_log.py b/colour/models/rgb/transfer_functions/red_log.py index dd5c5c1cd3..6a970c98fb 100644 --- a/colour/models/rgb/transfer_functions/red_log.py +++ b/colour/models/rgb/transfer_functions/red_log.py @@ -32,7 +32,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import (log_encoding_Cineon, log_decoding_Cineon) diff --git a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py index e9fed1fcaa..3b778305f7 100644 --- a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (as_float, as_int, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/smpte_240m.py b/colour/models/rgb/transfer_functions/smpte_240m.py index 1eb531fcb7..d674a8a6e6 100644 --- a/colour/models/rgb/transfer_functions/smpte_240m.py +++ b/colour/models/rgb/transfer_functions/smpte_240m.py @@ -20,7 +20,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (as_float, domain_range_scale, from_range_1, diff --git a/colour/models/rgb/transfer_functions/sony_slog.py b/colour/models/rgb/transfer_functions/sony_slog.py index 59fd81ec71..a37d9cd222 100644 --- a/colour/models/rgb/transfer_functions/sony_slog.py +++ b/colour/models/rgb/transfer_functions/sony_slog.py @@ -25,7 +25,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import (as_float, domain_range_scale, from_range_1, diff --git a/colour/models/rgb/transfer_functions/srgb.py b/colour/models/rgb/transfer_functions/srgb.py index fb3ec490b3..bc9044b201 100644 --- a/colour/models/rgb/transfer_functions/srgb.py +++ b/colour/models/rgb/transfer_functions/srgb.py @@ -26,7 +26,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import (as_float, domain_range_scale, from_range_1, diff --git a/colour/models/rgb/transfer_functions/st_2084.py b/colour/models/rgb/transfer_functions/st_2084.py index af26776e3f..4de802b5b1 100644 --- a/colour/models/rgb/transfer_functions/st_2084.py +++ b/colour/models/rgb/transfer_functions/st_2084.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.algebra import spow from colour.utilities import Structure, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/tests/test__init__.py b/colour/models/rgb/transfer_functions/tests/test__init__.py index 3eab00d642..35e2c8d6c7 100644 --- a/colour/models/rgb/transfer_functions/tests/test__init__.py +++ b/colour/models/rgb/transfer_functions/tests/test__init__.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_aces.py b/colour/models/rgb/transfer_functions/tests/test_aces.py index 40f7732358..5e070f9451 100644 --- a/colour/models/rgb/transfer_functions/tests/test_aces.py +++ b/colour/models/rgb/transfer_functions/tests/test_aces.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py index 1e1ddeb014..4aaf9683c6 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (oetf_ARIBSTDB67, diff --git a/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py b/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py index fa17229ec8..1e40619a64 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py +++ b/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_ALEXALogC, diff --git a/colour/models/rgb/transfer_functions/tests/test_canon_log.py b/colour/models/rgb/transfer_functions/tests/test_canon_log.py index b313c455b6..418eeba4ce 100644 --- a/colour/models/rgb/transfer_functions/tests/test_canon_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_canon_log.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_cineon.py b/colour/models/rgb/transfer_functions/tests/test_cineon.py index 4b680481d4..25819d5de0 100644 --- a/colour/models/rgb/transfer_functions/tests/test_cineon.py +++ b/colour/models/rgb/transfer_functions/tests/test_cineon.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_Cineon, diff --git a/colour/models/rgb/transfer_functions/tests/test_common.py b/colour/models/rgb/transfer_functions/tests/test_common.py index b1d4edaec6..3f7ba63704 100644 --- a/colour/models/rgb/transfer_functions/tests/test_common.py +++ b/colour/models/rgb/transfer_functions/tests/test_common.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (CV_range, legal_to_full, diff --git a/colour/models/rgb/transfer_functions/tests/test_dcdm.py b/colour/models/rgb/transfer_functions/tests/test_dcdm.py index dd7d853e94..54c5f1c7ba 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dcdm.py +++ b/colour/models/rgb/transfer_functions/tests/test_dcdm.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import eotf_inverse_DCDM, eotf_DCDM diff --git a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py index 8df04fdae7..7386031c05 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (eotf_inverse_DICOMGSDF, diff --git a/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py b/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py index d622acaba2..3e891a1b5a 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_DJIDLog, diff --git a/colour/models/rgb/transfer_functions/tests/test_exponent.py b/colour/models/rgb/transfer_functions/tests/test_exponent.py index e965a7f69e..63b75e4bf4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_exponent.py +++ b/colour/models/rgb/transfer_functions/tests/test_exponent.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py index 1ad3fa2ad3..f4e4229488 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_FilmicPro6, diff --git a/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py b/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py index 609cafcfcd..c8fd11f547 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_FilmLightTLog, diff --git a/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py b/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py index dbe7971601..590a7475f5 100644 --- a/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py +++ b/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_FLog, diff --git a/colour/models/rgb/transfer_functions/tests/test_gamma.py b/colour/models/rgb/transfer_functions/tests/test_gamma.py index 9b8ddee573..0226a7faac 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gamma.py +++ b/colour/models/rgb/transfer_functions/tests/test_gamma.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import gamma_function diff --git a/colour/models/rgb/transfer_functions/tests/test_gopro.py b/colour/models/rgb/transfer_functions/tests/test_gopro.py index b4b0aec0a0..04bd192863 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gopro.py +++ b/colour/models/rgb/transfer_functions/tests/test_gopro.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_Protune, diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py index 9e525a56ae..5789f4fcad 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (eotf_inverse_BT1886, diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py index e4e7a56e99..94198ebd4e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (eotf_inverse_BT2020, diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py index b5dec0afa0..1496db14a3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py index fdd431616d..00ea2c3805 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import oetf_BT601, oetf_inverse_BT601 diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py index e424e7a886..6fea4cde24 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import oetf_BT709, oetf_inverse_BT709 diff --git a/colour/models/rgb/transfer_functions/tests/test_linear.py b/colour/models/rgb/transfer_functions/tests/test_linear.py index 35e1383d03..5cac1dde3d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_linear.py +++ b/colour/models/rgb/transfer_functions/tests/test_linear.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import linear_function diff --git a/colour/models/rgb/transfer_functions/tests/test_log.py b/colour/models/rgb/transfer_functions/tests/test_log.py index 4459acdfc0..b40f3160a1 100644 --- a/colour/models/rgb/transfer_functions/tests/test_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_log.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_panalog.py b/colour/models/rgb/transfer_functions/tests/test_panalog.py index 1b1dcb296f..b7c1359e36 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panalog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panalog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_Panalog, diff --git a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py index 3b648b6171..02c80c1ef9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_VLog, diff --git a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py index 1e45b247b9..2336d9c3e8 100644 --- a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_PivotedLog, diff --git a/colour/models/rgb/transfer_functions/tests/test_red_log.py b/colour/models/rgb/transfer_functions/tests/test_red_log.py index 16de81af17..8754185a2c 100644 --- a/colour/models/rgb/transfer_functions/tests/test_red_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_red_log.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py index 6ca61afca9..a6e574ddf2 100644 --- a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py index 0e762172d4..7d3a631fb8 100644 --- a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py +++ b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import oetf_SMPTE240M, eotf_SMPTE240M diff --git a/colour/models/rgb/transfer_functions/tests/test_sony_slog.py b/colour/models/rgb/transfer_functions/tests/test_sony_slog.py index 56200e541c..ff6858d2f2 100644 --- a/colour/models/rgb/transfer_functions/tests/test_sony_slog.py +++ b/colour/models/rgb/transfer_functions/tests/test_sony_slog.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/transfer_functions/tests/test_srgb.py b/colour/models/rgb/transfer_functions/tests/test_srgb.py index e57f2ca8ac..f2e900da4d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_srgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_srgb.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import eotf_inverse_sRGB, eotf_sRGB diff --git a/colour/models/rgb/transfer_functions/tests/test_st_2084.py b/colour/models/rgb/transfer_functions/tests/test_st_2084.py index 09cf6cd9c8..246d577b22 100644 --- a/colour/models/rgb/transfer_functions/tests/test_st_2084.py +++ b/colour/models/rgb/transfer_functions/tests/test_st_2084.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (eotf_inverse_ST2084, diff --git a/colour/models/rgb/transfer_functions/tests/test_viper_log.py b/colour/models/rgb/transfer_functions/tests/test_viper_log.py index 703a387c2f..082d25c345 100644 --- a/colour/models/rgb/transfer_functions/tests/test_viper_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_viper_log.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models.rgb.transfer_functions import (log_encoding_ViperLog, diff --git a/colour/models/rgb/transfer_functions/viper_log.py b/colour/models/rgb/transfer_functions/viper_log.py index 6a33637c72..d57209790a 100644 --- a/colour/models/rgb/transfer_functions/viper_log.py +++ b/colour/models/rgb/transfer_functions/viper_log.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import from_range_1, to_domain_1 diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index 67b3d0e5bb..bd6eb1665b 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -45,7 +45,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.constants import DEFAULT_FLOAT_DTYPE, DEFAULT_INT_DTYPE from colour.models.rgb.transfer_functions import ( diff --git a/colour/models/rgb/ycocg.py b/colour/models/rgb/ycocg.py index 2ae84ca768..4fe5f27d12 100644 --- a/colour/models/rgb/ycocg.py +++ b/colour/models/rgb/ycocg.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import dot_vector diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index af1a4b88e0..983db05b0c 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_cie_lab.py b/colour/models/tests/test_cie_lab.py index 4b8353a727..b3e1aaba81 100644 --- a/colour/models/tests/test_cie_lab.py +++ b/colour/models/tests/test_cie_lab.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_cie_luv.py b/colour/models/tests/test_cie_luv.py index 9a52aec738..b190f3e854 100644 --- a/colour/models/tests/test_cie_luv.py +++ b/colour/models/tests/test_cie_luv.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_cie_ucs.py b/colour/models/tests/test_cie_ucs.py index 61f66e148d..81198ccd39 100644 --- a/colour/models/tests/test_cie_ucs.py +++ b/colour/models/tests/test_cie_ucs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_cie_uvw.py b/colour/models/tests/test_cie_uvw.py index 85d9c18443..e1869dc45c 100644 --- a/colour/models/tests/test_cie_uvw.py +++ b/colour/models/tests/test_cie_uvw.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_cie_xyy.py b/colour/models/tests/test_cie_xyy.py index 5309d39f14..4153685d79 100644 --- a/colour/models/tests/test_cie_xyy.py +++ b/colour/models/tests/test_cie_xyy.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_common.py b/colour/models/tests/test_common.py index d6db751d1b..93079c85dc 100644 --- a/colour/models/tests/test_common.py +++ b/colour/models/tests/test_common.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_din99.py b/colour/models/tests/test_din99.py index 08d9916277..c6c08ad13c 100644 --- a/colour/models/tests/test_din99.py +++ b/colour/models/tests/test_din99.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_hdr_cie_lab.py b/colour/models/tests/test_hdr_cie_lab.py index 9579ff12fb..dfb3c65c64 100644 --- a/colour/models/tests/test_hdr_cie_lab.py +++ b/colour/models/tests/test_hdr_cie_lab.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_hdr_ipt.py b/colour/models/tests/test_hdr_ipt.py index a4203b6565..38093494c1 100644 --- a/colour/models/tests/test_hdr_ipt.py +++ b/colour/models/tests/test_hdr_ipt.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_hunter_lab.py b/colour/models/tests/test_hunter_lab.py index 1fc0a02576..142dbc16d0 100644 --- a/colour/models/tests/test_hunter_lab.py +++ b/colour/models/tests/test_hunter_lab.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_hunter_rdab.py b/colour/models/tests/test_hunter_rdab.py index e04d5663e0..42482c9061 100644 --- a/colour/models/tests/test_hunter_rdab.py +++ b/colour/models/tests/test_hunter_rdab.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_ipt.py b/colour/models/tests/test_ipt.py index 0eb9685b25..182c5371ca 100644 --- a/colour/models/tests/test_ipt.py +++ b/colour/models/tests/test_ipt.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_jzazbz.py b/colour/models/tests/test_jzazbz.py index 89064b931e..29ffb0b949 100644 --- a/colour/models/tests/test_jzazbz.py +++ b/colour/models/tests/test_jzazbz.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/models/tests/test_osa_ucs.py b/colour/models/tests/test_osa_ucs.py index 2bffe17eb1..ac3a47c973 100644 --- a/colour/models/tests/test_osa_ucs.py +++ b/colour/models/tests/test_osa_ucs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/ndarray/__init__.py b/colour/ndarray/__init__.py new file mode 100644 index 0000000000..1fa491ef60 --- /dev/null +++ b/colour/ndarray/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from __future__ import absolute_import + +import sys + +from .backend import NDimensionalArrayBackend + + +class ndarray(NDimensionalArrayBackend): + def __getattr__(self, attribute): + return super(ndarray, self).__getattr__(attribute) + + +sys.modules['colour.ndarray'] = ndarray() + +del NDimensionalArrayBackend, sys \ No newline at end of file diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py new file mode 100644 index 0000000000..4c5f82df1b --- /dev/null +++ b/colour/ndarray/backend.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +""" +N-Dimensional Array Computations Backend +======================================== + +Defines the objects enabling the various n-dimensional array computations +backend. +""" + +from __future__ import division, unicode_literals + +import inspect +import os +import functools + +__author__ = 'Colour Developers' +__copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' +__license__ = 'New BSD License - https://opensource.org/licenses/BSD-3-Clause' +__maintainer__ = 'Colour Developers' +__email__ = 'colour-developers@colour-science.org' +__status__ = 'Production' + +__all__ = [ + 'get_ndimensional_array_backend', 'set_ndimensional_array_backend', + 'ndimensional_array_backend', 'NDimensionalArrayBackend' +] + +_NDIMENSIONAL_ARRAY_BACKEND = os.environ.get( + 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Numpy').lower() + + +def get_ndimensional_array_backend(): + + return _NDIMENSIONAL_ARRAY_BACKEND + + +def set_ndimensional_array_backend(backend='Numpy'): + global _NDIMENSIONAL_ARRAY_BACKEND + + backend = str(backend).lower() + valid = ('numpy', 'jax') + assert backend in valid, 'Scale must be one of "{0}".'.format(valid) + + _NDIMENSIONAL_ARRAY_BACKEND = backend + + +class ndimensional_array_backend(object): + def __init__(self, backend): + self._backend = backend + self._previous_backend = get_ndimensional_array_backend() + + def __enter__(self): + set_ndimensional_array_backend(self._backend) + + return self + + def __exit__(self, *args): + set_ndimensional_array_backend(self._previous_backend) + + def __call__(self, function): + @functools.wraps(function) + def wrapper(*args, **kwargs): + with self: + return function(*args, **kwargs) + + return wrapper + + +class NDimensionalArrayBackend(object): + def __init__(self): + # Numpy + import numpy + + self._failsafe = self._numpy = numpy + + # Jax + self._jax = None + self._jax_unsupported = [] + try: + import jax.numpy + + self._jax = jax.numpy + for name in dir(jax.numpy): + function = getattr(jax.numpy, name) + try: + source = inspect.getsource(function) + except (TypeError, OSError): + continue + + if "Numpy function {} not yet implemented" in source: + self._jax_unsupported.append(name) + + # TypeError: pad() got an unexpected keyword argument 'end_values' + self._jax_unsupported.append('pad') + # TypeError: full() takes from 2 to 3 positional arguments + # but 4 were given + self._jax_unsupported.append('full') + except ImportError: + pass + + def __getattr__(self, attribute): + failsafe = getattr(self._failsafe, attribute) + + if _NDIMENSIONAL_ARRAY_BACKEND == 'numpy': + return getattr(self._numpy, attribute) + elif _NDIMENSIONAL_ARRAY_BACKEND == 'jax' and self._jax is not None: + if attribute not in self._jax_unsupported: + try: + return getattr(self._jax, attribute) + except AttributeError: + return failsafe + else: + return failsafe + else: + return failsafe diff --git a/colour/notation/datasets/munsell/all.py b/colour/notation/datasets/munsell/all.py index 4656e9508e..4e2ce49b99 100644 --- a/colour/notation/datasets/munsell/all.py +++ b/colour/notation/datasets/munsell/all.py @@ -34,7 +34,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/notation/datasets/munsell/experimental.py b/colour/notation/datasets/munsell/experimental.py index 1fcf136e54..ef4c6adf8c 100644 --- a/colour/notation/datasets/munsell/experimental.py +++ b/colour/notation/datasets/munsell/experimental.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/notation/datasets/munsell/real.py b/colour/notation/datasets/munsell/real.py index d862586f54..ee0a1fb3a6 100644 --- a/colour/notation/datasets/munsell/real.py +++ b/colour/notation/datasets/munsell/real.py @@ -35,7 +35,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 0faf8949c2..0c57f3b3a3 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -11,7 +11,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.models import eotf_inverse_sRGB, eotf_sRGB from colour.utilities import (as_float_array, from_range_1, normalise_maximum, diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index f9a771c8b3..0809be7dee 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -116,7 +116,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import re from collections import OrderedDict diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index 9fb5b42334..bef2e0dd1a 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 040d6beaaf..38af249e4b 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index f62279db27..69ae2e4242 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, SpectralDistribution) from colour.constants import CONSTANT_AVOGADRO diff --git a/colour/phenomena/tests/test_rayleigh.py b/colour/phenomena/tests/test_rayleigh.py index 283c2af5a3..634bb2c374 100644 --- a/colour/phenomena/tests/test_rayleigh.py +++ b/colour/phenomena/tests/test_rayleigh.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/plotting/blindness.py b/colour/plotting/blindness.py index 43610d30de..3ad7662863 100644 --- a/colour/plotting/blindness.py +++ b/colour/plotting/blindness.py @@ -65,7 +65,7 @@ def plot_cvd_simulation_Machado2009(RGB, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> RGB = np.random.rand(32, 32, 3) >>> plot_cvd_simulation_Machado2009(RGB) # doctest: +ELLIPSIS (
, <...AxesSubplot...>) diff --git a/colour/plotting/characterisation.py b/colour/plotting/characterisation.py index f74ef7a910..7ab8f58be9 100644 --- a/colour/plotting/characterisation.py +++ b/colour/plotting/characterisation.py @@ -11,7 +11,7 @@ from __future__ import division -import numpy as np +import colour.ndarray as np from colour.models import xyY_to_XYZ from colour.plotting import ( diff --git a/colour/plotting/colorimetry.py b/colour/plotting/colorimetry.py index 57e6ab1fe2..1759803288 100644 --- a/colour/plotting/colorimetry.py +++ b/colour/plotting/colorimetry.py @@ -28,7 +28,7 @@ from __future__ import division import matplotlib.pyplot as plt -import numpy as np +import colour.ndarray as np from matplotlib.patches import Polygon from six.moves import reduce diff --git a/colour/plotting/common.py b/colour/plotting/common.py index f92238ddaa..2024ddff34 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -31,7 +31,7 @@ import matplotlib.cm import matplotlib.pyplot as plt import matplotlib.ticker -import numpy as np +import colour.ndarray as np import re from collections import OrderedDict, namedtuple from functools import partial @@ -331,7 +331,7 @@ def XYZ_to_plotting_colourspace(XYZ, Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> XYZ_to_plotting_colourspace(XYZ) # doctest: +ELLIPSIS array([ 0.7057393..., 0.1924826..., 0.2235416...]) diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index ad2174307e..6815ad67ff 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -16,7 +16,7 @@ from __future__ import division import bisect -import numpy as np +import colour.ndarray as np from matplotlib.collections import LineCollection from matplotlib.patches import Polygon diff --git a/colour/plotting/models.py b/colour/plotting/models.py index 529ab73e5a..1352a07fc9 100644 --- a/colour/plotting/models.py +++ b/colour/plotting/models.py @@ -43,7 +43,7 @@ from __future__ import division -import numpy as np +import colour.ndarray as np import scipy.optimize try: # pragma: no cover from collections import Mapping diff --git a/colour/plotting/notation.py b/colour/plotting/notation.py index 61f51dca1a..5399198015 100644 --- a/colour/plotting/notation.py +++ b/colour/plotting/notation.py @@ -11,7 +11,7 @@ from __future__ import division -import numpy as np +import colour.ndarray as np from colour.notation import MUNSELL_VALUE_METHODS from colour.plotting import (filter_passthrough, plot_multi_functions, diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index f59ebd1e79..0d18a275b9 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -13,7 +13,7 @@ from __future__ import division -import numpy as np +import colour.ndarray as np from itertools import cycle from colour.constants import DEFAULT_FLOAT_DTYPE diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index 3f5570b2f9..7e469313dd 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -14,7 +14,7 @@ from __future__ import division -import numpy as np +import colour.ndarray as np from colour.colorimetry import MSDS_CMFS, CCS_ILLUMINANTS from colour.models import (UCS_uv_to_xy, XYZ_to_UCS, UCS_to_uv, xy_to_XYZ) diff --git a/colour/plotting/tests/test_blindness.py b/colour/plotting/tests/test_blindness.py index 4c883d3244..69bf937173 100644 --- a/colour/plotting/tests/test_blindness.py +++ b/colour/plotting/tests/test_blindness.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from matplotlib.pyplot import Axes, Figure diff --git a/colour/plotting/tests/test_common.py b/colour/plotting/tests/test_common.py index e799568967..ce557f5ffd 100644 --- a/colour/plotting/tests/test_common.py +++ b/colour/plotting/tests/test_common.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals import matplotlib.pyplot as plt -import numpy as np +import colour.ndarray as np import os import shutil import tempfile diff --git a/colour/plotting/tests/test_models.py b/colour/plotting/tests/test_models.py index 76ffcd3241..c9205f03c5 100644 --- a/colour/plotting/tests/test_models.py +++ b/colour/plotting/tests/test_models.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from matplotlib.pyplot import Axes, Figure diff --git a/colour/plotting/tests/test_volume.py b/colour/plotting/tests/test_volume.py index adf56e7887..5e6ff77795 100644 --- a/colour/plotting/tests/test_volume.py +++ b/colour/plotting/tests/test_volume.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from matplotlib.pyplot import Axes, Figure diff --git a/colour/plotting/volume.py b/colour/plotting/volume.py index bb582a4aa4..8d6422f794 100644 --- a/colour/plotting/volume.py +++ b/colour/plotting/volume.py @@ -12,7 +12,7 @@ from __future__ import division import matplotlib.pyplot as plt -import numpy as np +import colour.ndarray as np from mpl_toolkits.mplot3d.art3d import Poly3DCollection from colour.constants import DEFAULT_FLOAT_DTYPE, DEFAULT_INT_DTYPE diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 8f5a777241..6fbe2e46c9 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -24,7 +24,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import euclidean_distance diff --git a/colour/quality/cri.py b/colour/quality/cri.py index 1f601dff65..073aba1385 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -18,7 +18,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.algebra import euclidean_distance, spow diff --git a/colour/quality/ssi.py b/colour/quality/ssi.py index afc6367a85..c5af22caae 100644 --- a/colour/quality/ssi.py +++ b/colour/quality/ssi.py @@ -16,7 +16,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.ndimage.filters import convolve1d from colour.algebra import LinearInterpolator diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index 6009535d52..c2b283dcbb 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.quality import CQS_Specification, colour_quality_scale diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index 0ae3b87c4b..dd1b2fdfc8 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.quality import CRI_Specification, colour_rendering_index diff --git a/colour/recovery/__init__.py b/colour/recovery/__init__.py index 93202c8a11..ce5f816f88 100644 --- a/colour/recovery/__init__.py +++ b/colour/recovery/__init__.py @@ -137,7 +137,7 @@ def XYZ_to_sd(XYZ, method='Meng 2015', **kwargs): *Mallett and Yuksel (2019)* reflectance recovery: - >>> import numpy as np + >>> import colour.ndarray as np >>> from colour.utilities import numpy_print_options >>> from colour.colorimetry import ( ... MSDS_CMFS_STANDARD_OBSERVER, SpectralShape, sd_to_XYZ_integration) diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 4cfc02c7dd..67791609f3 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.colorimetry import (MSDS_CMFS_STANDARD_OBSERVER, diff --git a/colour/recovery/smits1999.py b/colour/recovery/smits1999.py index 30006f431a..90c6191f78 100644 --- a/colour/recovery/smits1999.py +++ b/colour/recovery/smits1999.py @@ -14,7 +14,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.colorimetry import CCS_ILLUMINANTS from colour.models import (XYZ_to_RGB, normalised_primary_matrix, diff --git a/colour/recovery/tests/test__init__.py b/colour/recovery/tests/test__init__.py index d1e2f8707f..6f59c6a812 100644 --- a/colour/recovery/tests/test__init__.py +++ b/colour/recovery/tests/test__init__.py @@ -6,7 +6,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from six.moves import zip diff --git a/colour/recovery/tests/test_meng2015.py b/colour/recovery/tests/test_meng2015.py index b5d4627438..59e26c48fd 100644 --- a/colour/recovery/tests/test_meng2015.py +++ b/colour/recovery/tests/test_meng2015.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, diff --git a/colour/recovery/tests/test_smits1999.py b/colour/recovery/tests/test_smits1999.py index 49568ee65d..850404054d 100644 --- a/colour/recovery/tests/test_smits1999.py +++ b/colour/recovery/tests/test_smits1999.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.colorimetry import sd_to_XYZ_integration diff --git a/colour/temperature/__init__.py b/colour/temperature/__init__.py index 7aa13ca3a0..bf7bccc15b 100644 --- a/colour/temperature/__init__.py +++ b/colour/temperature/__init__.py @@ -93,7 +93,7 @@ def uv_to_CCT(uv, method='Ohno 2013', **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> uv = np.array([0.1978, 0.3122]) >>> # Doctests skipping for Python 2.x compatibility. >>> uv_to_CCT(uv) # doctest: +SKIP @@ -185,7 +185,7 @@ def CCT_to_uv(CCT_D_uv, method='Ohno 2013', **kwargs): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> CCT_D_uv = np.array([6507.47380460, 0.00322335]) >>> CCT_to_uv(CCT_D_uv) # doctest: +ELLIPSIS array([ 0.1977999..., 0.3121999...]) @@ -265,7 +265,7 @@ def xy_to_CCT(xy, method='CIE Illuminant D Series'): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy_to_CCT(np.array([0.31270, 0.32900])) # doctest: +ELLIPSIS 6508.1175148... >>> xy_to_CCT(np.array([0.31270, 0.32900]), 'Hernandez 1999') diff --git a/colour/temperature/cie_d.py b/colour/temperature/cie_d.py index 7075664627..859ecc9c58 100644 --- a/colour/temperature/cie_d.py +++ b/colour/temperature/cie_d.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.colorimetry import daylight_locus_function diff --git a/colour/temperature/hernandez1999.py b/colour/temperature/hernandez1999.py index 59c4691a3b..049125b524 100644 --- a/colour/temperature/hernandez1999.py +++ b/colour/temperature/hernandez1999.py @@ -23,7 +23,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/temperature/kang2002.py b/colour/temperature/kang2002.py index 68030eed5f..24e48fc49c 100644 --- a/colour/temperature/kang2002.py +++ b/colour/temperature/kang2002.py @@ -22,7 +22,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.utilities import as_float_array, as_numeric, tstack, usage_warning diff --git a/colour/temperature/krystek1985.py b/colour/temperature/krystek1985.py index ebf6244b1c..f747a11f53 100644 --- a/colour/temperature/krystek1985.py +++ b/colour/temperature/krystek1985.py @@ -22,7 +22,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.utilities import as_float_array, as_numeric, tstack diff --git a/colour/temperature/mccamy1992.py b/colour/temperature/mccamy1992.py index eb7c37fdd1..19328dac1e 100644 --- a/colour/temperature/mccamy1992.py +++ b/colour/temperature/mccamy1992.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.optimize import minimize from colour.colorimetry import CCS_ILLUMINANTS @@ -59,7 +59,7 @@ def xy_to_CCT_McCamy1992(xy): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> xy = np.array([0.31270, 0.32900]) >>> xy_to_CCT_McCamy1992(xy) # doctest: +ELLIPSIS 6505.0805913... diff --git a/colour/temperature/ohno2013.py b/colour/temperature/ohno2013.py index fb6a7a950f..2b85c4bfd6 100644 --- a/colour/temperature/ohno2013.py +++ b/colour/temperature/ohno2013.py @@ -22,7 +22,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, diff --git a/colour/temperature/robertson1968.py b/colour/temperature/robertson1968.py index 7db4fa9800..7a7c2a86b4 100644 --- a/colour/temperature/robertson1968.py +++ b/colour/temperature/robertson1968.py @@ -36,7 +36,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from collections import namedtuple from colour.utilities import as_float_array, tsplit diff --git a/colour/temperature/tests/test_cie_d.py b/colour/temperature/tests/test_cie_d.py index 9568a4e963..bb91624ad9 100644 --- a/colour/temperature/tests/test_cie_d.py +++ b/colour/temperature/tests/test_cie_d.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_hernandez1999.py b/colour/temperature/tests/test_hernandez1999.py index 2972a57f9b..430a141076 100644 --- a/colour/temperature/tests/test_hernandez1999.py +++ b/colour/temperature/tests/test_hernandez1999.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_kang2002.py b/colour/temperature/tests/test_kang2002.py index 5b30465d7e..3627b778a4 100644 --- a/colour/temperature/tests/test_kang2002.py +++ b/colour/temperature/tests/test_kang2002.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_krystek1985.py b/colour/temperature/tests/test_krystek1985.py index ee6aa0c26e..da06f283e5 100644 --- a/colour/temperature/tests/test_krystek1985.py +++ b/colour/temperature/tests/test_krystek1985.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_mccamy1992.py b/colour/temperature/tests/test_mccamy1992.py index d2f1529d22..1543f2a96d 100644 --- a/colour/temperature/tests/test_mccamy1992.py +++ b/colour/temperature/tests/test_mccamy1992.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_ohno2013.py b/colour/temperature/tests/test_ohno2013.py index 57324c4803..0b0d71d6fd 100644 --- a/colour/temperature/tests/test_ohno2013.py +++ b/colour/temperature/tests/test_ohno2013.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index 75b9c4a69a..a7f8e800a3 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/utilities/array.py b/colour/utilities/array.py index d6f39248ef..9f935d2141 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import sys try: # pragma: no cover from collections import Mapping diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 95dd30608a..34a2ffc8d0 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -20,7 +20,7 @@ import multiprocessing import multiprocessing.pool import functools -import numpy as np +import colour.ndarray as np import re import six import warnings diff --git a/colour/utilities/metrics.py b/colour/utilities/metrics.py index bc63c1ad19..12777245b7 100644 --- a/colour/utilities/metrics.py +++ b/colour/utilities/metrics.py @@ -19,7 +19,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import as_float_array diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 5ad955233e..5b5e8915ba 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from collections import namedtuple diff --git a/colour/utilities/tests/test_common.py b/colour/utilities/tests/test_common.py index 928b373849..7b98b2e420 100644 --- a/colour/utilities/tests/test_common.py +++ b/colour/utilities/tests/test_common.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest import six from collections import OrderedDict diff --git a/colour/utilities/tests/test_data_structures.py b/colour/utilities/tests/test_data_structures.py index edd8f8f4ad..ca5d22fb11 100644 --- a/colour/utilities/tests/test_data_structures.py +++ b/colour/utilities/tests/test_data_structures.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import operator import pickle import unittest diff --git a/colour/utilities/tests/test_metrics.py b/colour/utilities/tests/test_metrics.py index bd742283fe..e63e26de67 100644 --- a/colour/utilities/tests/test_metrics.py +++ b/colour/utilities/tests/test_metrics.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.utilities import metric_mse, metric_psnr diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index dc1c959b57..076cf8df00 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -8,7 +8,7 @@ from __future__ import division, print_function, unicode_literals -import numpy as np +import colour.ndarray as np import os import sys import traceback diff --git a/colour/volume/datasets/optimal_colour_stimuli.py b/colour/volume/datasets/optimal_colour_stimuli.py index 2b5e910d87..4b80466cfa 100644 --- a/colour/volume/datasets/optimal_colour_stimuli.py +++ b/colour/volume/datasets/optimal_colour_stimuli.py @@ -33,7 +33,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from colour.utilities import CaseInsensitiveMapping diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index 457f2df6c3..38de897703 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -8,7 +8,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.spatial import Delaunay from colour.models import xyY_to_XYZ diff --git a/colour/volume/mesh.py b/colour/volume/mesh.py index a61451b8d1..bb10984bda 100644 --- a/colour/volume/mesh.py +++ b/colour/volume/mesh.py @@ -8,7 +8,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np from scipy.spatial import Delaunay __author__ = 'Colour Developers' diff --git a/colour/volume/pointer_gamut.py b/colour/volume/pointer_gamut.py index e5f5f7743b..aea342f293 100644 --- a/colour/volume/pointer_gamut.py +++ b/colour/volume/pointer_gamut.py @@ -50,7 +50,7 @@ def is_within_pointer_gamut(XYZ, tolerance=None): Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> is_within_pointer_gamut(np.array([0.3205, 0.4131, 0.5100])) array(True, dtype=bool) >>> a = np.array([[0.3205, 0.4131, 0.5100], [0.0005, 0.0031, 0.0010]]) diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index ed96344275..6a374a91fd 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -16,7 +16,7 @@ import itertools import multiprocessing -import numpy as np +import colour.ndarray as np from colour.algebra import random_triplet_generator from colour.colorimetry import CCS_ILLUMINANTS diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py index bd32431818..e7f17d5489 100644 --- a/colour/volume/spectrum.py +++ b/colour/volume/spectrum.py @@ -17,7 +17,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import six from colour.colorimetry import (MSDS_CMFS, msds_to_XYZ, SpectralShape, sd_ones) @@ -266,7 +266,7 @@ def is_within_visible_spectrum( Examples -------- - >>> import numpy as np + >>> import colour.ndarray as np >>> is_within_visible_spectrum(np.array([0.3205, 0.4131, 0.51])) array(True, dtype=bool) >>> a = np.array([[0.3205, 0.4131, 0.51], diff --git a/colour/volume/tests/test_macadam_limits.py b/colour/volume/tests/test_macadam_limits.py index 4cee38c853..1c032c8e23 100644 --- a/colour/volume/tests/test_macadam_limits.py +++ b/colour/volume/tests/test_macadam_limits.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/volume/tests/test_mesh.py b/colour/volume/tests/test_mesh.py index bf474bf830..da22a9c65f 100644 --- a/colour/volume/tests/test_mesh.py +++ b/colour/volume/tests/test_mesh.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/volume/tests/test_pointer_gamut.py b/colour/volume/tests/test_pointer_gamut.py index 8528cbb667..a825146a64 100644 --- a/colour/volume/tests/test_pointer_gamut.py +++ b/colour/volume/tests/test_pointer_gamut.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/volume/tests/test_rgb.py b/colour/volume/tests/test_rgb.py index 76fb284e08..213ca49276 100644 --- a/colour/volume/tests/test_rgb.py +++ b/colour/volume/tests/test_rgb.py @@ -21,7 +21,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from colour.models import (RGB_COLOURSPACE_ACES2065_1, RGB_COLOURSPACE_BT2020, diff --git a/colour/volume/tests/test_spectrum.py b/colour/volume/tests/test_spectrum.py index f60eaaa22f..6ed5ef3e18 100644 --- a/colour/volume/tests/test_spectrum.py +++ b/colour/volume/tests/test_spectrum.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/et --hard HEAD@{5} b/et --hard HEAD@{5} new file mode 100644 index 0000000000..860266b19a --- /dev/null +++ b/et --hard HEAD@{5} @@ -0,0 +1,76 @@ +0599e49f (HEAD -> feature/ndarray_backend) HEAD@{0}: rebase finished: returning to refs/heads/feature/ndarray_backend +0599e49f (HEAD -> feature/ndarray_backend) HEAD@{1}: rebase: Fixes for the munsell code, still have one test to pass +167168c3 HEAD@{2}: rebase: Fixed the switches between cupy and numpy, turned jakob2019 to ndarray instead of numpy, redefined the as_float for numpy to avoid the zero division error, currently all tests work on numpy and some of them do not work on cupy as shared in the document +c9e08e51 HEAD@{3}: rebase: Tests for models, appearance and algebra +fe39c1b0 HEAD@{4}: rebase: Fixes for appearance, quality and phenomenal +ac344755 HEAD@{5}: rebase: Fixes for appearance, quality and phenomenal +8312766e HEAD@{6}: rebase: Fixes for models/rgb/derivation +e492b354 HEAD@{7}: rebase: Fixes for the temperature module +3ed6adc8 HEAD@{8}: rebase: Fixes for the temperature module +f0032963 HEAD@{9}: rebase: Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube +ec242fad HEAD@{10}: rebase: Fixes for the volume, luts, colorimetry, blindness and characterisation module +b02d16d1 HEAD@{11}: rebase: Fixes for algebra, colorimetry, luts, notation, phenomena and quality sub modules +3200a3d6 HEAD@{12}: rebase: Testing cupy support for models, adaptation, transfer_functions, rgb, coordinates, temperature, difference, biochemistry, colorimetry and algebra. Currently parts of the last two modules do not work. +f8500cf0 HEAD@{13}: rebase: Adding Cupy computational backend with supporting utility function to change backends +9170f204 HEAD@{14}: rebase: Investigate n-dimensional array backend change. +c5adcbae HEAD@{15}: rebase: Convert CAM test to unit tests. +cdd87391 (upstream/develop, develop) HEAD@{16}: rebase: checkout develop +28e979c1 (origin/feature/ndarray_backend) HEAD@{17}: checkout: moving from develop to feature/ndarray_backend +cdd87391 (upstream/develop, develop) HEAD@{18}: pull upstream develop: Fast-forward +bf9a50fc (origin/develop, origin/HEAD) HEAD@{19}: checkout: moving from feature/ndarray_backend to develop +28e979c1 (origin/feature/ndarray_backend) HEAD@{20}: commit: Fixes for the munsell code, still have one test to pass +f66cc9ac HEAD@{21}: commit: Fixed the switches between cupy and numpy, turned jakob2019 to ndarray instead of numpy, redefined the as_float for numpy to avoid the zero division error, currently all tests work on numpy and some of them do not work on cupy as shared in the document +e44f803a HEAD@{22}: commit: Tests for models, appearance and algebra +693a74ba HEAD@{23}: checkout: moving from feature/cam-unit-tests to feature/ndarray_backend +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{24}: reset: moving to HEAD +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{25}: checkout: moving from feature/ndarray_backend to feature/cam-unit-tests +693a74ba HEAD@{26}: reset: moving to HEAD +693a74ba HEAD@{27}: checkout: moving from feature/cam-unit-tests to feature/ndarray_backend +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{28}: reset: moving to HEAD +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{29}: checkout: moving from feature/ndarray_backend to feature/cam-unit-tests +693a74ba HEAD@{30}: checkout: moving from feature/cam-unit-tests to feature/ndarray_backend +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{31}: checkout: moving from feature/ndarray_backend to feature/cam-unit-tests +693a74ba HEAD@{32}: checkout: moving from feature/ndarray_backend to feature/ndarray_backend +693a74ba HEAD@{33}: commit: Fixes for appearance, quality and phenomenal +7f474da9 HEAD@{34}: commit: Fixes for appearance, quality and phenomenal +c5216b5f HEAD@{35}: rebase finished: returning to refs/heads/feature/ndarray_backend +c5216b5f HEAD@{36}: rebase: Fixes for models/rgb/derivation +b5adb486 HEAD@{37}: rebase: Fixes for the temperature module +2a5c455c HEAD@{38}: rebase: Fixes for the temperature module +dca2a93f HEAD@{39}: rebase: Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube +4f7f0849 HEAD@{40}: rebase: Fixes for the volume, luts, colorimetry, blindness and characterisation module +d74e9f49 HEAD@{41}: rebase: Fixes for algebra, colorimetry, luts, notation, phenomena and quality sub modules +2ce3c5da HEAD@{42}: rebase: Testing cupy support for models, adaptation, transfer_functions, rgb, coordinates, temperature, difference, biochemistry, colorimetry and algebra. Currently parts of the last two modules do not work. +c1caf486 HEAD@{43}: rebase: Adding Cupy computational backend with supporting utility function to change backends +51feea29 HEAD@{44}: rebase: Investigate n-dimensional array backend change. +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{45}: rebase: checkout feature/cam-unit-tests +42e4321f (upstream/feature/cam-unit-tests, feature/cam-unit-tests) HEAD@{46}: initial pull +2ebd0262 (feature/cam-unit-test) HEAD@{47}: reset: moving to HEAD +2ebd0262 (feature/cam-unit-test) HEAD@{48}: checkout: moving from feature/ndarray_backend to feature/cam-unit-test +2ebd0262 (feature/cam-unit-test) HEAD@{49}: reset: moving to HEAD +2ebd0262 (feature/cam-unit-test) HEAD@{50}: commit: Fixes for models/rgb/derivation +f21eb520 HEAD@{51}: checkout: moving from develop to feature/ndarray_backend +bf9a50fc (origin/develop, origin/HEAD) HEAD@{52}: checkout: moving from feature/ndarray_backend to develop +f21eb520 HEAD@{53}: commit: Fixes for the temperature module +9d0462f1 HEAD@{54}: commit: Fixes for the temperature module +271c5215 HEAD@{55}: commit: Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube +6f359160 HEAD@{56}: commit: Fixes for the volume, luts, colorimetry, blindness and characterisation module +f9cf2191 HEAD@{57}: commit: Fixes for algebra, colorimetry, luts, notation, phenomena and quality sub modules +e5b11a33 HEAD@{58}: commit: Testing cupy support for models, adaptation, transfer_functions, rgb, coordinates, temperature, difference, biochemistry, colorimetry and algebra. Currently parts of the last two modules do not work. +a422cef1 HEAD@{59}: reset: moving to HEAD~3 +604dddcd HEAD@{60}: commit: deleting array +10afbb52 HEAD@{61}: commit: Fixing code style issues +2c84b9a6 HEAD@{62}: commit: Testing cupy support for models, adaptation, transfer_functions, rgb, coordinates, temperature, difference, biochemistry, colorimetry and algebra. Currently parts of the last two modules do not work. +a422cef1 HEAD@{63}: reset: moving to HEAD~1 +d4bf2662 HEAD@{64}: reset: moving to HEAD~1 +216ba195 HEAD@{65}: commit: Numpy +d4bf2662 HEAD@{66}: commit: Creating default cupy +a422cef1 HEAD@{67}: commit: Adding Cupy computational backend with supporting utility function to change backends +0791f8ad HEAD@{68}: reset: moving to HEAD +0791f8ad HEAD@{69}: reset: moving to HEAD +0791f8ad HEAD@{70}: reset: moving to HEAD +0791f8ad HEAD@{71}: checkout: moving from develop to feature/ndarray_backend +bf9a50fc (origin/develop, origin/HEAD) HEAD@{72}: checkout: moving from feature/ndarray_backend to develop +0791f8ad HEAD@{73}: reset: moving to HEAD +0791f8ad HEAD@{74}: checkout: moving from develop to feature/ndarray_backend +bf9a50fc (origin/develop, origin/HEAD) HEAD@{75}: clone: from git@github.com:colour-science/colour.git diff --git a/pyproject.toml b/pyproject.toml index 93088d8cb9..e1b18ffa2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = "~2.7 || ^3.5" +python = "^3.6" imageio = "*" six = "*" scipy = "*" @@ -55,6 +55,8 @@ coverage = { version = "*", optional = true } # Development dependency. coveralls = { version = "*", optional = true } # Development dependency. flake8 = { version = "*", optional = true } # Development dependency. invoke = { version = "*", optional = true } # Development dependency. +jax = { version = "*", optional = true } +jaxlib = { version = "*", optional = true } jupyter = { version = "*", optional = true } # Development dependency. matplotlib = { version = "*", optional = true } mock = { version = "*", optional = true } # Development dependency. @@ -115,6 +117,7 @@ development = [ "twine", "yapf" ] +jax = [ "jax", "jaxlib" ] graphviz = [ "pygraphviz" ] optional = [ "networkx", "pandas" ] plotting = [ "backports.functools_lru_cache", "matplotlib" ] diff --git a/utilities/generate_plots.py b/utilities/generate_plots.py index 34a11f7e29..ff80e0dd0d 100755 --- a/utilities/generate_plots.py +++ b/utilities/generate_plots.py @@ -12,7 +12,7 @@ matplotlib.use('AGG') import matplotlib.pyplot as plt # noqa -import numpy as np # noqa +import colour.ndarray as np # noqa import os # noqa import colour # noqa From 671f67671e3af9257547ac93c63d241379b8eb4a Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Thu, 23 Jul 2020 17:54:53 +0200 Subject: [PATCH 03/17] Adding Cupy computational backend with supporting utility function to change backends --- colour/__init__.py | 2 +- colour/adaptation/vonkries.py | 3 +- colour/ndarray/backend.py | 64 ++++++++++++++++++++--------------- colour/utilities/__init__.py | 2 +- colour/utilities/array.py | 9 +++-- colour/utilities/common.py | 19 +++++++++++ setup.py | 5 +-- try.py | 9 +++++ 8 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 try.py diff --git a/colour/__init__.py b/colour/__init__.py index 51b7661187..b02fd955aa 100644 --- a/colour/__init__.py +++ b/colour/__init__.py @@ -52,7 +52,7 @@ from .utilities.deprecation import ModuleAPI, build_API_changes from .utilities.documentation import is_documentation_building from .utilities.common import (domain_range_scale, get_domain_range_scale, - set_domain_range_scale) + set_domain_range_scale, set_ndimensional_array_backend) from .adaptation import (CHROMATIC_ADAPTATION_METHODS, CHROMATIC_ADAPTATION_TRANSFORMS, diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index da73fbe852..3417149bff 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -102,7 +102,7 @@ def chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr, transform='CAT02'): XYZ_w = to_domain_1(XYZ_w) XYZ_wr = to_domain_1(XYZ_wr) - M = CHROMATIC_ADAPTATION_TRANSFORMS.get(transform) + M = np.array(CHROMATIC_ADAPTATION_TRANSFORMS.get(transform)) if M is None: raise KeyError( @@ -116,7 +116,6 @@ def chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr, transform='CAT02'): D = rgb_wr / rgb_w D = row_as_diagonal(D) - M_CAT = dot_matrix(np.linalg.inv(M), D) M_CAT = dot_matrix(M_CAT, M) diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index 4c5f82df1b..6ca65c5ca9 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -34,11 +34,11 @@ def get_ndimensional_array_backend(): return _NDIMENSIONAL_ARRAY_BACKEND -def set_ndimensional_array_backend(backend='Numpy'): +def _set_ndimensional_array_backend(backend='Numpy'): global _NDIMENSIONAL_ARRAY_BACKEND backend = str(backend).lower() - valid = ('numpy', 'jax') + valid = ('numpy', 'cupy') assert backend in valid, 'Scale must be one of "{0}".'.format(valid) _NDIMENSIONAL_ARRAY_BACKEND = backend @@ -73,28 +73,17 @@ def __init__(self): self._failsafe = self._numpy = numpy - # Jax - self._jax = None - self._jax_unsupported = [] + # CuPy + self._cupy = None + self._cupy_unsupported = [] try: - import jax.numpy - - self._jax = jax.numpy - for name in dir(jax.numpy): - function = getattr(jax.numpy, name) - try: - source = inspect.getsource(function) - except (TypeError, OSError): - continue - - if "Numpy function {} not yet implemented" in source: - self._jax_unsupported.append(name) - - # TypeError: pad() got an unexpected keyword argument 'end_values' - self._jax_unsupported.append('pad') - # TypeError: full() takes from 2 to 3 positional arguments - # but 4 were given - self._jax_unsupported.append('full') + import cupy + numpyList = dir(numpy) + cupyList = dir(cupy) + for i in numpyList: + if i not in cupyList: + self._cupy_unsupported.append(i) + self._cupy = cupy except ImportError: pass @@ -103,13 +92,34 @@ def __getattr__(self, attribute): if _NDIMENSIONAL_ARRAY_BACKEND == 'numpy': return getattr(self._numpy, attribute) - elif _NDIMENSIONAL_ARRAY_BACKEND == 'jax' and self._jax is not None: - if attribute not in self._jax_unsupported: + elif _NDIMENSIONAL_ARRAY_BACKEND == 'cupy' and self._cupy is not None: + if attribute not in self._cupy_unsupported: try: - return getattr(self._jax, attribute) + return getattr(self._cupy, attribute) except AttributeError: return failsafe else: - return failsafe + def middleware(*args, **kwargs): + args = list(args) + for i in range(len(args)): + if isinstance(args[i], self._cupy.ndarray): + args[i] = self._cupy.asnumpy(args[i]) + args = tuple(args) + r = failsafe(*args,**kwargs) + print(type(r)) + if isinstance(r, self._numpy.ndarray): + return self._cupy.array(r) + elif isinstance(r, (list)): + for z in range(len(r)): + if isinstance(r, self._numpy.ndarray): + r[z] = self._cupy.array(r[z]) + return r + if callable(failsafe): + return middleware + else: + return failsafe else: return failsafe + + def set_ndimensional_array_backend(self, backend): + _set_ndimensional_array_backend(backend) diff --git a/colour/utilities/__init__.py b/colour/utilities/__init__.py index 2468cbd09a..af627c40dd 100644 --- a/colour/utilities/__init__.py +++ b/colour/utilities/__init__.py @@ -13,7 +13,7 @@ filter_mapping, first_item, get_domain_range_scale, set_domain_range_scale, domain_range_scale, to_domain_1, to_domain_10, to_domain_100, to_domain_degrees, to_domain_int, from_range_1, from_range_10, - from_range_100, from_range_degrees, from_range_int) + from_range_100, from_range_degrees, from_range_int, set_ndimensional_array_backend) from .array import ( as_array, as_int_array, as_float_array, as_numeric, as_int, as_float, set_float_precision, set_int_precision, as_namedtuple, closest_indexes, diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 9f935d2141..1ebd93c328 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -225,6 +225,7 @@ def as_int(a, dtype=None): # https://github.com/numpy/numpy/issues/11956 is addressed. return int(a) except TypeError: + print('error') return as_int_array(a, dtype) @@ -269,8 +270,12 @@ def as_float(a, dtype=None): assert dtype in np.sctypes['float'], ( '"dtype" must be one of the following types: {0}'.format( np.sctypes['float'])) - - return dtype(a) + try: + # TODO: Change to "DEFAULT_INT_DTYPE" when and if + # https://github.com/numpy/numpy/issues/11956 is addressed. + return float(a) + except TypeError: + return as_float_array(a, dtype) def set_float_precision(dtype=DEFAULT_FLOAT_DTYPE): diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 34a2ffc8d0..f12a2c85cd 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -1446,3 +1446,22 @@ def from_range_int(a, bit_depth=8, dtype=None): a /= maximum_code_value / 100 return a + +def set_ndimensional_array_backend(backend): + """ + Changes the computation backend framework + + Parameters + ---------- + backend : string + possible values: "Numpy", "Cupy" + + + Returns + ------- + + Examples + -------- + - set_ndimensional_array_backend('Cupy') + """ + np.set_ndimensional_array_backend(backend) diff --git a/setup.py b/setup.py index 0440724506..1861da3d9e 100644 --- a/setup.py +++ b/setup.py @@ -105,7 +105,8 @@ 'colour.utilities.tests', 'colour.volume', 'colour.volume.datasets', - 'colour.volume.tests'] + 'colour.volume.tests', + 'colour.ndarray'] package_data = \ {'': ['*'], @@ -153,7 +154,7 @@ setup( name='colour-science', - version='0.3.15', + version='0.3.16', description='Colour Science for Python', long_description=codecs.open('README.rst', encoding='utf8').read(), author='Colour Developers', diff --git a/try.py b/try.py new file mode 100644 index 0000000000..857b2f2e16 --- /dev/null +++ b/try.py @@ -0,0 +1,9 @@ +import colour +from colour import read_image +import time +colour.utilities.set_ndimensional_array_backend('cupy') +RGB = read_image('testImage4K.jpg') +tim2 = time.time() +RGB2 = colour.models.RGB_to_HSL(RGB) +time2 = time.time()-tim2 +print(time2) From 77f86b39a31ca34f15b7d5c3f216e7a5836ffd35 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Wed, 29 Jul 2020 00:04:40 +0200 Subject: [PATCH 04/17] Testing cupy support for models, adaptation, transfer_functions, rgb, coordinates, temperature, difference, biochemistry, colorimetry and algebra. Currently parts of the last two modules do not work. --- colour/__init__.py | 2 +- colour/algebra/extrapolation.py | 2 - colour/algebra/geometry.py | 14 ++++-- colour/algebra/interpolation.py | 34 +++++++------- colour/biochemistry/michaelis_menten.py | 8 ++++ colour/colorimetry/dominant.py | 13 ++++-- colour/colorimetry/generation.py | 8 ++-- colour/colorimetry/illuminants.py | 6 ++- colour/colorimetry/lefs.py | 4 +- colour/colorimetry/photometry.py | 5 ++- colour/colorimetry/spectrum.py | 2 +- colour/continuous/signal.py | 3 ++ colour/models/osa_ucs.py | 10 ++++- colour/models/rgb/cylindrical.py | 5 ++- colour/models/rgb/transfer_functions/aces.py | 10 +++-- .../rgb/transfer_functions/filmic_pro.py | 6 +-- .../rgb/transfer_functions/itur_bt_2100.py | 16 +++++-- colour/ndarray/__init__.py | 2 +- colour/ndarray/backend.py | 45 +++++++++++++------ .../temperature/tests/test_robertson1968.py | 2 +- colour/utilities/__init__.py | 2 +- colour/utilities/array.py | 4 +- colour/utilities/common.py | 23 +--------- try.py | 9 ---- 24 files changed, 137 insertions(+), 98 deletions(-) delete mode 100644 try.py diff --git a/colour/__init__.py b/colour/__init__.py index b02fd955aa..51b7661187 100644 --- a/colour/__init__.py +++ b/colour/__init__.py @@ -52,7 +52,7 @@ from .utilities.deprecation import ModuleAPI, build_API_changes from .utilities.documentation import is_documentation_building from .utilities.common import (domain_range_scale, get_domain_range_scale, - set_domain_range_scale, set_ndimensional_array_backend) + set_domain_range_scale) from .adaptation import (CHROMATIC_ADAPTATION_METHODS, CHROMATIC_ADAPTATION_TRANSFORMS, diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 261abe6e7d..0d044be058 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -295,12 +295,10 @@ def _evaluate(self, x): ndarray Extrapolated points values. """ - xi = self._interpolator.x yi = self._interpolator.y y = np.empty_like(x) - if self._method == 'linear': y[x < xi[0]] = (yi[0] + (x[x < xi[0]] - xi[0]) * (yi[1] - yi[0]) / (xi[1] - xi[0])) diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py index 5e3197229e..5b8caf58cc 100644 --- a/colour/algebra/geometry.py +++ b/colour/algebra/geometry.py @@ -95,6 +95,10 @@ def euclidean_distance(a, b): b : array_like Point array :math:`b`. + Notes + ----- + On CuPy, this returns an array even for length of 1. + Returns ------- numeric or ndarray @@ -280,12 +284,16 @@ def intersect_line_segments(l_1, l_2): u_a = numerator_a / denominator u_b = numerator_b / denominator - intersect = np.logical_and.reduce((u_a >= 0, u_a <= 1, u_b >= 0, u_b <= 1)) + logicalAndA = np.logical_and(u_a >= 0, u_a <= 1) + logicalAndB = np.logical_and(u_b >= 0, u_b <= 1) + + intersect = np.logical_and(logicalAndA, logicalAndB) xy = tstack([x_1 + x_2_x_1 * u_a, y_1 + y_2_y_1 * u_a]) xy[~intersect] = np.nan parallel = denominator == 0 - coincident = np.logical_and.reduce((numerator_a == 0, numerator_b == 0, - parallel)) + + logicalAndNumerators = np.logical_and(numerator_a == 0, numerator_b == 0) + coincident = np.logical_and(logicalAndNumerators, parallel) return LineSegmentsIntersections_Specification(xy, intersect, parallel, coincident) diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 9547599927..8cf6f9a8a9 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -426,13 +426,16 @@ def x(self, value): self._x = value + minx = np.min(self._x) + maxx = np.max(self._x) + if self._window is not None: self._x_p = np.pad( self._x, (self._window, self._window), 'linear_ramp', end_values=( - np.min(self._x) - self._window * value_interval[0], - np.max(self._x) + self._window * value_interval[0])) + float(minx - self._window * value_interval[0]), + float(maxx + self._window * value_interval[0]))) @property def y(self): @@ -1122,18 +1125,18 @@ def y(self, value): '"y" dependent variable values count must be normalised to' 'domain [6:]!') - yp1 = np.ravel( - (np.dot(self.SPRAGUE_C_COEFFICIENTS[0], - np.array(value[0:6]).reshape([6, 1]))) / 209)[0] - yp2 = np.ravel( - (np.dot(self.SPRAGUE_C_COEFFICIENTS[1], - np.array(value[0:6]).reshape([6, 1]))) / 209)[0] - yp3 = np.ravel( - (np.dot(self.SPRAGUE_C_COEFFICIENTS[2], - np.array(value[-6:]).reshape([6, 1]))) / 209)[0] - yp4 = np.ravel( - (np.dot(self.SPRAGUE_C_COEFFICIENTS[3], - np.array(value[-6:]).reshape([6, 1]))) / 209)[0] + yp1 = np.ravel((np.dot( + np.array(self.SPRAGUE_C_COEFFICIENTS[0]), + np.array(value[0:6]).reshape([6, 1]))) / 209)[0] + yp2 = np.ravel((np.dot( + np.array(self.SPRAGUE_C_COEFFICIENTS[1]), + np.array(value[0:6]).reshape([6, 1]))) / 209)[0] + yp3 = np.ravel((np.dot( + np.array(self.SPRAGUE_C_COEFFICIENTS[2]), + np.array(value[-6:]).reshape([6, 1]))) / 209)[0] + yp4 = np.ravel((np.dot( + np.array(self.SPRAGUE_C_COEFFICIENTS[3]), + np.array(value[-6:]).reshape([6, 1]))) / 209)[0] self._yp = np.concatenate([ np.array([yp1, yp2]), @@ -1179,11 +1182,12 @@ def _evaluate(self, x): self._validate_dimensions() self._validate_interpolation_range(x) + self._xp = np.array(self._xp) i = np.searchsorted(self._xp, x) - 1 X = (x - self._xp[i]) / (self._xp[i + 1] - self._xp[i]) - r = self._yp + r = np.array(self._yp) a0p = r[i] a1p = ((2 * r[i - 2] - 16 * r[i - 1] + 16 * r[i + 1] - diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py index 78377a1325..5bb4e8d21d 100644 --- a/colour/biochemistry/michaelis_menten.py +++ b/colour/biochemistry/michaelis_menten.py @@ -56,6 +56,10 @@ def reaction_rate_MichealisMenten(S, V_max, K_m): ---------- :cite:`Wikipedia2003d` + Notes + ----- + On CuPy, this returns an array even for length of 1. + Examples -------- >>> reaction_rate_MichealisMenten(0.5, 2.5, 0.8) # doctest: +ELLIPSIS @@ -96,6 +100,10 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): ---------- :cite:`Wikipedia2003d` + Notes + ----- + On CuPy, this returns an array even for length of 1. + Examples -------- >>> substrate_concentration_MichealisMenten(0.961538461538461, 2.5, 0.8) diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index 29724af3a2..3234942625 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -109,7 +109,12 @@ def closest_spectral_locus_wavelength(xy, xy_n, xy_s, inverse=False): 'for "{0}" colour stimulus and "{1}" achromatic stimulus "xy" ' 'chromaticity coordinates!'.format(xy, xy_n)) - i_wl = np.argmin(scipy.spatial.distance.cdist(xy_wl, xy_s), axis=-1) + if np.__name__ == 'cupy': + i_wlnp = scipy.spatial.distance.cdist( + np.asnumpy(xy_wl), np.asnumpy(xy_s)) + i_wl = np.argmin(np.array(i_wlnp), axis=-1) + else: + i_wl = np.argmin(scipy.spatial.distance.cdist(xy_wl, xy_s), axis=-1) i_wl = np.reshape(i_wl, xy.shape[0:-1]) xy_wl = np.reshape(xy_wl, xy.shape) @@ -185,11 +190,11 @@ def dominant_wavelength(xy, xy = as_float_array(xy) xy_n = np.resize(xy_n, xy.shape) - xy_s = XYZ_to_xy(cmfs.values) + xy_s = XYZ_to_xy(np.array(cmfs.values)) i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, xy_s, inverse) xy_cwl = xy_wl - wl = cmfs.wavelengths[i_wl] + wl = np.array(cmfs.wavelengths)[i_wl] xy_e = (extend_line_segment(xy, xy_n) if inverse else extend_line_segment(xy_n, xy)) @@ -200,7 +205,7 @@ def dominant_wavelength(xy, i_wl_r, xy_cwl_r = closest_spectral_locus_wavelength( xy, xy_n, xy_s, not inverse) - wl_r = -cmfs.wavelengths[i_wl_r] + wl_r = -np.array(cmfs.wavelengths)[i_wl_r] wl = np.where(intersect, wl_r, wl) xy_cwl = np.where(intersect[..., np.newaxis], xy_cwl_r, xy_cwl) diff --git a/colour/colorimetry/generation.py b/colour/colorimetry/generation.py index a0cfaaa454..cfe1cb5795 100644 --- a/colour/colorimetry/generation.py +++ b/colour/colorimetry/generation.py @@ -94,7 +94,7 @@ def sd_constant(k, shape=SPECTRAL_SHAPE_DEFAULT, dtype=None): if dtype is None: dtype = DEFAULT_FLOAT_DTYPE - wavelengths = shape.range(dtype) + wavelengths = np.array(shape.range(dtype)) values = full(len(wavelengths), k, dtype) name = '{0} Constant'.format(k) @@ -204,7 +204,7 @@ def msds_constant(k, labels, shape=SPECTRAL_SHAPE_DEFAULT, dtype=None): if dtype is None: dtype = DEFAULT_FLOAT_DTYPE - wavelengths = shape.range(dtype) + wavelengths = np.array(shape.range(dtype)) values = full([len(wavelengths), len(labels)], k, dtype) name = '{0} Constant'.format(k) @@ -322,7 +322,7 @@ def sd_gaussian_normal(mu, sigma, shape=SPECTRAL_SHAPE_DEFAULT): 0.6065306... """ - wavelengths = shape.range() + wavelengths = np.array(shape.range()) values = np.exp(-(wavelengths - mu) ** 2 / (2 * sigma ** 2.)) @@ -368,7 +368,7 @@ def sd_gaussian_fwhm(peak_wavelength, fwhm, shape=SPECTRAL_SHAPE_DEFAULT): 0.3678794... """ - wavelengths = shape.range() + wavelengths = np.array(shape.range()) values = np.exp(-((wavelengths - peak_wavelength) / fwhm) ** 2) diff --git a/colour/colorimetry/illuminants.py b/colour/colorimetry/illuminants.py index 508cd3f478..2917f07c1f 100644 --- a/colour/colorimetry/illuminants.py +++ b/colour/colorimetry/illuminants.py @@ -290,7 +290,11 @@ def sd_CIE_illuminant_D_series(xy, M1_M2_rounding=True): S1 = SDS_ILLUMINANTS_D_SERIES['S1'] S2 = SDS_ILLUMINANTS_D_SERIES['S2'] - distribution = S0.values + M1 * S1.values + M2 * S2.values + S0Vals = np.array(S0.values) + S1Vals = np.array(S1.values) + S2Vals = np.array(S2.values) + + distribution = S0Vals + M1 * S1Vals + M2 * S2Vals return SpectralDistribution( distribution, diff --git a/colour/colorimetry/lefs.py b/colour/colorimetry/lefs.py index 3466ea9454..e458cbc1ad 100644 --- a/colour/colorimetry/lefs.py +++ b/colour/colorimetry/lefs.py @@ -542,9 +542,9 @@ def sd_mesopic_luminous_efficiency_function( sd_data = dict( zip( - wavelengths, + wavelengths.tolist(), mesopic_weighting_function(wavelengths, Lp, source, method, - photopic_lef, scotopic_lef))) + photopic_lef, scotopic_lef).tolist())) sd = SpectralDistribution( sd_data, name='{0} Lp Mesopic Luminous Efficiency Function'.format(Lp)) diff --git a/colour/colorimetry/photometry.py b/colour/colorimetry/photometry.py index ae9671417c..08d62bd3c0 100644 --- a/colour/colorimetry/photometry.py +++ b/colour/colorimetry/photometry.py @@ -118,8 +118,9 @@ def luminous_efficiency( }) sd = sd.copy() - efficiency = (np.trapz(lef.values * sd.values, sd.wavelengths) / np.trapz( - sd.values, sd.wavelengths)) + efficiency = (np.trapz( + np.array(lef.values) * np.array(sd.values), np.array(sd.wavelengths)) / + np.trapz(np.array(sd.values), np.array(sd.wavelengths))) return efficiency diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 12c839e1b9..3b8dbe3f42 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -773,7 +773,7 @@ def shape(self): 'using minimum interval!'.format(self.name))) return SpectralShape( - min(self.wavelengths), max(self.wavelengths), + as_float(min(self.wavelengths)), as_float(max(self.wavelengths)), as_float(min(wavelengths_interval))) def interpolate(self, diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index e26f0b4d5c..172a2b5d10 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -726,6 +726,7 @@ def __setitem__(self, x, y): else: x = np.atleast_1d(x).astype(self.dtype) y = np.resize(y, x.shape) + self._domain = np.array(self._domain) # Matching domain, updating existing `self._range` values. mask = np.in1d(x, self._domain) @@ -1019,6 +1020,8 @@ def arithmetical_operation(self, a, operation, in_place=False): [ 8. 280.] [ 9. 310.]] """ + self._domain = np.array(self._domain) + self._range = np.array(self._range) operation, ioperator = { '+': (add, iadd), diff --git a/colour/models/osa_ucs.py b/colour/models/osa_ucs.py index 1babf42514..fb7ee0c732 100644 --- a/colour/models/osa_ucs.py +++ b/colour/models/osa_ucs.py @@ -198,7 +198,11 @@ def OSA_UCS_to_XYZ(Ljg, optimisation_kwargs=None, **kwargs): 'ArgumentRenamed': [['optimisation_parameters', 'optimisation_kwargs'] ], }, **kwargs).get('optimisation_kwargs', optimisation_kwargs) - + cupy = False + if np.__name__ == 'cupy': + Ljg = np.asnumpy(Ljg) + np.set_ndimensional_array_backend('numpy') + cupy = True Ljg = to_domain_100(Ljg) shape = Ljg.shape Ljg = np.atleast_1d(Ljg.reshape([-1, 3])) @@ -223,5 +227,7 @@ def error_function(XYZ, Ljg): fmin(error_function, x_0, (Ljg_i, ), **optimisation_settings) for Ljg_i in Ljg ]) - + if cupy: + np.set_ndimensional_array_backend('cupy') + XYZ = np.array(XYZ) return from_range_100(XYZ.reshape(shape)) diff --git a/colour/models/rgb/cylindrical.py b/colour/models/rgb/cylindrical.py index e8dd48fa32..0c86d08672 100644 --- a/colour/models/rgb/cylindrical.py +++ b/colour/models/rgb/cylindrical.py @@ -171,14 +171,15 @@ def HSV_to_RGB(HSV): i = tstack([i, i, i]).astype(np.uint8) RGB = np.choose( - i, [ + i, + np.array([ tstack([V, l, j]), tstack([k, V, j]), tstack([j, V, l]), tstack([j, k, V]), tstack([l, j, V]), tstack([V, j, k]), - ], + ]), mode='clip') return from_range_1(RGB) diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index 425eb8eca0..fe49c299a4 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -190,11 +190,15 @@ def float_2_cv(x): return np.maximum(CV_min, np.minimum(CV_max, np.round(x))) + resized = np.full(lin_AP1.shape, CV_min) + + float2cv = float_2_cv((np.log2(lin_AP1) + constants.mid_log_offset) * + constants.steps_per_stop + constants.mid_CV_offset) + ACESproxy = np.where( lin_AP1 > 2 ** -9.72, - float_2_cv((np.log2(lin_AP1) + constants.mid_log_offset) * - constants.steps_per_stop + constants.mid_CV_offset), - np.resize(CV_min, lin_AP1.shape), + float2cv, + resized, ) if out_int: diff --git a/colour/models/rgb/transfer_functions/filmic_pro.py b/colour/models/rgb/transfer_functions/filmic_pro.py index 751e917546..f8dca81d1e 100644 --- a/colour/models/rgb/transfer_functions/filmic_pro.py +++ b/colour/models/rgb/transfer_functions/filmic_pro.py @@ -106,9 +106,9 @@ def _log_decoding_FilmicPro6_interpolator(): global _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE t = np.arange(0, 1, 0.0001) - if _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE is None: - _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = Extrapolator( - LinearInterpolator(log_encoding_FilmicPro6(t), t)) + # Turn from cupy to numpy and back creates an error + _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = Extrapolator( + LinearInterpolator(log_encoding_FilmicPro6(t), t)) return _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index a34df0899e..80e5ec91af 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -1084,7 +1084,9 @@ def ootf_HLG_BT2100_1(E, L_B=0, L_W=1000, gamma=None): alpha = L_W - L_B beta = L_B - Y_S = np.sum(WEIGHTS_BT2100_HLG * tstack([R_S, G_S, B_S]), axis=-1) + weights = np.array(WEIGHTS_BT2100_HLG) + + Y_S = np.sum(weights * tstack([R_S, G_S, B_S]), axis=-1) if gamma is None: gamma = gamma_function_HLG_BT2100(L_W) @@ -1166,7 +1168,9 @@ def ootf_HLG_BT2100_2(E, L_W=1000, gamma=None): alpha = L_W - Y_S = np.sum(WEIGHTS_BT2100_HLG * tstack([R_S, G_S, B_S]), axis=-1) + weights = np.array(WEIGHTS_BT2100_HLG) + + Y_S = np.sum(weights * tstack([R_S, G_S, B_S]), axis=-1) if gamma is None: gamma = gamma_function_HLG_BT2100(L_W) @@ -1336,7 +1340,9 @@ def ootf_inverse_HLG_BT2100_1(F_D, L_B=0, L_W=1000, gamma=None): else: R_D, G_D, B_D = tsplit(F_D) - Y_D = np.sum(WEIGHTS_BT2100_HLG * tstack([R_D, G_D, B_D]), axis=-1) + weights = np.array(WEIGHTS_BT2100_HLG) + + Y_D = np.sum(weights * tstack([R_D, G_D, B_D]), axis=-1) alpha = L_W - L_B beta = L_B @@ -1431,7 +1437,9 @@ def ootf_inverse_HLG_BT2100_2(F_D, L_W=1000, gamma=None): else: R_D, G_D, B_D = tsplit(F_D) - Y_D = np.sum(WEIGHTS_BT2100_HLG * tstack([R_D, G_D, B_D]), axis=-1) + weights = np.array(WEIGHTS_BT2100_HLG) + + Y_D = np.sum(weights * tstack([R_D, G_D, B_D]), axis=-1) alpha = L_W diff --git a/colour/ndarray/__init__.py b/colour/ndarray/__init__.py index 1fa491ef60..8de36066ce 100644 --- a/colour/ndarray/__init__.py +++ b/colour/ndarray/__init__.py @@ -14,4 +14,4 @@ def __getattr__(self, attribute): sys.modules['colour.ndarray'] = ndarray() -del NDimensionalArrayBackend, sys \ No newline at end of file +del NDimensionalArrayBackend, sys diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index 6ca65c5ca9..f73cc319ad 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -9,7 +9,6 @@ from __future__ import division, unicode_literals -import inspect import os import functools @@ -21,7 +20,7 @@ __status__ = 'Production' __all__ = [ - 'get_ndimensional_array_backend', 'set_ndimensional_array_backend', + 'get_ndimensional_array_backend', '_set_ndimensional_array_backend', 'ndimensional_array_backend', 'NDimensionalArrayBackend' ] @@ -50,12 +49,12 @@ def __init__(self, backend): self._previous_backend = get_ndimensional_array_backend() def __enter__(self): - set_ndimensional_array_backend(self._backend) + _set_ndimensional_array_backend(self._backend) return self def __exit__(self, *args): - set_ndimensional_array_backend(self._previous_backend) + _set_ndimensional_array_backend(self._previous_backend) def __call__(self, function): @functools.wraps(function) @@ -88,7 +87,11 @@ def __init__(self): pass def __getattr__(self, attribute): - failsafe = getattr(self._failsafe, attribute) + + try: + failsafe = getattr(self._failsafe, attribute) + except Exception: + failsafe = None if _NDIMENSIONAL_ARRAY_BACKEND == 'numpy': return getattr(self._numpy, attribute) @@ -99,21 +102,35 @@ def __getattr__(self, attribute): except AttributeError: return failsafe else: + def middleware(*args, **kwargs): args = list(args) for i in range(len(args)): if isinstance(args[i], self._cupy.ndarray): args[i] = self._cupy.asnumpy(args[i]) - args = tuple(args) - r = failsafe(*args,**kwargs) - print(type(r)) + else: + if isinstance(args[i], tuple): + args[i] = list(args[i]) + try: + for z in range(len(args[i])): + if isinstance(args[i][z], + self._cupy.ndarray): + arr = self._cupy.asnumpy(args[i][z]) + args[i][z] = arr + args[i] = tuple(args[i]) + except Exception: + pass + + args = tuple(args) + r = failsafe(*args, **kwargs) + if isinstance(r, self._numpy.ndarray): + return self._cupy.array(r) + elif isinstance(r, (list)): + for z in range(len(r)): if isinstance(r, self._numpy.ndarray): - return self._cupy.array(r) - elif isinstance(r, (list)): - for z in range(len(r)): - if isinstance(r, self._numpy.ndarray): - r[z] = self._cupy.array(r[z]) - return r + r[z] = self._cupy.array(r[z]) + return r + if callable(failsafe): return middleware else: diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index a7f8e800a3..75b9c4a69a 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import colour.ndarray as np +import numpy as np import unittest from itertools import permutations diff --git a/colour/utilities/__init__.py b/colour/utilities/__init__.py index af627c40dd..2468cbd09a 100644 --- a/colour/utilities/__init__.py +++ b/colour/utilities/__init__.py @@ -13,7 +13,7 @@ filter_mapping, first_item, get_domain_range_scale, set_domain_range_scale, domain_range_scale, to_domain_1, to_domain_10, to_domain_100, to_domain_degrees, to_domain_int, from_range_1, from_range_10, - from_range_100, from_range_degrees, from_range_int, set_ndimensional_array_backend) + from_range_100, from_range_degrees, from_range_int) from .array import ( as_array, as_int_array, as_float_array, as_numeric, as_int, as_float, set_float_precision, set_int_precision, as_namedtuple, closest_indexes, diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 1ebd93c328..84e050f5c6 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -447,7 +447,7 @@ def closest_indexes(a, b): """ a = np.ravel(a)[:, np.newaxis] - b = np.ravel(b)[np.newaxis, :] + b = np.ravel(np.array(b))[np.newaxis, :] return np.abs(a - b).argmin(axis=0) @@ -1227,7 +1227,7 @@ def ones(shape, dtype=None, order='C'): if dtype is None: dtype = DEFAULT_FLOAT_DTYPE - return np.ones(shape, dtype, order) + return np.ones(shape, dtype) def full(shape, fill_value, dtype=None, order='C'): diff --git a/colour/utilities/common.py b/colour/utilities/common.py index f12a2c85cd..ed05fe3b03 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -532,8 +532,8 @@ def is_integer(a): >>> is_integer(1.01) False """ - - return abs(a - np.around(a)) <= INTEGER_THRESHOLD + # FLOAT IS PLACEHOLDER + return abs(a - np.around(a)) <= float(INTEGER_THRESHOLD) def is_sibling(element, mapping): @@ -1446,22 +1446,3 @@ def from_range_int(a, bit_depth=8, dtype=None): a /= maximum_code_value / 100 return a - -def set_ndimensional_array_backend(backend): - """ - Changes the computation backend framework - - Parameters - ---------- - backend : string - possible values: "Numpy", "Cupy" - - - Returns - ------- - - Examples - -------- - - set_ndimensional_array_backend('Cupy') - """ - np.set_ndimensional_array_backend(backend) diff --git a/try.py b/try.py deleted file mode 100644 index 857b2f2e16..0000000000 --- a/try.py +++ /dev/null @@ -1,9 +0,0 @@ -import colour -from colour import read_image -import time -colour.utilities.set_ndimensional_array_backend('cupy') -RGB = read_image('testImage4K.jpg') -tim2 = time.time() -RGB2 = colour.models.RGB_to_HSL(RGB) -time2 = time.time()-tim2 -print(time2) From 9d2a1b9ec5326e64ea296e368bce251dd6291508 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Tue, 4 Aug 2020 01:30:25 +0200 Subject: [PATCH 05/17] Fixes for algebra, colorimetry, luts, notation, phenomena and quality sub modules --- colour/algebra/extrapolation.py | 10 +++++- colour/algebra/interpolation.py | 27 +++++++++++++-- colour/algebra/random.py | 3 +- colour/colorimetry/spectrum.py | 19 ++++++++--- colour/colorimetry/tristimulus.py | 28 +++++++++------- colour/geometry/vertices.py | 14 +++++++- colour/io/luts/cinespace_csp.py | 16 +++++++-- colour/io/luts/lut.py | 40 +++++++++++++++-------- colour/io/luts/sony_spi1d.py | 5 +++ colour/io/luts/sony_spi3d.py | 21 +++++++----- colour/notation/hexadecimal.py | 25 +++++++++++--- colour/notation/tests/test_hexadecimal.py | 20 +++++++----- colour/phenomena/rayleigh.py | 12 ++++--- colour/quality/cqs.py | 24 +++++++++----- colour/quality/cri.py | 4 +++ colour/quality/ssi.py | 12 +++++-- 16 files changed, 207 insertions(+), 73 deletions(-) diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 0d044be058..2fa782e8be 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -23,6 +23,7 @@ from colour.constants import DEFAULT_FLOAT_DTYPE from colour.utilities import as_float, is_numeric, is_string +from .interpolation import (CubicSplineInterpolator, PchipInterpolator) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -314,6 +315,13 @@ def _evaluate(self, x): y[x > xi[-1]] = self._right in_range = np.logical_and(x >= xi[0], x <= xi[-1]) - y[in_range] = self._interpolator(x[in_range]) + + instance_compare = isinstance( + self._interpolator, (CubicSplineInterpolator, PchipInterpolator)) + + if instance_compare and np.__name__ == 'cupy': + y[in_range] = np.array(self._interpolator(np.asnumpy(x[in_range]))) + else: + y[in_range] = self._interpolator(x[in_range]) return y diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 8cf6f9a8a9..2fe19ab801 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -1242,6 +1242,14 @@ class CubicSplineInterpolator(scipy.interpolate.interp1d): """ def __init__(self, *args, **kwargs): + + if np.__name__ == 'cupy': + args = list(args) + for i in range(len(args)): + if isinstance(args[i], np.ndarray): + args[i] = np.asnumpy(args[i]) + args = tuple(args) + super(CubicSplineInterpolator, self).__init__( kind='cubic', *args, **kwargs) @@ -1262,6 +1270,18 @@ class PchipInterpolator(scipy.interpolate.PchipInterpolator): """ def __init__(self, x, y, *args, **kwargs): + + if np.__name__ == 'cupy': + args = list(args) + for i in range(len(args)): + if isinstance(args[i], np.ndarray): + args[i] = np.asnumpy(args[i]) + args = tuple(args) + if isinstance(x, np.ndarray): + x = np.asnumpy(x) + if isinstance(y, np.ndarray): + y = np.asnumpy(y) + super(PchipInterpolator, self).__init__(x, y, *args, **kwargs) self._y = y @@ -1782,9 +1802,10 @@ def table_interpolation_trilinear(V_xyz, table): weights = np.moveaxis( np.transpose( - [(1 - x) * (1 - y) * (1 - z), (1 - x) * (1 - y) * z, - (1 - x) * y * (1 - z), (1 - x) * y * z, x * (1 - y) * (1 - z), - x * (1 - y) * z, x * y * (1 - z), x * y * z]), 0, -1) + np.array( + [(1 - x) * (1 - y) * (1 - z), (1 - x) * (1 - y) * z, + (1 - x) * y * (1 - z), (1 - x) * y * z, x * (1 - y) * (1 - z), + x * (1 - y) * z, x * y * (1 - z), x * y * z])), 0, -1) xyz_o = np.reshape(np.sum(vertices * weights, 1), V_xyz.shape) diff --git a/colour/algebra/random.py b/colour/algebra/random.py index 6ce304141d..a3882f12fd 100644 --- a/colour/algebra/random.py +++ b/colour/algebra/random.py @@ -84,7 +84,8 @@ def random_triplet_generator(size, if integer_size != size: runtime_warning( '"size" has been cast to integer: {0}'.format(integer_size)) - + integer_size = integer_size.item() + limits = np.array(limits) return tstack([ random_state.uniform(*limits[0], size=integer_size), random_state.uniform(*limits[1], size=integer_size), diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 3b8dbe3f42..fca2518cfd 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -1093,9 +1093,12 @@ def interpolate(self, round(self_shape.end) != self_shape.end): runtime_warning( 'Fractional bound encountered, rounding will occur!') - - shape.start = max(shape.start, np.ceil(self_shape.start)) - shape.end = min(shape.end, np.floor(self_shape.end)) + if np.__name__ == 'cupy': + shape.start = max(shape.start, np.ceil(self_shape.start).item()) + shape.end = min(shape.end, np.floor(self_shape.end).item()) + else: + shape.start = max(shape.start, np.ceil(self_shape.start)) + shape.end = min(shape.end, np.floor(self_shape.end)) if interpolator is None: # User has specifically chosen the interpolator thus it is used @@ -1121,7 +1124,13 @@ def interpolate(self, **interpolator_kwargs) self.domain = shape.range() - self.range = interpolator(self.domain) + + interpolator_compare = self.interpolator == CubicSplineInterpolator + + if interpolator_compare and np.__name__ == 'cupy': + self.range = np.array(interpolator(np.asnumpy(self.domain))) + else: + self.range = interpolator(self.domain) return self @@ -1465,6 +1474,8 @@ def trim(self, shape): [ 579. 0.1114554...] [ 580. 0.1128 ...]] """ + self.domain = np.array(self.domain) + self.values = np.array(self.values) start = max(shape.start, self.shape.start) end = min(shape.end, self.shape.end) diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 4e1548ad4f..8e3d34f570 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -488,9 +488,9 @@ def sd_to_XYZ_integration( sd.name, cmfs.name)) sd = sd.copy().align(cmfs.shape) - S = illuminant.values + S = np.array(illuminant.values) x_bar, y_bar, z_bar = tsplit(cmfs.values) - R = sd.values + R = np.array(sd.values) dw = cmfs.shape.interval @@ -1467,15 +1467,21 @@ def wavelength_to_XYZ(wavelength, >>> wavelength_to_XYZ(480.5, cmfs) # doctest: +ELLIPSIS array([ 0.0914287..., 0.1418350..., 0.7915726...]) """ - cmfs_shape = cmfs.shape - if (np.min(wavelength) < cmfs_shape.start or - np.max(wavelength) > cmfs_shape.end): - raise ValueError( - '"{0}nm" wavelength is not in "[{1}, {2}]" domain!'.format( - wavelength, cmfs_shape.start, cmfs_shape.end)) - - XYZ = np.reshape(cmfs[np.ravel(wavelength)], - as_float_array(wavelength).shape + (3, )) + if np.__name__ == 'cupy' and not (isinstance(wavelength, np.ndarray)): + if (wavelength < cmfs_shape.start or wavelength > cmfs_shape.end): + raise ValueError( + '"{0}nm" wavelength is not in "[{1}, {2}]" domain!'.format( + wavelength, cmfs_shape.start, cmfs_shape.end)) + XYZ = np.reshape(cmfs[wavelength], + as_float_array(wavelength).shape + (3, )) + else: + if (np.min(wavelength) < cmfs_shape.start or + np.max(wavelength) > cmfs_shape.end): + raise ValueError( + '"{0}nm" wavelength is not in "[{1}, {2}]" domain!'.format( + wavelength, cmfs_shape.start, cmfs_shape.end)) + XYZ = np.reshape(cmfs[np.ravel(wavelength)], + as_float_array(wavelength).shape + (3, )) return XYZ diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index f526ffee38..b7fa19b904 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -78,6 +78,10 @@ def primitive_vertices_quad_mpl(width=1, u, v = tsplit(origin) + if not (isinstance(u, np.float64)): + u = u.item() + v = v.item() + if axis == '+z': vertices = ((u, v, depth), (u + width, v, depth), (u + width, v + height, depth), (u, v + height, depth)) @@ -156,6 +160,10 @@ def primitive_vertices_grid_mpl(width=1, u, v = tsplit(origin) + if not (isinstance(u, np.float64)): + u = u.item() + v = v.item() + w_x, h_y = width / width_segments, height / height_segments quads = [] @@ -248,6 +256,10 @@ def primitive_vertices_cube_mpl(width=1, u, v, w = tsplit(origin) + if not (isinstance(u, np.float64)): + u = u.item() + v = v.item() + w_s, h_s, d_s = width_segments, height_segments, depth_segments grids = [] @@ -386,7 +398,7 @@ def primitive_vertices_sphere(radius=0.5, raise ValueError('Axis must be one of "{0}"!'.format( ['+x', '+y', '+z'])) - vertices += origin + vertices += np.array(origin) return vertices diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index bcf3c1bb16..7bd6824d15 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -167,7 +167,13 @@ def _parse_table_section(lines): if (is_3D and pre_LUT.shape == (6, 2) and np.array_equal( pre_LUT.reshape(3, 4).transpose()[2:4], unity_range)): - table = table.reshape([size[0], size[1], size[2], 3], order='F') + if np.__name__ == 'cupy': + table = table.reshape( + [size[0].item(), size[1].item(), size[2].item(), 3], + order='F') + else: + table = table.reshape( + [size[0], size[1], size[2], 3], order='F') LUT = LUT3D( domain=pre_LUT.reshape(3, 4).transpose()[0:2], name=title, @@ -190,7 +196,13 @@ def _parse_table_section(lines): pre_table = tstack((pre_LUT[1], pre_LUT[3], pre_LUT[5])) shaper_name = '{0} - Shaper'.format(title) cube_name = '{0} - Cube'.format(title) - table = table.reshape([size[0], size[1], size[2], 3], order='F') + if np.__name__ == 'cupy': + table = table.reshape( + [size[0].item(), size[1].item(), size[2].item(), 3], + order='F') + else: + table = table.reshape( + [size[0], size[1], size[2], 3], order='F') LUT_A = LUT3x1D(pre_table, shaper_name, pre_domain) LUT_B = LUT3D(table, cube_name, comments=comments) diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index cb03db94fb..3bc409fe14 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -1308,10 +1308,16 @@ def linear_table(size=10, domain=np.array([[0, 0, 0], [1, 1, 1]])): R, G, B = tsplit(domain) - samples = [ - np.linspace(a[0], a[1], size[i]) - for i, a in enumerate([R, G, B]) - ] + if np.__name__ == 'cupy': + samples = [ + np.linspace(a[0].item(), a[1].item(), size[i].item()) + for i, a in enumerate([B, G, R]) + ] + else: + samples = [ + np.linspace(a[0], a[1], size[i]) + for i, a in enumerate([R, G, B]) + ] if not len(np.unique(size)) == 1: runtime_warning('Table is non uniform, axis will be ' @@ -1791,16 +1797,24 @@ def linear_table(size=33, domain=np.array([[0, 0, 0], [1, 1, 1]])): size = np.tile(size, 3) R, G, B = tsplit(domain) + if np.__name__ == 'cupy': + samples = [ + np.linspace(a[0].item(), a[1].item(), size[i].item()) + for i, a in enumerate([B, G, R]) + ] + else: + samples = [ + np.linspace(a[0], a[1], size[i]) + for i, a in enumerate([B, G, R]) + ] - size = np.flip(size, -1) - samples = [ - np.linspace(a[0], a[1], size[i]) - for i, a in enumerate([B, G, R]) - ] - - table = np.meshgrid(*samples, indexing='ij') - table = np.flip( - np.transpose(table).reshape(np.hstack([np.flip(size, -1), 3])), -1) + table = np.array(np.meshgrid(*samples, indexing='ij')) + if np.__name__ == 'cupy': + table_tuple = tuple(np.asnumpy(np.hstack([np.flip(size, -1), 3]))) + table = np.flip(np.transpose(table).reshape(table_tuple), -1) + else: + hstack = np.hstack([np.flip(size, -1), 3]) + table = np.flip(np.transpose(table).reshape(hstack), -1) return table diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index 838948f40e..4827adb323 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -110,6 +110,11 @@ def read_LUT_SonySPI1D(path): table.append(tokens) table = as_float_array(table) + + if np.__name__ == 'cupy': + domain_min = domain_min.item() + domain_max = domain_max.item() + if dimensions == 1: return LUT1D( np.squeeze(table), diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 05cb27429b..30b962bb09 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -97,14 +97,19 @@ def read_LUT_SonySPI3D(path): indexes.append(as_int_array(tokens[:3])) table.append(as_float_array(tokens[3:])) - indexes = as_int_array(indexes) - sorting_indexes = np.lexsort((indexes[:, 2], indexes[:, 1], indexes[:, 0])) - - assert np.array_equal( - indexes[sorting_indexes], - DEFAULT_INT_DTYPE(np.around( - LUT3D.linear_table(size) * (size - 1))).reshape( - (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' + if np.__name__ == 'cupy': + assert np.array_equal( + indexes, + np.array( + np.around(LUT3D.linear_table(size) * (size - 1)), + dtype=np.int64).reshape( + (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' + else: + assert np.array_equal( + indexes, + DEFAULT_INT_DTYPE( + np.around(LUT3D.linear_table(size) * (size - 1))).reshape( + (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' table = as_float_array(table)[sorting_indexes].reshape( [size, size, size, 3]) diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 0c57f3b3a3..ef4fdc2ce7 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -73,11 +73,18 @@ def RGB_to_HEX(RGB): 'unpredictable results may occur!') RGB = eotf_inverse_sRGB(normalise_maximum(eotf_sRGB(RGB))) - - to_HEX = np.vectorize('{0:02x}'.format) - - HEX = to_HEX((RGB * 255).astype(np.uint8)).astype(object) - HEX = np.asarray('#') + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] + if np.__name__ == 'cupy': + RGB = np.asnumpy(RGB) + np.set_ndimensional_array_backend('numpy') + to_HEX = np.vectorize('{0:02x}'.format) + HEX = to_HEX((RGB * 255).astype(np.uint8)).astype(object) + HEX = np.asarray('#') + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] + np.set_ndimensional_array_backend('cupy') + else: + to_HEX = np.vectorize('{0:02x}'.format) + + HEX = to_HEX((RGB * 255).astype(np.uint8)).astype(object) + HEX = np.asarray('#') + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] return HEX @@ -111,6 +118,10 @@ def HEX_to_RGB(HEX): >>> HEX_to_RGB(HEX) # doctest: +ELLIPSIS array([ 0.6666666..., 0.8666666..., 1. ]) """ + cupy = False + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') HEX = np.core.defchararray.lstrip(HEX, '#') @@ -126,4 +137,8 @@ def to_RGB(x): RGB = as_float_array(to_RGB_v(HEX).tolist()) / 255 + if cupy is True: + np.set_ndimensional_array_backend('cupy') + RGB = np.array(RGB) + return from_range_1(RGB) diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index bef2e0dd1a..e49388ddd4 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -6,11 +6,13 @@ from __future__ import division, unicode_literals import colour.ndarray as np +import numpy import unittest from itertools import permutations from colour.notation.hexadecimal import (RGB_to_HEX, HEX_to_RGB) from colour.utilities import domain_range_scale, ignore_numpy_errors +np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -45,7 +47,7 @@ def test_RGB_to_HEX(self): RGB_to_HEX(np.array([1.00000000, 1.00000000, 1.00000000])), '#ffffff') - np.testing.assert_equal( + np.testing.assert_array_equal( RGB_to_HEX( np.array([ [10.00000000, 1.00000000, 1.00000000], @@ -63,7 +65,7 @@ def test_n_dimensional_RGB_to_HEX(self): HEX = RGB_to_HEX(RGB) RGB = np.tile(RGB, (6, 1)) - HEX = np.tile(HEX, 6) + HEX = numpy.tile(HEX, 6) self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist()) RGB = np.reshape(RGB, (2, 3, 3)) @@ -109,17 +111,17 @@ def test_HEX_to_RGB(self): Tests :func:`colour.notation.hexadecimal.HEX_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HEX_to_RGB('#74070a'), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=2) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HEX_to_RGB('#000000'), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=2) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HEX_to_RGB('#ffffff'), np.array([1.00000000, 1.00000000, 1.00000000]), decimal=2) @@ -133,13 +135,13 @@ def test_n_dimensional_HEX_to_RGB(self): HEX = '#74070a' RGB = HEX_to_RGB(HEX) - HEX = np.tile(HEX, 6) + HEX = numpy.tile(HEX, 6) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(HEX_to_RGB(HEX), RGB, decimal=2) + np.testing.assert_array_almost_equal(HEX_to_RGB(HEX), RGB, decimal=2) HEX = np.reshape(HEX, (2, 3)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(HEX_to_RGB(HEX), RGB, decimal=2) + np.testing.assert_array_almost_equal(HEX_to_RGB(HEX), RGB, decimal=2) def test_domain_range_scale_HEX_to_RGB(self): """ @@ -153,7 +155,7 @@ def test_domain_range_scale_HEX_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HEX_to_RGB(HEX), RGB * factor, decimal=2) diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index 69ae2e4242..0ace5da868 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -432,7 +432,8 @@ def molecular_density(temperature=CONSTANT_STANDARD_AIR_TEMPERATURE, >>> molecular_density(288.15, 6.0221367e23) # doctest: +ELLIPSIS 2.5468999...e+19 """ - + if not (isinstance(avogadro_constant, np.ndarray)): + avogadro_constant = float(avogadro_constant) T = as_float_array(temperature) N_s = (avogadro_constant / 22.4141) * (273.15 / T) * (1 / 1000) @@ -563,7 +564,8 @@ def scattering_cross_section( >>> scattering_cross_section(555 * 10e-8) # doctest: +ELLIPSIS 4.6613309...e-27 """ - + if not (isinstance(avogadro_constant, np.ndarray)): + avogadro_constant = float(avogadro_constant) wl = as_float_array(wavelength) CO2_c = as_float_array(CO2_concentration) temperature = as_float_array(temperature) @@ -640,7 +642,8 @@ def rayleigh_optical_depth( >>> rayleigh_optical_depth(555 * 10e-8) # doctest: +ELLIPSIS 0.1004070... """ - + if not (isinstance(avogadro_constant, np.ndarray)): + avogadro_constant = float(avogadro_constant) wavelength = as_float_array(wavelength) CO2_c = as_float_array(CO2_concentration) latitude = as_float_array(latitude) @@ -1138,7 +1141,8 @@ def sd_rayleigh_scattering( extrapolator=Extrapolator, extrapolator_kwargs={...}) """ - + if not (isinstance(avogadro_constant, np.ndarray)): + avogadro_constant = float(avogadro_constant) wavelengths = shape.range() return SpectralDistribution( data=dict( diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 6fbe2e46c9..d79715fe20 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -233,10 +233,17 @@ def colour_quality_scale(sd_test, additional_data=False, if method == 'nist cqs 9.0': Q_d = Q_p = None else: - p_delta_C = np.average([ - sample_data.D_C_ab if sample_data.D_C_ab > 0 else 0 - for sample_data in Q_as.values() - ]) + if np.__name__ == 'cupy': + p_delta_C = np.average( + np.array([ + sample_data.D_C_ab.item() if sample_data.D_C_ab > 0 else 0 + for sample_data in Q_as.values() + ])) + else: + p_delta_C = np.average([ + sample_data.D_C_ab if sample_data.D_C_ab > 0 else 0 + for sample_data in Q_as.values() + ]) Q_p = 100 - 3.6 * (D_Ep_RMS - p_delta_C) Q_d = G_t / G_r * CCT_f * 100 @@ -433,10 +440,11 @@ def delta_E_RMS(cqs_data, attribute): Root-mean-square average. """ - return np.sqrt(1 / len(cqs_data) * np.sum([ - getattr(sample_data, attribute) ** 2 - for sample_data in cqs_data.values() - ])) + return np.sqrt(1 / len(cqs_data) * np.sum( + np.array([ + getattr(sample_data, attribute) ** 2 + for sample_data in cqs_data.values() + ]))) def colour_quality_scales(test_data, reference_data, scaling_f, CCT_f): diff --git a/colour/quality/cri.py b/colour/quality/cri.py index 073aba1385..0174d52b6c 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -221,6 +221,10 @@ def d(x, y): U_tcs = 13 * W_tcs * (u_tcs - u_r) V_tcs = 13 * W_tcs * (v_tcs - v_r) + if np.__name__ == 'cupy': + U_tcs = U_tcs.item() + V_tcs = V_tcs.item() + tcs_data.append( TCS_ColorimetryData(sd_tcs.name, XYZ_tcs, uv_tcs, np.array([U_tcs, V_tcs, W_tcs]))) diff --git a/colour/quality/ssi.py b/colour/quality/ssi.py index c5af22caae..047c97fc39 100644 --- a/colour/quality/ssi.py +++ b/colour/quality/ssi.py @@ -106,11 +106,17 @@ def spectral_similarity_index(sd_test, sd_reference): d_i = test_i - reference_i dr_i = d_i / (reference_i + np.mean(reference_i)) - wdr_i = dr_i * [ + wdr_i = dr_i * np.array([ 12 / 45, 22 / 45, 32 / 45, 40 / 45, 44 / 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11 / 15, 3 / 15 - ] - c_wdr_i = convolve1d(np.hstack([0, wdr_i, 0]), [0.22, 0.56, 0.22]) + ]) + + if np.__name__ == 'cupy': + numpy_c_wdr_i = convolve1d( + np.asnumpy(np.hstack([0, wdr_i, 0])), [0.22, 0.56, 0.22]) + c_wdr_i = np.array(numpy_c_wdr_i) + else: + c_wdr_i = convolve1d(np.hstack([0, wdr_i, 0]), [0.22, 0.56, 0.22]) m_v = np.sum(c_wdr_i ** 2) SSI = np.around(100 - 32 * np.sqrt(m_v)) From 5440c56ea1bc85100bc63a0419d29cd6c588e865 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Fri, 7 Aug 2020 12:03:32 +0200 Subject: [PATCH 06/17] Fixes for the volume, luts, colorimetry, blindness and characterisation module --- colour/blindness/machado2009.py | 11 ++++++++++ colour/characterisation/aces_it.py | 34 ++++++++++++++++++++++++++---- colour/colorimetry/tristimulus.py | 4 ++-- colour/io/luts/cinespace_csp.py | 7 ++++++ colour/io/luts/iridas_cube.py | 24 +++++++++++++++------ colour/io/luts/resolve_cube.py | 8 +++++++ colour/io/luts/sony_spi1d.py | 25 ++++++++++++++++------ colour/io/luts/sony_spi3d.py | 24 ++++++++++++++++----- colour/volume/macadam_limits.py | 18 ++++++++++++---- colour/volume/mesh.py | 11 ++++++++++ 10 files changed, 138 insertions(+), 28 deletions(-) diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index c5ba22d435..110a8ae8f3 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -333,6 +333,12 @@ def cvd_matrix_Machado2009(deficiency, severity): '[5, 59] contrary to the domain [0, 20] used for protanomaly and ' 'deuteranomaly simulation.') + cupy = False + + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') + matrices = CVD_MATRICES_MACHADO2010[deficiency] samples = np.array(sorted(matrices.keys())) index = min(np.searchsorted(samples, severity), len(samples) - 1) @@ -342,6 +348,11 @@ def cvd_matrix_Machado2009(deficiency, severity): m1, m2 = matrices[a], matrices[b] + if cupy is True: + np.set_ndimensional_array_backend('cupy') + m1 = np.array(m1) + m2 = np.array(m2) + if a == b: # 1.0 severity CVD matrix, returning directly. return m1 diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 4d320f773b..07cca5d857 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -67,7 +67,7 @@ from colour.temperature import CCT_to_xy_CIE_D from colour.utilities import (CaseInsensitiveMapping, as_float_array, dot_vector, from_range_1, runtime_warning, - tsplit, suppress_warnings) + tsplit, suppress_warnings, as_int_array) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -317,8 +317,20 @@ def generate_illuminants_rawtoaces_v1(): CCT = i * 1.4388 / 1.4380 xy = CCT_to_xy_CIE_D(CCT) sd = sd_CIE_illuminant_D_series(xy) +<<<<<<< HEAD sd.name = 'D{0:d}'.format(DEFAULT_INT_DTYPE(CCT / 100)) illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES) +======= + if np.__name__ == 'cupy': + cctInt = as_int_array(CCT / 100) + cctInt = np.asnumpy(cctInt) + np.set_ndimensional_array_backend('numpy') + sd.name = 'D{0:d}'.format(cctInt) + np.set_ndimensional_array_backend('cupy') + else: + sd.name = 'D{0:d}'.format(DEFAULT_INT_DTYPE(CCT / 100)) + illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES) +>>>>>>> Fixes for the volume, luts, colorimetry, blindness and characterisation module # TODO: Remove when removing the "colour.sd_blackbody" definition # warning. @@ -380,7 +392,9 @@ def white_balance_multipliers(sensitivities, illuminant): illuminant = illuminant.copy().align(shape) RGB_w = 1 / np.sum( - sensitivities.values * illuminant.values[..., np.newaxis], axis=0) + np.array(sensitivities.values) * np.array( + illuminant.values)[..., np.newaxis], + axis=0) RGB_w *= 1 / np.min(RGB_w) return RGB_w @@ -810,8 +824,20 @@ def idt_matrix(sensitivities, if optimisation_kwargs is not None: optimisation_settings.update(optimisation_kwargs) + cupy = False + XYZoptimization = XYZ_to_optimization_colour_model(XYZ) + if np.__name__ == 'cupy': + RGB = np.asnumpy(RGB) + XYZoptimization = np.asnumpy(XYZoptimization) + np.set_ndimensional_array_backend('numpy') + cupy = True + M = minimize(objective_function, np.ravel(np.identity(3)), - (RGB, XYZ_to_optimization_colour_model(XYZ)), - **optimisation_settings).x.reshape([3, 3]) + (RGB, XYZoptimization), **optimisation_settings).x.reshape( + [3, 3]) + + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return np.array(M) return M diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 8e3d34f570..1151ab37bc 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -1085,9 +1085,9 @@ class instance or an *array_like* in which case the ``shape`` must be illuminant.name, shape)) illuminant = illuminant.copy().align(shape) - S = illuminant.values + S = np.array(illuminant.values) x_bar, y_bar, z_bar = tsplit(cmfs.values) - dw = cmfs.shape.interval + dw = np.array(cmfs.shape.interval) k = 100 / (np.sum(y_bar * S) * dw) if k is None else k diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 7bd6824d15..1e23be00af 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -274,6 +274,10 @@ def write_LUT_Cinespace(LUT, path, decimals=7): ... comments=['A first comment.', 'A second comment.']) >>> write_LUT_Cinespace(LUT, 'My_LUT.cube') # doctest: +SKIP """ + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True has_3D, has_3x1D, non_uniform = False, False, False @@ -431,4 +435,7 @@ def _format_tuple(array): for row in table: csp_file.write('{0}\n'.format(_format_array(row))) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return True diff --git a/colour/io/luts/iridas_cube.py b/colour/io/luts/iridas_cube.py index b40045ead1..4949f10b6e 100644 --- a/colour/io/luts/iridas_cube.py +++ b/colour/io/luts/iridas_cube.py @@ -227,6 +227,15 @@ def write_LUT_IridasCube(LUT, path, decimals=7): else: assert 2 <= size <= 256, '"LUT" size must be in domain [2, 256]!' + domain = LUT.domain + table = LUT.table + cupy = False + if np.__name__ == 'cupy': + domain = np.asnumpy(domain) + table = np.asnumpy(table) + np.set_ndimensional_array_backend('numpy') + cupy = True + def _format_array(array): """ Formats given array as an *Iridas* *.cube* data row. @@ -242,21 +251,24 @@ def _format_array(array): cube_file.write('# {0}\n'.format(comment)) cube_file.write('{0} {1}\n'.format( - 'LUT_1D_SIZE' if is_3x1D else 'LUT_3D_SIZE', LUT.table.shape[0])) + 'LUT_1D_SIZE' if is_3x1D else 'LUT_3D_SIZE', table.shape[0])) default_domain = np.array([[0, 0, 0], [1, 1, 1]]) - if not np.array_equal(LUT.domain, default_domain): + if not np.array_equal(domain, default_domain): cube_file.write('DOMAIN_MIN {0}\n'.format( - _format_array(LUT.domain[0]))) + _format_array(domain[0]))) cube_file.write('DOMAIN_MAX {0}\n'.format( - _format_array(LUT.domain[1]))) + _format_array(domain[1]))) if not is_3x1D: - table = LUT.table.reshape([-1, 3], order='F') + table = table.reshape([-1, 3], order='F') else: - table = LUT.table + table = table for row in table: cube_file.write('{0}\n'.format(_format_array(row))) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return True diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index b2b08a623a..4d78850f31 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -272,6 +272,11 @@ def write_LUT_ResolveCube(LUT, path, decimals=7): >>> write_LUT_ResolveCube(LUT_sequence, 'My_LUT.cube') # doctest: +SKIP """ + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True + has_3D, has_3x1D = False, False if isinstance(LUT, LUTSequence): @@ -366,4 +371,7 @@ def _format_tuple(array): for row in table: cube_file.write('{0}\n'.format(_format_array(row))) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return True diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index 4827adb323..fa77fd0941 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -191,10 +191,18 @@ def write_LUT_SonySPI1D(LUT, path, decimals=7): is_1D = isinstance(LUT, LUT1D) - if is_1D: - domain = LUT.domain - else: - domain = np.unique(LUT.domain) + domain = LUT.domain + table = LUT.table + cupy = False + + if np.__name__ == 'cupy': + domain = np.asnumpy(domain) + table = np.asnumpy(table) + np.set_ndimensional_array_backend('numpy') + cupy = True + + if not (is_1D): + domain = np.unique(domain) assert len(domain) == 2, 'Non-uniform "LUT" domain is unsupported!' @@ -211,13 +219,13 @@ def _format_array(array): spi1d_file.write('From {1:0.{0}f} {2:0.{0}f}\n'.format( decimals, *domain)) - spi1d_file.write('Length {0}\n'.format(LUT.table.size if is_1D else - LUT.table.shape[0])) + spi1d_file.write( + 'Length {0}\n'.format(table.size if is_1D else table.shape[0])) spi1d_file.write('Components {0}\n'.format(1 if is_1D else 3)) spi1d_file.write('{\n') - for row in LUT.table: + for row in table: if is_1D: spi1d_file.write(' {1:0.{0}f}\n'.format(decimals, row)) else: @@ -228,4 +236,7 @@ def _format_array(array): for comment in LUT.comments: spi1d_file.write('# {0}\n'.format(comment)) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return True diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 30b962bb09..6425e605c2 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -164,7 +164,19 @@ def write_LUT_SonySPI3D(LUT, path, decimals=7): assert isinstance(LUT, LUT3D), '"LUT" must be either a 3D "LUT"!' - assert np.array_equal(LUT.domain, np.array([ + domain = LUT.domain + table = LUT.table + indexTable = LUT.linear_table(LUT.size) + + cupy = False + if np.__name__ == 'cupy': + domain = np.asnumpy(domain) + table = np.asnumpy(table) + indexTable = np.asnumpy(indexTable) + np.set_ndimensional_array_backend('numpy') + cupy = True + + assert np.array_equal(domain, np.array([ [0, 0, 0], [1, 1, 1], ])), '"LUT" domain must be [[0, 0, 0], [1, 1, 1]]!' @@ -184,10 +196,9 @@ def _format_array(array): spi3d_file.write('{0} {0} {0}\n'.format(LUT.size)) - indexes = DEFAULT_INT_DTYPE( - np.around(LUT.linear_table(LUT.size) * (LUT.size - 1))).reshape( - [-1, 3]) - table = LUT.table.reshape([-1, 3]) + indexes = DEFAULT_INT_DTYPE(np.around( + indexTable * (LUT.size - 1))).reshape([-1, 3]) + table = table.reshape([-1, 3]) for i, row in enumerate(indexes): spi3d_file.write('{0}\n'.format( @@ -197,4 +208,7 @@ def _format_array(array): for comment in LUT.comments: spi3d_file.write('# {0}\n'.format(comment)) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return True diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index 38de897703..9920c2a700 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -99,10 +99,20 @@ def is_within_macadam_limits(xyY, illuminant, tolerance=None): triangulation = _CACHE_OPTIMAL_COLOUR_STIMULI_XYZ_TRIANGULATIONS.get( illuminant) if triangulation is None: - _CACHE_OPTIMAL_COLOUR_STIMULI_XYZ_TRIANGULATIONS[illuminant] = \ - triangulation = Delaunay(optimal_colour_stimuli) - - simplex = triangulation.find_simplex(xyY_to_XYZ(xyY), tol=tolerance) + if np.__name__ == 'cupy': + _CACHE_OPTIMAL_COLOUR_STIMULI_XYZ_TRIANGULATIONS[illuminant]\ + = triangulation = \ + Delaunay(np.asnumpy(optimal_colour_stimuli)) + else: + _CACHE_OPTIMAL_COLOUR_STIMULI_XYZ_TRIANGULATIONS[illuminant] = \ + triangulation = Delaunay(optimal_colour_stimuli) + + if np.__name__ == 'cupy': + xyz = np.asnumpy(xyY_to_XYZ(xyY)) + simplex = triangulation.find_simplex(xyz, tol=tolerance) + simplex = np.array(simplex) + else: + simplex = triangulation.find_simplex(xyY_to_XYZ(xyY), tol=tolerance) simplex = np.where(simplex >= 0, True, False) return simplex diff --git a/colour/volume/mesh.py b/colour/volume/mesh.py index bb10984bda..56450d773b 100644 --- a/colour/volume/mesh.py +++ b/colour/volume/mesh.py @@ -56,10 +56,21 @@ def is_within_mesh_volume(points, mesh, tolerance=None): >>> is_within_mesh_volume(a, mesh) array([ True, False], dtype=bool) """ + cupy = False + if np.__name__ == 'cupy': + cupy = True + points = np.asnumpy(points) + mesh = np.asnumpy(mesh) + np.set_ndimensional_array_backend('numpy') triangulation = Delaunay(mesh) simplex = triangulation.find_simplex(points, tol=tolerance) + + if cupy is True: + np.set_ndimensional_array_backend('cupy') + simplex = np.array(simplex) + simplex = np.where(simplex >= 0, True, False) return simplex From 43f64c87a72a7b7a86fc75d2b34110a2d3a3e53e Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Tue, 11 Aug 2020 17:31:22 +0200 Subject: [PATCH 07/17] Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube --- colour/adaptation/tests/test_cie1994.py | 14 +- colour/adaptation/tests/test_cmccat2000.py | 28 +-- colour/adaptation/tests/test_fairchild1990.py | 14 +- colour/adaptation/tests/test_vonkries.py | 36 +-- colour/algebra/geometry.py | 21 +- colour/algebra/interpolation.py | 16 +- colour/algebra/regression.py | 13 + colour/algebra/tests/test_common.py | 6 +- colour/algebra/tests/test_extrapolation.py | 12 +- colour/algebra/tests/test_geometry.py | 32 +-- colour/algebra/tests/test_interpolation.py | 106 ++++---- colour/algebra/tests/test_random.py | 2 +- colour/algebra/tests/test_regression.py | 4 +- colour/appearance/ciecam02.py | 13 +- colour/biochemistry/michaelis_menten.py | 13 +- .../tests/test_michaelis_menten.py | 12 +- colour/blindness/tests/test_machado2009.py | 24 +- colour/characterisation/aces_it.py | 5 - colour/characterisation/correction.py | 3 + colour/characterisation/tests/test_aces_it.py | 26 +- .../characterisation/tests/test_correction.py | 44 ++-- colour/colorimetry/dominant.py | 5 +- colour/colorimetry/luminance.py | 30 ++- colour/colorimetry/spectrum.py | 2 +- colour/colorimetry/tests/test_blackbody.py | 6 +- colour/colorimetry/tests/test_correction.py | 2 +- colour/colorimetry/tests/test_dominant.py | 86 ++++--- colour/colorimetry/tests/test_generation.py | 18 +- colour/colorimetry/tests/test_illuminants.py | 6 +- colour/colorimetry/tests/test_lefs.py | 11 +- colour/colorimetry/tests/test_lightness.py | 59 +++-- colour/colorimetry/tests/test_luminance.py | 59 +++-- colour/colorimetry/tests/test_spectrum.py | 24 +- .../colorimetry/tests/test_transformations.py | 30 +-- colour/colorimetry/tests/test_tristimulus.py | 127 +++++----- colour/colorimetry/tests/test_whiteness.py | 56 +++-- colour/colorimetry/tests/test_yellowness.py | 16 +- colour/colorimetry/whiteness.py | 41 ++- colour/continuous/multi_signals.py | 6 + colour/continuous/signal.py | 12 + colour/continuous/tests/test_multi_signal.py | 80 +++--- colour/continuous/tests/test_signal.py | 74 +++--- colour/contrast/tests/test_barten1999.py | 76 +++--- colour/corresponding/datasets/breneman1987.py | 21 +- colour/corresponding/tests/test_prediction.py | 20 +- colour/difference/delta_e.py | 18 ++ colour/difference/tests/test__init__.py | 2 +- colour/difference/tests/test_cam02_ucs.py | 4 +- colour/difference/tests/test_delta_e.py | 24 +- colour/difference/tests/test_din99.py | 6 +- colour/geometry/primitives.py | 4 +- colour/geometry/tests/test_primitives.py | 60 ++--- colour/geometry/tests/test_vertices.py | 54 ++-- colour/graph/tests/test_conversion.py | 12 +- colour/io/luts/lut.py | 26 +- colour/io/luts/resolve_cube.py | 18 +- colour/io/luts/tests/test__init__.py | 4 +- colour/io/luts/tests/test_cinespace_csp.py | 7 +- colour/io/luts/tests/test_iridas_cube.py | 2 +- colour/io/luts/tests/test_lut.py | 89 +++---- colour/io/luts/tests/test_resolve_cube.py | 4 +- colour/io/luts/tests/test_sony_spi1d.py | 2 +- colour/io/luts/tests/test_sony_spi3d.py | 2 +- colour/io/tests/test_ies_tm2714.py | 2 +- colour/io/tests/test_image.py | 12 +- colour/models/hdr_cie_lab.py | 15 +- colour/models/rgb/derivation.py | 4 +- colour/models/rgb/tests/test_cmyk.py | 48 ++-- colour/models/rgb/tests/test_common.py | 24 +- colour/models/rgb/tests/test_cylindrical.py | 48 ++-- colour/models/rgb/tests/test_derivation.py | 39 +-- colour/models/rgb/tests/test_ictcp.py | 28 ++- colour/models/rgb/tests/test_prismatic.py | 24 +- .../models/rgb/tests/test_rgb_colourspace.py | 76 +++--- colour/models/rgb/tests/test_ycbcr.py | 54 ++-- .../models/rgb/transfer_functions/cineon.py | 20 +- .../models/rgb/transfer_functions/common.py | 10 +- .../rgb/transfer_functions/filmic_pro.py | 18 +- .../rgb/transfer_functions/fujifilm_flog.py | 3 + colour/models/rgb/transfer_functions/gopro.py | 20 +- .../rgb/transfer_functions/itur_bt_1886.py | 20 +- .../rgb/transfer_functions/itur_bt_2100.py | 8 +- .../models/rgb/transfer_functions/panalog.py | 20 +- .../rgb/transfer_functions/panasonic_vlog.py | 6 + .../rgb/transfer_functions/pivoted_log.py | 20 +- .../models/rgb/transfer_functions/red_log.py | 78 +++++- .../rgb/transfer_functions/sony_slog.py | 3 + .../models/rgb/transfer_functions/st_2084.py | 3 + .../transfer_functions/tests/test__init__.py | 2 +- .../rgb/transfer_functions/tests/test_aces.py | 52 ++-- .../tests/test_arib_std_b67.py | 19 +- .../tests/test_arri_alexa_log_c.py | 22 +- .../tests/test_canon_log.py | 48 ++-- .../transfer_functions/tests/test_cineon.py | 22 +- .../transfer_functions/tests/test_common.py | 16 +- .../rgb/transfer_functions/tests/test_dcdm.py | 16 +- .../tests/test_dicom_gsdf.py | 19 +- .../transfer_functions/tests/test_dji_dlog.py | 22 +- .../transfer_functions/tests/test_exponent.py | 60 ++--- .../tests/test_filmic_pro.py | 16 +- .../tests/test_filmlight_tlog.py | 16 +- .../tests/test_fujifilm_flog.py | 16 +- .../transfer_functions/tests/test_gamma.py | 33 +-- .../transfer_functions/tests/test_gopro.py | 22 +- .../tests/test_itur_bt_1886.py | 19 +- .../tests/test_itur_bt_2020.py | 19 +- .../tests/test_itur_bt_2100.py | 234 ++++++++++-------- .../tests/test_itur_bt_601.py | 19 +- .../tests/test_itur_bt_709.py | 19 +- .../transfer_functions/tests/test_linear.py | 9 +- .../rgb/transfer_functions/tests/test_log.py | 22 +- .../transfer_functions/tests/test_panalog.py | 22 +- .../tests/test_panasonic_vlog.py | 16 +- .../tests/test_pivoted_log.py | 16 +- .../transfer_functions/tests/test_red_log.py | 92 ++++--- .../tests/test_rimm_romm_rgb.py | 48 ++-- .../tests/test_smpte_240m.py | 22 +- .../tests/test_sony_slog.py | 66 +++-- .../rgb/transfer_functions/tests/test_srgb.py | 19 +- .../transfer_functions/tests/test_st_2084.py | 19 +- .../tests/test_viper_log.py | 22 +- .../rgb/transfer_functions/viper_log.py | 20 +- colour/models/rgb/ycbcr.py | 4 + colour/models/tests/test_cam02_ucs.py | 41 +-- colour/models/tests/test_cie_lab.py | 68 ++--- colour/models/tests/test_cie_luv.py | 130 +++++----- colour/models/tests/test_cie_ucs.py | 70 +++--- colour/models/tests/test_cie_uvw.py | 40 +-- colour/models/tests/test_cie_xyy.py | 94 +++---- colour/models/tests/test_common.py | 24 +- colour/models/tests/test_din99.py | 28 ++- colour/models/tests/test_hdr_cie_lab.py | 44 ++-- colour/models/tests/test_hdr_ipt.py | 58 ++--- colour/models/tests/test_hunter_lab.py | 50 ++-- colour/models/tests/test_hunter_rdab.py | 40 +-- colour/models/tests/test_ipt.py | 38 +-- colour/models/tests/test_jzazbz.py | 14 +- colour/models/tests/test_osa_ucs.py | 16 +- colour/ndarray/backend.py | 12 + colour/notation/tests/test_hexadecimal.py | 1 - colour/notation/tests/test_munsell.py | 142 ++++++----- colour/phenomena/rayleigh.py | 81 +++++- colour/phenomena/tests/test_rayleigh.py | 106 ++++---- colour/quality/cqs.py | 14 +- colour/quality/cri.py | 8 +- colour/quality/ssi.py | 8 +- colour/quality/tests/test_cqs.py | 4 +- colour/quality/tests/test_cri.py | 2 +- colour/recovery/tests/test__init__.py | 2 +- colour/recovery/tests/test_meng2015.py | 12 +- colour/recovery/tests/test_smits1999.py | 14 +- colour/temperature/mccamy1992.py | 9 +- colour/temperature/tests/test_cie_d.py | 18 +- .../temperature/tests/test_hernandez1999.py | 14 +- colour/temperature/tests/test_kang2002.py | 18 +- colour/temperature/tests/test_krystek1985.py | 14 +- colour/temperature/tests/test_mccamy1992.py | 14 +- colour/temperature/tests/test_ohno2013.py | 22 +- .../temperature/tests/test_robertson1968.py | 10 +- colour/utilities/array.py | 1 - colour/utilities/metrics.py | 10 +- colour/utilities/tests/test_array.py | 94 +++---- colour/volume/rgb.py | 22 +- colour/volume/tests/test_macadam_limits.py | 6 +- colour/volume/tests/test_mesh.py | 6 +- colour/volume/tests/test_pointer_gamut.py | 4 +- colour/volume/tests/test_rgb.py | 12 +- colour/volume/tests/test_spectrum.py | 4 +- 168 files changed, 2772 insertions(+), 2027 deletions(-) diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py index 83b5fb084b..e067b3767e 100644 --- a/colour/adaptation/tests/test_cie1994.py +++ b/colour/adaptation/tests/test_cie1994.py @@ -35,7 +35,7 @@ def test_chromatic_adaptation_CIE1994(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([28.00, 21.26, 5.27]), xy_o1=np.array([0.44760, 0.40740]), @@ -46,7 +46,7 @@ def test_chromatic_adaptation_CIE1994(self): np.array([24.03379521, 21.15621214, 17.64301199]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([21.77, 19.18, 16.73]), xy_o1=np.array([0.31270, 0.32900]), @@ -57,7 +57,7 @@ def test_chromatic_adaptation_CIE1994(self): np.array([21.12891746, 19.42980532, 19.49577765]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([0.07818780, 0.06157201, 0.28099326]) * 100, xy_o1=np.array([0.31270, 0.32900]), @@ -85,7 +85,7 @@ def test_n_dimensional_chromatic_adaptation_CIE1994(self): XYZ_1 = np.tile(XYZ_1, (6, 1)) XYZ_2 = np.tile(XYZ_2, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) @@ -95,7 +95,7 @@ def test_n_dimensional_chromatic_adaptation_CIE1994(self): Y_o = np.tile(Y_o, 6) E_o1 = np.tile(E_o1, 6) E_o2 = np.tile(E_o2, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) @@ -107,7 +107,7 @@ def test_n_dimensional_chromatic_adaptation_CIE1994(self): E_o1 = np.reshape(E_o1, (2, 3)) E_o2 = np.reshape(E_o2, (2, 3)) XYZ_2 = np.reshape(XYZ_2, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) @@ -130,7 +130,7 @@ def test_domain_range_scale_chromatic_adaptation_CIE1994(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_CIE1994(XYZ_1 * factor, xy_o1, xy_o2, Y_o * factor, E_o1, E_o2), XYZ_2 * factor, diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py index c1081a6a10..05e31baf3b 100644 --- a/colour/adaptation/tests/test_cmccat2000.py +++ b/colour/adaptation/tests/test_cmccat2000.py @@ -41,7 +41,7 @@ def test_chromatic_adaptation_forward_CMCCAT2000(self): chromatic_adaptation_forward_CMCCAT2000` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000( np.array([22.48, 22.74, 8.54]), np.array([111.15, 100.00, 35.20]), @@ -49,7 +49,7 @@ def test_chromatic_adaptation_forward_CMCCAT2000(self): np.array([19.52698326, 23.06833960, 24.97175229]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000( np.array([0.14222010, 0.23042768, 0.10495772]) * 100, np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -58,7 +58,7 @@ def test_chromatic_adaptation_forward_CMCCAT2000(self): np.array([17.90511171, 22.75299363, 3.79837384]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000( np.array([0.07818780, 0.06157201, 0.28099326]) * 100, np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -84,7 +84,7 @@ def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self): XYZ = np.tile(XYZ, (6, 1)) XYZ_c = np.tile(XYZ_c, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ_c, @@ -94,7 +94,7 @@ def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self): XYZ_wr = np.tile(XYZ_wr, (6, 1)) L_A1 = np.tile(L_A1, 6) L_A2 = np.tile(L_A2, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ_c, @@ -106,7 +106,7 @@ def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self): L_A1 = np.reshape(L_A1, (2, 3)) L_A2 = np.reshape(L_A2, (2, 3)) XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ_c, @@ -130,7 +130,7 @@ def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_forward_CMCCAT2000( XYZ * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, L_A2), @@ -168,7 +168,7 @@ def test_chromatic_adaptation_inverse_CMCCAT2000(self): chromatic_adaptation_inverse_CMCCAT2000` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000( np.array([19.52698326, 23.06833960, 24.97175229]), np.array([111.15, 100.00, 35.20]), @@ -176,7 +176,7 @@ def test_chromatic_adaptation_inverse_CMCCAT2000(self): np.array([22.48, 22.74, 8.54]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000( np.array([17.90511171, 22.75299363, 3.79837384]), np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -185,7 +185,7 @@ def test_chromatic_adaptation_inverse_CMCCAT2000(self): np.array([0.14222010, 0.23042768, 0.10495772]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000( np.array([6.76564344, 5.86585763, 18.40577315]), np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -211,7 +211,7 @@ def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self): XYZ_c = np.tile(XYZ_c, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ, @@ -221,7 +221,7 @@ def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self): XYZ_wr = np.tile(XYZ_wr, (6, 1)) L_A1 = np.tile(L_A1, 6) L_A2 = np.tile(L_A2, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ, @@ -233,7 +233,7 @@ def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self): L_A1 = np.reshape(L_A1, (2, 3)) L_A2 = np.reshape(L_A2, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, L_A2), XYZ, @@ -257,7 +257,7 @@ def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_inverse_CMCCAT2000( XYZ_c * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, L_A2), diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py index 4f52bf4556..1fdf535fde 100644 --- a/colour/adaptation/tests/test_fairchild1990.py +++ b/colour/adaptation/tests/test_fairchild1990.py @@ -35,7 +35,7 @@ def test_chromatic_adaptation_Fairchild1990(self): chromatic_adaptation_Fairchild1990` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990( np.array([19.53, 23.07, 24.97]), np.array([111.15, 100.00, 35.20]), @@ -43,7 +43,7 @@ def test_chromatic_adaptation_Fairchild1990(self): np.array([23.32526349, 23.32455819, 76.11593750]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990( np.array([0.14222010, 0.23042768, 0.10495772]) * 100, np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -51,7 +51,7 @@ def test_chromatic_adaptation_Fairchild1990(self): np.array([19.28089326, 22.91583715, 3.42923503]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990( np.array([0.07818780, 0.06157201, 0.28099326]) * 100, np.array([0.95045593, 1.00000000, 1.08905775]) * 100, @@ -73,7 +73,7 @@ def test_n_dimensional_chromatic_adaptation_Fairchild1990(self): XYZ_1 = np.tile(XYZ_1, (6, 1)) XYZ_c = np.tile(XYZ_c, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), XYZ_c, decimal=7) @@ -81,7 +81,7 @@ def test_n_dimensional_chromatic_adaptation_Fairchild1990(self): XYZ_n = np.tile(XYZ_n, (6, 1)) XYZ_r = np.tile(XYZ_r, (6, 1)) Y_n = np.tile(Y_n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), XYZ_c, decimal=7) @@ -91,7 +91,7 @@ def test_n_dimensional_chromatic_adaptation_Fairchild1990(self): XYZ_r = np.reshape(XYZ_r, (2, 3, 3)) Y_n = np.reshape(Y_n, (2, 3)) XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), XYZ_c, decimal=7) @@ -111,7 +111,7 @@ def test_domain_range_scale_chromatic_adaptation_Fairchild1990(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_Fairchild1990( XYZ_1 * factor, XYZ_n * factor, XYZ_r * factor, Y_n), XYZ_c * factor, diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py index 3f80eb3ed7..5e0d63b0ff 100644 --- a/colour/adaptation/tests/test_vonkries.py +++ b/colour/adaptation/tests/test_vonkries.py @@ -39,7 +39,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): chromatic_adaptation_matrix_VonKries` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([0.96429568, 1.00000000, 0.82510460])), @@ -50,7 +50,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([1.09846607, 1.00000000, 0.35582280])), @@ -61,7 +61,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([0.99144661, 1.00000000, 0.67315942])), @@ -71,7 +71,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): np.array([0.95045593, 1.00000000, 1.08905775]))), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([0.96429568, 1.00000000, 0.82510460]), @@ -83,7 +83,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([0.96429568, 1.00000000, 0.82510460]), @@ -95,7 +95,7 @@ def test_chromatic_adaptation_matrix_VonKries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( np.array([0.95045593, 1.00000000, 1.08905775]), np.array([0.96429568, 1.00000000, 0.82510460]), @@ -133,13 +133,13 @@ def test_n_dimensional_chromatic_adaptation_matrix_VonKries(self): XYZ_w = np.tile(XYZ_w, (6, 1)) XYZ_wr = np.tile(XYZ_wr, (6, 1)) M = np.reshape(np.tile(M, (6, 1)), (6, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) M = np.reshape(M, (2, 3, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) def test_domain_range_scale_chromatic_adaptation_VonKries(self): @@ -156,7 +156,7 @@ def test_domain_range_scale_chromatic_adaptation_VonKries(self): d_r = (('reference', 1), (1, 1), (100, 0.01)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_matrix_VonKries( XYZ_w * factor, XYZ_wr * factor), M, @@ -189,7 +189,7 @@ def test_chromatic_adaptation_VonKries(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -197,7 +197,7 @@ def test_chromatic_adaptation_VonKries(self): np.array([0.21638819, 0.12570000, 0.03847494]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.14222010, 0.23042768, 0.10495772]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -205,7 +205,7 @@ def test_chromatic_adaptation_VonKries(self): np.array([0.18673833, 0.23111171, 0.03285972]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.07818780, 0.06157201, 0.28099326]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -213,7 +213,7 @@ def test_chromatic_adaptation_VonKries(self): np.array([0.06385467, 0.05509729, 0.17506386]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -222,7 +222,7 @@ def test_chromatic_adaptation_VonKries(self): np.array([0.20954755, 0.12197225, 0.03891917]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -231,7 +231,7 @@ def test_chromatic_adaptation_VonKries(self): np.array([0.21666003, 0.12604777, 0.03855068]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.95045593, 1.00000000, 1.08905775]), @@ -255,7 +255,7 @@ def test_n_dimensional_chromatic_adaptation_VonKries(self): XYZ_w = np.tile(XYZ_w, (6, 1)) XYZ_wr = np.tile(XYZ_wr, (6, 1)) XYZ_a = np.tile(XYZ_a, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), XYZ_a, decimal=7) @@ -264,7 +264,7 @@ def test_n_dimensional_chromatic_adaptation_VonKries(self): XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) XYZ_a = np.reshape(XYZ_a, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), XYZ_a, decimal=7) @@ -283,7 +283,7 @@ def test_domain_range_scale_chromatic_adaptation_VonKries(self): d_r = (('reference', 1), (1, 1), (100, 0.01)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation_VonKries(XYZ * factor, XYZ_w * factor, XYZ_wr * factor), XYZ_a * factor, diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py index 5b8caf58cc..867892e435 100644 --- a/colour/algebra/geometry.py +++ b/colour/algebra/geometry.py @@ -41,7 +41,7 @@ from collections import namedtuple from colour.utilities import (CaseInsensitiveMapping, as_float_array, ones, - tsplit, tstack) + tsplit, tstack, as_float) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -112,7 +112,12 @@ def euclidean_distance(a, b): 451.7133019... """ - return np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) + distance = np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) + + if np.__name__ == 'cupy': + return as_float(distance) + + return distance def extend_line_segment(a, b, distance=1): @@ -518,12 +523,20 @@ def ellipse_fitting_Halir1998(a): M = S1 + np.dot(S2, T) M = np.array([M[2, :] / 2, -M[1, :], M[0, :] / 2]) - _w, v = np.linalg.eig(M) + if np.__name__ == 'cupy': + Mnp = np.asnumpy(M) + np.set_ndimensional_array_backend('numpy') + _w, v = np.linalg.eig(Mnp) + np.set_ndimensional_array_backend('cupy') + _w = np.array(_w) + v = np.array(v) + else: + _w, v = np.linalg.eig(M) A1 = v[:, np.nonzero(4 * v[0, :] * v[2, :] - v[1, :] ** 2 > 0)[0]] A2 = np.dot(T, A1) - A = np.ravel([A1, A2]) + A = np.ravel(np.array([A1, A2])) return A diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 2fe19ab801..5f3d8c172f 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -1204,6 +1204,9 @@ def _evaluate(self, x): y = (a0p + a1p * X + a2p * X ** 2 + a3p * X ** 3 + a4p * X ** 4 + a5p * X ** 5) + if np.__name__ == 'cupy': + return as_float(y) + return y def _validate_dimensions(self): @@ -1246,13 +1249,24 @@ def __init__(self, *args, **kwargs): if np.__name__ == 'cupy': args = list(args) for i in range(len(args)): - if isinstance(args[i], np.ndarray): + if isinstance(args[i], (np.ndarray, tuple)): args[i] = np.asnumpy(args[i]) args = tuple(args) super(CubicSplineInterpolator, self).__init__( kind='cubic', *args, **kwargs) + def __call__(self, *args, **kwargs): + + if np.__name__ == 'cupy': + args = list(args) + for i in range(len(args)): + if isinstance(args[i], (np.ndarray, tuple)): + args[i] = np.asnumpy(args[i]) + args = tuple(args) + + return super(CubicSplineInterpolator, self).__call__(*args, **kwargs) + class PchipInterpolator(scipy.interpolate.PchipInterpolator): """ diff --git a/colour/algebra/regression.py b/colour/algebra/regression.py index afbc7c9c63..9da2eb5ca7 100644 --- a/colour/algebra/regression.py +++ b/colour/algebra/regression.py @@ -66,4 +66,17 @@ def least_square_mapping_MoorePenrose(y, x): y = np.atleast_2d(y) x = np.atleast_2d(x) + if np.__name__ == 'cupy': + x = np.asnumpy(x) + y = np.asnumpy(y) + np.set_ndimensional_array_backend('numpy') + try: + pinv_y = np.linalg.pinv(np.transpose(y)) + result = np.dot(np.transpose(x), pinv_y) + np.set_ndimensional_array_backend('cupy') + except Exception: + np.set_ndimensional_array_backend('cupy') + raise + return np.array(result) + return np.dot(np.transpose(x), np.linalg.pinv(np.transpose(y))) diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py index 88e5b8266d..6459ffe214 100644 --- a/colour/algebra/tests/test_common.py +++ b/colour/algebra/tests/test_common.py @@ -115,17 +115,17 @@ def test_spow(self): self.assertEqual(spow(-2, 2), -4.0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spow([2, -2, -2, 0], [2, 2, 0.15, 0]), np.array([4.00000000, -4.00000000, -1.10956947, 0.00000000]), decimal=7) with spow_enable(True): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spow(-2, 0.15), -1.10956947, decimal=7) with spow_enable(False): - np.testing.assert_equal(spow(-2, 0.15), np.nan) + np.testing.assert_array_equal(spow(-2, 0.15), np.nan) class TestSmoothstepFunction(unittest.TestCase): diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py index af75d52797..302b685351 100644 --- a/colour/algebra/tests/test_extrapolation.py +++ b/colour/algebra/tests/test_extrapolation.py @@ -104,13 +104,13 @@ def test__call__(self): extrapolator = Extrapolator( LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7]))) - np.testing.assert_almost_equal(extrapolator((4, 8)), (4, 8)) + np.testing.assert_array_almost_equal(extrapolator((4, 8)), (4, 8)) self.assertEqual(extrapolator(4), 4) extrapolator = Extrapolator( LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), method='Constant') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extrapolator((0.1, 0.2, 8, 9)), (1, 1, 3, 3)) self.assertEqual(extrapolator(0.1), 1.) @@ -118,7 +118,7 @@ def test__call__(self): LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), method='Constant', left=0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extrapolator((0.1, 0.2, 8, 9)), (0, 0, 3, 3)) self.assertEqual(extrapolator(0.1), 0) @@ -126,20 +126,20 @@ def test__call__(self): LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), method='Constant', right=0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extrapolator((0.1, 0.2, 8, 9)), (1, 1, 0, 0)) self.assertEqual(extrapolator(9), 0) extrapolator = Extrapolator( CubicSplineInterpolator( np.array([3, 4, 5, 6]), np.array([1, 2, 3, 4]))) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) self.assertEqual(extrapolator(9), 7) extrapolator = Extrapolator( PchipInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3]))) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) self.assertEqual(extrapolator(9), 7.) diff --git a/colour/algebra/tests/test_geometry.py b/colour/algebra/tests/test_geometry.py index 81862a06d3..59f7a855a3 100644 --- a/colour/algebra/tests/test_geometry.py +++ b/colour/algebra/tests/test_geometry.py @@ -42,17 +42,17 @@ def test_normalise_vector(self): Tests :func:`colour.algebra.geometry.normalise_vector` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_vector(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.84197033, 0.49722560, 0.20941026]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_vector(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.48971705, 0.79344877, 0.36140872]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_vector(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([0.26229003, 0.20655044, 0.94262445]), decimal=7) @@ -103,13 +103,13 @@ def test_n_dimensional_euclidean_distance(self): a = np.tile(a, (6, 1)) b = np.tile(b, (6, 1)) distance = np.tile(distance, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( euclidean_distance(a, b), distance, decimal=7) a = np.reshape(a, (2, 3, 3)) b = np.reshape(b, (2, 3, 3)) distance = np.reshape(distance, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( euclidean_distance(a, b), distance, decimal=7) @ignore_numpy_errors @@ -138,21 +138,21 @@ def test_extend_line_segment(self): Tests :func:`colour.algebra.geometry.extend_line_segment` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extend_line_segment( np.array([0.95694934, 0.13720932]), np.array([0.28382835, 0.60608318])), np.array([-0.5367248, 1.17765341]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extend_line_segment( np.array([0.95694934, 0.13720932]), np.array([0.28382835, 0.60608318]), 5), np.array([-3.81893739, 3.46393435]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( extend_line_segment( np.array([0.95694934, 0.13720932]), np.array([0.28382835, 0.60608318]), -1), @@ -185,7 +185,7 @@ def test_intersect_line_segments(self): s = intersect_line_segments(l_1, l_2) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( s.xy, np.array([[[np.nan, np.nan], [0.22791841, 0.60064309], [np.nan, np.nan], [np.nan, np.nan]], @@ -220,13 +220,13 @@ def test_ellipse_coefficients_canonical_form(self): ellipse_coefficients_canonical_form` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ellipse_coefficients_canonical_form( np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5])), np.array([0.5, 0.5, 2, 1, 45]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ellipse_coefficients_canonical_form( np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0])), np.array([0.0, 0.0, 1, 1, 0]), @@ -245,12 +245,12 @@ def test_ellipse_coefficients_general_form(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ellipse_coefficients_general_form(np.array([0.5, 0.5, 2, 1, 45])), np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ellipse_coefficients_general_form(np.array([0.0, 0.0, 1, 1, 0])), np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0]), decimal=7) @@ -268,13 +268,13 @@ def test_point_at_angle_on_ellipse(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( point_at_angle_on_ellipse( np.array([0, 90, 180, 270]), np.array([0.0, 0.0, 2, 1, 0])), np.array([[2, 0], [0, 1], [-2, 0], [0, -1]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( point_at_angle_on_ellipse( np.linspace(0, 360, 10), np.array([0.5, 0.5, 2, 1, 45])), np.array([ @@ -304,7 +304,7 @@ def test_ellipse_fitting_Halir1998(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ellipse_fitting_Halir1998( np.array([[2, 0], [0, 1], [-2, 0], [0, -1]])), np.array([ diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index c64b3d0c34..7b4c10c312 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -10,22 +10,22 @@ """ from __future__ import division, unicode_literals - -import colour.ndarray as np -import os -import unittest -from itertools import permutations - -from colour.algebra.interpolation import vertices_and_relative_coordinates +from colour.utilities import ignore_numpy_errors +from colour.io import read_LUT +from colour.algebra import random_triplet_generator from colour.algebra import ( kernel_nearest_neighbour, kernel_linear, kernel_sinc, kernel_lanczos, kernel_cardinal_spline, KernelInterpolator, NearestNeighbourInterpolator, LinearInterpolator, SpragueInterpolator, CubicSplineInterpolator, PchipInterpolator, NullInterpolator, lagrange_coefficients, table_interpolation_trilinear, table_interpolation_tetrahedral) -from colour.algebra import random_triplet_generator -from colour.io import read_LUT -from colour.utilities import ignore_numpy_errors +from colour.algebra.interpolation import vertices_and_relative_coordinates + +import colour.ndarray as np +import os +import unittest +from itertools import permutations +np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -171,7 +171,7 @@ def test_kernel_nearest(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_nearest_neighbour(np.linspace(-5, 5, 25)), np.array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, @@ -191,7 +191,7 @@ def test_kernel_linear(self): Tests :func:`colour.algebra.interpolation.kernel_linear` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_linear(np.linspace(-5, 5, 25)), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -214,7 +214,7 @@ def test_kernel_sinc(self): Tests :func:`colour.algebra.interpolation.kernel_sinc` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_sinc(np.linspace(-5, 5, 25)), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -225,7 +225,7 @@ def test_kernel_sinc(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_sinc(np.linspace(-5, 5, 25), 1), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -248,7 +248,7 @@ def test_kernel_lanczos(self): Tests :func:`colour.algebra.interpolation.kernel_lanczos` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_lanczos(np.linspace(-5, 5, 25)), np.array([ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, @@ -261,7 +261,7 @@ def test_kernel_lanczos(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_lanczos(np.linspace(-5, 5, 25), 1), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -285,7 +285,7 @@ def test_kernel_cardinal_spline(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_cardinal_spline(np.linspace(-5, 5, 25)), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -296,7 +296,7 @@ def test_kernel_cardinal_spline(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_cardinal_spline(np.linspace(-5, 5, 25), 0, 1), np.array([ 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, @@ -344,7 +344,7 @@ def test_x(self): x = y = np.linspace(0, 1, 10) kernel_interpolator = KernelInterpolator(x, y) - np.testing.assert_equal(kernel_interpolator.x, x) + np.testing.assert_array_equal(kernel_interpolator.x, x) def test_y(self): """ @@ -355,7 +355,7 @@ def test_y(self): x = y = np.linspace(0, 1, 10) kernel_interpolator = KernelInterpolator(x, y) - np.testing.assert_equal(kernel_interpolator.y, y) + np.testing.assert_array_equal(kernel_interpolator.y, y) def test_window(self): """ @@ -430,7 +430,7 @@ def test__call__(self): x_i = np.linspace(11, 25, 25) kernel_interpolator = KernelInterpolator(x, y) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_interpolator(x_i), np.array([ 4.43848790, 4.26286480, 3.64640076, 2.77982023, 2.13474499, @@ -442,7 +442,7 @@ def test__call__(self): decimal=7) kernel_interpolator = KernelInterpolator(x, y, kernel=kernel_sinc) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_interpolator(x_i), np.array([ 4.43848790, 4.47570010, 3.84353906, 3.05959493, 2.53514958, @@ -454,7 +454,7 @@ def test__call__(self): decimal=7) kernel_interpolator = KernelInterpolator(x, y, window=1) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_interpolator(x_i), np.array([ 4.43848790, 4.96712277, 4.09584229, 3.23991575, 2.80418924, @@ -467,7 +467,7 @@ def test__call__(self): kernel_interpolator = KernelInterpolator( x, y, window=1, kernel_kwargs={'a': 1}) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_interpolator(x_i), np.array([ 4.43848790, 3.34379320, 3.62463711, 2.34585418, 2.04767083, @@ -483,7 +483,7 @@ def test__call__(self): 'pad_width': (3, 3), 'mode': 'mean' }) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( kernel_interpolator(x_i), np.array([ 4.4384879, 4.35723245, 3.62918155, 2.77471295, 2.13474499, @@ -500,12 +500,12 @@ def test__call__(self): y = np.sin(x_1 / len(x_1) * np.pi * 6) / (x_1 / len(x_1)) x_i = np.linspace(1, 9, 25) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( KernelInterpolator(x_1, y)(x_i), KernelInterpolator(x_2, y)(x_i * 10), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( KernelInterpolator(x_1, y)(x_i), KernelInterpolator(x_3, y)(x_i / 10), decimal=7) @@ -630,7 +630,7 @@ def test__call__(self): linear_interpolator(value), places=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( linear_interpolator( np.arange(0, len(DATA_POINTS_A) - 1 + interval, interval)), @@ -720,7 +720,7 @@ def test__call__(self): sprague_interpolator(value), places=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sprague_interpolator( np.arange(0, len(DATA_POINTS_A) - 1 + interval, interval)), @@ -773,12 +773,16 @@ def test__call__(self): - This class is a wrapper around *scipy.interpolate.interp1d* class and is assumed to be unit tested thoroughly. """ - - np.testing.assert_almost_equal( + print( + np.linspace(0, 1, + len(POINTS_DATA_A) * 2), + type(np.linspace(0, 1, + len(POINTS_DATA_A) * 2))) + np.testing.assert_array_almost_equal( CubicSplineInterpolator( np.linspace(0, 1, len(DATA_POINTS_A)), - DATA_POINTS_A)(np.linspace(0, 1, - len(DATA_POINTS_A) * 2)), + np.array(POINTS_DATA_A))(np.linspace(0, 1, + len(DATA_POINTS_A) * 2)), DATA_POINTS_A_CUBIC_SPLINE_INTERPOLATED_X2_SAMPLES) @@ -844,7 +848,7 @@ def test_x(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y) - np.testing.assert_equal(null_interpolator.x, x) + np.testing.assert_array_equal(null_interpolator.x, x) def test_y(self): """ @@ -855,7 +859,7 @@ def test_y(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y) - np.testing.assert_equal(null_interpolator.y, y) + np.testing.assert_array_equal(null_interpolator.y, y) def test_absolute_tolerance(self): """ @@ -866,7 +870,8 @@ def test_absolute_tolerance(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y, absolute_tolerance=0.1) - np.testing.assert_equal(null_interpolator.absolute_tolerance, 0.1) + np.testing.assert_array_equal(null_interpolator.absolute_tolerance, + 0.1) def test_relative_tolerance(self): """ @@ -877,7 +882,8 @@ def test_relative_tolerance(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y, relative_tolerance=0.1) - np.testing.assert_equal(null_interpolator.relative_tolerance, 0.1) + np.testing.assert_array_equal(null_interpolator.relative_tolerance, + 0.1) def test_default(self): """ @@ -888,7 +894,7 @@ def test_default(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y, default=0) - np.testing.assert_equal(null_interpolator.default, 0) + np.testing.assert_array_equal(null_interpolator.default, 0) def test_raise_exception___init__(self): """ @@ -907,12 +913,12 @@ def test__call__(self): x = np.arange(len(DATA_POINTS_A)) null_interpolator = NullInterpolator(x, DATA_POINTS_A) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), np.array([np.nan, 12.46, 9.51, np.nan])) null_interpolator = NullInterpolator(x, DATA_POINTS_A, 0.25, 0.25) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), np.array([12.32, 12.46, 9.51, 4.33])) @@ -968,11 +974,15 @@ def test_lagrange_coefficients(self): :cite:`Fairman1985b` """ - lc = [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)] - np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_A, decimal=7) + lc = np.array( + [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)]) + np.testing.assert_array_almost_equal( + lc, LAGRANGE_COEFFICIENTS_A, decimal=7) - lc = [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)] - np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_B, decimal=7) + lc = np.array( + [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)]) + np.testing.assert_array_almost_equal( + lc, LAGRANGE_COEFFICIENTS_B, decimal=7) class TestVerticesAndRelativeCoordinates(unittest.TestCase): @@ -992,7 +1002,7 @@ def test_vertices_and_relative_coordinates(self): V_xyz = random_triplet_generator(4, random_state=prng) vertices, V_xyzr = vertices_and_relative_coordinates(V_xyz, LUT_TABLE) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices, np.array([ [ @@ -1044,7 +1054,7 @@ def test_vertices_and_relative_coordinates(self): [1.13122500, 0.29792000, 0.29792000], ], ])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( V_xyzr, np.array([ [0.90108952, 0.09318647, 0.75894709], @@ -1070,7 +1080,7 @@ def test_interpolation_trilinear(self): V_xyz = random_triplet_generator(16, random_state=prng) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( table_interpolation_trilinear(V_xyz, LUT_TABLE), np.array([ [1.07937594, -0.02773926, 0.55498254], @@ -1108,7 +1118,7 @@ def test_interpolation_tetrahedral(self): V_xyz = random_triplet_generator(16, random_state=prng) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( table_interpolation_tetrahedral(V_xyz, LUT_TABLE), np.array([ [1.08039215, -0.02840092, 0.55855303], diff --git a/colour/algebra/tests/test_random.py b/colour/algebra/tests/test_random.py index 75f62f2c98..921a10df52 100644 --- a/colour/algebra/tests/test_random.py +++ b/colour/algebra/tests/test_random.py @@ -61,7 +61,7 @@ def test_random_triplet_generator(self): """ prng = np.random.RandomState(4) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RANDOM_TRIPLETS, random_triplet_generator(10, random_state=prng), decimal=7) diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py index f9b1f9ff36..f1b23d9aa4 100644 --- a/colour/algebra/tests/test_regression.py +++ b/colour/algebra/tests/test_regression.py @@ -36,7 +36,7 @@ def test_least_square_mapping_MoorePenrose(self): y = prng.random_sample((24, 3)) x = y + (prng.random_sample((24, 3)) - 0.5) * 0.5 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( least_square_mapping_MoorePenrose(y, x), np.array([ [1.05263767, 0.13780789, -0.22763399], @@ -47,7 +47,7 @@ def test_least_square_mapping_MoorePenrose(self): y = prng.random_sample((4, 3, 2)) x = y + (prng.random_sample((4, 3, 2)) - 0.5) * 0.5 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( least_square_mapping_MoorePenrose(y, x), np.array([ [ diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 70e52aeeca..b6bd68c116 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -39,7 +39,7 @@ from colour.utilities import ( CaseInsensitiveMapping, as_float_array, as_int_array, as_namedtuple, as_float, from_range_degrees, dot_matrix, dot_vector, from_range_100, ones, - to_domain_100, to_domain_degrees, tsplit, tstack, zeros) + to_domain_100, to_domain_degrees, tsplit, tstack, zeros, as_int) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -1031,7 +1031,16 @@ def hue_quadrature(h): # *np.searchsorted* returns an erroneous index if a *nan* is used as input. h[np.asarray(np.isnan(h))] = 0 - i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) + + if np.__name__ == 'cupy': + hnp = np.asnumpy(h) + h_inp = np.asnumpy(h_i) + np.set_ndimensional_array_backend('numpy') + i = as_int_array(np.searchsorted(h_inp, hnp, side='left') - 1) + np.set_ndimensional_array_backend('cupy') + i = as_int(i) + else: + i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) h_ii = h_i[i] e_ii = e_i[i] diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py index 5bb4e8d21d..b2c5d2c400 100644 --- a/colour/biochemistry/michaelis_menten.py +++ b/colour/biochemistry/michaelis_menten.py @@ -17,7 +17,8 @@ from __future__ import division, unicode_literals -from colour.utilities import as_float_array +from colour.utilities import as_float_array, as_float +import colour.ndarray as np __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -72,6 +73,9 @@ def reaction_rate_MichealisMenten(S, V_max, K_m): v = (V_max * S) / (K_m + S) + if np.__name__ == 'cupy' and v.size == 1: + return as_float(v) + return v @@ -100,10 +104,6 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): ---------- :cite:`Wikipedia2003d` - Notes - ----- - On CuPy, this returns an array even for length of 1. - Examples -------- >>> substrate_concentration_MichealisMenten(0.961538461538461, 2.5, 0.8) @@ -117,4 +117,7 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): S = (v * K_m) / (V_max - v) + if np.__name__ == 'cupy' and S.size == 1: + return as_float(S) + return S diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py index 9f39ae7a37..f22524c997 100644 --- a/colour/biochemistry/tests/test_michaelis_menten.py +++ b/colour/biochemistry/tests/test_michaelis_menten.py @@ -67,19 +67,19 @@ def test_n_dimensional_reaction_rate_MichealisMenten(self): v = np.tile(v, (6, 1)) S = np.tile(S, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) V_max = np.tile(V_max, (6, 1)) K_m = np.tile(K_m, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) v = np.reshape(v, (2, 3, 1)) V_max = np.reshape(V_max, (2, 3, 1)) K_m = np.reshape(K_m, (2, 3, 1)) S = np.reshape(S, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) @ignore_numpy_errors @@ -139,14 +139,14 @@ def test_n_dimensional_substrate_concentration_MichealisMenten(self): S = np.tile(S, (6, 1)) v = np.tile(v, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( substrate_concentration_MichealisMenten(S, V_max, K_m), v, decimal=7) V_max = np.tile(V_max, (6, 1)) K_m = np.tile(K_m, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( substrate_concentration_MichealisMenten(S, V_max, K_m), v, decimal=7) @@ -155,7 +155,7 @@ def test_n_dimensional_substrate_concentration_MichealisMenten(self): V_max = np.reshape(V_max, (2, 3, 1)) K_m = np.reshape(K_m, (2, 3, 1)) v = np.reshape(v, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( substrate_concentration_MichealisMenten(S, V_max, K_m), v, decimal=7) diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py index 39eb109e28..5152dd540b 100644 --- a/colour/blindness/tests/test_machado2009.py +++ b/colour/blindness/tests/test_machado2009.py @@ -41,43 +41,43 @@ def test_anomalous_trichromacy_cmfs_Machado2009(self): """ cmfs = MSDS_CMFS_LMS.get('Smith & Pokorny 1975 Normal Trichromats') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array([0, 0, 0], ))[450], cmfs[450], decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array([1, 0, 0], ))[450], np.array([0.03631700, 0.06350000, 0.91000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array([0, 1, 0], ))[450], np.array([0.03430000, 0.06178404, 0.91000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array([0, 0, 1], ))[450], np.array([0.03430000, 0.06350000, 0.92270240]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( [10, 0, 0], ))[450], np.array([0.05447001, 0.06350000, 0.91000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( [0, 10, 0], ))[450], np.array([0.03430000, 0.04634036, 0.91000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( [0, 0, 10], ))[450], np.array([0.03430000, 0.06350000, 1.00000000]), @@ -98,7 +98,7 @@ def test_anomalous_trichromacy_matrix_Machado2009(self): cmfs = MSDS_CMFS_LMS.get('Smith & Pokorny 1975 Normal Trichromats') primaries = MSDS_DISPLAY_PRIMARIES['Typical CRT Brainard 1997'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( anomalous_trichromacy_matrix_Machado2009(cmfs, primaries, np.array([0, 0, 0])), np.identity(3), @@ -159,7 +159,7 @@ def test_cvd_matrix_Machado2009(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cvd_matrix_Machado2009('Protanomaly', 0.0), np.array([ [1, 0, 0], @@ -168,7 +168,7 @@ def test_cvd_matrix_Machado2009(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cvd_matrix_Machado2009('Deuteranomaly', 0.1), np.array([ [0.86643500, 0.17770400, -0.04413900], @@ -177,7 +177,7 @@ def test_cvd_matrix_Machado2009(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cvd_matrix_Machado2009('Tritanomaly', 1.0), np.array([ [1.25552800, -0.07674900, -0.17877900], @@ -186,7 +186,7 @@ def test_cvd_matrix_Machado2009(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cvd_matrix_Machado2009('Tritanomaly', 0.55), np.array([ [1.06088700, -0.01504350, -0.04584350], diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 07cca5d857..dea3fc144b 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -317,10 +317,6 @@ def generate_illuminants_rawtoaces_v1(): CCT = i * 1.4388 / 1.4380 xy = CCT_to_xy_CIE_D(CCT) sd = sd_CIE_illuminant_D_series(xy) -<<<<<<< HEAD - sd.name = 'D{0:d}'.format(DEFAULT_INT_DTYPE(CCT / 100)) - illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES) -======= if np.__name__ == 'cupy': cctInt = as_int_array(CCT / 100) cctInt = np.asnumpy(cctInt) @@ -330,7 +326,6 @@ def generate_illuminants_rawtoaces_v1(): else: sd.name = 'D{0:d}'.format(DEFAULT_INT_DTYPE(CCT / 100)) illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES) ->>>>>>> Fixes for the volume, luts, colorimetry, blindness and characterisation module # TODO: Remove when removing the "colour.sd_blackbody" definition # warning. diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 09337bad25..4c41c30caa 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -215,6 +215,7 @@ def polynomial_expansion_Finlayson2015(RGB, 0.1051335...]) """ + RGB = np.array(RGB) R, G, B = tsplit(RGB) # TODO: Generalise polynomial expansion. @@ -772,6 +773,8 @@ def colour_correction_Vandermonde(RGB, M_T, M_R, degree=1): array([ 0.2128689..., 0.1106242..., 0.036213 ...]) """ + M_T = np.array((M_T)) + M_R = np.array((M_R)) RGB = as_float_array(RGB) shape = RGB.shape diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py index 125acbdbed..ebdf02e33c 100644 --- a/colour/characterisation/tests/test_aces_it.py +++ b/colour/characterisation/tests/test_aces_it.py @@ -63,39 +63,39 @@ def test_spectral_to_aces_relative_exposure_values(self): shape = MSDS_ACES_RICD.shape grey_reflector = sd_constant(0.18, shape) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values(grey_reflector), np.array([0.18, 0.18, 0.18]), decimal=7) perfect_reflector = sd_ones(shape) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values(perfect_reflector), np.array([0.97783784, 0.97783784, 0.97783784]), decimal=7) dark_skin = SDS_COLOURCHECKERS['ColorChecker N Ohta']['dark skin'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values(dark_skin), np.array([0.11718149, 0.08663609, 0.05897268]), decimal=7) dark_skin = SDS_COLOURCHECKERS['ColorChecker N Ohta']['dark skin'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values(dark_skin, SDS_ILLUMINANTS['A']), np.array([0.13583991, 0.09431845, 0.05928214]), decimal=7) dark_skin = SDS_COLOURCHECKERS['ColorChecker N Ohta']['dark skin'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values( dark_skin, apply_chromatic_adaptation=True), np.array([0.11807796, 0.08690312, 0.05891252]), decimal=7) dark_skin = SDS_COLOURCHECKERS['ColorChecker N Ohta']['dark skin'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values( dark_skin, apply_chromatic_adaptation=True, @@ -118,7 +118,7 @@ def test_domain_range_scale_spectral_to_aces_relative_exposure_values( d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_aces_relative_exposure_values(grey_reflector), RGB * factor, decimal=7) @@ -176,13 +176,13 @@ def test_white_balance_multipliers(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( white_balance_multipliers(MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS['D55']), np.array([2.34141541, 1.00000000, 1.51633759]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( white_balance_multipliers( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS['ISO 7589 Studio Tungsten']), @@ -249,7 +249,7 @@ def test_training_data_sds_to_RGB(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( training_data_sds_to_RGB(read_training_data_rawtoaces_v1(), MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS['D55']), @@ -449,7 +449,7 @@ def test_training_data_sds_to_RGB(self): training_data = sds_and_msds_to_msds( SDS_COLOURCHECKERS['BabelColor Average'].values()) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( training_data_sds_to_RGB(training_data, MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS['D55']), np.array([ @@ -493,7 +493,7 @@ def test_training_data_sds_to_XYZ(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( training_data_sds_to_XYZ( read_training_data_rawtoaces_v1(), MSDS_CMFS['CIE 1931 2 Degree Standard Observer'], @@ -695,7 +695,7 @@ def test_training_data_sds_to_XYZ(self): training_data = sds_and_msds_to_msds( SDS_COLOURCHECKERS['BabelColor Average'].values()) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( training_data_sds_to_XYZ( training_data, MSDS_CMFS['CIE 1931 2 Degree Standard Observer'], diff --git a/colour/characterisation/tests/test_correction.py b/colour/characterisation/tests/test_correction.py index f0ef488f8c..8775874eb9 100644 --- a/colour/characterisation/tests/test_correction.py +++ b/colour/characterisation/tests/test_correction.py @@ -165,7 +165,7 @@ def test_augmented_matrix_Cheung2004(self): for i, terms in enumerate([3, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22]): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( augmented_matrix_Cheung2004(RGB, terms), polynomials[i], decimal=7) @@ -255,11 +255,11 @@ def test_polynomial_expansion_Finlayson2015(self): ] for i in range(4): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polynomial_expansion_Finlayson2015(RGB, i + 1, False), polynomials[i][0], decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polynomial_expansion_Finlayson2015(RGB, i + 1, True), polynomials[i][1], decimal=7) @@ -318,7 +318,7 @@ def test_polynomial_expansion_Vandermonde(self): ] for i in range(4): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polynomial_expansion_Vandermonde(RGB, i + 1), polynomials[i], decimal=7) @@ -348,7 +348,7 @@ def test_colour_correction_matrix_Cheung2004(self): colour_correction_matrix_Cheung2004` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Cheung2004(MATRIX_TEST, MATRIX_REFERENCE), np.array([ [0.69822661, 0.03071629, 0.16210422], @@ -357,7 +357,7 @@ def test_colour_correction_matrix_Cheung2004(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Cheung2004( MATRIX_TEST, MATRIX_REFERENCE, terms=7), np.array([ @@ -406,7 +406,7 @@ def test_colour_correction_matrix_Finlayson2015(self): colour_correction_matrix_Finlayson2015` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Finlayson2015(MATRIX_TEST, MATRIX_REFERENCE), np.array([ @@ -416,7 +416,7 @@ def test_colour_correction_matrix_Finlayson2015(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Finlayson2015( MATRIX_TEST, MATRIX_REFERENCE, degree=3), np.array([ @@ -471,7 +471,7 @@ def test_colour_correction_matrix_Vandermonde(self): colour_correction_matrix_Vandermonde` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Vandermonde(MATRIX_TEST, MATRIX_REFERENCE), np.array([ @@ -481,7 +481,7 @@ def test_colour_correction_matrix_Vandermonde(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_matrix_Vandermonde( MATRIX_TEST, MATRIX_REFERENCE, degree=3), np.array([ @@ -535,12 +535,12 @@ def test_colour_correction_Cheung2004(self): RGB = np.array([0.17224810, 0.09170660, 0.06416938]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Cheung2004(RGB, MATRIX_TEST, MATRIX_REFERENCE), np.array([0.13348722, 0.08439216, 0.05990144]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Cheung2004( RGB, MATRIX_TEST, MATRIX_REFERENCE, terms=7), np.array([0.15850295, 0.09871628, 0.08105752]), @@ -558,14 +558,14 @@ def test_n_dimensional_colour_correction_Cheung2004(self): RGB = np.tile(RGB, (6, 1)) RGB_c = np.tile(RGB_c, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Cheung2004(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) RGB_c = np.reshape(RGB_c, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Cheung2004(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, decimal=7) @@ -602,13 +602,13 @@ def test_colour_correction_Finlayson2015(self): RGB = np.array([0.17224810, 0.09170660, 0.06416938]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Finlayson2015(RGB, MATRIX_TEST, MATRIX_REFERENCE), np.array([0.13348722, 0.08439216, 0.05990144]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Finlayson2015( RGB, MATRIX_TEST, MATRIX_REFERENCE, degree=3), np.array([0.13914542, 0.08602124, 0.06422973]), @@ -626,7 +626,7 @@ def test_n_dimensional_colour_correction_Finlayson2015(self): RGB = np.tile(RGB, (6, 1)) RGB_c = np.tile(RGB_c, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Finlayson2015(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, @@ -634,7 +634,7 @@ def test_n_dimensional_colour_correction_Finlayson2015(self): RGB = np.reshape(RGB, (2, 3, 3)) RGB_c = np.reshape(RGB_c, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Finlayson2015(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, @@ -672,12 +672,12 @@ def test_colour_correction_Vandermonde(self): RGB = np.array([0.17224810, 0.09170660, 0.06416938]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Vandermonde(RGB, MATRIX_TEST, MATRIX_REFERENCE), np.array([0.15034881, 0.10503956, 0.10512517]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Vandermonde( RGB, MATRIX_TEST, MATRIX_REFERENCE, degree=3), np.array([0.15747814, 0.10035799, 0.06616709]), @@ -695,14 +695,14 @@ def test_n_dimensional_colour_correction_Vandermonde(self): RGB = np.tile(RGB, (6, 1)) RGB_c = np.tile(RGB_c, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Vandermonde(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) RGB_c = np.reshape(RGB_c, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colour_correction_Vandermonde(RGB, MATRIX_TEST, MATRIX_REFERENCE), RGB_c, decimal=7) diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index 3234942625..67d48d8c89 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -31,7 +31,7 @@ intersect_line_segments) from colour.colorimetry import MSDS_CMFS from colour.models import XYZ_to_xy -from colour.utilities import as_float_array +from colour.utilities import as_float_array, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -358,4 +358,7 @@ def colorimetric_purity(xy, P_c = P_e * xy_wl[..., 1] / xy[..., 1] + if np.__name__ == 'cupy' and P_c.size == 1: + return as_float(P_c) + return P_c diff --git a/colour/colorimetry/luminance.py b/colour/colorimetry/luminance.py index 2b2d254b0b..366ec0f73c 100644 --- a/colour/colorimetry/luminance.py +++ b/colour/colorimetry/luminance.py @@ -125,8 +125,12 @@ def luminance_Newhall1943(V): R_Y = (1.2219 * V - 0.23111 * (V * V) + 0.23951 * (V ** 3) - 0.021009 * (V ** 4) + 0.0008404 * (V ** 5)) + R_Y = from_range_100(R_Y) - return from_range_100(R_Y) + if np.__name__ == 'cupy' and R_Y.size == 1: + return as_float(R_Y) + + return R_Y def luminance_ASTMD1535(V): @@ -173,8 +177,12 @@ def luminance_ASTMD1535(V): Y = (1.1914 * V - 0.22533 * (V ** 2) + 0.23352 * (V ** 3) - 0.020484 * (V ** 4) + 0.00081939 * (V ** 5)) + Y = from_range_100(Y) + + if np.__name__ == 'cupy' and isinstance(Y, np.ndarray) and Y.size == 1: + return as_float(Y) - return from_range_100(Y) + return Y def intermediate_luminance_function_CIE1976(f_Y_Y_n, Y_n=100): @@ -287,8 +295,12 @@ def luminance_CIE1976(L_star, Y_n=100): f_Y_Y_n = (L_star + 16) / 116 Y = intermediate_luminance_function_CIE1976(f_Y_Y_n, Y_n) + Y = from_range_100(Y) - return from_range_100(Y) + if np.__name__ == 'cupy' and isinstance(Y, np.ndarray) and Y.size == 1: + return as_float(Y) + + return Y def luminance_Fairchild2010(L_hdr, epsilon=1.836): @@ -345,8 +357,12 @@ def luminance_Fairchild2010(L_hdr, epsilon=1.836): np.log( substrate_concentration_MichealisMenten(L_hdr - 0.02, 100, 0.184 ** epsilon)) / epsilon) + Y = from_range_1(Y) - return from_range_1(Y) + if np.__name__ == 'cupy' and isinstance(Y, np.ndarray) and Y.size == 1: + return as_float(Y) + + return Y def luminance_Fairchild2011(L_hdr, epsilon=0.474, method='hdr-CIELAB'): @@ -409,8 +425,12 @@ def luminance_Fairchild2011(L_hdr, epsilon=0.474, method='hdr-CIELAB'): np.log( substrate_concentration_MichealisMenten( L_hdr - 0.02, maximum_perception, 2 ** epsilon)) / epsilon) + Y = from_range_1(Y) - return from_range_1(Y) + if np.__name__ == 'cupy' and isinstance(Y, np.ndarray) and Y.size == 1: + return as_float(Y) + + return Y LUMINANCE_METHODS = CaseInsensitiveMapping({ diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index fca2518cfd..53b479a867 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -1128,7 +1128,7 @@ def interpolate(self, interpolator_compare = self.interpolator == CubicSplineInterpolator if interpolator_compare and np.__name__ == 'cupy': - self.range = np.array(interpolator(np.asnumpy(self.domain))) + self.range = np.array(interpolator(self.domain)) else: self.range = interpolator(self.domain) diff --git a/colour/colorimetry/tests/test_blackbody.py b/colour/colorimetry/tests/test_blackbody.py index ba267c9636..a8b5d57e6e 100644 --- a/colour/colorimetry/tests/test_blackbody.py +++ b/colour/colorimetry/tests/test_blackbody.py @@ -4536,15 +4536,15 @@ def test_n_dimensional_planck_law(self): wl = np.tile(wl, 6) p = np.tile(p, 6) - np.testing.assert_almost_equal(planck_law(wl, 5500), p) + np.testing.assert_array_almost_equal(planck_law(wl, 5500), p) wl = np.reshape(wl, (2, 3)) p = np.reshape(p, (2, 3)) - np.testing.assert_almost_equal(planck_law(wl, 5500), p) + np.testing.assert_array_almost_equal(planck_law(wl, 5500), p) wl = np.reshape(wl, (2, 3, 1)) p = np.reshape(p, (2, 3, 1)) - np.testing.assert_almost_equal(planck_law(wl, 5500), p) + np.testing.assert_array_almost_equal(planck_law(wl, 5500), p) @ignore_numpy_errors def test_nan_planck_law(self): diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index 5a2bf031e3..895cbcd9c7 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -52,7 +52,7 @@ def test_bandpass_correction_Stearns1988(self): range(len(DATA_NON_BANDPASS_CORRECTED)), DATA_NON_BANDPASS_CORRECTED))) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( bandpass_correction_Stearns1988(sd).values, DATA_BANDPASS_CORRECTED) diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index a2dc1848b0..69c1626525 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -59,14 +59,14 @@ def test_closest_spectral_locus_wavelength(self): i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) self.assertEqual(i_wl, np.array(256)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.68354746, 0.31628409]), decimal=7) xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) self.assertEqual(i_wl, np.array(248)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.45723147, 0.13628148]), decimal=7) def test_n_dimensional_closest_spectral_locus_wavelength(self): @@ -79,24 +79,24 @@ def test_n_dimensional_closest_spectral_locus_wavelength(self): xy_n = CCS_D65 i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) i_wl_r, xy_wl_r = np.array(256), np.array([0.68354746, 0.31628409]) - np.testing.assert_almost_equal(i_wl, i_wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(i_wl, i_wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) i_wl_r = np.tile(i_wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) - np.testing.assert_almost_equal(i_wl, i_wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(i_wl, i_wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) i_wl_r = np.reshape(i_wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) - np.testing.assert_almost_equal(i_wl, i_wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(i_wl, i_wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) @ignore_numpy_errors def test_nan_closest_spectral_locus_wavelength(self): @@ -132,9 +132,9 @@ def test_dominant_wavelength(self): xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931) self.assertEqual(wl, np.array(616.0)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.68354746, 0.31628409]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_cwl, np.array([0.68354746, 0.31628409]), decimal=7) xy = np.array([0.37605506, 0.24452225]) @@ -142,9 +142,9 @@ def test_dominant_wavelength(self): xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931) self.assertEqual(i_wl, np.array(-509.0)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.45723147, 0.13628148]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_cwl, np.array([0.01040962, 0.73207453]), decimal=7) def test_n_dimensional_dominant_wavelength(self): @@ -160,9 +160,9 @@ def test_n_dimensional_dominant_wavelength(self): wl_r, xy_wl_r, xy_cwl_r = (np.array(616.0), np.array([0.68354746, 0.31628409]), np.array([0.68354746, 0.31628409])) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) @@ -171,9 +171,9 @@ def test_n_dimensional_dominant_wavelength(self): wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) @@ -182,9 +182,9 @@ def test_n_dimensional_dominant_wavelength(self): wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) @ignore_numpy_errors def test_nan_dominant_wavelength(self): @@ -221,9 +221,9 @@ def test_complementary_wavelength(self): xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931) self.assertEqual(wl, np.array(492.0)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.03647950, 0.33847127]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_cwl, np.array([0.03647950, 0.33847127]), decimal=7) xy = np.array([0.37605506, 0.24452225]) @@ -231,9 +231,9 @@ def test_complementary_wavelength(self): xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931) self.assertEqual(i_wl, np.array(509.0)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_wl, np.array([0.01040962, 0.73207453]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_cwl, np.array([0.01040962, 0.73207453]), decimal=7) def test_n_dimensional_complementary_wavelength(self): @@ -249,9 +249,9 @@ def test_n_dimensional_complementary_wavelength(self): wl_r, xy_wl_r, xy_cwl_r = (np.array(492.0), np.array([0.03647950, 0.33847127]), np.array([0.03647950, 0.33847127])) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) @@ -260,9 +260,9 @@ def test_n_dimensional_complementary_wavelength(self): wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) @@ -271,9 +271,9 @@ def test_n_dimensional_complementary_wavelength(self): wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) - np.testing.assert_almost_equal(wl, wl_r) - np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) - np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) + np.testing.assert_array_almost_equal(wl, wl_r) + np.testing.assert_array_almost_equal(xy_wl, xy_wl_r, decimal=7) + np.testing.assert_array_almost_equal(xy_cwl, xy_cwl_r, decimal=7) @ignore_numpy_errors def test_nan_complementary_wavelength(self): @@ -333,20 +333,30 @@ def test_n_dimensional_excitation_purity(self): xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) P_e = np.tile(P_e, 6) - np.testing.assert_almost_equal( +<<<<<<< HEAD + np.testing.assert_array_almost_equal( excitation_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, decimal=7) +======= + np.testing.assert_array_almost_equal( + excitation_purity(xy, xy_n, CIE_2_1931_CMFS), P_e, decimal=7) +>>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) P_e = np.reshape(P_e, (2, 3)) - np.testing.assert_almost_equal( +<<<<<<< HEAD + np.testing.assert_array_almost_equal( excitation_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, decimal=7) +======= + np.testing.assert_array_almost_equal( + excitation_purity(xy, xy_n, CIE_2_1931_CMFS), P_e, decimal=7) +>>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube @ignore_numpy_errors def test_nan_excitation_purity(self): @@ -407,7 +417,7 @@ def test_n_dimensional_colorimetric_purity(self): xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) P_e = np.tile(P_e, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colorimetric_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, @@ -416,7 +426,7 @@ def test_n_dimensional_colorimetric_purity(self): xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) P_e = np.reshape(P_e, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( colorimetric_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, diff --git a/colour/colorimetry/tests/test_generation.py b/colour/colorimetry/tests/test_generation.py index fd43d87b38..8079f63268 100644 --- a/colour/colorimetry/tests/test_generation.py +++ b/colour/colorimetry/tests/test_generation.py @@ -101,13 +101,13 @@ def test_msds_constant(self): msds = msds_constant(np.pi, labels=['a', 'b', 'c']) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[360], np.array([np.pi, np.pi, np.pi]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[555], np.array([np.pi, np.pi, np.pi]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[780], np.array([np.pi, np.pi, np.pi]), decimal=7) @@ -125,11 +125,11 @@ def test_msds_zeros(self): msds = msds_zeros(labels=['a', 'b', 'c']) - np.testing.assert_equal(msds[360], np.array([0, 0, 0])) + np.testing.assert_array_equal(msds[360], np.array([0, 0, 0])) - np.testing.assert_equal(msds[555], np.array([0, 0, 0])) + np.testing.assert_array_equal(msds[555], np.array([0, 0, 0])) - np.testing.assert_equal(msds[780], np.array([0, 0, 0])) + np.testing.assert_array_equal(msds[780], np.array([0, 0, 0])) class TestMsdsOnes(unittest.TestCase): @@ -145,11 +145,11 @@ def test_msds_ones(self): msds = msds_ones(labels=['a', 'b', 'c']) - np.testing.assert_equal(msds[360], np.array([1, 1, 1])) + np.testing.assert_array_equal(msds[360], np.array([1, 1, 1])) - np.testing.assert_equal(msds[555], np.array([1, 1, 1])) + np.testing.assert_array_equal(msds[555], np.array([1, 1, 1])) - np.testing.assert_equal(msds[780], np.array([1, 1, 1])) + np.testing.assert_array_equal(msds[780], np.array([1, 1, 1])) class TestSdGaussianNormal(unittest.TestCase): diff --git a/colour/colorimetry/tests/test_illuminants.py b/colour/colorimetry/tests/test_illuminants.py index efe3bd33f2..b670dcadaa 100644 --- a/colour/colorimetry/tests/test_illuminants.py +++ b/colour/colorimetry/tests/test_illuminants.py @@ -137,7 +137,7 @@ def test_sd_CIE_standard_illuminant_A(self): sd_CIE_standard_illuminant_A` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_CIE_standard_illuminant_A(SpectralShape(360, 830, 5)).values, DATA_A, decimal=7) @@ -205,12 +205,12 @@ def test_n_dimensional_daylight_locus_function(self): x_D = np.tile(x_D, (6, 1)) y_D = np.tile(y_D, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( daylight_locus_function(x_D), y_D, decimal=7) x_D = np.reshape(x_D, (2, 3, 1)) y_D = np.reshape(y_D, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( daylight_locus_function(x_D), y_D, decimal=7) @ignore_numpy_errors diff --git a/colour/colorimetry/tests/test_lefs.py b/colour/colorimetry/tests/test_lefs.py index af367b8873..fa69d2fbe7 100644 --- a/colour/colorimetry/tests/test_lefs.py +++ b/colour/colorimetry/tests/test_lefs.py @@ -166,15 +166,18 @@ def test_n_dimensional_mesopic_weighting_function(self): wl = np.tile(wl, 6) Vm = np.tile(Vm, 6) - np.testing.assert_almost_equal(mesopic_weighting_function(wl, 0.2), Vm) + np.testing.assert_array_almost_equal( + mesopic_weighting_function(wl, 0.2), Vm) wl = np.reshape(wl, (2, 3)) Vm = np.reshape(Vm, (2, 3)) - np.testing.assert_almost_equal(mesopic_weighting_function(wl, 0.2), Vm) + np.testing.assert_array_almost_equal( + mesopic_weighting_function(wl, 0.2), Vm) wl = np.reshape(wl, (2, 3, 1)) Vm = np.reshape(Vm, (2, 3, 1)) - np.testing.assert_almost_equal(mesopic_weighting_function(wl, 0.2), Vm) + np.testing.assert_array_almost_equal( + mesopic_weighting_function(wl, 0.2), Vm) @ignore_numpy_errors def test_nan_mesopic_weighting_function(self): @@ -199,7 +202,7 @@ def test_sd_mesopic_luminous_efficiency_function(self): sd_mesopic_luminous_efficiency_function` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_mesopic_luminous_efficiency_function(0.2).values, DATA_MESOPIC_LEF, decimal=7) diff --git a/colour/colorimetry/tests/test_lightness.py b/colour/colorimetry/tests/test_lightness.py index 5c0ab6dd8c..0341209113 100644 --- a/colour/colorimetry/tests/test_lightness.py +++ b/colour/colorimetry/tests/test_lightness.py @@ -61,15 +61,18 @@ def test_n_dimensional_lightness_Glasser1958(self): Y = np.tile(Y, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(lightness_Glasser1958(Y), L, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Glasser1958(Y), L, decimal=7) Y = np.reshape(Y, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(lightness_Glasser1958(Y), L, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Glasser1958(Y), L, decimal=7) Y = np.reshape(Y, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(lightness_Glasser1958(Y), L, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Glasser1958(Y), L, decimal=7) def test_domain_range_scale_lightness_Glasser1958(self): """ @@ -82,7 +85,7 @@ def test_domain_range_scale_lightness_Glasser1958(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Glasser1958(12.19722535 * factor), L * factor, decimal=7) @@ -130,15 +133,18 @@ def test_n_dimensional_lightness_Wyszecki1963(self): Y = np.tile(Y, 6) W = np.tile(W, 6) - np.testing.assert_almost_equal(lightness_Wyszecki1963(Y), W, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Wyszecki1963(Y), W, decimal=7) Y = np.reshape(Y, (2, 3)) W = np.reshape(W, (2, 3)) - np.testing.assert_almost_equal(lightness_Wyszecki1963(Y), W, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Wyszecki1963(Y), W, decimal=7) Y = np.reshape(Y, (2, 3, 1)) W = np.reshape(W, (2, 3, 1)) - np.testing.assert_almost_equal(lightness_Wyszecki1963(Y), W, decimal=7) + np.testing.assert_array_almost_equal( + lightness_Wyszecki1963(Y), W, decimal=7) def test_domain_range_scale_lightness_Wyszecki1963(self): """ @@ -151,7 +157,7 @@ def test_domain_range_scale_lightness_Wyszecki1963(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Wyszecki1963(12.19722535 * factor), W * factor, decimal=7) @@ -206,17 +212,17 @@ def test_n_dimensional_intermediate_lightness_function_CIE1976(self): Y = np.tile(Y, 6) f_Y_Y_n = np.tile(f_Y_Y_n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_lightness_function_CIE1976(Y), f_Y_Y_n, decimal=7) Y = np.reshape(Y, (2, 3)) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_lightness_function_CIE1976(Y), f_Y_Y_n, decimal=7) Y = np.reshape(Y, (2, 3, 1)) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_lightness_function_CIE1976(Y), f_Y_Y_n, decimal=7) def test_domain_range_scale_intermediate_lightness_function_CIE1976(self): @@ -230,7 +236,7 @@ def test_domain_range_scale_intermediate_lightness_function_CIE1976(self): for scale in ('reference', 1, 100): with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_lightness_function_CIE1976(12.19722535, 100), f_Y_Y_n, decimal=7) @@ -287,15 +293,18 @@ def test_n_dimensional_lightness_CIE1976(self): Y = np.tile(Y, 6) L_star = np.tile(L_star, 6) - np.testing.assert_almost_equal(lightness_CIE1976(Y), L_star, decimal=7) + np.testing.assert_array_almost_equal( + lightness_CIE1976(Y), L_star, decimal=7) Y = np.reshape(Y, (2, 3)) L_star = np.reshape(L_star, (2, 3)) - np.testing.assert_almost_equal(lightness_CIE1976(Y), L_star, decimal=7) + np.testing.assert_array_almost_equal( + lightness_CIE1976(Y), L_star, decimal=7) Y = np.reshape(Y, (2, 3, 1)) L_star = np.reshape(L_star, (2, 3, 1)) - np.testing.assert_almost_equal(lightness_CIE1976(Y), L_star, decimal=7) + np.testing.assert_array_almost_equal( + lightness_CIE1976(Y), L_star, decimal=7) def test_domain_range_scale_lightness_CIE1976(self): """ @@ -308,7 +317,7 @@ def test_domain_range_scale_lightness_CIE1976(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_CIE1976(12.19722535 * factor, 100), L_star * factor, decimal=7) @@ -372,17 +381,17 @@ def test_n_dimensional_lightness_Fairchild2010(self): Y = np.tile(Y, 6) L_hdr = np.tile(L_hdr, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2010(Y), L_hdr, decimal=7) Y = np.reshape(Y, (2, 3)) L_hdr = np.reshape(L_hdr, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2010(Y), L_hdr, decimal=7) Y = np.reshape(Y, (2, 3, 1)) L_hdr = np.reshape(L_hdr, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2010(Y), L_hdr, decimal=7) def test_domain_range_scale_lightness_Fairchild2010(self): @@ -396,7 +405,7 @@ def test_domain_range_scale_lightness_Fairchild2010(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2010(12.19722535 / 100 * factor_a), L_hdr * factor_b, decimal=7) @@ -461,17 +470,17 @@ def test_n_dimensional_lightness_Fairchild2011(self): Y = np.tile(Y, 6) L_hdr = np.tile(L_hdr, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2011(Y), L_hdr, decimal=7) Y = np.reshape(Y, (2, 3)) L_hdr = np.reshape(L_hdr, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2011(Y), L_hdr, decimal=7) Y = np.reshape(Y, (2, 3, 1)) L_hdr = np.reshape(L_hdr, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2011(Y), L_hdr, decimal=7) def test_domain_range_scale_lightness_Fairchild2011(self): @@ -485,7 +494,7 @@ def test_domain_range_scale_lightness_Fairchild2011(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness_Fairchild2011(12.19722535 / 100 * factor_a), L_hdr * factor_b, decimal=7) @@ -521,7 +530,7 @@ def test_domain_range_scale_lightness(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lightness(12.19722535 * factor, method, Y_n=100), value * factor, decimal=7) diff --git a/colour/colorimetry/tests/test_luminance.py b/colour/colorimetry/tests/test_luminance.py index 3a9bb855df..1e36cf363c 100644 --- a/colour/colorimetry/tests/test_luminance.py +++ b/colour/colorimetry/tests/test_luminance.py @@ -61,15 +61,18 @@ def test_n_dimensional_luminance_Newhall1943(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(luminance_Newhall1943(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_Newhall1943(V), Y, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(luminance_Newhall1943(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_Newhall1943(V), Y, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal(luminance_Newhall1943(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_Newhall1943(V), Y, decimal=7) def test_domain_range_scale_luminance_Newhall1943(self): """ @@ -82,7 +85,7 @@ def test_domain_range_scale_luminance_Newhall1943(self): d_r = (('reference', 1, 1), (1, 0.1, 0.01), (100, 10, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Newhall1943(4.08244375 * factor_a), Y * factor_b, decimal=7) @@ -130,15 +133,18 @@ def test_n_dimensional_luminance_ASTMD1535(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(luminance_ASTMD1535(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_ASTMD1535(V), Y, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(luminance_ASTMD1535(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_ASTMD1535(V), Y, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal(luminance_ASTMD1535(V), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_ASTMD1535(V), Y, decimal=7) def test_domain_range_scale_luminance_ASTMD1535(self): """ @@ -151,7 +157,7 @@ def test_domain_range_scale_luminance_ASTMD1535(self): d_r = (('reference', 1, 1), (1, 0.1, 0.01), (100, 10, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_ASTMD1535(4.08244375 * factor_a), Y * factor_b, decimal=7) @@ -206,17 +212,17 @@ def test_n_dimensional_intermediate_luminance_function_CIE1976(self): f_Y_Y_n = np.tile(f_Y_Y_n, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): @@ -230,7 +236,7 @@ def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): for scale in ('reference', 1, 100): with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( intermediate_luminance_function_CIE1976( 41.527875844653451, 100), Y, @@ -298,15 +304,18 @@ def test_n_dimensional_luminance_CIE1976(self): L_star = np.tile(L_star, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) + np.testing.assert_array_almost_equal( + luminance_CIE1976(L_star), Y, decimal=7) def test_domain_range_scale_luminance_CIE1976(self): """ @@ -319,7 +328,7 @@ def test_domain_range_scale_luminance_CIE1976(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_CIE1976(41.527875844653451 * factor, 100), Y * factor, decimal=7) @@ -387,17 +396,17 @@ def test_n_dimensional_luminance_Fairchild2010(self): L_hdr = np.tile(L_hdr, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2010(L_hdr), Y, decimal=7) L_hdr = np.reshape(L_hdr, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2010(L_hdr), Y, decimal=7) L_hdr = np.reshape(L_hdr, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2010(L_hdr), Y, decimal=7) def test_domain_range_scale_luminance_Fairchild2010(self): @@ -411,7 +420,7 @@ def test_domain_range_scale_luminance_Fairchild2010(self): d_r = (('reference', 1, 1), (1, 0.01, 1), (100, 1, 100)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2010(31.996390226262736 * factor_a), Y * factor_b, decimal=7) @@ -480,17 +489,17 @@ def test_n_dimensional_luminance_Fairchild2011(self): L_hdr = np.tile(L_hdr, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2011(L_hdr), Y, decimal=7) L_hdr = np.reshape(L_hdr, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2011(L_hdr), Y, decimal=7) L_hdr = np.reshape(L_hdr, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2011(L_hdr), Y, decimal=7) def test_domain_range_scale_luminance_Fairchild2011(self): @@ -504,7 +513,7 @@ def test_domain_range_scale_luminance_Fairchild2011(self): d_r = (('reference', 1, 1), (1, 0.01, 1), (100, 1, 100)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance_Fairchild2011(26.459509817572265 * factor_a), Y * factor_b, decimal=7) @@ -540,7 +549,7 @@ def test_domain_range_scale_luminance(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( luminance( 41.527875844653451 * factor, method, Y_n=100), value * factor, diff --git a/colour/colorimetry/tests/test_spectrum.py b/colour/colorimetry/tests/test_spectrum.py index 66c43b9deb..2068a1764c 100644 --- a/colour/colorimetry/tests/test_spectrum.py +++ b/colour/colorimetry/tests/test_spectrum.py @@ -1302,7 +1302,7 @@ def test__iter__(self): method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [wavelength for wavelength in SpectralShape(0, 10, 0.1)], np.arange(0, 10 + 0.1, 0.1)) @@ -1350,7 +1350,7 @@ def test_range(self): Tests :func:`colour.colorimetry.spectrum.SpectralShape.range` method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [wavelength for wavelength in SpectralShape(0, 10, 0.1)], np.arange(0, 10 + 0.1, 0.1)) @@ -1452,7 +1452,7 @@ def test_interpolate(self): SpectralDistribution.interpolate` method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._sd.copy().interpolate(SpectralShape(interval=1)).values, DATA_SAMPLE_INTERPOLATED, decimal=7) @@ -1526,7 +1526,7 @@ def test_normalise(self): SpectralDistribution.normalise` method. """ - np.testing.assert_almost_equal(self._sd.copy().normalise(100).values, + np.testing.assert_array_almost_equal(self._sd.copy().normalise(100).values, DATA_SAMPLE_NORMALISED) @@ -1660,7 +1660,7 @@ def test_interpolate(self): msds.interpolate(SpectralShape(interval=1)) for signal in msds.signals.values(): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.values, DATA_SAMPLE_INTERPOLATED, decimal=7) # TODO: Remove statement whenever we make "Scipy" 0.19.0 the minimum @@ -1688,9 +1688,9 @@ def test_extrapolate(self): msds = MultiSpectralDistributions(data) msds.extrapolate(SpectralShape(10, 50)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[10], np.array([0.0, 0.0, 0.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[50], np.array([1.0, 1.0, 1.0]), decimal=7) msds = MultiSpectralDistributions( @@ -1702,9 +1702,9 @@ def test_extrapolate(self): 'left': None, 'right': None }) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[10], np.array([-1.5, -1.5, -1.5]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds[50], np.array([2.5, 2.5, 2.5]), decimal=7) def test_align(self): @@ -1739,7 +1739,7 @@ def test_normalise(self): MultiSpectralDistributions.normalise` method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._sample_msds.copy().normalise(100).values, tstack([DATA_SAMPLE_NORMALISED] * 3)) @@ -1820,13 +1820,13 @@ def test_sds_and_msds_to_msds(self): sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).shape, shape) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).wavelengths, shape.range(), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).values, tstack([sd_1.align(shape).values, diff --git a/colour/colorimetry/tests/test_transformations.py b/colour/colorimetry/tests/test_transformations.py index 9bf4b84d10..ce392df34d 100644 --- a/colour/colorimetry/tests/test_transformations.py +++ b/colour/colorimetry/tests/test_transformations.py @@ -72,17 +72,17 @@ def test_n_dimensional_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): wl = np.tile(wl, 6) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) @ignore_numpy_errors @@ -136,17 +136,17 @@ def test_n_dimensional_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): wl = np.tile(wl, 6) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) @ignore_numpy_errors @@ -200,17 +200,17 @@ def test_n_dimensional_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): wl = np.tile(wl, 6) LMS = np.tile(LMS, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(wl), LMS) wl = np.reshape(wl, (2, 3)) LMS = np.reshape(LMS, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(wl), LMS) wl = np.reshape(wl, (2, 3, 1)) LMS = np.reshape(LMS, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(wl), LMS) @ignore_numpy_errors @@ -264,17 +264,17 @@ def test_n_dimensional_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): wl = np.tile(wl, 6) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(wl), XYZ) @ignore_numpy_errors @@ -328,17 +328,17 @@ def test_n_dimensional_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): wl = np.tile(wl, 6) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) wl = np.reshape(wl, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(wl), XYZ) @ignore_numpy_errors diff --git a/colour/colorimetry/tests/test_tristimulus.py b/colour/colorimetry/tests/test_tristimulus.py index 97e9f66a16..75ca1b7f98 100644 --- a/colour/colorimetry/tests/test_tristimulus.py +++ b/colour/colorimetry/tests/test_tristimulus.py @@ -438,12 +438,12 @@ def test_lagrange_coefficients_ASTME2022(self): lagrange_coefficients_ASTME2022` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lagrange_coefficients_ASTME2022(10, 'inner'), LAGRANGE_COEFFICIENTS_A, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lagrange_coefficients_ASTME2022(10, 'boundary'), LAGRANGE_COEFFICIENTS_B, decimal=7) @@ -476,12 +476,12 @@ def test_tristimulus_weighting_factors_ASTME2022(self): twf = tristimulus_weighting_factors_ASTME2022( cmfs, A, SpectralShape(360, 830, 10)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.round(twf, 3), TWF_A_CIE_1964_10_10, decimal=3) twf = tristimulus_weighting_factors_ASTME2022( cmfs, A, SpectralShape(360, 830, 20)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.round(twf, 3), TWF_A_CIE_1964_10_20, decimal=3) cmfs = MSDS_CMFS['CIE 1931 2 Degree Standard Observer'] @@ -489,12 +489,12 @@ def test_tristimulus_weighting_factors_ASTME2022(self): cmfs.shape, interpolator=LinearInterpolator) twf = tristimulus_weighting_factors_ASTME2022( cmfs, D65, SpectralShape(360, 830, 20)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.round(twf, 3), TWF_D65_CIE_1931_2_20, decimal=3) twf = tristimulus_weighting_factors_ASTME2022( cmfs, D65, SpectralShape(360, 830, 20), k=1) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( twf, TWF_D65_CIE_1931_2_20_K1, decimal=7) def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self): @@ -528,7 +528,7 @@ def test_adjust_tristimulus_weighting_factors_ASTME308(self): adjust_tristimulus_weighting_factors_ASTME308` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( adjust_tristimulus_weighting_factors_ASTME308( TWF_D65_CIE_1931_2_20, SpectralShape(360, 830, 20), SpectralShape(400, 700, 20)), @@ -549,23 +549,23 @@ def test_sd_to_XYZ_integration(self): """ cmfs = MSDS_CMFS['CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(SD_SAMPLE, cmfs, SDS_ILLUMINANTS['A']), np.array([14.46341147, 10.85819624, 2.04695585]), decimal=7) cmfs = MSDS_CMFS['CIE 1964 10 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(SD_SAMPLE, cmfs, SDS_ILLUMINANTS['C']), np.array([10.77002699, 9.44876636, 6.62415290]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(SD_SAMPLE, cmfs, SDS_ILLUMINANTS['FL2']), np.array([11.57540576, 9.98608874, 3.95242590]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['FL2'], k=683), np.array([122375.09261493, 105572.84645912, 41785.01342332]), @@ -583,7 +583,7 @@ def test_domain_range_scale_sd_to_XYZ_integration(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(SD_SAMPLE, cmfs, SDS_ILLUMINANTS['A']), XYZ * factor, @@ -605,47 +605,52 @@ def test_sd_to_XYZ_tristimulus_weighting_factors_ASTME308(self): """ cmfs = MSDS_CMFS['CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['A']), np.array([14.46341867, 10.85820227, 2.04697034]), decimal=7) +<<<<<<< HEAD cmfs = MSDS_CMFS['CIE 1964 10 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( +======= + cmfs = CMFS['CIE 1964 10 Degree Standard Observer'] + np.testing.assert_array_almost_equal( +>>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['C']), np.array([10.77005571, 9.44877491, 6.62428210]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['FL2']), np.array([11.57542759, 9.98605604, 3.95273304]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE.copy().trim(SpectralShape(400, 700, 5)), cmfs, SDS_ILLUMINANTS['A']), np.array([14.38153638, 10.74503131, 2.01613844]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE.copy().interpolate(SpectralShape(400, 700, 10)), cmfs, SDS_ILLUMINANTS['A']), np.array([14.38257202, 10.74568178, 2.01588427]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE.copy().interpolate(SpectralShape(400, 700, 20)), cmfs, SDS_ILLUMINANTS['A']), np.array([14.38329645, 10.74603515, 2.01561113]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE.copy().interpolate(SpectralShape(400, 700, 20)), cmfs, @@ -668,7 +673,7 @@ def test_domain_range_scale_sd_to_XYZ_twf_ASTME308(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['A']), XYZ * factor, @@ -696,13 +701,13 @@ def test_sd_to_XYZ_ASTME308_mi_1nm(self): definition for 1 nm measurement intervals. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308(self._sd.copy().align(self._cmfs.shape), self._cmfs, self._A), np.array([14.46372680, 10.85832950, 2.04663200]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(self._cmfs.shape), self._cmfs, @@ -711,14 +716,14 @@ def test_sd_to_XYZ_ASTME308_mi_1nm(self): np.array([14.46366018, 10.85827949, 2.04662258]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 1)), self._cmfs, self._A), np.array([14.54173397, 10.88628632, 2.04965822]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 1)), self._cmfs, @@ -727,7 +732,7 @@ def test_sd_to_XYZ_ASTME308_mi_1nm(self): np.array([14.54203076, 10.88636754, 2.04964877]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 1)), self._cmfs, @@ -742,14 +747,14 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): definition for 5 nm measurement intervals. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 5)), self._cmfs, self._A), np.array([14.46372173, 10.85832502, 2.04664734]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 5)), self._cmfs, @@ -758,7 +763,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.46366388, 10.85828159, 2.04663915]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 5)), self._cmfs, @@ -767,14 +772,14 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.46373399, 10.85833553, 2.0466465]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 5)), self._cmfs, self._A), np.array([14.54025742, 10.88576251, 2.04950226]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 5)), self._cmfs, @@ -783,7 +788,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.54051517, 10.88583304, 2.04949406]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 5)), self._cmfs, @@ -792,7 +797,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.54022093, 10.88575468, 2.04951057]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 5)), self._cmfs, @@ -802,7 +807,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.46366737, 10.85828552, 2.04663707]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 5)), self._cmfs, @@ -812,7 +817,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): np.array([14.54051772, 10.88583590, 2.04950113]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 5)), self._cmfs, @@ -827,14 +832,14 @@ def test_sd_to_XYZ_ASTME308_mi_10nm(self): definition for 10 nm measurement intervals. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 10)), self._cmfs, self._A), np.array([14.47779980, 10.86358645, 2.04751388]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 830, 10)), self._cmfs, @@ -843,14 +848,14 @@ def test_sd_to_XYZ_ASTME308_mi_10nm(self): np.array([14.47773312, 10.86353641, 2.04750445]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 10)), self._cmfs, self._A), np.array([14.54137532, 10.88641727, 2.04931318]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 10)), self._cmfs, @@ -859,7 +864,7 @@ def test_sd_to_XYZ_ASTME308_mi_10nm(self): np.array([14.54167211, 10.88649849, 2.04930374]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 10)), self._cmfs, @@ -874,14 +879,14 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): definition for 20 nm measurement intervals. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 820, 20)), self._cmfs, self._A), np.array([14.50187464, 10.87217124, 2.04918305]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 820, 20)), self._cmfs, @@ -890,7 +895,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.50180785, 10.87212116, 2.04917361]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 820, 20)), self._cmfs, @@ -899,14 +904,14 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.50216194, 10.87236873, 2.04977256]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 20)), self._cmfs, self._A), np.array([14.54114025, 10.88634755, 2.04916445]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 20)), self._cmfs, @@ -915,7 +920,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.54143704, 10.88642877, 2.04915501]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 20)), self._cmfs, @@ -924,7 +929,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.54242562, 10.88694088, 2.04919645]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(360, 820, 20)), self._cmfs, @@ -934,7 +939,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.50209515, 10.87231865, 2.04976312]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 20)), self._cmfs, @@ -944,7 +949,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): np.array([14.54272240, 10.88702210, 2.04918701]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_ASTME308( self._sd.copy().align(SpectralShape(400, 700, 20)), self._cmfs, @@ -976,12 +981,12 @@ def test_msds_to_XYZ_integration(self): """ cmfs = MSDS_CMFS['CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_integration(MSDS_TWO, cmfs, SDS_ILLUMINANTS['D65']), TVS_D65_INTEGRATION_MSDS, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_integration( DATA_TWO, cmfs, @@ -990,7 +995,7 @@ def test_msds_to_XYZ_integration(self): TVS_D65_ARRAY_INTEGRATION, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_integration( DATA_TWO, cmfs, @@ -1010,7 +1015,7 @@ def test_domain_range_scale_msds_to_XYZ_integration(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_integration( DATA_TWO, cmfs, @@ -1034,12 +1039,12 @@ def test_msds_to_XYZ_ASTME308(self): cmfs = MSDS_CMFS['CIE 1931 2 Degree Standard Observer'] msds = MSDS_TWO.copy().align(SpectralShape(400, 700, 20)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_ASTME308(msds, cmfs, SDS_ILLUMINANTS['D65']), TVS_D65_ASTME308_MSDS, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_ASTME308(msds, cmfs, SDS_ILLUMINANTS['D65'], k=1), TVS_D65_ASTME308_K1_MSDS, decimal=7) @@ -1054,7 +1059,7 @@ def test_domain_range_scale_msds_to_XYZ_ASTME308(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( msds_to_XYZ_ASTME308( MSDS_TWO.copy().align(SpectralShape(400, 700, 20)), cmfs, SDS_ILLUMINANTS['D65']), @@ -1082,19 +1087,19 @@ def test_wavelength_to_XYZ(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ( 480, MSDS_CMFS['CIE 1931 2 Degree Standard Observer']), np.array([0.09564, 0.13902, 0.81295]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ( 480, MSDS_CMFS['CIE 2012 2 Degree Standard Observer']), np.array([0.08182895, 0.17880480, 0.75523790]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ( 641.5, MSDS_CMFS['CIE 2012 2 Degree Standard Observer']), np.array([0.44575583, 0.18184213, 0.00000000]), @@ -1122,17 +1127,17 @@ def test_n_dimensional_wavelength_to_XYZ(self): wl = np.tile(wl, 6) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ(wl, cmfs), XYZ, decimal=7) wl = np.reshape(wl, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ(wl, cmfs), XYZ, decimal=7) wl = np.reshape(wl, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( wavelength_to_XYZ(wl, cmfs), XYZ, decimal=7) diff --git a/colour/colorimetry/tests/test_whiteness.py b/colour/colorimetry/tests/test_whiteness.py index d80af794e2..6269d7b6a5 100644 --- a/colour/colorimetry/tests/test_whiteness.py +++ b/colour/colorimetry/tests/test_whiteness.py @@ -75,13 +75,13 @@ def test_n_dimensional_whiteness_Berger1959(self): XYZ = np.tile(XYZ, (6, 1)) XYZ_0 = np.tile(XYZ_0, (6, 1)) W = np.tile(W, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Berger1959(XYZ, XYZ_0), W, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) XYZ_0 = np.reshape(XYZ_0, (2, 3, 3)) W = np.reshape(W, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Berger1959(XYZ, XYZ_0), W, decimal=7) def test_domain_range_scale_whiteness_Berger1959(self): @@ -97,7 +97,7 @@ def test_domain_range_scale_whiteness_Berger1959(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Berger1959(XYZ * factor, XYZ_0 * factor), W * factor, decimal=7) @@ -163,13 +163,13 @@ def test_n_dimensional_whiteness_Taube1960(self): XYZ = np.tile(XYZ, (6, 1)) XYZ_0 = np.tile(XYZ_0, (6, 1)) WI = np.tile(WI, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Taube1960(XYZ, XYZ_0), WI, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) XYZ_0 = np.reshape(XYZ_0, (2, 3, 3)) WI = np.reshape(WI, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Taube1960(XYZ, XYZ_0), WI, decimal=7) def test_domain_range_scale_whiteness_Taube1960(self): @@ -185,7 +185,7 @@ def test_domain_range_scale_whiteness_Taube1960(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Taube1960(XYZ * factor, XYZ_0 * factor), WI * factor, decimal=7) @@ -243,12 +243,12 @@ def test_n_dimensional_whiteness_Stensby1968(self): Lab = np.tile(Lab, (6, 1)) WI = np.tile(WI, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Stensby1968(Lab), WI, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) WI = np.reshape(WI, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Stensby1968(Lab), WI, decimal=7) def test_domain_range_scale_whiteness_Stensby1968(self): @@ -263,7 +263,7 @@ def test_domain_range_scale_whiteness_Stensby1968(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Stensby1968(Lab * factor), WI * factor, decimal=7) @@ -323,11 +323,13 @@ def test_n_dimensional_whiteness_ASTME313(self): XYZ = np.tile(XYZ, (6, 1)) WI = np.tile(WI, 6) - np.testing.assert_almost_equal(whiteness_ASTME313(XYZ), WI, decimal=7) + np.testing.assert_array_almost_equal( + whiteness_ASTME313(XYZ), WI, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) WI = np.reshape(WI, (2, 3)) - np.testing.assert_almost_equal(whiteness_ASTME313(XYZ), WI, decimal=7) + np.testing.assert_array_almost_equal( + whiteness_ASTME313(XYZ), WI, decimal=7) def test_domain_range_scale_whiteness_ASTME313(self): """ @@ -341,7 +343,7 @@ def test_domain_range_scale_whiteness_ASTME313(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_ASTME313(XYZ * factor), WI * factor, decimal=7) @ignore_numpy_errors @@ -370,17 +372,17 @@ def test_whiteness_Ganz1979(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(np.array([0.3139, 0.3311]), 100), np.array([99.33176520, 1.76108290]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(np.array([0.3500, 0.3334]), 100), np.array([23.38525400, -32.66182560]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(np.array([0.3334, 0.3334]), 100), np.array([54.39939920, -16.04152380]), decimal=7) @@ -397,17 +399,17 @@ def test_n_dimensional_whiteness_Ganz1979(self): xy = np.tile(xy, (6, 1)) WT = np.tile(WT, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(xy, Y), WT, decimal=7) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(xy, Y), WT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) Y = np.reshape(Y, (2, 3)) WT = np.reshape(WT, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(xy, Y), WT, decimal=7) def test_domain_range_scale_whiteness_Ganz1979(self): @@ -423,7 +425,7 @@ def test_domain_range_scale_whiteness_Ganz1979(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_Ganz1979(xy, Y * factor), WT * factor, decimal=7) @ignore_numpy_errors @@ -453,19 +455,19 @@ def test_whiteness_CIE2004(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004( np.array([0.3139, 0.3311]), 100, np.array([0.3139, 0.3311])), np.array([100.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004( np.array([0.3500, 0.3334]), 100, np.array([0.3139, 0.3311])), np.array([67.21000000, -34.60500000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004( np.array([0.3334, 0.3334]), 100, np.array([0.3139, 0.3311])), np.array([80.49000000, -18.00500000]), @@ -484,19 +486,19 @@ def test_n_dimensional_whiteness_CIE2004(self): xy = np.tile(xy, (6, 1)) WT = np.tile(WT, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) Y = np.tile(Y, 6) xy_n = np.tile(xy_n, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) Y = np.reshape(Y, (2, 3)) xy_n = np.reshape(xy_n, (2, 3, 2)) WT = np.reshape(WT, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) def test_domain_range_scale_whiteness_CIE2004(self): @@ -513,7 +515,7 @@ def test_domain_range_scale_whiteness_CIE2004(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness_CIE2004(xy, Y * factor, xy_n), WT * factor, decimal=7) @@ -557,7 +559,7 @@ def test_domain_range_scale_whiteness(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( whiteness(XYZ * factor, XYZ_0 * factor, method), value * factor, decimal=7) diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index 632852d365..4aa0040823 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -66,12 +66,12 @@ def test_n_dimensional_yellowness_ASTMD1925(self): XYZ = np.tile(XYZ, (6, 1)) YI = np.tile(YI, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( yellowness_ASTMD1925(XYZ), YI, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) YI = np.reshape(YI, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( yellowness_ASTMD1925(XYZ), YI, decimal=7) def test_domain_range_scale_yellowness_ASTMD1925(self): @@ -86,7 +86,7 @@ def test_domain_range_scale_yellowness_ASTMD1925(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( yellowness_ASTMD1925(XYZ * factor), YI * factor, decimal=7) @ignore_numpy_errors @@ -144,11 +144,13 @@ def test_n_dimensional_yellowness_ASTME313(self): XYZ = np.tile(XYZ, (6, 1)) YI = np.tile(YI, 6) - np.testing.assert_almost_equal(yellowness_ASTME313(XYZ), YI, decimal=7) + np.testing.assert_array_almost_equal( + yellowness_ASTME313(XYZ), YI, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) YI = np.reshape(YI, (2, 3)) - np.testing.assert_almost_equal(yellowness_ASTME313(XYZ), YI, decimal=7) + np.testing.assert_array_almost_equal( + yellowness_ASTME313(XYZ), YI, decimal=7) def test_domain_range_scale_yellowness_ASTME313(self): """ @@ -162,7 +164,7 @@ def test_domain_range_scale_yellowness_ASTME313(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( yellowness_ASTME313(XYZ * factor), YI * factor, decimal=7) @ignore_numpy_errors @@ -200,7 +202,7 @@ def test_domain_range_scale_yellowness(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( yellowness(XYZ * factor, method), value * factor, decimal=7) diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index 30c9c12ed3..d534349854 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -47,7 +47,7 @@ from colour.utilities import (CaseInsensitiveMapping, get_domain_range_scale, filter_kwargs, from_range_100, to_domain_100, - tsplit, tstack) + tsplit, tstack, as_float) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -118,7 +118,15 @@ def whiteness_Berger1959(XYZ, XYZ_0): WI = 0.333 * Y + 125 * (Z / Z_0) - 125 * (X / X_0) - return from_range_100(WI) + WI = from_range_100(WI) + + try: + if WI.size == 1: + return as_float(WI) + except Exception: + pass + + return WI def whiteness_Taube1960(XYZ, XYZ_0): @@ -175,8 +183,15 @@ def whiteness_Taube1960(XYZ, XYZ_0): _X_0, _Y_0, Z_0 = tsplit(to_domain_100(XYZ_0)) WI = 400 * (Z / Z_0) - 3 * Y + WI = from_range_100(WI) - return from_range_100(WI) + try: + if WI.size == 1: + return as_float(WI) + except Exception: + pass + + return WI def whiteness_Stensby1968(Lab): @@ -232,7 +247,15 @@ def whiteness_Stensby1968(Lab): WI = L - 3 * b + 3 * a - return from_range_100(WI) + WI = from_range_100(WI) + + try: + if WI.size == 1: + return as_float(WI) + except Exception: + pass + + return WI def whiteness_ASTME313(XYZ): @@ -281,7 +304,15 @@ def whiteness_ASTME313(XYZ): WI = 3.388 * Z - 3 * Y - return from_range_100(WI) + WI = from_range_100(WI) + + try: + if WI.size == 1: + return as_float(WI) + except Exception: + pass + + return WI def whiteness_Ganz1979(xy, Y): diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 9347222e18..24eb3f17c6 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -1486,6 +1486,12 @@ def to_dataframe(self): if is_pandas_installed(): from pandas import DataFrame + if np.__name__ == 'cupy': + return DataFrame( + data=np.asnumpy(self.range), + index=np.asnumpy(self.domain), + columns=np.asnumpy(self.labels)) + return DataFrame( data=self.range, index=self.domain, columns=self.labels) diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 172a2b5d10..f5cb6f809d 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -279,6 +279,8 @@ def domain(self): ndarray Continuous signal independent domain :math:`x` variable. """ + if np.__name__ == 'cupy' and self._domain is None: + return None return np.copy(self._domain) @@ -289,6 +291,7 @@ def domain(self, value): """ if value is not None: + value = np.array(value) if np.asarray(value).dtype != object: if not np.all(np.isfinite(value)): runtime_warning( @@ -328,6 +331,8 @@ def range(self): ndarray Continuous signal corresponding range :math:`y` variable. """ + if np.__name__ == 'cupy' and self._range is None: + return None return np.copy(self._range) @@ -338,6 +343,7 @@ def range(self, value): """ if value is not None: + value = np.array(value) if np.asarray(value).dtype != object: if not np.all(np.isfinite(value)): runtime_warning( @@ -1249,6 +1255,12 @@ def to_series(self): if is_pandas_installed(): from pandas import Series + if np.__name__ == 'cupy': + return Series( + data=np.asnumpy(self._range), + index=np.asnumpy(self._domain), + name=self.name) + return Series(data=self._range, index=self._domain, name=self.name) # ------------------------------------------------------------------------# diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index ebdcba69d3..500b1755a3 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -93,7 +93,7 @@ def test_domain(self): multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2])], np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0]]), @@ -104,7 +104,7 @@ def test_domain(self): np.testing.assert_array_equal(multi_signals.domain, self._domain_1 * 10) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2]) * 10], np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0]]), @@ -123,7 +123,7 @@ def test_range(self): multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2])], np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0]]), @@ -134,7 +134,7 @@ def test_range(self): np.testing.assert_array_equal(multi_signals.range, tstack([self._range_1] * 3) * 10) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2])], np.array([[10.0, 10.0, 10.0], [20.0, 20.0, 20.0], [30.0, 30.0, 30.0]]) * 10, @@ -144,7 +144,7 @@ def test_range(self): np.testing.assert_array_equal(multi_signals.range, self._range_2 * 10) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2])], np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0]]) * 10, @@ -158,7 +158,7 @@ def test_interpolator(self): multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.linspace(0, 5, 5)], np.array([[10.00000000, 20.00000000, 30.00000000], [22.83489024, 32.80460562, 42.77432100], @@ -169,7 +169,7 @@ def test_interpolator(self): multi_signals.interpolator = CubicSplineInterpolator - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.linspace(0, 5, 5)], np.array([[10.00000000, 20.00000000, 30.00000000], [22.50000000, 32.50000000, 42.50000000], @@ -186,7 +186,7 @@ def test_interpolator_kwargs(self): multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.linspace(0, 5, 5)], np.array([[10.00000000, 20.00000000, 30.00000000], [22.83489024, 32.80460562, 42.77432100], @@ -202,7 +202,7 @@ def test_interpolator_kwargs(self): } } - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.linspace(0, 5, 5)], np.array([[10.00000000, 20.00000000, 30.00000000], [18.91328761, 27.91961505, 36.92594248], @@ -233,7 +233,7 @@ def test_extrapolator_kwargs(self): 'method': 'Linear', } - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([-1000, 1000])], np.array([[-9990.0, -9980.0, -9970.0], [10010.0, 10020.0, 10030.0]]), @@ -412,16 +412,16 @@ def test__getitem__(self): method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals[0], np.array([10.0, 20.0, 30.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals[np.array([0, 1, 2])], np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals[np.linspace(0, 5, 5)], np.array([[10.00000000, 20.00000000, 30.00000000], [22.83489024, 32.80460562, 42.77432100], @@ -467,32 +467,32 @@ def test__setitem__(self): multi_signals = self._multi_signals.copy() multi_signals[0] = 20 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[0], np.array([20.0, 20.0, 20.0]), decimal=7) multi_signals[np.array([0, 1, 2])] = 30 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[np.array([0, 1, 2])], np.array([[30.0, 30.0, 30.0], [30.0, 30.0, 30.0], [30.0, 30.0, 30.0]]), decimal=7) multi_signals[0:3] = 40 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals[0:3], np.array([[40.0, 40.0, 40.0], [40.0, 40.0, 40.0], [40.0, 40.0, 40.0]]), decimal=7) multi_signals[np.linspace(0, 5, 5)] = 50 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.domain, np.array([ 0.00, 1.00, 1.25, 2.00, 2.50, 3.00, 3.75, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00 ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.range, np.array([ [50.0, 50.0, 50.0], @@ -512,7 +512,7 @@ def test__setitem__(self): decimal=7) multi_signals[np.array([0, 1, 2])] = np.array([10, 20, 30]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.range, np.array([ [10.0, 20.0, 30.0], @@ -532,7 +532,7 @@ def test__setitem__(self): decimal=7) multi_signals[np.array([0, 1, 2])] = np.arange(1, 10, 1).reshape(3, 3) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.range, np.array([ [1.0, 2.0, 3.0], @@ -644,81 +644,81 @@ def test_arithmetical_operation(self): arithmetical_operation` method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.arithmetical_operation(10, '+', False).range, self._range_2 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.arithmetical_operation(10, '-', False).range, self._range_2 - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.arithmetical_operation(10, '*', False).range, self._range_2 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.arithmetical_operation(10, '/', False).range, self._range_2 / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.arithmetical_operation(10, '**', False).range, self._range_2 ** 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._multi_signals + 10).range, self._range_2 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._multi_signals - 10).range, self._range_2 - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._multi_signals * 10).range, self._range_2 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._multi_signals / 10).range, self._range_2 / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._multi_signals ** 10).range, self._range_2 ** 10, decimal=7) multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(10, '+', True).range, self._range_2 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(10, '-', True).range, self._range_2, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(10, '*', True).range, self._range_2 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(10, '/', True).range, self._range_2, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(10, '**', True).range, self._range_2 ** 10, decimal=7) multi_signals = self._multi_signals.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(self._range_2, '+', False).range, self._range_2 + self._range_2, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.arithmetical_operation(multi_signals, '+', False).range, self._range_2 + self._range_2, @@ -812,7 +812,7 @@ def test_fill_nan(self): multi_signals[3:7] = np.nan - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.fill_nan().range, np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [ 30.0, 40.0, 50.0 @@ -823,7 +823,7 @@ def test_fill_nan(self): multi_signals[3:7] = np.nan - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( multi_signals.fill_nan(method='Constant').range, np.array([[10.0, 20.0, 30.0], [20.0, 30.0, 40.0], [30.0, 40.0, 50.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], @@ -840,7 +840,7 @@ def test_domain_distance(self): self.assertAlmostEqual( self._multi_signals.domain_distance(0.5), 0.5, places=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._multi_signals.domain_distance(np.linspace(0, 9, 10) + 0.5), np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]), decimal=7) diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index b98670e43b..d94ae65aa2 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -85,7 +85,7 @@ def test_domain(self): signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.array([0, 1, 2])], np.array([10.0, 20.0, 30.0]), decimal=7) @@ -94,7 +94,7 @@ def test_domain(self): np.testing.assert_array_equal(signal.domain, np.arange(0, 10, 1) * 10) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.array([0, 1, 2]) * 10], np.array([10.0, 20.0, 30.0]), decimal=7) @@ -111,7 +111,7 @@ def test_range(self): signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.array([0, 1, 2])], np.array([10.0, 20.0, 30.0]), decimal=7) @@ -120,7 +120,7 @@ def test_range(self): np.testing.assert_array_equal(signal.range, self._range * 10) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.array([0, 1, 2])], np.array([10.0, 20.0, 30.0]) * 10, decimal=7) @@ -132,7 +132,7 @@ def test_interpolator(self): signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.linspace(0, 5, 5)], np.array([ 10.00000000, 22.83489024, 34.80044921, 47.55353925, 60.00000000 @@ -141,7 +141,7 @@ def test_interpolator(self): signal.interpolator = CubicSplineInterpolator - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.linspace(0, 5, 5)], np.array([10.0, 22.5, 35.0, 47.5, 60.0]), decimal=7) @@ -154,7 +154,7 @@ def test_interpolator_kwargs(self): signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.linspace(0, 5, 5)], np.array([ 10.00000000, 22.83489024, 34.80044921, 47.55353925, 60.00000000 @@ -163,7 +163,7 @@ def test_interpolator_kwargs(self): signal.interpolator_kwargs = {'window': 1, 'kernel_kwargs': {'a': 1}} - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.linspace(0, 5, 5)], np.array([ 10.00000000, 18.91328761, 28.36993142, 44.13100443, 60.00000000 @@ -191,7 +191,7 @@ def test_extrapolator_kwargs(self): 'method': 'Linear', } - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal[np.array([-1000, 1000])], np.array([-9990.0, 10010.0]), decimal=7) @@ -300,12 +300,12 @@ def test__getitem__(self): self.assertEqual(self._signal[0], 10.0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal[np.array([0, 1, 2])], np.array([10.0, 20.0, 30.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal[np.linspace(0, 5, 5)], np.array([ 10.00000000, 22.83489024, 34.80044921, 47.55353925, 60.00000000 @@ -337,34 +337,34 @@ def test__setitem__(self): signal = self._signal.copy() signal[0] = 20 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.range, np.array( [20.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0])) signal[np.array([0, 1, 2])] = 30 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.range, np.array( [30.0, 30.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]), decimal=7) signal[0:3] = 40 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.range, np.array( [40.0, 40.0, 40.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]), decimal=7) signal[np.linspace(0, 5, 5)] = 50 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.domain, np.array([ 0.00, 1.00, 1.25, 2.00, 2.50, 3.00, 3.75, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00 ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.range, np.array([ 50.0, 40.0, 50.0, 40.0, 50.0, 40.0, 50.0, 50.0, 50.0, 70.0, @@ -373,7 +373,7 @@ def test__setitem__(self): decimal=7) signal[np.array([0, 1, 2])] = np.array([10, 20, 30]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.range, np.array([ 10.0, 20.0, 50.0, 30.0, 50.0, 40.0, 50.0, 50.0, 50.0, 70.0, @@ -462,81 +462,81 @@ def test_arithmetical_operation(self): method. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.arithmetical_operation(10, '+', False).range, self._range + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.arithmetical_operation(10, '-', False).range, self._range - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.arithmetical_operation(10, '*', False).range, self._range * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.arithmetical_operation(10, '/', False).range, self._range / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.arithmetical_operation(10, '**', False).range, self._range ** 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._signal + 10).range, self._range + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._signal - 10).range, self._range - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._signal * 10).range, self._range * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._signal / 10).range, self._range / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (self._signal ** 10).range, self._range ** 10, decimal=7) signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(10, '+', True).range, self._range + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(10, '-', True).range, self._range, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(10, '*', True).range, self._range * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(10, '/', True).range, self._range, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(10, '**', True).range, self._range ** 10, decimal=7) signal = self._signal.copy() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(self._range, '+', False).range, signal.range + self._range, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.arithmetical_operation(signal, '+', False).range, signal.range + signal._range, decimal=7) @@ -601,7 +601,7 @@ def test_fill_nan(self): signal[3:7] = np.nan - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.fill_nan().range, np.array( [10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]), @@ -609,7 +609,7 @@ def test_fill_nan(self): signal[3:7] = np.nan - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( signal.fill_nan(method='Constant').range, np.array([10.0, 20.0, 30.0, 0.0, 0.0, 0.0, 0.0, 80.0, 90.0, 100.0]), @@ -623,7 +623,7 @@ def test_domain_distance(self): self.assertAlmostEqual( self._signal.domain_distance(0.5), 0.5, places=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._signal.domain_distance(np.linspace(0, 9, 10) + 0.5), np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]), decimal=7) diff --git a/colour/contrast/tests/test_barten1999.py b/colour/contrast/tests/test_barten1999.py index 9b7affd5cf..21a02c6fce 100644 --- a/colour/contrast/tests/test_barten1999.py +++ b/colour/contrast/tests/test_barten1999.py @@ -42,13 +42,13 @@ def test_optical_MTF_Barten1999(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( optical_MTF_Barten1999(4, 0.01), 0.968910791191297, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( optical_MTF_Barten1999(8, 0.01), 0.881323136669471, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( optical_MTF_Barten1999(4, 0.05), 0.454040738727245, decimal=7) def test_n_dimensional_optical_MTF_Barten1999(self): @@ -64,13 +64,13 @@ def test_n_dimensional_optical_MTF_Barten1999(self): u = np.tile(u, (6, 1)) sigma = np.tile(sigma, (6, 1)) M_opt = np.tile(M_opt, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( optical_MTF_Barten1999(u, sigma), M_opt, decimal=7) u = np.reshape(u, (2, 3, 3)) sigma = np.reshape(sigma, (2, 3, 3)) M_opt = np.reshape(M_opt, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( optical_MTF_Barten1999(u, sigma), M_opt, decimal=7) @ignore_numpy_errors @@ -98,13 +98,13 @@ def test_pupil_diameter_Barten1999(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( pupil_diameter_Barten1999(20, 60), 2.272517118855717, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( pupil_diameter_Barten1999(0.2, 600), 2.272517118855717, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( pupil_diameter_Barten1999(20, 60, 30), 2.459028745178825, decimal=7) @@ -123,13 +123,13 @@ def test_n_dimensional_pupil_diameter_Barten1999(self): L = np.tile(L, (6, 1)) X_0 = np.tile(X_0, (6, 1)) d = np.tile(d, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( pupil_diameter_Barten1999(L, X_0, Y_0), d, decimal=7) L = np.reshape(L, (2, 3, 3)) X_0 = np.reshape(X_0, (2, 3, 3)) d = np.reshape(d, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( pupil_diameter_Barten1999(L, X_0, Y_0), d, decimal=7) @ignore_numpy_errors @@ -157,22 +157,22 @@ def test_sigma_Barten1999(self): Tests :func:`colour.contrast.barten1999.sigma_Barten1999` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(0.5 / 60, 0.08 / 60, 2.1), 0.008791157173231, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(0.75 / 60, 0.08 / 60, 2.1), 0.012809761902549, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(0.5 / 60, 0.16 / 60, 2.1), 0.010040141654601, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(0.5 / 60, 0.08 / 60, 2.5), 0.008975274678558, decimal=7) @@ -191,13 +191,13 @@ def test_n_dimensional_sigma_Barten1999(self): sigma_0 = np.tile(sigma_0, (6, 1)) C_ab = np.tile(C_ab, (6, 1)) sigma = np.tile(sigma, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(sigma_0, C_ab, d), sigma, decimal=7) sigma_0 = np.reshape(sigma_0, (2, 3, 3)) C_ab = np.reshape(C_ab, (2, 3, 3)) sigma = np.reshape(sigma, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sigma_Barten1999(sigma_0, C_ab, d), sigma, decimal=7) @ignore_numpy_errors @@ -225,17 +225,17 @@ def test_retinal_illuminance_Barten1999(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( retinal_illuminance_Barten1999(20, 2.1, True), 66.082316060529919, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( retinal_illuminance_Barten1999(20, 2.5, True), 91.815644777503664, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( retinal_illuminance_Barten1999(20, 2.1, False), 69.272118011654939, decimal=7) @@ -253,13 +253,13 @@ def test_n_dimensional_retinal_illuminance_Barten1999(self): L = np.tile(L, (6, 1)) d = np.tile(d, (6, 1)) E = np.tile(E, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( retinal_illuminance_Barten1999(L, d), E, decimal=7) L = np.reshape(L, (2, 3, 3)) d = np.reshape(d, (2, 3, 3)) E = np.reshape(E, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( retinal_illuminance_Barten1999(L, d), E, decimal=7) @ignore_numpy_errors @@ -287,27 +287,27 @@ def test_maximum_angular_size_Barten1999(self): maximum_angular_size_Barten1999` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(4, 60, 12, 15), 3.572948005052482, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(8, 60, 12, 15), 1.851640199545103, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(4, 120, 12, 15), 3.577708763999663, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(4, 60, 24, 15), 3.698001308168194, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(4, 60, 12, 30), 6.324555320336758, decimal=7) @@ -327,7 +327,7 @@ def test_n_dimensional_maximum_angular_size_Barten1999(self): u = np.tile(u, (6, 1)) X_0 = np.tile(X_0, (6, 1)) X = np.tile(X, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(u, X_0, X_max, N_max), X, decimal=7) @@ -335,7 +335,7 @@ def test_n_dimensional_maximum_angular_size_Barten1999(self): u = np.reshape(u, (2, 3, 3)) X_0 = np.reshape(X_0, (2, 3, 3)) X = np.reshape(X, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( maximum_angular_size_Barten1999(u, X_0, X_max, N_max), X, decimal=7) @@ -366,7 +366,7 @@ def test_contrast_sensitivity_function_Barten1999(self): contrast_sensitivity_function_Barten1999` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -379,7 +379,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 352.761342126727020, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=8, sigma=0.01, @@ -392,7 +392,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 177.706338840717340, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.02, @@ -405,7 +405,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 320.872401634215750, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -418,7 +418,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 455.171315756946400, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -431,7 +431,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 352.996281545740660, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -444,7 +444,7 @@ def test_contrast_sensitivity_function_Barten1999(self): 358.881580104493650, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -465,7 +465,7 @@ def test_contrast_sensitivity_function_Barten1999(self): p=1.2 * 10 ** 6), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=4, sigma=0.01, @@ -494,7 +494,7 @@ def test_n_dimensional_contrast_sensitivity_function_Barten1999(self): u = np.tile(u, (6, 1)) E = np.tile(E, (6, 1)) S = np.tile(S, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=u, sigma=sigma, E=E, X_0=X_0), S, @@ -503,7 +503,7 @@ def test_n_dimensional_contrast_sensitivity_function_Barten1999(self): u = np.reshape(u, (2, 3, 3)) E = np.reshape(E, (2, 3, 3)) S = np.reshape(S, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( contrast_sensitivity_function_Barten1999( u=u, sigma=sigma, E=E, X_0=X_0), S, diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index 4ee585b4a9..a7ed6e6cbc 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -65,7 +65,13 @@ class BrenemanExperimentResult( :math:`\\delta_uv_g^p`. """ - def __new__(cls, name, uv_t, uv_m, s_uv=None, d_uv_i=None, d_uv_g=None): + def __new__(cls, + name, + uv_t, + uv_m, + s_uv=np.nan, + d_uv_i=np.nan, + d_uv_g=np.nan): """ Returns a new instance of the :class:`colour.corresponding.datasets.corresponding_chromaticities.\ @@ -73,8 +79,7 @@ def __new__(cls, name, uv_t, uv_m, s_uv=None, d_uv_i=None, d_uv_g=None): """ return super(BrenemanExperimentResult, cls).__new__( - cls, name, np.array(uv_t), np.array(uv_m), np.array(s_uv), - np.array(d_uv_i), np.array(d_uv_g)) + cls, name, np.array(uv_t), np.array(uv_m), s_uv, d_uv_i, d_uv_g) class PrimariesChromaticityCoordinates( @@ -104,9 +109,9 @@ def __new__(cls, experiment, illuminants, Y, - P_uvp=None, - D_uvp=None, - T_uvp=None): + P_uvp=np.nan, + D_uvp=np.nan, + T_uvp=np.nan): """ Returns a new instance of the :class:`colour.corresponding.datasets.corresponding_chromaticities.\ @@ -114,8 +119,8 @@ def __new__(cls, """ return super(PrimariesChromaticityCoordinates, cls).__new__( - cls, experiment, np.array(illuminants), np.array(Y), - np.array(P_uvp), np.array(D_uvp), np.array(T_uvp)) + cls, experiment, illuminants, np.array(Y), np.array(P_uvp), + np.array(D_uvp), np.array(T_uvp)) # yapf: disable diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index e58a39ee63..8824cac4af 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -149,32 +149,32 @@ def test_convert_experiment_results_Breneman1987(self): corresponding_colour_dataset = convert_experiment_results_Breneman1987( 1) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.XYZ_r, DATASET_CORRESPONDING_COLOUR_1.XYZ_r, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.XYZ_t, DATASET_CORRESPONDING_COLOUR_1.XYZ_t, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.XYZ_cr, DATASET_CORRESPONDING_COLOUR_1.XYZ_cr, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.XYZ_ct, DATASET_CORRESPONDING_COLOUR_1.XYZ_ct, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.Y_r, DATASET_CORRESPONDING_COLOUR_1.Y_r, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( corresponding_colour_dataset.Y_t, DATASET_CORRESPONDING_COLOUR_1.Y_t, decimal=7) @@ -194,7 +194,7 @@ def test_corresponding_chromaticities_prediction_Fairchild1990(self): corresponding_chromaticities_prediction_Fairchild1990` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.array( [(p.uv_m, p.uv_p) for p in corresponding_chromaticities_prediction_Fairchild1990()]), @@ -214,7 +214,7 @@ def test_corresponding_chromaticities_prediction_CIE1994(self): corresponding_chromaticities_prediction_CIE1994` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.array( [(p.uv_m, p.uv_p) for p in corresponding_chromaticities_prediction_CIE1994()]), @@ -235,7 +235,7 @@ def test_corresponding_chromaticities_prediction_CMCCAT2000(self): corresponding_chromaticities_prediction_CMCCAT2000` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.array([ (p.uv_m, p.uv_p) for p in corresponding_chromaticities_prediction_CMCCAT2000() @@ -257,7 +257,7 @@ def test_corresponding_chromaticities_prediction_VonKries(self): corresponding_chromaticities_prediction_VonKries` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( np.array( [(p.uv_m, p.uv_p) for p in corresponding_chromaticities_prediction_VonKries()]), diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 06e439a6c3..53b9b83995 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -221,6 +221,12 @@ def delta_E_CIE1994(Lab_1, Lab_2, textiles=False): d_E = np.sqrt(L + C + H) + try: + if d_E.size == 1: + return d_E.item() + except Exception: + pass + return d_E @@ -364,6 +370,12 @@ def delta_E_CIE2000(Lab_1, Lab_2, textiles=False): (delta_C_prime / (k_C * s_C)) * (delta_H_prime / (k_H * s_H)) * r_T) + try: + if d_E.size == 1: + return d_E.item() + except Exception: + pass + return d_E @@ -456,4 +468,10 @@ def delta_E_CMC(Lab_1, Lab_2, l=2, c=1): # noqa d_E = np.sqrt(v_1 ** 2 + v_2 ** 2 + (delta_H2 / (v_3 * v_3))) + try: + if d_E.size == 1: + return d_E.item() + except Exception: + pass + return d_E diff --git a/colour/difference/tests/test__init__.py b/colour/difference/tests/test__init__.py index df052db4b7..c4fa956922 100644 --- a/colour/difference/tests/test__init__.py +++ b/colour/difference/tests/test__init__.py @@ -43,7 +43,7 @@ def test_domain_range_scale_delta_E(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E(Lab_1 * factor, Lab_2 * factor, method), value, decimal=7) diff --git a/colour/difference/tests/test_cam02_ucs.py b/colour/difference/tests/test_cam02_ucs.py index 0486482988..6c7d05706b 100644 --- a/colour/difference/tests/test_cam02_ucs.py +++ b/colour/difference/tests/test_cam02_ucs.py @@ -88,7 +88,7 @@ def test_n_dimensional_delta_E_Luo2006(self): Jpapbp_1 = np.tile(Jpapbp_1, (6, 1)) Jpapbp_2 = np.tile(Jpapbp_2, (6, 1)) delta_E_p = np.tile(delta_E_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_Luo2006(Jpapbp_1, Jpapbp_2, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), delta_E_p, @@ -97,7 +97,7 @@ def test_n_dimensional_delta_E_Luo2006(self): Jpapbp_1 = np.reshape(Jpapbp_1, (2, 3, 3)) Jpapbp_2 = np.reshape(Jpapbp_2, (2, 3, 3)) delta_E_p = np.reshape(delta_E_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_Luo2006(Jpapbp_1, Jpapbp_2, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), delta_E_p, diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py index e12e6d84a1..903fc6a471 100644 --- a/colour/difference/tests/test_delta_e.py +++ b/colour/difference/tests/test_delta_e.py @@ -57,7 +57,7 @@ def test_delta_E_CIE1976(self): Lab_1 = np.tile(Lab_1, (6, 1)).reshape([2, 3, 3]) Lab_2 = np.tile(Lab_2, (6, 1)).reshape([2, 3, 3]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE1976(Lab_1, Lab_2), euclidean_distance(Lab_1, Lab_2), decimal=7) @@ -82,7 +82,7 @@ def test_domain_range_scale_delta_E_CIE1976(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE1976(Lab_1 * factor, Lab_2 * factor), euclidean_distance(Lab_1, Lab_2), decimal=7) @@ -166,13 +166,13 @@ def test_n_dimensional_delta_E_CIE1994(self): Lab_1 = np.tile(Lab_1, (6, 1)) Lab_2 = np.tile(Lab_2, (6, 1)) delta_E = np.tile(delta_E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE1994(Lab_1, Lab_2), delta_E, decimal=7) Lab_1 = np.reshape(Lab_1, (2, 3, 3)) Lab_2 = np.reshape(Lab_2, (2, 3, 3)) delta_E = np.reshape(delta_E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE1994(Lab_1, Lab_2), delta_E, decimal=7) def test_domain_range_scale_delta_E_CIE1994(self): @@ -188,7 +188,7 @@ def test_domain_range_scale_delta_E_CIE1994(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE1994(Lab_1 * factor, Lab_2 * factor), delta_E, decimal=7) @@ -277,13 +277,13 @@ def test_n_dimensional_delta_E_CIE2000(self): Lab_1 = np.tile(Lab_1, (6, 1)) Lab_2 = np.tile(Lab_2, (6, 1)) delta_E = np.tile(delta_E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE2000(Lab_1, Lab_2), delta_E, decimal=7) Lab_1 = np.reshape(Lab_1, (2, 3, 3)) Lab_2 = np.reshape(Lab_2, (2, 3, 3)) delta_E = np.reshape(delta_E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE2000(Lab_1, Lab_2), delta_E, decimal=7) def test_domain_range_scale_delta_E_CIE2000(self): @@ -299,7 +299,7 @@ def test_domain_range_scale_delta_E_CIE2000(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE2000(Lab_1 * factor, Lab_2 * factor), delta_E, decimal=7) @@ -410,7 +410,7 @@ def test_delta_E_CIE2000_Sharma2004(self): 0.6377, 0.9082 ]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CIE2000(Lab_1, Lab_2), d_E, decimal=4) @@ -483,13 +483,13 @@ def test_n_dimensional_delta_E_CMC(self): Lab_1 = np.tile(Lab_1, (6, 1)) Lab_2 = np.tile(Lab_2, (6, 1)) delta_E = np.tile(delta_E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CMC(Lab_1, Lab_2), delta_E, decimal=7) Lab_1 = np.reshape(Lab_1, (2, 3, 3)) Lab_2 = np.reshape(Lab_2, (2, 3, 3)) delta_E = np.reshape(delta_E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CMC(Lab_1, Lab_2), delta_E, decimal=7) def test_domain_range_scale_delta_E_CMC(self): @@ -505,7 +505,7 @@ def test_domain_range_scale_delta_E_CMC(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_CMC(Lab_1 * factor, Lab_2 * factor), delta_E, decimal=7) diff --git a/colour/difference/tests/test_din99.py b/colour/difference/tests/test_din99.py index 5f4bb3d926..d5e38a6ee0 100644 --- a/colour/difference/tests/test_din99.py +++ b/colour/difference/tests/test_din99.py @@ -92,13 +92,13 @@ def test_n_dimensional_delta_E_DIN99(self): Lab_1 = np.tile(Lab_1, (6, 1)) Lab_2 = np.tile(Lab_2, (6, 1)) delta_E = np.tile(delta_E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_DIN99(Lab_1, Lab_2), delta_E, decimal=7) Lab_1 = np.reshape(Lab_1, (2, 3, 3)) Lab_2 = np.reshape(Lab_2, (2, 3, 3)) delta_E = np.reshape(delta_E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_DIN99(Lab_1, Lab_2), delta_E, decimal=7) def test_domain_range_scale_delta_E_DIN99(self): @@ -114,7 +114,7 @@ def test_domain_range_scale_delta_E_DIN99(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( delta_E_DIN99(Lab_1 * factor, Lab_2 * factor), delta_E, decimal=7) diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index fb22d6d3ac..1f6616b748 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -148,8 +148,8 @@ def primitive_grid(width=1, uvs = np.reshape(uvs, (-1, 2)) normals = np.reshape(normals, (-1, 3)) - faces = np.reshape(faces, (-1, 3)).astype(np.uint32) - outline = np.reshape(outline, (-1, 2)).astype(np.uint32) + faces = np.reshape(np.array(faces), (-1, 3)).astype(np.uint32) + outline = np.reshape(np.array(outline), (-1, 2)).astype(np.uint32) if axis in ('-x', '+x'): shift, zero_axis = 1, 0 diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index 5a77549e96..d33ac9f744 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -4,12 +4,12 @@ """ from __future__ import division, unicode_literals +from colour.geometry import (PLANE_TO_AXIS_MAPPING, primitive_grid, + primitive_cube) import colour.ndarray as np import unittest - -from colour.geometry import (PLANE_TO_AXIS_MAPPING, primitive_grid, - primitive_cube) +np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -34,7 +34,7 @@ def test_primitive_grid(self): """ vertices, faces, outline = primitive_grid() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['position'], np.array([ [-0.5, 0.5, 0.0], @@ -44,17 +44,17 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['uv'], np.array([[0, 1], [1, 1], [0, 0], [1, 0]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['normal'], np.array([[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['colour'], np.array([ [0, 1, 0, 1], @@ -64,10 +64,10 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_equal(faces, np.array([[0, 2, 1], [2, 3, 1]])) + np.testing.assert_array_equal(faces, np.array([[0, 2, 1], [2, 3, 1]])) - np.testing.assert_equal(outline, - np.array([[0, 2], [2, 3], [3, 1], [1, 0]])) + np.testing.assert_array_equal( + outline, np.array([[0, 2], [2, 3], [3, 1], [1, 0]])) vertices, faces, outline = primitive_grid( width=0.2, @@ -76,7 +76,7 @@ def test_primitive_grid(self): height_segments=2, axis='+z') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['position'], np.array([ [-0.10000000, 0.20000000, 0.00000000], @@ -88,7 +88,7 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['uv'], np.array([ [0.00000000, 1.00000000], @@ -100,7 +100,7 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['normal'], np.array([ [0, 0, 1], @@ -112,7 +112,7 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['colour'], np.array([ [0.25000000, 1.00000000, 0.00000000, 1.00000000], @@ -124,7 +124,7 @@ def test_primitive_grid(self): ]), decimal=7) - np.testing.assert_equal( + np.testing.assert_array_equal( faces, np.array([ [0, 2, 1], [2, 3, 1], @@ -132,7 +132,7 @@ def test_primitive_grid(self): [4, 5, 3], ])) - np.testing.assert_equal( + np.testing.assert_array_equal( outline, np.array([ [0, 2], @@ -146,7 +146,7 @@ def test_primitive_grid(self): ])) for plane in PLANE_TO_AXIS_MAPPING.keys(): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_grid(axis=plane)[0]['position'], primitive_grid( axis=PLANE_TO_AXIS_MAPPING[plane])[0]['position'], @@ -166,7 +166,7 @@ def test_primitive_cube(self): """ vertices, faces, outline = primitive_cube() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['position'], np.array([ [-0.5, 0.5, -0.5], @@ -196,7 +196,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['uv'], np.array([ [0, 1], @@ -226,7 +226,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['normal'], np.array([ [0, 0, -1.], @@ -256,7 +256,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['colour'], np.array([ [0, 1, 0, 1], @@ -286,7 +286,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_equal( + np.testing.assert_array_equal( faces, np.array([ [1, 2, 0], @@ -303,7 +303,7 @@ def test_primitive_cube(self): [22, 23, 21], ])) - np.testing.assert_equal( + np.testing.assert_array_equal( outline, np.array([ [0, 2], @@ -340,7 +340,7 @@ def test_primitive_cube(self): height_segments=2, depth_segments=3) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['position'], np.array([ [-0.10000000, 0.30000001, -0.20000000], @@ -398,7 +398,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['uv'], np.array([ [0.00000000, 1.00000000], @@ -456,7 +456,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['normal'], np.array([ [-0., -0., -1.], @@ -514,7 +514,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( vertices['colour'], np.array([ [0.33333334, 1.00000000, 0.16666667, 1.00000000], @@ -572,7 +572,7 @@ def test_primitive_cube(self): ]), decimal=7) - np.testing.assert_equal( + np.testing.assert_array_equal( faces, np.array([ [1, 2, 0], @@ -621,7 +621,7 @@ def test_primitive_cube(self): [50, 51, 47], ])) - np.testing.assert_equal( + np.testing.assert_array_equal( outline, np.array([ [0, 2], @@ -715,7 +715,7 @@ def test_primitive_cube(self): ])) for plane in PLANE_TO_AXIS_MAPPING.keys(): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_cube(planes=[plane])[0]['position'], primitive_cube( planes=[PLANE_TO_AXIS_MAPPING[plane]])[0]['position'], diff --git a/colour/geometry/tests/test_vertices.py b/colour/geometry/tests/test_vertices.py index 4b5431fb5b..047ba2d98f 100644 --- a/colour/geometry/tests/test_vertices.py +++ b/colour/geometry/tests/test_vertices.py @@ -38,22 +38,22 @@ def test_primitive_vertices_quad_mpl(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl(), np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl(axis='+y'), np.array([[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl(axis='+x'), np.array([[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl( width=0.2, height=0.4, @@ -68,7 +68,7 @@ def test_primitive_vertices_quad_mpl(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl( width=-0.2, height=-0.4, @@ -84,7 +84,7 @@ def test_primitive_vertices_quad_mpl(self): decimal=7) for plane in ('xy', 'xz', 'yz'): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_quad_mpl(axis=plane), primitive_vertices_quad_mpl(axis=PLANE_TO_AXIS_MAPPING[plane]), decimal=7) @@ -105,22 +105,22 @@ def test_primitive_vertices_grid_mpl(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_grid_mpl(), np.array([[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_grid_mpl(axis='+y'), np.array([[[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_grid_mpl(axis='+x'), np.array([[[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_grid_mpl( width=0.2, height=0.4, @@ -145,7 +145,7 @@ def test_primitive_vertices_grid_mpl(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_grid_mpl( width=-0.2, height=-0.4, @@ -183,7 +183,7 @@ def test_primitive_vertices_cube_mpl(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(), np.array([ [ @@ -225,37 +225,37 @@ def test_primitive_vertices_cube_mpl(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['+x']), np.array([[[1, 0, 0], [1, 1, 0], [1, 1, 1], [1, 0, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['-x']), np.array([[[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['+y']), np.array([[[0, 1, 0], [1, 1, 0], [1, 1, 1], [0, 1, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['-y']), np.array([[[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['+z']), np.array([[[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=['-z']), np.array([[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl( width=0.2, height=0.4, @@ -400,7 +400,7 @@ def test_primitive_vertices_cube_mpl(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl( width=-0.2, height=-0.4, @@ -546,7 +546,7 @@ def test_primitive_vertices_cube_mpl(self): decimal=7) for plane in PLANE_TO_AXIS_MAPPING.keys(): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_cube_mpl(planes=[plane]), primitive_vertices_cube_mpl( planes=[PLANE_TO_AXIS_MAPPING[plane]]), @@ -565,7 +565,7 @@ def test_primitive_vertices_sphere(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere(), np.array([ [ @@ -659,7 +659,7 @@ def test_primitive_vertices_sphere(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere(intermediate=True), np.array([ [ @@ -745,7 +745,7 @@ def test_primitive_vertices_sphere(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere(segments=6, axis='+y'), np.array([ [ @@ -805,7 +805,7 @@ def test_primitive_vertices_sphere(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere(segments=6, axis='+x'), np.array([ [ @@ -865,7 +865,7 @@ def test_primitive_vertices_sphere(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere( radius=100, segments=6, @@ -930,7 +930,7 @@ def test_primitive_vertices_sphere(self): decimal=7) for plane in ('xy', 'xz', 'yz'): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( primitive_vertices_sphere(axis=plane), primitive_vertices_sphere(axis=PLANE_TO_AXIS_MAPPING[plane]), decimal=7) diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 8840219a77..570825badf 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -63,11 +63,11 @@ def test_convert(self): RGB_a = convert(SDS_COLOURCHECKERS['ColorChecker N Ohta']['dark skin'], 'Spectral Distribution', 'sRGB') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_a, np.array([0.45675795, 0.30986982, 0.24861924]), decimal=7) Jpapbp = convert(RGB_a, 'Output-Referred RGB', 'CAM16UCS') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Jpapbp, np.array([0.39994810, 0.09206557, 0.08127526]), decimal=7) RGB_b = convert( @@ -77,7 +77,7 @@ def test_convert(self): # exact roundtrip. np.testing.assert_allclose(RGB_a, RGB_b, rtol=1e-5, atol=1e-5) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert('#808080', 'Hexadecimal', 'Scene-Referred RGB'), np.array([0.21586050, 0.21586050, 0.21586050]), decimal=7) @@ -87,7 +87,7 @@ def test_convert(self): 0.21586050, places=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert( convert( np.array([0.5, 0.5, 0.5]), 'Output-Referred RGB', @@ -95,7 +95,7 @@ def test_convert(self): np.array([0.49215686, 0.50196078, 0.50196078]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert( RGB_a, 'RGB', @@ -113,7 +113,7 @@ def test_convert_direct_keyword_argument_passing(self): a = np.array([0.20654008, 0.12197225, 0.05136952]) illuminant = CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][ 'D50'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert( a, 'CIE XYZ', 'CIE xyY', XYZ_to_xyY={'illuminant': illuminant}), diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 3bc409fe14..047db0df5f 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -1787,11 +1787,24 @@ def linear_table(size=33, domain=np.array([[0, 0, 0], [1, 1, 1]])): domain = as_float_array(domain) if domain.shape != (2, 3): - samples = np.flip([ - axes[:(~np.isnan(axes)).cumsum().argmax() + 1] - for axes in np.transpose(domain) - ], -1) - size = [len(axes) for axes in samples] + + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + samples = np.flip( + np.array([ + axes[:(~np.isnan(axes)).cumsum().argmax() + 1] + for axes in np.transpose(np.array(domain)) + ]), -1) + table = np.array(np.meshgrid(*samples, indexing='ij')) + np.set_ndimensional_array_backend('cupy') + table = np.array(table) + else: + samples = np.flip([ + axes[:(~np.isnan(axes)).cumsum().argmax() + 1] + for axes in np.transpose(domain) + ], -1) + + size = np.array([len(axes) for axes in samples]) else: if is_numeric(size): size = np.tile(size, 3) @@ -1802,17 +1815,18 @@ def linear_table(size=33, domain=np.array([[0, 0, 0], [1, 1, 1]])): np.linspace(a[0].item(), a[1].item(), size[i].item()) for i, a in enumerate([B, G, R]) ] + table = np.array(np.meshgrid(*samples, indexing='ij')) else: samples = [ np.linspace(a[0], a[1], size[i]) for i, a in enumerate([B, G, R]) ] - table = np.array(np.meshgrid(*samples, indexing='ij')) if np.__name__ == 'cupy': table_tuple = tuple(np.asnumpy(np.hstack([np.flip(size, -1), 3]))) table = np.flip(np.transpose(table).reshape(table_tuple), -1) else: + table = np.array(np.meshgrid(*samples, indexing='ij')) hstack = np.hstack([np.flip(size, -1), 3]) table = np.flip(np.transpose(table).reshape(hstack), -1) diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index 4d78850f31..6aa918cf6c 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -349,25 +349,31 @@ def _format_tuple(array): if has_3x1D: cube_file.write('{0} {1}\n'.format('LUT_1D_SIZE', LUT[0].table.shape[0])) - if not np.array_equal(LUT[0].domain, default_domain): + if not np.array_equal(np.array(LUT[0].domain), default_domain): cube_file.write('LUT_1D_INPUT_RANGE {0}\n'.format( - _format_tuple([LUT[0].domain[0][0], LUT[0].domain[1][0]]))) + _format_tuple([ + np.array(LUT[0].domain)[0][0], + np.array(LUT[0].domain)[1][0] + ]))) if has_3D: cube_file.write('{0} {1}\n'.format('LUT_3D_SIZE', LUT[1].table.shape[0])) - if not np.array_equal(LUT[1].domain, default_domain): + if not np.array_equal(np.array(LUT[1].domain), default_domain): cube_file.write('LUT_3D_INPUT_RANGE {0}\n'.format( - _format_tuple([LUT[1].domain[0][0], LUT[1].domain[1][0]]))) + _format_tuple([ + np.array(LUT[1].domain)[0][0], + np.array(LUT[1].domain)[1][0] + ]))) if has_3x1D: - table = LUT[0].table + table = np.array(LUT[0].table) for row in table: cube_file.write('{0}\n'.format(_format_array(row))) cube_file.write('\n') if has_3D: - table = LUT[1].table.reshape([-1, 3], order='F') + table = np.array(LUT[1].table).reshape([-1, 3], order='F') for row in table: cube_file.write('{0}\n'.format(_format_array(row))) diff --git a/colour/io/luts/tests/test__init__.py b/colour/io/luts/tests/test__init__.py index 9aaf7884d0..faf2757743 100644 --- a/colour/io/luts/tests/test__init__.py +++ b/colour/io/luts/tests/test__init__.py @@ -39,7 +39,7 @@ def test_read_LUT(self): LUT_1 = read_LUT( os.path.join(LUTS_DIRECTORY, 'sony_spi1d', 'eotf_sRGB_1D.spi1d')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ -7.73990000e-03, 5.16000000e-04, 1.22181000e-02, @@ -58,7 +58,7 @@ def test_read_LUT(self): LUT_2 = read_LUT( os.path.join(LUTS_DIRECTORY, 'resolve_cube', 'LogC_Video.cube')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2[0].table, np.array([ [0.00000000, 0.00000000, 0.00000000], diff --git a/colour/io/luts/tests/test_cinespace_csp.py b/colour/io/luts/tests/test_cinespace_csp.py index ea07c0aa20..f4ac528e0e 100644 --- a/colour/io/luts/tests/test_cinespace_csp.py +++ b/colour/io/luts/tests/test_cinespace_csp.py @@ -43,7 +43,7 @@ def test_read_LUT_Cinespace(self): LUT_1 = read_LUT_Cinespace( os.path.join(LUTS_DIRECTORY, 'ACES_Proxy_10_to_ACES.csp')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ [4.88300000e-04, 4.88300000e-04, 4.88300000e-04], @@ -176,8 +176,9 @@ def test_write_LUT_Cinespace(self): 'RaggedDomain.csp')) LUT_4_r = read_LUT_Cinespace( os.path.join(self._temporary_directory, 'RaggedDomain.csp')) - np.testing.assert_almost_equal(LUT_4_t.domain, LUT_4_r.domain) - np.testing.assert_almost_equal(LUT_4_t.table, LUT_4_r.table, decimal=6) + np.testing.assert_array_almost_equal(LUT_4_t.domain, LUT_4_r.domain) + np.testing.assert_array_almost_equal( + LUT_4_t.table, LUT_4_r.table, decimal=6) LUT_5_r = read_LUT_Cinespace( os.path.join(LUTS_DIRECTORY, diff --git a/colour/io/luts/tests/test_iridas_cube.py b/colour/io/luts/tests/test_iridas_cube.py index c3f9f89fc7..598a66a8dc 100644 --- a/colour/io/luts/tests/test_iridas_cube.py +++ b/colour/io/luts/tests/test_iridas_cube.py @@ -42,7 +42,7 @@ def test_read_LUT_IridasCube(self): LUT_1 = read_LUT_IridasCube( os.path.join(LUTS_DIRECTORY, 'ACES_Proxy_10_to_ACES.cube')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ [4.88300000e-04, 4.88300000e-04, 4.88300000e-04], diff --git a/colour/io/luts/tests/test_lut.py b/colour/io/luts/tests/test_lut.py index 658d2629f3..8a1c52a1b3 100644 --- a/colour/io/luts/tests/test_lut.py +++ b/colour/io/luts/tests/test_lut.py @@ -130,7 +130,8 @@ def test__init__(self): # pylint: disable=E1102 LUT = self._LUT_factory(self._table_1) - np.testing.assert_almost_equal(LUT.table, self._table_1, decimal=7) + np.testing.assert_array_almost_equal( + LUT.table, self._table_1, decimal=7) self.assertEqual(str(id(LUT)), LUT.name) @@ -159,7 +160,7 @@ def test_table(self): table_1 = self._table_1 * 0.8 + 0.1 LUT.table = table_1 - np.testing.assert_almost_equal(LUT.table, table_1, decimal=7) + np.testing.assert_array_almost_equal(LUT.table, table_1, decimal=7) def test_name(self): """ @@ -360,67 +361,67 @@ def test_arithmetical_operation(self): # pylint: disable=E1102 LUT_2 = self._LUT_factory() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.arithmetical_operation(10, '+', False).table, self._table_1 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.arithmetical_operation(10, '-', False).table, self._table_1 - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.arithmetical_operation(10, '*', False).table, self._table_1 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.arithmetical_operation(10, '/', False).table, self._table_1 / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.arithmetical_operation(10, '**', False).table, self._table_1 ** 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (LUT_1 + 10).table, self._table_1 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (LUT_1 - 10).table, self._table_1 - 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (LUT_1 * 10).table, self._table_1 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (LUT_1 / 10).table, self._table_1 / 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( (LUT_1 ** 10).table, self._table_1 ** 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(10, '+', True).table, self._table_1 + 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(10, '-', True).table, self._table_1, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(10, '*', True).table, self._table_1 * 10, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(10, '/', True).table, self._table_1, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(10, '**', True).table, self._table_1 ** 10, decimal=7) @@ -428,12 +429,12 @@ def test_arithmetical_operation(self): # pylint: disable=E1102 LUT_2 = self._LUT_factory() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(self._table_1, '+', False).table, LUT_2.table + self._table_1, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.arithmetical_operation(LUT_2, '+', False).table, LUT_2.table + LUT_2.table, decimal=7) @@ -451,10 +452,10 @@ def test_linear_table(self): # pylint: disable=E1102 LUT_1 = self._LUT_factory() - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.linear_table(), self._table_1, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spow( self._LUT_factory.linear_table(**self._table_3_kwargs), 1 / 2.6), @@ -474,20 +475,20 @@ def test_apply(self): # pylint: disable=E1102 LUT_1 = self._LUT_factory(self._table_2) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.apply(RANDOM_TRIPLETS), self._applied_1, decimal=7) # pylint: disable=E1102 LUT_2 = self._LUT_factory(domain=self._domain_2) LUT_2.table = spow(LUT_2.table, 1 / 2.2) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_2.apply(RANDOM_TRIPLETS), self._applied_2, decimal=7) # pylint: disable=E1102 LUT_3 = self._LUT_factory(self._table_3, domain=self._domain_3) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_3.apply(RANDOM_TRIPLETS), self._applied_3, decimal=7) def test_copy(self): @@ -708,21 +709,23 @@ def __init__(self, *args): np.hstack([samples_2, np.full(5, np.nan)]), samples_3, ]) - self._table_1 = np.meshgrid( - *[ - np.linspace(axes[0], axes[1], 33) - for axes in reversed(tsplit(self._domain_1)) - ], - indexing='ij') + self._table_1 = np.array( + np.meshgrid( + *[ + np.linspace(axes[0], axes[1], 33) + for axes in reversed(tsplit(self._domain_1)) + ], + indexing='ij')) self._table_1 = np.flip( np.transpose(self._table_1).reshape([33, 33, 33, 3]), -1) self._table_2 = self._table_1 ** (1 / 2.2) - self._table_3 = np.meshgrid( - *[ - axes[:(~np.isnan(axes)).cumsum().argmax() + 1] - for axes in reversed(tsplit(self._domain_3)) - ], - indexing='ij') + self._table_3 = np.array( + np.meshgrid( + *[ + axes[:(~np.isnan(axes)).cumsum().argmax() + 1] + for axes in reversed(tsplit(self._domain_3)) + ], + indexing='ij')) self._table_3 = spow( np.flip(np.transpose(self._table_3).reshape([10, 15, 20, 3]), -1), 1 / 2.6) @@ -1213,7 +1216,7 @@ def apply(self, RGB, *args): samples = np.linspace(0, 1, 5) RGB = tstack([samples, samples, samples]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_sequence.apply(RGB), np.array([ [0.48779047, 0.48779047, 0.48779047], @@ -1239,7 +1242,7 @@ def setUp(self): self._LUT_1 = LUT1D(LUT1D.linear_table(16) ** (1 / 2.2)) self._LUT_2 = LUT3x1D( - LUT3x1D.linear_table(16) ** (1 / 2.2) * (1.0, 0.75, 0.5), + LUT3x1D.linear_table(16) ** (1 / 2.2) * np.array([1.0, 0.75, 0.5]), domain=self._domain) self._LUT_3 = LUT3D( LUT3D.linear_table(16) ** (1 / 2.2), domain=self._domain) @@ -1265,7 +1268,7 @@ def test_LUT_to_LUT(self): LUT = LUT_to_LUT(self._LUT_1, LUT3D, force_conversion=True, size=5) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT.table, np.array([[[ [0.00000000, 0.00000000, 0.00000000], @@ -1459,7 +1462,7 @@ def test_LUT_to_LUT(self): LUT = LUT_to_LUT(self._LUT_2, LUT3D, force_conversion=True, size=5) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT.table, np.array([[[ [0.00000000, 0.00000000, 0.00000000], @@ -1625,7 +1628,7 @@ def test_LUT_to_LUT(self): size=16, channel_weights=channel_weights) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT.table, np.array([ 0.00000000, 0.29202031, 0.40017033, 0.48115651, 0.54837380, @@ -1642,7 +1645,7 @@ def test_LUT_to_LUT(self): size=16, channel_weights=channel_weights) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT.table, np.array([ 0.04562817, 0.24699999, 0.40967557, 0.50401689, 0.57985117, @@ -1656,7 +1659,7 @@ def test_LUT_to_LUT(self): LUT = LUT_to_LUT(self._LUT_3, LUT3x1D, force_conversion=True, size=16) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT.table, np.array([ [0.00000000, 0.00000000, 0.00000000], diff --git a/colour/io/luts/tests/test_resolve_cube.py b/colour/io/luts/tests/test_resolve_cube.py index d511f62d9e..df8b0afd74 100644 --- a/colour/io/luts/tests/test_resolve_cube.py +++ b/colour/io/luts/tests/test_resolve_cube.py @@ -43,7 +43,7 @@ def test_read_LUT_ResolveCube(self): LUT_1 = read_LUT_ResolveCube( os.path.join(LUTS_DIRECTORY, 'ACES_Proxy_10_to_ACES.cube')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ [4.88300000e-04, 4.88300000e-04, 4.88300000e-04], @@ -98,7 +98,7 @@ def test_read_LUT_ResolveCube(self): LUT_4 = read_LUT_ResolveCube( os.path.join(LUTS_DIRECTORY, 'LogC_Video.cube')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_4[0].table, np.array([ [0.00000000, 0.00000000, 0.00000000], diff --git a/colour/io/luts/tests/test_sony_spi1d.py b/colour/io/luts/tests/test_sony_spi1d.py index 8026364269..8be9b3df32 100644 --- a/colour/io/luts/tests/test_sony_spi1d.py +++ b/colour/io/luts/tests/test_sony_spi1d.py @@ -40,7 +40,7 @@ def test_read_LUT_SonySPI1D(self): LUT_1 = read_LUT_SonySPI1D( os.path.join(LUTS_DIRECTORY, 'eotf_sRGB_1D.spi1d')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ -7.73990000e-03, 5.16000000e-04, 1.22181000e-02, diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index 7f0fb6393b..8642a0e3d9 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -42,7 +42,7 @@ def test_read_LUT_SonySPI3D(self): LUT_1 = read_LUT_SonySPI3D( os.path.join(LUTS_DIRECTORY, 'Colour_Correct.spi3d')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LUT_1.table, np.array([ [ diff --git a/colour/io/tests/test_ies_tm2714.py b/colour/io/tests/test_ies_tm2714.py index fe8e2f8540..a137713c69 100644 --- a/colour/io/tests/test_ies_tm2714.py +++ b/colour/io/tests/test_ies_tm2714.py @@ -220,7 +220,7 @@ def test_read(self, sd=None): sd_r = SpectralDistribution(FLUORESCENT_FILE_SPECTRAL_DATA) np.testing.assert_array_equal(sd_r.domain, sd.domain) - np.testing.assert_almost_equal(sd_r.values, sd.values, decimal=7) + np.testing.assert_array_almost_equal(sd_r.values, sd.values, decimal=7) for test, read in ((FLUORESCENT_FILE_HEADER, sd.header), (FLUORESCENT_FILE_SPECTRAL_DESCRIPTION, sd)): diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index 437170f3d9..2d8b4efb2f 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -59,7 +59,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float16').dtype, np.dtype('float16')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float16'), np.array([ 0.0000, 0.1098, 0.2235, 0.3333, 0.443, 0.5566, 0.6665, 0.7764, @@ -69,7 +69,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float32').dtype, np.dtype('float32')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float32'), np.array([ 0.00000000, 0.10980392, 0.22352941, 0.33333334, 0.44313726, @@ -96,7 +96,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float16').dtype, np.dtype('float16')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float16'), np.array([ 0.0000, 0.1098, 0.2235, 0.3333, 0.443, 0.5566, 0.6665, 0.7764, @@ -106,7 +106,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float32').dtype, np.dtype('float32')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float32'), np.array([ 0.00000000, 0.11111620, 0.22221714, 0.33333334, 0.44444954, @@ -137,7 +137,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float16').dtype, np.dtype('float16')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float16'), np.array([ 0.0000, 0.1111, 0.2222, 0.3333, 0.4443, 0.5557, 0.6665, 0.7780, @@ -147,7 +147,7 @@ def test_convert_bit_depth(self): self.assertIs( convert_bit_depth(a, 'float32').dtype, np.dtype('float32')) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( convert_bit_depth(a, 'float32'), a, decimal=7) self.assertIs( diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 1823d693fb..46948f7ac0 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -30,11 +30,10 @@ CCS_ILLUMINANTS, lightness_Fairchild2010, lightness_Fairchild2011, luminance_Fairchild2010, luminance_Fairchild2011) from colour.models import xy_to_xyY, xyY_to_XYZ -from colour.utilities import (as_float_array, domain_range_scale, from_range_1, - from_range_100, to_domain_1, to_domain_100, - tsplit, tstack) -from colour.utilities.documentation import (DocstringTuple, - is_documentation_building) +from colour.utilities import (as_float, as_float_array, domain_range_scale, + from_range_1, from_range_100, to_domain_1, + to_domain_100, tsplit, tstack) +from colour.utilities.documentation import DocstringTuple __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -123,6 +122,12 @@ def exponent_hdr_CIELab(Y_s, Y_abs, method='Fairchild 2011'): else: epsilon /= sf * lf + try: + if epsilon.size == 1: + return as_float(epsilon) + except Exception: + pass + return epsilon diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index 1f3bed53f8..5a66cd4169 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -103,7 +103,7 @@ def normalised_primary_matrix(primaries, whitepoint): [ 0.0000000...e+00, 0.0000000...e+00, 1.0088251...e+00]]) """ - primaries = np.reshape(primaries, (3, 2)) + primaries = np.reshape(np.array(primaries), (3, 2)) z = xy_to_z(primaries)[..., np.newaxis] primaries = np.transpose(np.hstack([primaries, z])) @@ -159,7 +159,7 @@ def chromatically_adapted_primaries(primaries, [ 0.1558932..., 0.0660492...]]) """ - primaries = np.reshape(primaries, (3, 2)) + primaries = np.reshape(np.array(primaries), (3, 2)) XYZ_a = chromatic_adaptation_VonKries( xy_to_XYZ(primaries), xy_to_XYZ(whitepoint_t), xy_to_XYZ(whitepoint_r), diff --git a/colour/models/rgb/tests/test_cmyk.py b/colour/models/rgb/tests/test_cmyk.py index 1084139a9f..6b2b0f20de 100644 --- a/colour/models/rgb/tests/test_cmyk.py +++ b/colour/models/rgb/tests/test_cmyk.py @@ -36,17 +36,17 @@ def test_RGB_to_CMY(self): Tests :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_CMY(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.54379481, 0.96918929, 0.95908048]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_CMY(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([1.00000000, 1.00000000, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_CMY(np.array([1.00000000, 1.00000000, 1.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) @@ -62,11 +62,11 @@ def test_n_dimensional_RGB_to_CMY(self): RGB = np.tile(RGB, (6, 1)) CMY = np.tile(CMY, (6, 1)) - np.testing.assert_almost_equal(RGB_to_CMY(RGB), CMY, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_CMY(RGB), CMY, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) CMY = np.reshape(CMY, (2, 3, 3)) - np.testing.assert_almost_equal(RGB_to_CMY(RGB), CMY, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_CMY(RGB), CMY, decimal=7) def test_domain_range_scale_RGB_to_CMY(self): """ @@ -80,7 +80,7 @@ def test_domain_range_scale_RGB_to_CMY(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_CMY(RGB * factor), CMY * factor, decimal=7) @ignore_numpy_errors @@ -108,17 +108,17 @@ def test_CMY_to_RGB(self): Tests :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_RGB(np.array([0.54379481, 0.96918929, 0.95908048])), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_RGB(np.array([1.00000000, 1.00000000, 1.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_RGB(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([1.00000000, 1.00000000, 1.00000000]), decimal=7) @@ -134,11 +134,11 @@ def test_n_dimensional_CMY_to_RGB(self): CMY = np.tile(CMY, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(CMY_to_RGB(CMY), RGB, decimal=7) + np.testing.assert_array_almost_equal(CMY_to_RGB(CMY), RGB, decimal=7) CMY = np.reshape(CMY, (2, 3, 3)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(CMY_to_RGB(CMY), RGB, decimal=7) + np.testing.assert_array_almost_equal(CMY_to_RGB(CMY), RGB, decimal=7) def test_domain_range_scale_CMY_to_RGB(self): """ @@ -152,7 +152,7 @@ def test_domain_range_scale_CMY_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_RGB(CMY * factor), RGB * factor, decimal=7) @ignore_numpy_errors @@ -179,17 +179,17 @@ def test_CMY_to_CMYK(self): Tests :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_CMYK(np.array([0.54379481, 0.96918929, 0.95908048])), np.array([0.00000000, 0.93246304, 0.91030457, 0.54379481]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_CMYK(np.array([0.15000000, 1.00000000, 1.00000000])), np.array([0.00000000, 1.00000000, 1.00000000, 0.15000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_CMYK(np.array([0.15000000, 0.00000000, 0.00000000])), np.array([0.15000000, 0.00000000, 0.00000000, 0.00000000]), decimal=7) @@ -205,11 +205,11 @@ def test_n_dimensional_CMY_to_CMYK(self): CMY = np.tile(CMY, (6, 1)) CMYK = np.tile(CMYK, (6, 1)) - np.testing.assert_almost_equal(CMY_to_CMYK(CMY), CMYK, decimal=7) + np.testing.assert_array_almost_equal(CMY_to_CMYK(CMY), CMYK, decimal=7) CMY = np.reshape(CMY, (2, 3, 3)) CMYK = np.reshape(CMYK, (2, 3, 4)) - np.testing.assert_almost_equal(CMY_to_CMYK(CMY), CMYK, decimal=7) + np.testing.assert_array_almost_equal(CMY_to_CMYK(CMY), CMYK, decimal=7) def test_domain_range_scale_CMY_to_CMYK(self): """ @@ -223,7 +223,7 @@ def test_domain_range_scale_CMY_to_CMYK(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMY_to_CMYK(CMY * factor), CMYK * factor, decimal=7) @ignore_numpy_errors @@ -251,19 +251,19 @@ def test_CMYK_to_CMY(self): Tests :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMYK_to_CMY( np.array([0.00000000, 0.93246304, 0.91030457, 0.54379481])), np.array([0.54379481, 0.96918929, 0.95908048]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMYK_to_CMY( np.array([0.00000000, 1.00000000, 1.00000000, 0.15000000])), np.array([0.15000000, 1.00000000, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMYK_to_CMY( np.array([0.15000000, 0.00000000, 0.00000000, 0.00000000])), np.array([0.15000000, 0.00000000, 0.00000000]), @@ -280,11 +280,11 @@ def test_n_dimensional_CMYK_to_CMY(self): CMYK = np.tile(CMYK, (6, 1)) CMY = np.tile(CMY, (6, 1)) - np.testing.assert_almost_equal(CMYK_to_CMY(CMYK), CMY, decimal=7) + np.testing.assert_array_almost_equal(CMYK_to_CMY(CMYK), CMY, decimal=7) CMYK = np.reshape(CMYK, (2, 3, 4)) CMY = np.reshape(CMY, (2, 3, 3)) - np.testing.assert_almost_equal(CMYK_to_CMY(CMYK), CMY, decimal=7) + np.testing.assert_array_almost_equal(CMYK_to_CMY(CMYK), CMY, decimal=7) def test_domain_range_scale_CMYK_to_CMY(self): """ @@ -298,7 +298,7 @@ def test_domain_range_scale_CMYK_to_CMY(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CMYK_to_CMY(CMYK * factor), CMY * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/tests/test_common.py b/colour/models/rgb/tests/test_common.py index fa15f79d69..b3b1eeff65 100644 --- a/colour/models/rgb/tests/test_common.py +++ b/colour/models/rgb/tests/test_common.py @@ -31,38 +31,38 @@ def test_XYZ_to_sRGB(self): Tests :func:`colour.models.rgb.common.XYZ_to_sRGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.70573936, 0.19248266, 0.22354169]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.25847003, 0.58276102, 0.29718877]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB( np.array([0.07818780, 0.06157201, 0.28099326]), np.array([0.34570, 0.35850])), np.array([0.09838967, 0.25404426, 0.65130925]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB( np.array([0.00000000, 0.00000000, 0.00000000]), np.array([0.44757, 0.40745])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB( np.array([0.20654008, 0.12197225, 0.05136952]), chromatic_adaptation_transform='Bradford'), np.array([0.70573936, 0.19248266, 0.22354169]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_sRGB( np.array([0.20654008, 0.12197225, 0.05136952]), apply_cctf_encoding=False), @@ -81,38 +81,38 @@ def test_sRGB_to_XYZ(self): Tests :func:`colour.models.rgb.common.sRGB_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ(np.array([0.70573936, 0.19248266, 0.22354169])), np.array([0.20654290, 0.12197943, 0.05137140]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ(np.array([0.25847003, 0.58276102, 0.29718877])), np.array([0.14222582, 0.23043727, 0.10496290]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ( np.array([0.09838967, 0.25404426, 0.65130925]), np.array([0.34570, 0.35850])), np.array([0.07819162, 0.06157356, 0.28099475]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ( np.array([0.00000000, 0.00000000, 0.00000000]), np.array([0.44757, 0.40745])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ( np.array([0.17498172, 0.38818743, 0.32159978]), chromatic_adaptation_method='Bradford'), np.array([0.07049534, 0.10080000, 0.09558313]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sRGB_to_XYZ( np.array([0.45620520, 0.03081070, 0.04091953]), apply_cctf_decoding=False), diff --git a/colour/models/rgb/tests/test_cylindrical.py b/colour/models/rgb/tests/test_cylindrical.py index 0ce648c4d6..9c5071a9f9 100644 --- a/colour/models/rgb/tests/test_cylindrical.py +++ b/colour/models/rgb/tests/test_cylindrical.py @@ -36,17 +36,17 @@ def test_RGB_to_HSV(self): Tests :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSV(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.99603944, 0.93246304, 0.45620519]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSV(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSV(np.array([1.00000000, 1.00000000, 1.00000000])), np.array([0.00000000, 0.00000000, 1.00000000]), decimal=7) @@ -62,11 +62,11 @@ def test_n_dimensional_RGB_to_HSV(self): RGB = np.tile(RGB, (6, 1)) HSV = np.tile(HSV, (6, 1)) - np.testing.assert_almost_equal(RGB_to_HSV(RGB), HSV, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_HSV(RGB), HSV, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) HSV = np.reshape(HSV, (2, 3, 3)) - np.testing.assert_almost_equal(RGB_to_HSV(RGB), HSV, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_HSV(RGB), HSV, decimal=7) def test_domain_range_scale_RGB_to_HSV(self): """ @@ -80,7 +80,7 @@ def test_domain_range_scale_RGB_to_HSV(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSV(RGB * factor), HSV * factor, decimal=7) @ignore_numpy_errors @@ -108,17 +108,17 @@ def test_HSV_to_RGB(self): Tests :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSV_to_RGB(np.array([0.99603944, 0.93246304, 0.45620519])), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSV_to_RGB(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSV_to_RGB(np.array([0.00000000, 0.00000000, 1.00000000])), np.array([1.00000000, 1.00000000, 1.00000000]), decimal=7) @@ -134,11 +134,11 @@ def test_n_dimensional_HSV_to_RGB(self): HSV = np.tile(HSV, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(HSV_to_RGB(HSV), RGB, decimal=7) + np.testing.assert_array_almost_equal(HSV_to_RGB(HSV), RGB, decimal=7) HSV = np.reshape(HSV, (2, 3, 3)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(HSV_to_RGB(HSV), RGB, decimal=7) + np.testing.assert_array_almost_equal(HSV_to_RGB(HSV), RGB, decimal=7) def test_domain_range_scale_HSV_to_RGB(self): """ @@ -152,7 +152,7 @@ def test_domain_range_scale_HSV_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSV_to_RGB(HSV * factor), RGB * factor, decimal=7) @ignore_numpy_errors @@ -180,17 +180,17 @@ def test_RGB_to_HSL(self): Tests :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSL(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.99603944, 0.87347144, 0.24350795]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSL(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSL(np.array([1.00000000, 1.00000000, 1.00000000])), np.array([0.00000000, 0.00000000, 1.00000000]), decimal=7) @@ -206,11 +206,11 @@ def test_n_dimensional_RGB_to_HSL(self): RGB = np.tile(RGB, (6, 1)) HSL = np.tile(HSL, (6, 1)) - np.testing.assert_almost_equal(RGB_to_HSL(RGB), HSL, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_HSL(RGB), HSL, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) HSL = np.reshape(HSL, (2, 3, 3)) - np.testing.assert_almost_equal(RGB_to_HSL(RGB), HSL, decimal=7) + np.testing.assert_array_almost_equal(RGB_to_HSL(RGB), HSL, decimal=7) def test_domain_range_scale_RGB_to_HSL(self): """ @@ -224,7 +224,7 @@ def test_domain_range_scale_RGB_to_HSL(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_HSL(RGB * factor), HSL * factor, decimal=7) @ignore_numpy_errors @@ -252,17 +252,17 @@ def test_HSL_to_RGB(self): Tests :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSL_to_RGB(np.array([0.99603944, 0.87347144, 0.24350795])), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSL_to_RGB(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSL_to_RGB(np.array([0.00000000, 0.00000000, 1.00000000])), np.array([1.00000000, 1.00000000, 1.00000000]), decimal=7) @@ -278,11 +278,11 @@ def test_n_dimensional_HSL_to_RGB(self): HSL = np.tile(HSL, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(HSL_to_RGB(HSL), RGB, decimal=7) + np.testing.assert_array_almost_equal(HSL_to_RGB(HSL), RGB, decimal=7) HSL = np.reshape(HSL, (2, 3, 3)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(HSL_to_RGB(HSL), RGB, decimal=7) + np.testing.assert_array_almost_equal(HSL_to_RGB(HSL), RGB, decimal=7) def test_domain_range_scale_HSL_to_RGB(self): """ @@ -296,7 +296,7 @@ def test_domain_range_scale_HSL_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( HSL_to_RGB(HSL * factor), RGB * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/tests/test_derivation.py b/colour/models/rgb/tests/test_derivation.py index 9881943c9c..b710365d64 100644 --- a/colour/models/rgb/tests/test_derivation.py +++ b/colour/models/rgb/tests/test_derivation.py @@ -42,13 +42,13 @@ def test_xy_to_z(self): Tests :func:`colour.models.rgb.derivation.xy_to_z` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_z(np.array([0.2500, 0.2500])), 0.50000000, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_z(np.array([0.0001, -0.0770])), 1.07690000, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_z(np.array([0.0000, 1.0000])), 0.00000000, decimal=7) def test_n_dimensional_xy_to_z(self): @@ -65,11 +65,11 @@ def test_n_dimensional_xy_to_z(self): z, 6, ) - np.testing.assert_almost_equal(xy_to_z(xy), z, decimal=7) + np.testing.assert_array_almost_equal(xy_to_z(xy), z, decimal=7) xy = np.reshape(xy, (2, 3, 2)) z = np.reshape(z, (2, 3)) - np.testing.assert_almost_equal(xy_to_z(xy), z, decimal=7) + np.testing.assert_array_almost_equal(xy_to_z(xy), z, decimal=7) @ignore_numpy_errors def test_nan_xy_to_z(self): @@ -81,6 +81,7 @@ def test_nan_xy_to_z(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=2)) for case in cases: + case = np.array(case) xy_to_z(case) @@ -96,7 +97,7 @@ def test_normalised_primary_matrix(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalised_primary_matrix( np.array( [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]), @@ -108,7 +109,7 @@ def test_normalised_primary_matrix(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalised_primary_matrix( np.array([0.640, 0.330, 0.300, 0.600, 0.150, 0.060]), np.array([0.3127, 0.3290])), @@ -129,6 +130,7 @@ def test_nan_normalised_primary_matrix(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=2)) for case in cases: + case = np.array(case) P = np.array(np.vstack([case, case, case])) W = np.array(case) try: @@ -149,7 +151,7 @@ def test_chromatically_adapted_primaries(self): chromatically_adapted_primaries` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatically_adapted_primaries( np.array( [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]), @@ -161,7 +163,7 @@ def test_chromatically_adapted_primaries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatically_adapted_primaries( np.array([0.640, 0.330, 0.300, 0.600, 0.150, 0.060]), np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850])), @@ -172,7 +174,7 @@ def test_chromatically_adapted_primaries(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatically_adapted_primaries( np.array([0.640, 0.330, 0.300, 0.600, 0.150, 0.060]), np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850]), @@ -194,6 +196,7 @@ def test_nan_chromatically_adapted_primaries(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=2)) for case in cases: + case = np.array(case) P = np.array(np.vstack([case, case, case])) W = np.array(case) chromatically_adapted_primaries(P, W, W) @@ -217,7 +220,7 @@ def test_primaries_whitepoint(self): [0.34396645, 0.72816610, -0.07213255], [0.00000000, 0.00000000, 1.00882518], ])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( P, np.array([ [0.73470, 0.26530], @@ -225,7 +228,7 @@ def test_primaries_whitepoint(self): [0.00010, -0.07700], ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( W, np.array([0.32168, 0.33767]), decimal=7) P, W = primaries_whitepoint( @@ -234,7 +237,7 @@ def test_primaries_whitepoint(self): [0.21260000, 0.71520000, 0.07220000], [0.01930000, 0.11920000, 0.95050000], ])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( P, np.array([ [0.64007450, 0.32997051], @@ -242,7 +245,7 @@ def test_primaries_whitepoint(self): [0.15001662, 0.06000665], ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( W, np.array([0.31271591, 0.32900148]), decimal=7) @ignore_numpy_errors @@ -255,6 +258,7 @@ def test_nan_primaries_whitepoint(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: + case = np.array(case) M = np.array(np.vstack([case, case, case])) primaries_whitepoint(M) @@ -340,11 +344,11 @@ def test_n_dimensional_RGB_luminance(self): RGB = np.tile(RGB, (6, 1)) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(RGB_luminance(RGB, P, W), Y) + np.testing.assert_array_almost_equal(RGB_luminance(RGB, P, W), Y) RGB = np.reshape(RGB, (2, 3, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(RGB_luminance(RGB, P, W), Y) + np.testing.assert_array_almost_equal(RGB_luminance(RGB, P, W), Y) @ignore_numpy_errors def test_nan_RGB_luminance(self): @@ -356,7 +360,8 @@ def test_nan_RGB_luminance(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: - RGB = np.array(case) + case = np.array(case) + RGB = case P = np.array(np.vstack([case[0:2], case[0:2], case[0:2]])) W = np.array(case[0:2]) try: diff --git a/colour/models/rgb/tests/test_ictcp.py b/colour/models/rgb/tests/test_ictcp.py index 2d319167ff..f27bb18f8d 100644 --- a/colour/models/rgb/tests/test_ictcp.py +++ b/colour/models/rgb/tests/test_ictcp.py @@ -33,17 +33,17 @@ def test_RGB_to_ICTCP(self): Tests :func:`colour.models.rgb.ictpt.RGB_to_ICTCP` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_ICTCP(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.07351364, 0.00475253, 0.09351596]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_ICTCP(np.array([0.45620519, 0.03081071, 0.04091952]), 4000), np.array([0.10516931, 0.00514031, 0.12318730]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_ICTCP(np.array([0.45620519, 0.03081071, 0.04091952]), 1000), np.array([0.17079612, 0.00485580, 0.17431356]), decimal=7) @@ -59,11 +59,13 @@ def test_n_dimensional_RGB_to_ICTCP(self): RGB = np.tile(RGB, (6, 1)) ICTCP = np.tile(ICTCP, (6, 1)) - np.testing.assert_almost_equal(RGB_to_ICTCP(RGB), ICTCP, decimal=7) + np.testing.assert_array_almost_equal( + RGB_to_ICTCP(RGB), ICTCP, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) ICTCP = np.reshape(ICTCP, (2, 3, 3)) - np.testing.assert_almost_equal(RGB_to_ICTCP(RGB), ICTCP, decimal=7) + np.testing.assert_array_almost_equal( + RGB_to_ICTCP(RGB), ICTCP, decimal=7) def test_domain_range_scale_RGB_to_ICTCP(self): """ @@ -77,7 +79,7 @@ def test_domain_range_scale_RGB_to_ICTCP(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_ICTCP(RGB * factor), ICTCP * factor, decimal=7) @ignore_numpy_errors @@ -105,17 +107,17 @@ def test_ICTCP_to_RGB(self): Tests :func:`colour.models.rgb.ictpt.ICTCP_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ICTCP_to_RGB(np.array([0.07351364, 0.00475253, 0.09351596])), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ICTCP_to_RGB(np.array([0.10516931, 0.00514031, 0.12318730]), 4000), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ICTCP_to_RGB(np.array([0.17079612, 0.00485580, 0.17431356]), 1000), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) @@ -131,11 +133,13 @@ def test_n_dimensional_ICTCP_to_RGB(self): ICTCP = np.tile(ICTCP, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(ICTCP_to_RGB(ICTCP), RGB, decimal=7) + np.testing.assert_array_almost_equal( + ICTCP_to_RGB(ICTCP), RGB, decimal=7) ICTCP = np.reshape(ICTCP, (2, 3, 3)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(ICTCP_to_RGB(ICTCP), RGB, decimal=7) + np.testing.assert_array_almost_equal( + ICTCP_to_RGB(ICTCP), RGB, decimal=7) def test_domain_range_scale_ICTCP_to_RGB(self): """ @@ -149,7 +153,7 @@ def test_domain_range_scale_ICTCP_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ICTCP_to_RGB(ICTCP * factor), RGB * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/tests/test_prismatic.py b/colour/models/rgb/tests/test_prismatic.py index c5b7edbf37..69d9ed092f 100644 --- a/colour/models/rgb/tests/test_prismatic.py +++ b/colour/models/rgb/tests/test_prismatic.py @@ -33,12 +33,12 @@ def test_RGB_to_Prismatic(self): Tests :func:`colour.models.rgb.prismatic.RGB_to_Prismatic` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_Prismatic(np.array([0.0, 0.0, 0.0])), np.array([0.0, 0.0, 0.0, 0.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_Prismatic(np.array([0.25, 0.50, 0.75])), np.array([0.7500000, 0.1666667, 0.3333333, 0.5000000]), decimal=7) @@ -54,11 +54,13 @@ def test_n_dimensional_RGB_to_Prismatic(self): RGB = np.tile(RGB, (6, 1)) Lrgb = np.tile(Lrgb, (6, 1)) - np.testing.assert_almost_equal(RGB_to_Prismatic(RGB), Lrgb, decimal=7) + np.testing.assert_array_almost_equal( + RGB_to_Prismatic(RGB), Lrgb, decimal=7) RGB = np.reshape(RGB, (2, 3, 3)) Lrgb = np.reshape(Lrgb, (2, 3, 4)) - np.testing.assert_almost_equal(RGB_to_Prismatic(RGB), Lrgb, decimal=7) + np.testing.assert_array_almost_equal( + RGB_to_Prismatic(RGB), Lrgb, decimal=7) def test_domain_range_scale_RGB_to_Prismatic(self): """ @@ -72,7 +74,7 @@ def test_domain_range_scale_RGB_to_Prismatic(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_Prismatic(RGB * factor), Lrgb * factor, decimal=7) @ignore_numpy_errors @@ -100,12 +102,12 @@ def test_Prismatic_to_RGB(self): Tests :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Prismatic_to_RGB(np.array([0.0, 0.0, 0.0, 0.0])), np.array([0.0, 0.0, 0.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Prismatic_to_RGB( np.array([0.7500000, 0.1666667, 0.3333333, 0.5000000])), np.array([0.25, 0.50, 0.75]), @@ -122,11 +124,13 @@ def test_n_dimensional_Prismatic_to_RGB(self): Lrgb = np.tile(Lrgb, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal(Prismatic_to_RGB(Lrgb), RGB, decimal=7) + np.testing.assert_array_almost_equal( + Prismatic_to_RGB(Lrgb), RGB, decimal=7) Lrgb = np.reshape(Lrgb, (2, 3, 4)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal(Prismatic_to_RGB(Lrgb), RGB, decimal=7) + np.testing.assert_array_almost_equal( + Prismatic_to_RGB(Lrgb), RGB, decimal=7) def test_domain_range_scale_Prismatic_to_RGB(self): """ @@ -140,7 +144,7 @@ def test_domain_range_scale_Prismatic_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Prismatic_to_RGB(Lrgb * factor), RGB * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/tests/test_rgb_colourspace.py b/colour/models/rgb/tests/test_rgb_colourspace.py index 969439d0f2..876c47aa54 100644 --- a/colour/models/rgb/tests/test_rgb_colourspace.py +++ b/colour/models/rgb/tests/test_rgb_colourspace.py @@ -81,7 +81,7 @@ def test_transformation_matrices(self): colourspace.use_derived_transformation_matrices(True) RGB = np.dot(colourspace.XYZ_to_RGB_matrix, XYZ_r) XYZ = np.dot(colourspace.RGB_to_XYZ_matrix, RGB) - np.testing.assert_almost_equal(XYZ_r, XYZ, decimal=7) + np.testing.assert_array_almost_equal(XYZ_r, XYZ, decimal=7) def test_cctf(self): """ @@ -106,7 +106,7 @@ def test_cctf(self): cctf_encoding_s = colourspace.cctf_encoding(samples) cctf_decoding_s = colourspace.cctf_decoding(cctf_encoding_s) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( samples, cctf_decoding_s, decimal=decimals.get(colourspace.name, 7)) @@ -124,28 +124,28 @@ def test_n_dimensional_cctf(self): value_cctf_encoding = 0.5 value_cctf_decoding = colourspace.cctf_decoding( colourspace.cctf_encoding(value_cctf_encoding)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value_cctf_encoding, value_cctf_decoding, decimal=decimals.get(colourspace.name, 7)) value_cctf_encoding = np.tile(value_cctf_encoding, 6) value_cctf_decoding = np.tile(value_cctf_decoding, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value_cctf_encoding, value_cctf_decoding, decimal=decimals.get(colourspace.name, 7)) value_cctf_encoding = np.reshape(value_cctf_encoding, (3, 2)) value_cctf_decoding = np.reshape(value_cctf_decoding, (3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value_cctf_encoding, value_cctf_decoding, decimal=decimals.get(colourspace.name, 7)) value_cctf_encoding = np.reshape(value_cctf_encoding, (3, 2, 1)) value_cctf_decoding = np.reshape(value_cctf_decoding, (3, 2, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value_cctf_encoding, value_cctf_decoding, decimal=decimals.get(colourspace.name, 7)) @@ -301,7 +301,7 @@ def test_use_derived_transformation_matrices(self): self.assertTrue( self._colourspace.use_derived_transformation_matrices()) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._colourspace.RGB_to_XYZ_matrix, np.array([ [0.95255240, 0.00000000, 0.00009368], @@ -309,7 +309,7 @@ def test_use_derived_transformation_matrices(self): [0.00000000, 0.00000000, 1.00882518], ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( self._colourspace.XYZ_to_RGB_matrix, np.array([ [1.04981102, 0.00000000, -0.00009748], @@ -388,7 +388,7 @@ def test_XYZ_to_RGB(self): Tests :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB( np.array([0.21638819, 0.12570000, 0.03847493]), np.array([0.34570, 0.35850]), np.array([0.31270, 0.32900]), @@ -400,7 +400,7 @@ def test_XYZ_to_RGB(self): np.array([0.70556599, 0.19109268, 0.22340812]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB( np.array([0.21638819, 0.12570000, 0.03847493]), np.array([0.34570, 0.35850]), np.array([0.31270, 0.32900]), @@ -412,7 +412,7 @@ def test_XYZ_to_RGB(self): np.array([0.72794579, 0.18180021, 0.17951580]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB( np.array([0.21638819, 0.12570000, 0.03847493]), np.array([0.34570, 0.35850]), np.array([0.32168, 0.33767]), @@ -424,7 +424,7 @@ def test_XYZ_to_RGB(self): np.array([0.21959099, 0.06985815, 0.04703704]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB( np.array([0.21638819, 0.12570000, 0.03847493]), np.array([0.34570, 0.35850]), @@ -455,14 +455,14 @@ def test_n_dimensional_XYZ_to_RGB(self): XYZ = np.tile(XYZ, (6, 1)) RGB = np.tile(RGB, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB(XYZ, W_R, W_T, M, 'Bradford', eotf_inverse_sRGB), RGB, decimal=7) W_R = np.tile(W_R, (6, 1)) W_T = np.tile(W_T, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB(XYZ, W_R, W_T, M, 'Bradford', eotf_inverse_sRGB), RGB, decimal=7) @@ -471,7 +471,7 @@ def test_n_dimensional_XYZ_to_RGB(self): W_R = np.reshape(W_R, (2, 3, 2)) W_T = np.reshape(W_T, (2, 3, 2)) RGB = np.reshape(RGB, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB(XYZ, W_R, W_T, M, 'Bradford', eotf_inverse_sRGB), RGB, decimal=7) @@ -495,7 +495,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RGB(XYZ * factor, W_R, W_T, M), RGB * factor, decimal=7) @@ -528,7 +528,7 @@ def test_RGB_to_XYZ(self): Tests :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ( np.array([0.70556599, 0.19109268, 0.22340812]), np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850]), @@ -540,7 +540,7 @@ def test_RGB_to_XYZ(self): np.array([0.21638819, 0.12570000, 0.03847493]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ( np.array([0.72794579, 0.18180021, 0.17951580]), np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850]), @@ -552,7 +552,7 @@ def test_RGB_to_XYZ(self): np.array([0.21638819, 0.12570000, 0.03847493]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ( np.array([0.21959099, 0.06985815, 0.04703704]), np.array([0.32168, 0.33767]), np.array([0.34570, 0.35850]), @@ -564,7 +564,7 @@ def test_RGB_to_XYZ(self): np.array([0.21638819, 0.12570000, 0.03847493]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ( np.array([0.45620801, 0.03079991, 0.04091883]), np.array([0.31270, 0.32900, 1.00000]), @@ -595,14 +595,14 @@ def test_n_dimensional_RGB_to_XYZ(self): RGB = np.tile(RGB, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ(RGB, W_R, W_T, M, 'Bradford', eotf_sRGB), XYZ, decimal=7) W_R = np.tile(W_R, (6, 1)) W_T = np.tile(W_T, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ(RGB, W_R, W_T, M, 'Bradford', eotf_sRGB), XYZ, decimal=7) @@ -611,7 +611,7 @@ def test_n_dimensional_RGB_to_XYZ(self): W_R = np.reshape(W_R, (2, 3, 2)) W_T = np.reshape(W_T, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ(RGB, W_R, W_T, M, 'Bradford', eotf_sRGB), XYZ, decimal=7) @@ -635,7 +635,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_XYZ(RGB * factor, W_R, W_T, M), XYZ * factor, decimal=7) @@ -673,7 +673,7 @@ def test_RGB_to_RGB_matrix(self): aces_cg_colourspace = RGB_COLOURSPACES['ACEScg'] sRGB_colourspace = RGB_COLOURSPACES['sRGB'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB_matrix(aces_2065_1_colourspace, sRGB_colourspace), np.array([ [2.52164943, -1.13688855, -0.38491759], @@ -682,7 +682,7 @@ def test_RGB_to_RGB_matrix(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB_matrix(sRGB_colourspace, aces_2065_1_colourspace), np.array([ [0.43958564, 0.38392940, 0.17653274], @@ -691,7 +691,7 @@ def test_RGB_to_RGB_matrix(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB_matrix(aces_2065_1_colourspace, aces_cg_colourspace, 'Bradford'), np.array([ @@ -701,7 +701,7 @@ def test_RGB_to_RGB_matrix(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB_matrix(aces_2065_1_colourspace, sRGB_colourspace, 'Bradford'), np.array([ @@ -711,7 +711,7 @@ def test_RGB_to_RGB_matrix(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB_matrix(aces_2065_1_colourspace, sRGB_colourspace, None), np.array([ [2.55809607, -1.11933692, -0.39181451], @@ -735,28 +735,28 @@ def test_RGB_to_RGB(self): aces_2065_1_colourspace = RGB_COLOURSPACES['ACES2065-1'] sRGB_colourspace = RGB_COLOURSPACES['sRGB'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.21931722, 0.06950287, 0.04694832]), aces_2065_1_colourspace, sRGB_colourspace), np.array([0.45595289, 0.03040780, 0.04087313]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.45595571, 0.03039702, 0.04087245]), sRGB_colourspace, aces_2065_1_colourspace), np.array([0.21931722, 0.06950287, 0.04694832]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.21931722, 0.06950287, 0.04694832]), aces_2065_1_colourspace, sRGB_colourspace, 'Bradford'), np.array([0.45597530, 0.03030054, 0.04086041]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.21931722, 0.06950287, 0.04694832]), aces_2065_1_colourspace, sRGB_colourspace, None), @@ -766,7 +766,7 @@ def test_RGB_to_RGB(self): aces_cg_colourspace = RGB_COLOURSPACES['ACEScg'] aces_cc_colourspace = RGB_COLOURSPACES['ACEScc'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.21931722, 0.06950287, 0.04694832]), aces_cg_colourspace, @@ -776,7 +776,7 @@ def test_RGB_to_RGB(self): np.array([0.42985679, 0.33522924, 0.30292336]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB( np.array([0.46956438, 0.48137533, 0.43788601]), aces_cc_colourspace, @@ -807,14 +807,14 @@ def test_n_dimensional_RGB_to_RGB(self): RGB_i = np.tile(RGB_i, (6, 1)) RGB_o = np.tile(RGB_o, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB(RGB_i, aces_2065_1_colourspace, sRGB_colourspace), RGB_o, decimal=7) RGB_i = np.reshape(RGB_i, (2, 3, 3)) RGB_o = np.reshape(RGB_o, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB(RGB_i, aces_2065_1_colourspace, sRGB_colourspace), RGB_o, decimal=7) @@ -833,7 +833,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_RGB(RGB_i * factor, aces_2065_1_colourspace, sRGB_colourspace), RGB_o * factor, diff --git a/colour/models/rgb/tests/test_ycbcr.py b/colour/models/rgb/tests/test_ycbcr.py index 0ceaf8d476..1f96a0bf37 100644 --- a/colour/models/rgb/tests/test_ycbcr.py +++ b/colour/models/rgb/tests/test_ycbcr.py @@ -38,12 +38,12 @@ def test_RGB_to_YCbCr(self): Tests :func:`colour.models.rgb.ycbcr.RGB_to_YCbCr` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YCbCr(np.array([0.75, 0.75, 0.0])), np.array([0.66035745, 0.17254902, 0.53216593]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YCbCr( np.array([0.25, 0.5, 0.75]), K=WEIGHTS_YCBCR['ITU-R BT.601'], @@ -53,7 +53,7 @@ def test_RGB_to_YCbCr(self): np.array([461, 662, 382]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YCbCr( np.array([0.0, 0.75, 0.75]), K=WEIGHTS_YCBCR['ITU-R BT.2020'], @@ -62,7 +62,7 @@ def test_RGB_to_YCbCr(self): np.array([0.55297500, 0.10472255, -0.37500000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YCbCr( np.array([0.75, 0.0, 0.75]), K=WEIGHTS_YCBCR['ITU-R BT.709'], @@ -83,19 +83,19 @@ def test_n_dimensional_RGB_to_YCbCr(self): RGB = np.reshape(RGB, (4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 3)) - np.testing.assert_almost_equal(RGB_to_YCbCr(RGB), YCbCr) + np.testing.assert_array_almost_equal(RGB_to_YCbCr(RGB), YCbCr) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 4, 3)) - np.testing.assert_almost_equal(RGB_to_YCbCr(RGB), YCbCr) + np.testing.assert_array_almost_equal(RGB_to_YCbCr(RGB), YCbCr) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 4, 4, 3)) - np.testing.assert_almost_equal(RGB_to_YCbCr(RGB), YCbCr) + np.testing.assert_array_almost_equal(RGB_to_YCbCr(RGB), YCbCr) def test_domain_range_scale_RGB_to_YCbCr(self): """ @@ -109,7 +109,7 @@ def test_domain_range_scale_RGB_to_YCbCr(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YCbCr(RGB * factor), YCbCr * factor, decimal=7) @ignore_numpy_errors @@ -137,12 +137,12 @@ def test_YCbCr_to_RGB(self): Tests :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YCbCr_to_RGB(np.array([0.66035745, 0.17254902, 0.53216593])), np.array([0.75, 0.75, 0.0]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YCbCr_to_RGB( np.array([471, 650, 390]), in_bits=10, @@ -151,7 +151,7 @@ def test_YCbCr_to_RGB(self): np.array([0.25018598, 0.49950072, 0.75040741]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YCbCr_to_RGB( np.array([150, 99, 175]), in_bits=8, @@ -176,19 +176,19 @@ def test_n_dimensional_YCbCr_to_RGB(self): RGB = np.reshape(RGB, (4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 3)) - np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB) + np.testing.assert_array_almost_equal(YCbCr_to_RGB(YCbCr), RGB) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 4, 3)) - np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB) + np.testing.assert_array_almost_equal(YCbCr_to_RGB(YCbCr), RGB) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YCbCr = np.tile(YCbCr, 4) YCbCr = np.reshape(YCbCr, (4, 4, 4, 3)) - np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB) + np.testing.assert_array_almost_equal(YCbCr_to_RGB(YCbCr), RGB) def test_domain_range_scale_YCbCr_to_RGB(self): """ @@ -202,7 +202,7 @@ def test_domain_range_scale_YCbCr_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YCbCr_to_RGB(YCbCr * factor), RGB * factor, decimal=7) @ignore_numpy_errors @@ -230,12 +230,12 @@ def test_RGB_to_YcCbcCrc(self): Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.37020379, 0.41137200, 0.77704674]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc( np.array([0.18, 0.18, 0.18]), out_bits=10, @@ -258,21 +258,21 @@ def test_n_dimensional_RGB_to_YcCbcCrc(self): RGB = np.reshape(RGB, (4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) def test_domain_range_scale_RGB_to_YcCbcCrc(self): @@ -287,7 +287,7 @@ def test_domain_range_scale_RGB_to_YcCbcCrc(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_YcCbcCrc(RGB * factor), YcCbcCrc * factor, decimal=7) @@ -317,12 +317,12 @@ def test_YcCbcCrc_to_RGB(self): Tests :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB(np.array([0.37020379, 0.41137200, 0.77704674])), np.array([0.45620519, 0.03081071, 0.04091952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB( np.array([1689, 2048, 2048]), in_bits=12, @@ -345,21 +345,21 @@ def test_n_dimensional_YcCbcCrc_to_RGB(self): RGB = np.reshape(RGB, (4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB(YcCbcCrc), RGB, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB(YcCbcCrc), RGB, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 4, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB(YcCbcCrc), RGB, decimal=7) def test_domain_range_scale_YcCbcCrc_to_RGB(self): @@ -374,7 +374,7 @@ def test_domain_range_scale_YcCbcCrc_to_RGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( YcCbcCrc_to_RGB(YcCbcCrc * factor), RGB * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/cineon.py b/colour/models/rgb/transfer_functions/cineon.py index 215492eba8..d6e5e59b9a 100644 --- a/colour/models/rgb/transfer_functions/cineon.py +++ b/colour/models/rgb/transfer_functions/cineon.py @@ -20,7 +20,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -77,8 +77,15 @@ def log_encoding_Cineon(x, black_offset=10 ** ((95 - 685) / 300)): x = to_domain_1(x) y = ((685 + 300 * np.log10(x * (1 - black_offset) + black_offset)) / 1023) + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_Cineon(y, black_offset=10 ** ((95 - 685) / 300)): @@ -126,5 +133,12 @@ def log_decoding_Cineon(y, black_offset=10 ** ((95 - 685) / 300)): y = to_domain_1(y) x = ((10 ** ((1023 * y - 685) / 300) - black_offset) / (1 - black_offset)) + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/transfer_functions/common.py b/colour/models/rgb/transfer_functions/common.py index 0d80787365..8bcb8a1d4c 100644 --- a/colour/models/rgb/transfer_functions/common.py +++ b/colour/models/rgb/transfer_functions/common.py @@ -11,7 +11,7 @@ import colour.ndarray as np from colour.constants import DEFAULT_FLOAT_DTYPE, DEFAULT_INT_DTYPE -from colour.utilities import as_float_array +from colour.utilities import as_float_array, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -120,7 +120,9 @@ def legal_to_full(CV, bit_depth=10, in_int=False, out_int=False): CV = (CV - B) / (W - B) - return np.round(CV * MV).astype(DEFAULT_INT_DTYPE) if out_int else CV + intCV = np.round(CV * MV).astype(DEFAULT_INT_DTYPE) + + return intCV if out_int else as_float(CV) def full_to_legal(CV, bit_depth=10, in_int=False, out_int=False): @@ -179,4 +181,6 @@ def full_to_legal(CV, bit_depth=10, in_int=False, out_int=False): CV = (W - B) * CV + B - return np.round(CV).astype(DEFAULT_INT_DTYPE) if out_int else CV / MV + intCV = np.round(CV).astype(DEFAULT_INT_DTYPE) + + return intCV if out_int else as_float(CV / MV) diff --git a/colour/models/rgb/transfer_functions/filmic_pro.py b/colour/models/rgb/transfer_functions/filmic_pro.py index f8dca81d1e..f0ac975e72 100644 --- a/colour/models/rgb/transfer_functions/filmic_pro.py +++ b/colour/models/rgb/transfer_functions/filmic_pro.py @@ -19,7 +19,7 @@ import colour.ndarray as np from colour.algebra import Extrapolator, LinearInterpolator -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -84,8 +84,15 @@ def log_encoding_FilmicPro6(t): t = to_domain_1(t) y = 0.371 * (np.sqrt(t) + 0.28257 * np.log(t) + 1.69542) + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = None @@ -106,9 +113,10 @@ def _log_decoding_FilmicPro6_interpolator(): global _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE t = np.arange(0, 1, 0.0001) - # Turn from cupy to numpy and back creates an error - _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = Extrapolator( - LinearInterpolator(log_encoding_FilmicPro6(t), t)) + + if _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE is None: + _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = Extrapolator( + LinearInterpolator(log_encoding_FilmicPro6(t), t)) return _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE diff --git a/colour/models/rgb/transfer_functions/fujifilm_flog.py b/colour/models/rgb/transfer_functions/fujifilm_flog.py index 24ddedca15..577c1b9ca7 100644 --- a/colour/models/rgb/transfer_functions/fujifilm_flog.py +++ b/colour/models/rgb/transfer_functions/fujifilm_flog.py @@ -200,6 +200,9 @@ def log_decoding_FLog(out_r, e = constants.e f = constants.f + if np.__name__ == 'cupy': + out_r = np.array(out_r) + in_r = np.where( out_r < cut2, (out_r - f) / e, diff --git a/colour/models/rgb/transfer_functions/gopro.py b/colour/models/rgb/transfer_functions/gopro.py index fbfc556ec7..b8470ff4c9 100644 --- a/colour/models/rgb/transfer_functions/gopro.py +++ b/colour/models/rgb/transfer_functions/gopro.py @@ -20,7 +20,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -75,8 +75,15 @@ def log_encoding_Protune(x): x = to_domain_1(x) y = np.log(x * 112 + 1) / np.log(113) + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_Protune(y): @@ -122,5 +129,12 @@ def log_decoding_Protune(y): y = to_domain_1(y) x = (113 ** y - 1) / 112 + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/transfer_functions/itur_bt_1886.py b/colour/models/rgb/transfer_functions/itur_bt_1886.py index 86ac3b5b8c..cdaa760cba 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1886.py @@ -23,7 +23,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -90,8 +90,15 @@ def eotf_inverse_BT1886(L, L_B=0, L_W=1): b = L_B ** gamma_d / n V = (L / a) ** gamma_d - b + V = from_range_1(V) - return from_range_1(V) + try: + if V.size == 1: + return as_float(V) + except Exception: + pass + + return V def eotf_BT1886(V, L_B=0, L_W=1): @@ -151,5 +158,12 @@ def eotf_BT1886(V, L_B=0, L_W=1): a = n ** gamma b = L_B ** gamma_d / n L = a * np.maximum(V + b, 0) ** gamma + L = from_range_1(L) + + try: + if L.size == 1: + return as_float(L) + except Exception: + pass - return from_range_1(L) + return L diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 80e5ec91af..78cdf172ec 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -423,7 +423,7 @@ def gamma_function_HLG_BT2100(L_W=1000): gamma = 1.2 + 0.42 * np.log10(L_W / 1000) - return gamma + return as_float(gamma) def oetf_HLG_BT2100(E, constants=CONSTANTS_BT2100_HLG): @@ -561,7 +561,7 @@ def black_level_lift_HLG_BT2100(L_B=0, L_W=1000, gamma=None): beta = np.sqrt(3 * spow((L_B / L_W), 1 / gamma)) - return beta + return as_float(beta) def eotf_HLG_BT2100_1(E_p, @@ -919,9 +919,9 @@ def eotf_inverse_HLG_BT2100_2(F_D, beta = black_level_lift_HLG_BT2100(L_B, L_W, gamma) - return (oetf_ARIBSTDB67( + return as_float((oetf_ARIBSTDB67( ootf_inverse_HLG_BT2100_2(F_D, L_W, gamma) * 12, constants=constants) - - beta) / (1 - beta) + beta) / (1 - beta)) BT2100_HLG_EOTF_INVERSE_METHODS = CaseInsensitiveMapping({ diff --git a/colour/models/rgb/transfer_functions/panalog.py b/colour/models/rgb/transfer_functions/panalog.py index 90910d0f0c..5e526448f9 100644 --- a/colour/models/rgb/transfer_functions/panalog.py +++ b/colour/models/rgb/transfer_functions/panalog.py @@ -20,7 +20,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -82,8 +82,15 @@ def log_encoding_Panalog(x, black_offset=10 ** ((64 - 681) / 444)): x = to_domain_1(x) y = (681 + 444 * np.log10(x * (1 - black_offset) + black_offset)) / 1023 + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_Panalog(y, black_offset=10 ** ((64 - 681) / 444)): @@ -136,5 +143,12 @@ def log_decoding_Panalog(y, black_offset=10 ** ((64 - 681) / 444)): y = to_domain_1(y) x = (10 ** ((1023 * y - 681) / 444) - black_offset) / (1 - black_offset) + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/transfer_functions/panasonic_vlog.py b/colour/models/rgb/transfer_functions/panasonic_vlog.py index e222000590..07f03a3660 100644 --- a/colour/models/rgb/transfer_functions/panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/panasonic_vlog.py @@ -129,6 +129,9 @@ def log_encoding_VLog(L_in, c = constants.c d = constants.d + if np.__name__ == 'cupy': + L_in = np.array(L_in) + V_out = np.where( L_in < cut1, 5.6 * L_in + 0.125, @@ -214,6 +217,9 @@ def log_decoding_VLog(V_out, c = constants.c d = constants.d + if np.__name__ == 'cupy': + V_out = np.array(V_out) + L_in = np.where( V_out < cut2, (V_out - 0.125) / 5.6, diff --git a/colour/models/rgb/transfer_functions/pivoted_log.py b/colour/models/rgb/transfer_functions/pivoted_log.py index f930a874ce..62eec13e87 100644 --- a/colour/models/rgb/transfer_functions/pivoted_log.py +++ b/colour/models/rgb/transfer_functions/pivoted_log.py @@ -20,7 +20,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -88,8 +88,15 @@ def log_encoding_PivotedLog(x, y = ((log_reference + np.log10(x / linear_reference) / (density_per_code_value / negative_gamma)) / 1023) + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_PivotedLog(y, @@ -148,5 +155,12 @@ def log_decoding_PivotedLog(y, x = (10 ** ((y * 1023 - log_reference) * (density_per_code_value / negative_gamma)) * linear_reference) + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/transfer_functions/red_log.py b/colour/models/rgb/transfer_functions/red_log.py index 6a970c98fb..e756f6d6e0 100644 --- a/colour/models/rgb/transfer_functions/red_log.py +++ b/colour/models/rgb/transfer_functions/red_log.py @@ -37,7 +37,8 @@ from colour.models.rgb.transfer_functions import (log_encoding_Cineon, log_decoding_Cineon) -from colour.utilities import CaseInsensitiveMapping, from_range_1, to_domain_1 +from colour.utilities import (CaseInsensitiveMapping, from_range_1, + to_domain_1, as_float) from colour.utilities.deprecation import handle_arguments_deprecation __author__ = 'Colour Developers' @@ -102,8 +103,15 @@ def log_encoding_REDLog(x, black_offset=10 ** ((0 - 1023) / 511)): x = to_domain_1(x) y = (1023 + 511 * np.log10(x * (1 - black_offset) + black_offset)) / 1023 + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_REDLog(y, black_offset=10 ** ((0 - 1023) / 511)): @@ -151,8 +159,15 @@ def log_decoding_REDLog(y, black_offset=10 ** ((0 - 1023) / 511)): y = to_domain_1(y) x = ((10 ** ((1023 * y - 1023) / 511)) - black_offset) / (1 - black_offset) + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x def log_encoding_REDLogFilm(x, black_offset=10 ** ((95 - 685) / 300)): @@ -288,8 +303,15 @@ def log_encoding_Log3G10_v1(x): x = to_domain_1(x) y = np.sign(x) * 0.222497 * np.log10((np.abs(x) * 169.379333) + 1) + y = from_range_1(y) + + try: + if y.size == 1: + return as_float(y) + except Exception: + pass - return from_range_1(y) + return y def log_decoding_Log3G10_v1(y): @@ -335,8 +357,15 @@ def log_decoding_Log3G10_v1(y): y = to_domain_1(y) x = (np.sign(y) * (10.0 ** (np.abs(y) / 0.222497) - 1) / 169.379333) + x = from_range_1(x) - return from_range_1(x) + try: + if x.size == 1: + return as_float(x) + except Exception: + pass + + return x def log_encoding_Log3G10_v2(x): @@ -384,7 +413,17 @@ def log_encoding_Log3G10_v2(x): y = (np.sign(x + 0.01) * 0.224282 * np.log10((np.abs(x + 0.01) * 155.975327) + 1)) - return from_range_1(y) + y = from_range_1(y) + + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y + + return y def log_decoding_Log3G10_v2(y): @@ -430,8 +469,15 @@ def log_decoding_Log3G10_v2(y): y = to_domain_1(y) x = (np.sign(y) * (10.0 ** (np.abs(y) / 0.224282) - 1) / 155.975327) - 0.01 + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x LOG3G10_ENCODING_METHODS = CaseInsensitiveMapping({ @@ -657,8 +703,15 @@ def log_encoding_Log3G12(x): x = to_domain_1(x) y = np.sign(x) * 0.184904 * np.log10((np.abs(x) * 347.189667) + 1) + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_Log3G12(y): @@ -704,5 +757,12 @@ def log_decoding_Log3G12(y): y = to_domain_1(y) x = np.sign(y) * (10.0 ** (np.abs(y) / 0.184904) - 1) / 347.189667 + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/transfer_functions/sony_slog.py b/colour/models/rgb/transfer_functions/sony_slog.py index a37d9cd222..00096b826f 100644 --- a/colour/models/rgb/transfer_functions/sony_slog.py +++ b/colour/models/rgb/transfer_functions/sony_slog.py @@ -499,6 +499,9 @@ def log_decoding_SLog3(y, y = y if in_normalised_code_value else full_to_legal(y, bit_depth) + if np.__name__ == 'cupy': + y = np.array(y) + x = np.where( y >= 171.2102946929 / 1023, ((10 ** ((y * 1023 - 420) / 261.5)) * (0.18 + 0.01) - 0.01), diff --git a/colour/models/rgb/transfer_functions/st_2084.py b/colour/models/rgb/transfer_functions/st_2084.py index 4de802b5b1..c8bb923309 100644 --- a/colour/models/rgb/transfer_functions/st_2084.py +++ b/colour/models/rgb/transfer_functions/st_2084.py @@ -189,6 +189,9 @@ def eotf_ST2084(N, L_p=10000, constants=CONSTANTS_ST2084): n = V_p - constants.c_1 # Limiting negative values. + if np.__name__ == 'cupy': + n = np.array(n) + n = np.where(n < 0, 0, n) L = spow((n / (constants.c_2 - constants.c_3 * V_p)), m_1_d) diff --git a/colour/models/rgb/transfer_functions/tests/test__init__.py b/colour/models/rgb/transfer_functions/tests/test__init__.py index 35e2c8d6c7..61f6a7823d 100644 --- a/colour/models/rgb/transfer_functions/tests/test__init__.py +++ b/colour/models/rgb/transfer_functions/tests/test__init__.py @@ -95,7 +95,7 @@ def test_transfer_functions(self): encoded_s = CCTF_ENCODINGS[name](samples) decoded_s = CCTF_DECODINGS[name](encoded_s) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( samples, decoded_s, decimal=decimals.get(name, 7)) diff --git a/colour/models/rgb/transfer_functions/tests/test_aces.py b/colour/models/rgb/transfer_functions/tests/test_aces.py index 5e070f9451..0a2cfea1b9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_aces.py +++ b/colour/models/rgb/transfer_functions/tests/test_aces.py @@ -66,17 +66,17 @@ def test_n_dimensional_log_encoding_ACESproxy(self): lin_AP1 = np.tile(lin_AP1, 6) ACESproxy = np.tile(ACESproxy, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACESproxy(lin_AP1), ACESproxy, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3)) ACESproxy = np.reshape(ACESproxy, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACESproxy(lin_AP1), ACESproxy, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) ACESproxy = np.reshape(ACESproxy, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACESproxy(lin_AP1), ACESproxy, decimal=7) def test_domain_range_scale_log_encoding_ACESproxy(self): @@ -91,7 +91,7 @@ def test_domain_range_scale_log_encoding_ACESproxy(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACESproxy(lin_AP1 * factor), ACESproxy * factor, decimal=7) @@ -161,17 +161,17 @@ def test_n_dimensional_log_decoding_ACESproxy(self): ACESproxy = np.tile(ACESproxy, 6) lin_AP1 = np.tile(lin_AP1, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACESproxy(ACESproxy), lin_AP1, decimal=7) ACESproxy = np.reshape(ACESproxy, (2, 3)) lin_AP1 = np.reshape(lin_AP1, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACESproxy(ACESproxy), lin_AP1, decimal=7) ACESproxy = np.reshape(ACESproxy, (2, 3, 1)) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACESproxy(ACESproxy), lin_AP1, decimal=7) def test_domain_range_scale_log_decoding_ACESproxy(self): @@ -186,7 +186,7 @@ def test_domain_range_scale_log_decoding_ACESproxy(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACESproxy(ACESproxy * factor), lin_AP1 * factor, decimal=7) @@ -234,17 +234,17 @@ def test_n_dimensional_log_encoding_ACEScc(self): lin_AP1 = np.tile(lin_AP1, 6) ACEScc = np.tile(ACEScc, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScc(lin_AP1), ACEScc, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3)) ACEScc = np.reshape(ACEScc, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScc(lin_AP1), ACEScc, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) ACEScc = np.reshape(ACEScc, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScc(lin_AP1), ACEScc, decimal=7) def test_domain_range_scale_log_encoding_ACEScc(self): @@ -259,7 +259,7 @@ def test_domain_range_scale_log_encoding_ACEScc(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScc(lin_AP1 * factor), ACEScc * factor, decimal=7) @@ -307,17 +307,17 @@ def test_n_dimensional_log_decoding_ACEScc(self): ACEScc = np.tile(ACEScc, 6) lin_AP1 = np.tile(lin_AP1, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScc(ACEScc), lin_AP1, decimal=7) ACEScc = np.reshape(ACEScc, (2, 3)) lin_AP1 = np.reshape(lin_AP1, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScc(ACEScc), lin_AP1, decimal=7) ACEScc = np.reshape(ACEScc, (2, 3, 1)) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScc(ACEScc), lin_AP1, decimal=7) def test_domain_range_scale_log_decoding_ACEScc(self): @@ -332,7 +332,7 @@ def test_domain_range_scale_log_decoding_ACEScc(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScc(ACEScc * factor), lin_AP1 * factor, decimal=7) @@ -380,17 +380,17 @@ def test_n_dimensional_log_encoding_ACEScct(self): lin_AP1 = np.tile(lin_AP1, 6) ACEScct = np.tile(ACEScct, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScct(lin_AP1), ACEScct, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3)) ACEScct = np.reshape(ACEScct, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScct(lin_AP1), ACEScct, decimal=7) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) ACEScct = np.reshape(ACEScct, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScct(lin_AP1), ACEScct, decimal=7) def test_domain_range_scale_log_encoding_ACEScct(self): @@ -405,7 +405,7 @@ def test_domain_range_scale_log_encoding_ACEScct(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScct(lin_AP1 * factor), ACEScct * factor, decimal=7) @@ -419,7 +419,7 @@ def test_ACEScc_equivalency_log_encoding_ACEScct(self): """ equiv = np.linspace(0.0078125, 222.86094420380761, 100) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ACEScct(equiv), log_encoding_ACEScc(equiv), decimal=7) @ignore_numpy_errors @@ -465,17 +465,17 @@ def test_n_dimensional_log_decoding_ACEScct(self): ACEScct = np.tile(ACEScct, 6) lin_AP1 = np.tile(lin_AP1, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScct(ACEScct), lin_AP1, decimal=7) ACEScct = np.reshape(ACEScct, (2, 3)) lin_AP1 = np.reshape(lin_AP1, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScct(ACEScct), lin_AP1, decimal=7) ACEScct = np.reshape(ACEScct, (2, 3, 1)) lin_AP1 = np.reshape(lin_AP1, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScct(ACEScct), lin_AP1, decimal=7) def test_domain_range_scale_log_decoding_ACEScct(self): @@ -490,7 +490,7 @@ def test_domain_range_scale_log_decoding_ACEScct(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScct(ACEScc * factor), lin_AP1 * factor, decimal=7) @@ -504,7 +504,7 @@ def test_ACEScc_equivalency_log_decoding_ACEScct(self): """ equiv = np.linspace(0.15525114155251146, 1.0, 100) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ACEScct(equiv), log_decoding_ACEScc(equiv), decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py index 4aaf9683c6..deaf2db627 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py @@ -58,15 +58,18 @@ def test_n_dimensional_oetf_ARIBSTDB67(self): E = np.tile(E, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal(oetf_ARIBSTDB67(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_ARIBSTDB67(E), E_p, decimal=7) E = np.reshape(E, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal(oetf_ARIBSTDB67(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_ARIBSTDB67(E), E_p, decimal=7) E = np.reshape(E, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_ARIBSTDB67(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_ARIBSTDB67(E), E_p, decimal=7) def test_domain_range_scale_oetf_ARIBSTDB67(self): """ @@ -80,7 +83,7 @@ def test_domain_range_scale_oetf_ARIBSTDB67(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_ARIBSTDB67(E * factor), E_p * factor, decimal=7) @ignore_numpy_errors @@ -128,17 +131,17 @@ def test_n_dimensional_oetf_inverse_ARIBSTDB67(self): E_p = np.tile(E_p, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_ARIBSTDB67(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_ARIBSTDB67(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_ARIBSTDB67(E_p), E, decimal=7) def test_domain_range_scale_oetf_inverse_ARIBSTDB67(self): @@ -153,7 +156,7 @@ def test_domain_range_scale_oetf_inverse_ARIBSTDB67(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_ARIBSTDB67(E_p * factor), E * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py b/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py index 1e40619a64..c963506c4e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py +++ b/colour/models/rgb/transfer_functions/tests/test_arri_alexa_log_c.py @@ -55,15 +55,18 @@ def test_n_dimensional_log_encoding_ALEXALogC(self): x = np.tile(x, 6) t = np.tile(t, 6) - np.testing.assert_almost_equal(log_encoding_ALEXALogC(x), t, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ALEXALogC(x), t, decimal=7) x = np.reshape(x, (2, 3)) t = np.reshape(t, (2, 3)) - np.testing.assert_almost_equal(log_encoding_ALEXALogC(x), t, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ALEXALogC(x), t, decimal=7) x = np.reshape(x, (2, 3, 1)) t = np.reshape(t, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_ALEXALogC(x), t, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ALEXALogC(x), t, decimal=7) def test_domain_range_scale_log_encoding_ALEXALogC(self): """ @@ -77,7 +80,7 @@ def test_domain_range_scale_log_encoding_ALEXALogC(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ALEXALogC(x * factor), t * factor, decimal=7) @ignore_numpy_errors @@ -122,15 +125,18 @@ def test_n_dimensional_log_decoding_ALEXALogC(self): t = np.tile(t, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_ALEXALogC(t), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ALEXALogC(t), x, decimal=7) t = np.reshape(t, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_ALEXALogC(t), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ALEXALogC(t), x, decimal=7) t = np.reshape(t, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_ALEXALogC(t), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ALEXALogC(t), x, decimal=7) def test_domain_range_scale_log_decoding_ALEXALogC(self): """ @@ -144,7 +150,7 @@ def test_domain_range_scale_log_decoding_ALEXALogC(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ALEXALogC(t * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_canon_log.py b/colour/models/rgb/transfer_functions/tests/test_canon_log.py index 418eeba4ce..870062b082 100644 --- a/colour/models/rgb/transfer_functions/tests/test_canon_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_canon_log.py @@ -77,17 +77,17 @@ def test_n_dimensional_log_encoding_CanonLog(self): x = np.tile(x, 6) clog = np.tile(clog, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog(x), clog, decimal=7) x = np.reshape(x, (2, 3)) clog = np.reshape(clog, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog(x), clog, decimal=7) x = np.reshape(x, (2, 3, 1)) clog = np.reshape(clog, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog(x), clog, decimal=7) def test_domain_range_scale_log_encoding_CanonLog(self): @@ -102,7 +102,7 @@ def test_domain_range_scale_log_encoding_CanonLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog(x * factor), clog * factor, decimal=7) @@ -166,17 +166,17 @@ def test_n_dimensional_log_decoding_CanonLog(self): clog = np.tile(clog, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog(clog), x, decimal=7) clog = np.reshape(clog, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog(clog), x, decimal=7) clog = np.reshape(clog, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog(clog), x, decimal=7) def test_domain_range_scale_log_decoding_CanonLog(self): @@ -191,7 +191,7 @@ def test_domain_range_scale_log_decoding_CanonLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog(clog * factor), x * factor, decimal=7) @@ -255,17 +255,17 @@ def test_n_dimensional_log_encoding_CanonLog2(self): x = np.tile(x, 6) clog2 = np.tile(clog2, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog2(x), clog2, decimal=7) x = np.reshape(x, (2, 3)) clog2 = np.reshape(clog2, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog2(x), clog2, decimal=7) x = np.reshape(x, (2, 3, 1)) clog2 = np.reshape(clog2, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog2(x), clog2, decimal=7) def test_domain_range_scale_log_encoding_CanonLog2(self): @@ -280,7 +280,7 @@ def test_domain_range_scale_log_encoding_CanonLog2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog2(x * factor), clog2 * factor, decimal=7) @@ -344,17 +344,17 @@ def test_n_dimensional_log_decoding_CanonLog2(self): clog2 = np.tile(clog2, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog2(clog2), x, decimal=7) clog2 = np.reshape(clog2, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog2(clog2), x, decimal=7) clog2 = np.reshape(clog2, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog2(clog2), x, decimal=7) def test_domain_range_scale_log_decoding_CanonLog2(self): @@ -369,7 +369,7 @@ def test_domain_range_scale_log_decoding_CanonLog2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog2(clog * factor), x * factor, decimal=7) @@ -433,17 +433,17 @@ def test_n_dimensional_log_encoding_CanonLog3(self): x = np.tile(x, 6) clog3 = np.tile(clog3, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog3(x), clog3, decimal=7) x = np.reshape(x, (2, 3)) clog3 = np.reshape(clog3, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog3(x), clog3, decimal=7) x = np.reshape(x, (2, 3, 1)) clog3 = np.reshape(clog3, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog3(x), clog3, decimal=7) def test_domain_range_scale_log_encoding_CanonLog3(self): @@ -458,7 +458,7 @@ def test_domain_range_scale_log_encoding_CanonLog3(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_CanonLog3(x * factor), clog3 * factor, decimal=7) @@ -522,17 +522,17 @@ def test_n_dimensional_log_decoding_CanonLog3(self): clog3 = np.tile(clog3, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog3(clog3), x, decimal=7) clog3 = np.reshape(clog3, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog3(clog3), x, decimal=7) clog3 = np.reshape(clog3, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog3(clog3), x, decimal=7) def test_domain_range_scale_log_decoding_CanonLog3(self): @@ -547,7 +547,7 @@ def test_domain_range_scale_log_decoding_CanonLog3(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_CanonLog3(clog * factor), x * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_cineon.py b/colour/models/rgb/transfer_functions/tests/test_cineon.py index 25819d5de0..e6669111ee 100644 --- a/colour/models/rgb/transfer_functions/tests/test_cineon.py +++ b/colour/models/rgb/transfer_functions/tests/test_cineon.py @@ -55,15 +55,18 @@ def test_n_dimensional_log_encoding_Cineon(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_Cineon(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Cineon(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_Cineon(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Cineon(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_Cineon(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Cineon(x), y, decimal=7) def test_domain_range_scale_log_encoding_Cineon(self): """ @@ -77,7 +80,7 @@ def test_domain_range_scale_log_encoding_Cineon(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Cineon(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -123,15 +126,18 @@ def test_n_dimensional_log_decoding_Cineon(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_Cineon(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Cineon(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_Cineon(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Cineon(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_Cineon(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Cineon(y), x, decimal=7) def test_domain_range_scale_log_decoding_Cineon(self): """ @@ -145,7 +151,7 @@ def test_domain_range_scale_log_decoding_Cineon(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Cineon(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_common.py b/colour/models/rgb/transfer_functions/tests/test_common.py index 3f7ba63704..7d661c9be6 100644 --- a/colour/models/rgb/transfer_functions/tests/test_common.py +++ b/colour/models/rgb/transfer_functions/tests/test_common.py @@ -45,7 +45,7 @@ def test_CV_range(self): np.testing.assert_array_equal( CV_range(8, False, True), np.array([0, 255])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CV_range(8, True, False), np.array([0.06274510, 0.92156863]), decimal=7) @@ -59,7 +59,7 @@ def test_CV_range(self): np.testing.assert_array_equal( CV_range(10, False, True), np.array([0, 1023])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CV_range(10, True, False), np.array([0.06256109, 0.91886608]), decimal=7) @@ -108,17 +108,17 @@ def test_n_dimensional_legal_to_full(self): CV_l = np.tile(CV_l, 6) CV_f = np.tile(CV_f, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( legal_to_full(CV_l, 10), CV_f, decimal=7) CV_l = np.reshape(CV_l, (2, 3)) CV_f = np.reshape(CV_f, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( legal_to_full(CV_l, 10), CV_f, decimal=7) CV_l = np.reshape(CV_l, (2, 3, 1)) CV_f = np.reshape(CV_f, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( legal_to_full(CV_l, 10), CV_f, decimal=7) @ignore_numpy_errors @@ -173,17 +173,17 @@ def test_n_dimensional_full_to_legal(self): CF_f = np.tile(CF_f, 6) CV_l = np.tile(CV_l, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( full_to_legal(CF_f, 10), CV_l, decimal=7) CF_f = np.reshape(CF_f, (2, 3)) CV_l = np.reshape(CV_l, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( full_to_legal(CF_f, 10), CV_l, decimal=7) CF_f = np.reshape(CF_f, (2, 3, 1)) CV_l = np.reshape(CV_l, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( full_to_legal(CF_f, 10), CV_l, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_dcdm.py b/colour/models/rgb/transfer_functions/tests/test_dcdm.py index 54c5f1c7ba..2a19438201 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dcdm.py +++ b/colour/models/rgb/transfer_functions/tests/test_dcdm.py @@ -53,17 +53,17 @@ def test_n_dimensional_eotf_inverse_DCDM(self): XYZ = np.tile(XYZ, 6) XYZ_p = np.tile(XYZ_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_DCDM(XYZ), XYZ_p, decimal=7) XYZ = np.reshape(XYZ, (2, 3)) XYZ_p = np.reshape(XYZ_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_DCDM(XYZ), XYZ_p, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 1)) XYZ_p = np.reshape(XYZ_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_DCDM(XYZ), XYZ_p, decimal=7) def test_domain_range_scale_eotf_inverse_DCDM(self): @@ -78,7 +78,7 @@ def test_domain_range_scale_eotf_inverse_DCDM(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_DCDM(XYZ * factor), XYZ_p * factor, decimal=7) @ignore_numpy_errors @@ -123,15 +123,15 @@ def test_n_dimensional_eotf_DCDM(self): XYZ_p = np.tile(XYZ_p, 6) XYZ = np.tile(XYZ, 6) - np.testing.assert_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) + np.testing.assert_array_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) XYZ_p = np.reshape(XYZ_p, (2, 3)) XYZ = np.reshape(XYZ, (2, 3)) - np.testing.assert_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) + np.testing.assert_array_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) XYZ_p = np.reshape(XYZ_p, (2, 3, 1)) XYZ = np.reshape(XYZ, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) + np.testing.assert_array_almost_equal(eotf_DCDM(XYZ_p), XYZ, decimal=7) def test_domain_range_scale_eotf_DCDM(self): """ @@ -145,7 +145,7 @@ def test_domain_range_scale_eotf_DCDM(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_DCDM(XYZ_p * factor), XYZ * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py index 7386031c05..62d6bb42fd 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py @@ -58,15 +58,18 @@ def test_n_dimensional_eotf_inverse_DICOMGSDF(self): L = np.tile(L, 6) J = np.tile(J, 6) - np.testing.assert_almost_equal(eotf_inverse_DICOMGSDF(L), J, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_DICOMGSDF(L), J, decimal=7) L = np.reshape(L, (2, 3)) J = np.reshape(J, (2, 3)) - np.testing.assert_almost_equal(eotf_inverse_DICOMGSDF(L), J, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_DICOMGSDF(L), J, decimal=7) L = np.reshape(L, (2, 3, 1)) J = np.reshape(J, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_inverse_DICOMGSDF(L), J, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_DICOMGSDF(L), J, decimal=7) def test_domain_range_scale_eotf_inverse_DICOMGSDF(self): """ @@ -80,7 +83,7 @@ def test_domain_range_scale_eotf_inverse_DICOMGSDF(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_DICOMGSDF(L * factor), J * factor, decimal=7) @ignore_numpy_errors @@ -129,15 +132,15 @@ def test_n_dimensional_eotf_DICOMGSDF(self): J = np.tile(J, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) J = np.reshape(J, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) J = np.reshape(J, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_DICOMGSDF(J), L, decimal=7) def test_domain_range_scale_eotf_DICOMGSDF(self): """ @@ -151,7 +154,7 @@ def test_domain_range_scale_eotf_DICOMGSDF(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_DICOMGSDF(J * factor), L * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py b/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py index 3e891a1b5a..8460f5c020 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_dji_dlog.py @@ -53,15 +53,18 @@ def test_n_dimensional_log_encoding_DLog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_DJIDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_DJIDLog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_DJIDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_DJIDLog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_DJIDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_DJIDLog(x), y, decimal=7) def test_domain_range_scale_log_encoding_DLog(self): """ @@ -75,7 +78,7 @@ def test_domain_range_scale_log_encoding_DLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_DJIDLog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -119,15 +122,18 @@ def test_n_dimensional_log_decoding_DLog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_DJIDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_DJIDLog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_DJIDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_DJIDLog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_DJIDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_DJIDLog(y), x, decimal=7) def test_domain_range_scale_log_decoding_DLog(self): """ @@ -141,7 +147,7 @@ def test_domain_range_scale_log_decoding_DLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_DJIDLog(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_exponent.py b/colour/models/rgb/transfer_functions/tests/test_exponent.py index 63b75e4bf4..18fc2cbbe3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_exponent.py +++ b/colour/models/rgb/transfer_functions/tests/test_exponent.py @@ -92,33 +92,33 @@ def test_n_dimensional_exponent_function_basic(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorFwd'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruFwd'), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorFwd'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruFwd'), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorFwd'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruFwd'), a_p, decimal=7) @@ -128,33 +128,33 @@ def test_n_dimensional_exponent_function_basic(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruRev'), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruRev'), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicMirrorRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_basic(a, 2.2, 'basicPassThruRev'), a_p, decimal=7) @@ -252,9 +252,9 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorFwd'), a_p, @@ -262,9 +262,9 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorFwd'), a_p, @@ -272,9 +272,9 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorFwd'), a_p, @@ -285,11 +285,11 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorRev'), a_p, @@ -297,11 +297,11 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorRev'), a_p, @@ -309,11 +309,11 @@ def test_n_dimensional_exponent_function_monitor_curve(self): a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveRev'), a_p, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_function_monitor_curve(a, 2.2, 0.001, 'monCurveMirrorRev'), a_p, diff --git a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py index f4e4229488..9af55938b4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py @@ -54,17 +54,17 @@ def test_n_dimensional_log_encoding_FilmicPro6(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmicPro6(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmicPro6(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmicPro6(x), y, decimal=7) def test_domain_range_scale_log_encoding_FilmicPro6(self): @@ -79,7 +79,7 @@ def test_domain_range_scale_log_encoding_FilmicPro6(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmicPro6(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -124,17 +124,17 @@ def test_n_dimensional_log_decoding_FilmicPro6(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmicPro6(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmicPro6(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmicPro6(y), x, decimal=7) def test_domain_range_scale_log_decoding_FilmicPro6(self): @@ -149,7 +149,7 @@ def test_domain_range_scale_log_decoding_FilmicPro6(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmicPro6(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py b/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py index c8fd11f547..8b77de56b9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmlight_tlog.py @@ -55,17 +55,17 @@ def test_n_dimensional_log_encoding_TLog(self): x = np.tile(x, 6) t = np.tile(t, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmLightTLog(x), t, decimal=7) x = np.reshape(x, (2, 3)) t = np.reshape(t, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmLightTLog(x), t, decimal=7) x = np.reshape(x, (2, 3, 1)) t = np.reshape(t, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmLightTLog(x), t, decimal=7) def test_domain_range_scale_log_encoding_TLog(self): @@ -80,7 +80,7 @@ def test_domain_range_scale_log_encoding_TLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FilmLightTLog(x * factor), t * factor, decimal=7) @@ -128,17 +128,17 @@ def test_n_dimensional_log_decoding_TLog(self): t = np.tile(t, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmLightTLog(t), x, decimal=7) t = np.reshape(t, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmLightTLog(t), x, decimal=7) t = np.reshape(t, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmLightTLog(t), x, decimal=7) def test_domain_range_scale_log_decoding_TLog(self): @@ -153,7 +153,7 @@ def test_domain_range_scale_log_decoding_TLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FilmLightTLog(t * factor), x * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py b/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py index 590a7475f5..f20cc0aa73 100644 --- a/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py +++ b/colour/models/rgb/transfer_functions/tests/test_fujifilm_flog.py @@ -66,17 +66,17 @@ def test_n_dimensional_log_encoding_FLog(self): L_in = np.tile(L_in, 6) V_out = np.tile(V_out, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FLog(L_in), V_out, decimal=7) L_in = np.reshape(L_in, (2, 3)) V_out = np.reshape(V_out, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FLog(L_in), V_out, decimal=7) L_in = np.reshape(L_in, (2, 3, 1)) V_out = np.reshape(V_out, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FLog(L_in), V_out, decimal=7) def test_domain_range_scale_log_encoding_FLog(self): @@ -91,7 +91,7 @@ def test_domain_range_scale_log_encoding_FLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_FLog(L_in * factor), V_out * factor, decimal=7) @@ -149,17 +149,17 @@ def test_n_dimensional_log_decoding_FLog(self): V_out = np.tile(V_out, 6) L_in = np.tile(L_in, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FLog(V_out), L_in, decimal=7) V_out = np.reshape(V_out, (2, 3)) L_in = np.reshape(L_in, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FLog(V_out), L_in, decimal=7) V_out = np.reshape(V_out, (2, 3, 1)) L_in = np.reshape(L_in, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FLog(V_out), L_in, decimal=7) def test_domain_range_scale_log_decoding_FLog(self): @@ -174,7 +174,7 @@ def test_domain_range_scale_log_decoding_FLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_FLog(V_out * factor), L_in * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_gamma.py b/colour/models/rgb/transfer_functions/tests/test_gamma.py index 0226a7faac..c910be8df9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gamma.py +++ b/colour/models/rgb/transfer_functions/tests/test_gamma.py @@ -77,74 +77,77 @@ def test_n_dimensional_gamma_function(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal(gamma_function(a, 2.2), a_p, decimal=7) + np.testing.assert_array_almost_equal( + gamma_function(a, 2.2), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal(gamma_function(a, 2.2), a_p, decimal=7) + np.testing.assert_array_almost_equal( + gamma_function(a, 2.2), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal(gamma_function(a, 2.2), a_p, decimal=7) + np.testing.assert_array_almost_equal( + gamma_function(a, 2.2), a_p, decimal=7) a = -0.18 a_p = -0.022993204992707 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Mirror'), a_p, decimal=7) a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Mirror'), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Mirror'), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Mirror'), a_p, decimal=7) a = -0.18 a_p = -0.18 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Preserve'), a_p, decimal=7) a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Preserve'), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Preserve'), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Preserve'), a_p, decimal=7) a = -0.18 a_p = 0.0 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Clamp'), a_p, decimal=7) a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Clamp'), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Clamp'), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( gamma_function(a, 2.2, 'Clamp'), a_p, decimal=7) def test_raise_exception_gamma_function(self): diff --git a/colour/models/rgb/transfer_functions/tests/test_gopro.py b/colour/models/rgb/transfer_functions/tests/test_gopro.py index 04bd192863..209bd46164 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gopro.py +++ b/colour/models/rgb/transfer_functions/tests/test_gopro.py @@ -53,15 +53,18 @@ def test_n_dimensional_log_encoding_Protune(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_Protune(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Protune(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_Protune(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Protune(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_Protune(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Protune(x), y, decimal=7) def test_domain_range_scale_log_encoding_Protune(self): """ @@ -75,7 +78,7 @@ def test_domain_range_scale_log_encoding_Protune(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Protune(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -119,15 +122,18 @@ def test_n_dimensional_log_decoding_Protune(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_Protune(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Protune(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_Protune(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Protune(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_Protune(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Protune(y), x, decimal=7) def test_domain_range_scale_log_decoding_Protune(self): """ @@ -141,7 +147,7 @@ def test_domain_range_scale_log_decoding_Protune(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Protune(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py index 5789f4fcad..e5a7fe2d92 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py @@ -53,15 +53,18 @@ def test_n_dimensional_eotf_inverse_BT1886(self): L = np.tile(L, 6) V = np.tile(V, 6) - np.testing.assert_almost_equal(eotf_inverse_BT1886(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT1886(L), V, decimal=7) L = np.reshape(L, (2, 3)) V = np.reshape(V, (2, 3)) - np.testing.assert_almost_equal(eotf_inverse_BT1886(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT1886(L), V, decimal=7) L = np.reshape(L, (2, 3, 1)) V = np.reshape(V, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_inverse_BT1886(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT1886(L), V, decimal=7) def test_domain_range_scale_eotf_inverse_BT1886(self): """ @@ -75,7 +78,7 @@ def test_domain_range_scale_eotf_inverse_BT1886(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_BT1886(L * factor), V * factor, decimal=7) @ignore_numpy_errors @@ -118,15 +121,15 @@ def test_n_dimensional_eotf_BT1886(self): V = np.tile(V, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(eotf_BT1886(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT1886(V), L, decimal=7) V = np.reshape(V, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(eotf_BT1886(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT1886(V), L, decimal=7) V = np.reshape(V, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_BT1886(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT1886(V), L, decimal=7) def test_domain_range_scale_eotf_BT1886(self): """ @@ -140,7 +143,7 @@ def test_domain_range_scale_eotf_BT1886(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_BT1886(V * factor), L * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py index 94198ebd4e..4dd02f6c80 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py @@ -53,15 +53,18 @@ def test_n_dimensional_eotf_inverse_BT2020(self): E = np.tile(E, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal(eotf_inverse_BT2020(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT2020(E), E_p, decimal=7) E = np.reshape(E, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal(eotf_inverse_BT2020(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT2020(E), E_p, decimal=7) E = np.reshape(E, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_inverse_BT2020(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_BT2020(E), E_p, decimal=7) def test_domain_range_scale_eotf_inverse_BT2020(self): """ @@ -75,7 +78,7 @@ def test_domain_range_scale_eotf_inverse_BT2020(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_BT2020(E * factor), E_p * factor, decimal=7) @ignore_numpy_errors @@ -118,15 +121,15 @@ def test_n_dimensional_eotf_BT2020(self): E_p = np.tile(E_p, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal(eotf_BT2020(E_p), E, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT2020(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal(eotf_BT2020(E_p), E, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT2020(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_BT2020(E_p), E, decimal=7) + np.testing.assert_array_almost_equal(eotf_BT2020(E_p), E, decimal=7) def test_domain_range_scale_eotf_BT2020(self): """ @@ -140,7 +143,7 @@ def test_domain_range_scale_eotf_BT2020(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_BT2020(E_p * factor), E * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py index 1496db14a3..c1f8ba1ebc 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py @@ -72,15 +72,15 @@ def test_n_dimensional_oetf_PQ_BT2100(self): E = np.tile(E, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) E = np.reshape(E, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) E = np.reshape(E, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal(oetf_PQ_BT2100(E), E_p, decimal=7) def test_domain_range_scale_oetf_PQ_BT2100(self): """ @@ -94,7 +94,7 @@ def test_domain_range_scale_oetf_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_PQ_BT2100(E * factor), E_p * factor, decimal=7) @ignore_numpy_errors @@ -139,17 +139,17 @@ def test_n_dimensional_oetf_inverse_PQ_BT2100(self): E_p = np.tile(E_p, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_PQ_BT2100(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_PQ_BT2100(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_PQ_BT2100(E_p), E, decimal=7) def test_domain_range_scale_oetf_inverse_PQ_BT2100(self): @@ -164,7 +164,7 @@ def test_domain_range_scale_oetf_inverse_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_PQ_BT2100(E_p * factor), E * factor, decimal=7) @@ -210,15 +210,18 @@ def test_n_dimensional_eotf_PQ_BT2100(self): E_p = np.tile(E_p, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(eotf_PQ_BT2100(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_PQ_BT2100(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(eotf_PQ_BT2100(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_PQ_BT2100(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_PQ_BT2100(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_PQ_BT2100(E_p), F_D, decimal=7) def test_domain_range_scale_eotf_PQ_BT2100(self): """ @@ -232,7 +235,7 @@ def test_domain_range_scale_eotf_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_PQ_BT2100(E_p * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -278,17 +281,17 @@ def test_n_dimensional_eotf_inverse_PQ_BT2100(self): F_D = np.tile(F_D, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_PQ_BT2100(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_PQ_BT2100(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_PQ_BT2100(F_D), E_p, decimal=7) def test_domain_range_scale_eotf_inverse_PQ_BT2100(self): @@ -303,7 +306,7 @@ def test_domain_range_scale_eotf_inverse_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_PQ_BT2100(F_D * factor), E_p * factor, decimal=7) @@ -350,15 +353,15 @@ def test_n_dimensional_ootf_PQ_BT2100(self): E = np.tile(E, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) + np.testing.assert_array_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) E = np.reshape(E, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) + np.testing.assert_array_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) E = np.reshape(E, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) + np.testing.assert_array_almost_equal(ootf_PQ_BT2100(E), F_D, decimal=7) def test_domain_range_scale_ootf_PQ_BT2100(self): """ @@ -372,7 +375,7 @@ def test_domain_range_scale_ootf_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_PQ_BT2100(E * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -416,17 +419,17 @@ def test_n_dimensional_ootf_inverse_PQ_BT2100(self): F_D = np.tile(F_D, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_PQ_BT2100(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_PQ_BT2100(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_PQ_BT2100(F_D), E, decimal=7) def test_domain_range_scale_ootf_inverse_PQ_BT2100(self): @@ -441,7 +444,7 @@ def test_domain_range_scale_ootf_inverse_PQ_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_PQ_BT2100(F_D * factor), E * factor, decimal=7) @@ -513,15 +516,18 @@ def test_n_dimensional_oetf_HLG_BT2100(self): E = np.tile(E, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal(oetf_HLG_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_HLG_BT2100(E), E_p, decimal=7) E = np.reshape(E, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal(oetf_HLG_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_HLG_BT2100(E), E_p, decimal=7) E = np.reshape(E, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_HLG_BT2100(E), E_p, decimal=7) + np.testing.assert_array_almost_equal( + oetf_HLG_BT2100(E), E_p, decimal=7) def test_domain_range_scale_oetf_HLG_BT2100(self): """ @@ -535,7 +541,7 @@ def test_domain_range_scale_oetf_HLG_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_HLG_BT2100(E * factor), E_p * factor, decimal=7) @ignore_numpy_errors @@ -579,17 +585,17 @@ def test_n_dimensional_oetf_inverse_HLG_BT2100(self): E_p = np.tile(E_p, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_HLG_BT2100(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_HLG_BT2100(E_p), E, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_HLG_BT2100(E_p), E, decimal=7) def test_domain_range_scale_oetf_inverse_HLG_BT2100(self): @@ -604,7 +610,7 @@ def test_domain_range_scale_oetf_inverse_HLG_BT2100(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_HLG_BT2100(E_p * factor), E * factor, decimal=7) @@ -656,31 +662,38 @@ def test_n_dimensional_eotf_HLG_BT2100_1(self): E_p = np.tile(E_p, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (6, 1)) F_D = np.reshape(F_D, (6, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.array([0.25, 0.50, 0.75]) F_D = np.array([12.49759413, 49.99037650, 158.94693786]) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.tile(E_p, (6, 1)) F_D = np.tile(F_D, (6, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3, 3)) F_D = np.reshape(F_D, (2, 3, 3)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_1(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_1(E_p), F_D, decimal=7) def test_domain_range_scale_eotf_HLG_BT2100_1(self): """ @@ -694,7 +707,7 @@ def test_domain_range_scale_eotf_HLG_BT2100_1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_HLG_BT2100_1(E_p * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -743,31 +756,38 @@ def test_n_dimensional_eotf_HLG_BT2100_2(self): E_p = np.tile(E_p, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (6, 1)) F_D = np.reshape(F_D, (6, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.array([0.25, 0.50, 0.75]) F_D = np.array([12.49759413, 49.99037650, 158.94693786]) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.tile(E_p, (6, 1)) F_D = np.tile(F_D, (6, 1)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) E_p = np.reshape(E_p, (2, 3, 3)) F_D = np.reshape(F_D, (2, 3, 3)) - np.testing.assert_almost_equal(eotf_HLG_BT2100_2(E_p), F_D, decimal=7) + np.testing.assert_array_almost_equal( + eotf_HLG_BT2100_2(E_p), F_D, decimal=7) def test_domain_range_scale_eotf_HLG_BT2100_2(self): """ @@ -781,7 +801,7 @@ def test_domain_range_scale_eotf_HLG_BT2100_2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_HLG_BT2100_2(E_p * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -832,37 +852,37 @@ def test_n_dimensional_eotf_inverse_HLG_BT2100_1(self): F_D = np.tile(F_D, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (6, 1)) E_p = np.reshape(E_p, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.array([12.49759413, 49.99037650, 158.94693786]) E_p = np.array([0.25, 0.50, 0.75]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.tile(F_D, (6, 1)) E_p = np.tile(E_p, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3, 3)) E_p = np.reshape(E_p, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D), E_p, decimal=7) def test_domain_range_scale_eotf_inverse_HLG_BT2100_1(self): @@ -877,7 +897,7 @@ def test_domain_range_scale_eotf_inverse_HLG_BT2100_1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_1(F_D * factor), E_p * factor, decimal=7) @@ -931,37 +951,37 @@ def test_n_dimensional_eotf_inverse_HLG_BT2100_2(self): F_D = np.tile(F_D, 6) E_p = np.tile(E_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3)) E_p = np.reshape(E_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E_p = np.reshape(E_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (6, 1)) E_p = np.reshape(E_p, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.array([12.49759413, 49.99037650, 158.94693786]) E_p = np.array([0.25, 0.50, 0.75]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.tile(F_D, (6, 1)) E_p = np.tile(E_p, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) F_D = np.reshape(F_D, (2, 3, 3)) E_p = np.reshape(E_p, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D), E_p, decimal=7) def test_domain_range_scale_eotf_inverse_HLG_BT2100_2(self): @@ -976,7 +996,7 @@ def test_domain_range_scale_eotf_inverse_HLG_BT2100_2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_HLG_BT2100_2(F_D * factor), E_p * factor, decimal=7) @@ -1021,7 +1041,7 @@ def test_ootf_HLG_BT2100_1(self): -63.095734448019336, -63.095734448019336, -63.095734448019336 ], [63.095734448019336, 63.095734448019336, 63.095734448019336], [51.320396090100672, -51.320396090100672, 51.320396090100672]], ) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_HLG_BT2100_1( np.array([[0.1, 0.0, -0.1], [-0.1, -0.1, -0.1], [0.1, 0.1, 0.1], [0.1, -0.1, 0.1]])), @@ -1039,31 +1059,38 @@ def test_n_dimensional_ootf_HLG_BT2100_1(self): E = np.tile(E, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.reshape(E, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.reshape(E, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.reshape(E, (6, 1)) F_D = np.reshape(F_D, (6, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.array([0.25, 0.50, 0.75]) F_D = np.array([213.01897444, 426.03794887, 639.05692331]) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.tile(E, (6, 1)) F_D = np.tile(F_D, (6, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) E = np.reshape(E, (2, 3, 3)) F_D = np.reshape(F_D, (2, 3, 3)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_1(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_1(E), F_D, decimal=7) def test_domain_range_scale_ootf_HLG_BT2100_1(self): """ @@ -1077,7 +1104,7 @@ def test_domain_range_scale_ootf_HLG_BT2100_1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_HLG_BT2100_1(E * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -1118,7 +1145,7 @@ def test_ootf_HLG_BT2100_2(self): [63.095734448019336, 63.095734448019336, 63.095734448019336], [51.320396090100672, -51.320396090100672, 51.320396090100672], ], ) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_HLG_BT2100_2( np.array([[0.1, 0.0, -0.1], [-0.1, -0.1, -0.1], [0.1, 0.1, 0.1], [0.1, -0.1, 0.1]])), @@ -1136,31 +1163,38 @@ def test_n_dimensional_ootf_HLG_BT2100_2(self): E = np.tile(E, 6) F_D = np.tile(F_D, 6) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.reshape(E, (2, 3)) F_D = np.reshape(F_D, (2, 3)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.reshape(E, (2, 3, 1)) F_D = np.reshape(F_D, (2, 3, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.reshape(E, (6, 1)) F_D = np.reshape(F_D, (6, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.array([0.25, 0.50, 0.75]) F_D = np.array([213.01897444, 426.03794887, 639.05692331]) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.tile(E, (6, 1)) F_D = np.tile(F_D, (6, 1)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) E = np.reshape(E, (2, 3, 3)) F_D = np.reshape(F_D, (2, 3, 3)) - np.testing.assert_almost_equal(ootf_HLG_BT2100_2(E), F_D, decimal=7) + np.testing.assert_array_almost_equal( + ootf_HLG_BT2100_2(E), F_D, decimal=7) def test_domain_range_scale_ootf_HLG_BT2100_2(self): """ @@ -1174,7 +1208,7 @@ def test_domain_range_scale_ootf_HLG_BT2100_2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_HLG_BT2100_1(E * factor), F_D * factor, decimal=7) @ignore_numpy_errors @@ -1217,7 +1251,7 @@ def test_ootf_inverse_HLG_BT2100_1(self): -63.095734448019336, -63.095734448019336, -63.095734448019336 ], [63.095734448019336, 63.095734448019336, 63.095734448019336], [51.320396090100672, -51.320396090100672, 51.320396090100672]]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(a), np.array([[0.1, 0.0, -0.1], [-0.1, -0.1, -0.1], [0.1, 0.1, 0.1], [0.1, -0.1, 0.1]]), @@ -1234,37 +1268,37 @@ def test_n_dimensional_ootf_inverse_HLG_BT2100_1(self): F_D = np.tile(F_D, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.reshape(F_D, (6, 1)) E = np.reshape(E, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.array([213.01897444, 426.03794887, 639.05692331]) E = np.array([0.25, 0.50, 0.75]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.tile(F_D, (6, 1)) E = np.tile(E, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3, 3)) E = np.reshape(E, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D), E, decimal=7) def test_domain_range_scale_ootf_inverse_HLG_BT2100_1(self): @@ -1279,7 +1313,7 @@ def test_domain_range_scale_ootf_inverse_HLG_BT2100_1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_1(F_D * factor), E * factor, decimal=7) @@ -1325,7 +1359,7 @@ def test_ootf_inverse_HLG_BT2100_2(self): -63.095734448019336, -63.095734448019336, -63.095734448019336 ], [63.095734448019336, 63.095734448019336, 63.095734448019336], [51.320396090100672, -51.320396090100672, 51.320396090100672]]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(a), np.array([[0.1, 0.0, -0.1], [-0.1, -0.1, -0.1], [0.1, 0.1, 0.1], [0.1, -0.1, 0.1]]), @@ -1342,37 +1376,37 @@ def test_n_dimensional_ootf_inverse_HLG_BT2100_2(self): F_D = np.tile(F_D, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.reshape(F_D, (6, 1)) E = np.reshape(E, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.array([213.01897444, 426.03794887, 639.05692331]) E = np.array([0.25, 0.50, 0.75]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.tile(F_D, (6, 1)) E = np.tile(E, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) F_D = np.reshape(F_D, (2, 3, 3)) E = np.reshape(E, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D), E, decimal=7) def test_domain_range_scale_ootf_inverse_HLG_BT2100_2(self): @@ -1387,7 +1421,7 @@ def test_domain_range_scale_ootf_inverse_HLG_BT2100_2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( ootf_inverse_HLG_BT2100_2(F_D * factor), E * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py index 00ea2c3805..7441a46fb2 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py @@ -53,15 +53,15 @@ def test_n_dimensional_oetf_BT601(self): L = np.tile(L, 6) E = np.tile(E, 6) - np.testing.assert_almost_equal(oetf_BT601(L), E, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT601(L), E, decimal=7) L = np.reshape(L, (2, 3)) E = np.reshape(E, (2, 3)) - np.testing.assert_almost_equal(oetf_BT601(L), E, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT601(L), E, decimal=7) L = np.reshape(L, (2, 3, 1)) E = np.reshape(E, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_BT601(L), E, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT601(L), E, decimal=7) def test_domain_range_scale_oetf_BT601(self): """ @@ -75,7 +75,7 @@ def test_domain_range_scale_oetf_BT601(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_BT601(L * factor), E * factor, decimal=7) @ignore_numpy_errors @@ -121,15 +121,18 @@ def test_n_dimensional_oetf_inverse_BT601(self): E = np.tile(E, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(oetf_inverse_BT601(E), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT601(E), L, decimal=7) E = np.reshape(E, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(oetf_inverse_BT601(E), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT601(E), L, decimal=7) E = np.reshape(E, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_inverse_BT601(E), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT601(E), L, decimal=7) def test_domain_range_scale_oetf_inverse_BT601(self): """ @@ -143,7 +146,7 @@ def test_domain_range_scale_oetf_inverse_BT601(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_BT601(E * factor), L * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py index 6fea4cde24..7e7d646657 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py @@ -53,15 +53,15 @@ def test_n_dimensional_oetf_BT709(self): L = np.tile(L, 6) V = np.tile(V, 6) - np.testing.assert_almost_equal(oetf_BT709(L), V, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT709(L), V, decimal=7) L = np.reshape(L, (2, 3)) V = np.reshape(V, (2, 3)) - np.testing.assert_almost_equal(oetf_BT709(L), V, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT709(L), V, decimal=7) L = np.reshape(L, (2, 3, 1)) V = np.reshape(V, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_BT709(L), V, decimal=7) + np.testing.assert_array_almost_equal(oetf_BT709(L), V, decimal=7) def test_domain_range_scale_oetf_BT709(self): """ @@ -75,7 +75,7 @@ def test_domain_range_scale_oetf_BT709(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_BT709(L * factor), V * factor, decimal=7) @ignore_numpy_errors @@ -121,15 +121,18 @@ def test_n_dimensional_oetf_inverse_BT709(self): V = np.tile(V, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(oetf_inverse_BT709(V), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT709(V), L, decimal=7) V = np.reshape(V, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(oetf_inverse_BT709(V), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT709(V), L, decimal=7) V = np.reshape(V, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_inverse_BT709(V), L, decimal=7) + np.testing.assert_array_almost_equal( + oetf_inverse_BT709(V), L, decimal=7) def test_domain_range_scale_oetf_inverse_BT709(self): """ @@ -143,7 +146,7 @@ def test_domain_range_scale_oetf_inverse_BT709(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_inverse_BT709(V * factor), L * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_linear.py b/colour/models/rgb/transfer_functions/tests/test_linear.py index 5cac1dde3d..f1e7928ceb 100644 --- a/colour/models/rgb/transfer_functions/tests/test_linear.py +++ b/colour/models/rgb/transfer_functions/tests/test_linear.py @@ -51,15 +51,18 @@ def test_n_dimensional_linear_function(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal(linear_function(a), a_p, decimal=7) + np.testing.assert_array_almost_equal( + linear_function(a), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal(linear_function(a), a_p, decimal=7) + np.testing.assert_array_almost_equal( + linear_function(a), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal(linear_function(a), a_p, decimal=7) + np.testing.assert_array_almost_equal( + linear_function(a), a_p, decimal=7) @ignore_numpy_errors def test_nan_linear_function(self): diff --git a/colour/models/rgb/transfer_functions/tests/test_log.py b/colour/models/rgb/transfer_functions/tests/test_log.py index b40f3160a1..50e9bddd8e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_log.py @@ -431,15 +431,18 @@ def test_n_dimensional_log_encoding_Log2(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_Log2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log2(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_Log2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log2(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_Log2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log2(x), y, decimal=7) def test_domain_range_scale_log_encoding_Log2(self): """ @@ -453,7 +456,7 @@ def test_domain_range_scale_log_encoding_Log2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log2(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -510,15 +513,18 @@ def test_n_dimensional_log_decoding_Log2(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_Log2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log2(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_Log2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log2(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_Log2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log2(y), x, decimal=7) def test_domain_range_scale_log_decoding_Log2(self): """ @@ -532,7 +538,7 @@ def test_domain_range_scale_log_decoding_Log2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log2(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_panalog.py b/colour/models/rgb/transfer_functions/tests/test_panalog.py index b7c1359e36..511c9abdb3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panalog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panalog.py @@ -55,15 +55,18 @@ def test_n_dimensional_log_encoding_Panalog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_Panalog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Panalog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_Panalog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Panalog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_Panalog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Panalog(x), y, decimal=7) def test_domain_range_scale_log_encoding_Panalog(self): """ @@ -77,7 +80,7 @@ def test_domain_range_scale_log_encoding_Panalog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Panalog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -123,15 +126,18 @@ def test_n_dimensional_log_decoding_Panalog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_Panalog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Panalog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_Panalog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Panalog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_Panalog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Panalog(y), x, decimal=7) def test_domain_range_scale_log_decoding_Panalog(self): """ @@ -145,7 +151,7 @@ def test_domain_range_scale_log_decoding_Panalog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Panalog(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py index 02c80c1ef9..56239b057b 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py @@ -65,17 +65,17 @@ def test_n_dimensional_log_encoding_VLog(self): L_in = np.tile(L_in, 6) V_out = np.tile(V_out, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_VLog(L_in), V_out, decimal=7) L_in = np.reshape(L_in, (2, 3)) V_out = np.reshape(V_out, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_VLog(L_in), V_out, decimal=7) L_in = np.reshape(L_in, (2, 3, 1)) V_out = np.reshape(V_out, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_VLog(L_in), V_out, decimal=7) def test_domain_range_scale_log_encoding_VLog(self): @@ -90,7 +90,7 @@ def test_domain_range_scale_log_encoding_VLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_VLog(L_in * factor), V_out * factor, decimal=7) @@ -147,17 +147,17 @@ def test_n_dimensional_log_decoding_VLog(self): V_out = np.tile(V_out, 6) L_in = np.tile(L_in, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_VLog(V_out), L_in, decimal=7) V_out = np.reshape(V_out, (2, 3)) L_in = np.reshape(L_in, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_VLog(V_out), L_in, decimal=7) V_out = np.reshape(V_out, (2, 3, 1)) L_in = np.reshape(L_in, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_VLog(V_out), L_in, decimal=7) def test_domain_range_scale_log_decoding_VLog(self): @@ -172,7 +172,7 @@ def test_domain_range_scale_log_decoding_VLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_VLog(V_out * factor), L_in * factor, decimal=7) diff --git a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py index 2336d9c3e8..d5d9939cf2 100644 --- a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py @@ -54,17 +54,17 @@ def test_n_dimensional_log_encoding_PivotedLog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_PivotedLog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_PivotedLog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_PivotedLog(x), y, decimal=7) def test_domain_range_scale_log_encoding_PivotedLog(self): @@ -79,7 +79,7 @@ def test_domain_range_scale_log_encoding_PivotedLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_PivotedLog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -124,17 +124,17 @@ def test_n_dimensional_log_decoding_PivotedLog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_PivotedLog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_PivotedLog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_PivotedLog(y), x, decimal=7) def test_domain_range_scale_log_decoding_PivotedLog(self): @@ -149,7 +149,7 @@ def test_domain_range_scale_log_decoding_PivotedLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_PivotedLog(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_red_log.py b/colour/models/rgb/transfer_functions/tests/test_red_log.py index 8754185a2c..ae308d0492 100644 --- a/colour/models/rgb/transfer_functions/tests/test_red_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_red_log.py @@ -63,15 +63,18 @@ def test_n_dimensional_log_encoding_REDLog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_REDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_REDLog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_REDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_REDLog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_REDLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_REDLog(x), y, decimal=7) def test_domain_range_scale_log_encoding_REDLog(self): """ @@ -85,7 +88,7 @@ def test_domain_range_scale_log_encoding_REDLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_REDLog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -129,15 +132,18 @@ def test_n_dimensional_log_decoding_REDLog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_REDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_REDLog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_REDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_REDLog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_REDLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_REDLog(y), x, decimal=7) def test_domain_range_scale_log_decoding_REDLog(self): """ @@ -151,7 +157,7 @@ def test_domain_range_scale_log_decoding_REDLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_REDLog(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -197,17 +203,17 @@ def test_n_dimensional_log_encoding_REDLogFilm(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_REDLogFilm(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_REDLogFilm(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_REDLogFilm(x), y, decimal=7) def test_domain_range_scale_log_encoding_REDLogFilm(self): @@ -222,7 +228,7 @@ def test_domain_range_scale_log_encoding_REDLogFilm(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_REDLogFilm(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -268,17 +274,17 @@ def test_n_dimensional_log_decoding_REDLogFilm(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_REDLogFilm(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_REDLogFilm(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_REDLogFilm(y), x, decimal=7) def test_domain_range_scale_log_decoding_REDLogFilm(self): @@ -293,7 +299,7 @@ def test_domain_range_scale_log_decoding_REDLogFilm(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_REDLogFilm(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -338,17 +344,17 @@ def test_n_dimensional_log_encoding_Log3G10_v1(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v1(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v1(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v1(x), y, decimal=7) def test_domain_range_scale_log_encoding_Log3G10_v1(self): @@ -363,7 +369,7 @@ def test_domain_range_scale_log_encoding_Log3G10_v1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v1(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -408,17 +414,17 @@ def test_n_dimensional_log_decoding_Log3G10_v1(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v1(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v1(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v1(y), x, decimal=7) def test_domain_range_scale_log_decoding_Log3G10_v1(self): @@ -433,7 +439,7 @@ def test_domain_range_scale_log_decoding_Log3G10_v1(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v1(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -479,17 +485,17 @@ def test_n_dimensional_log_encoding_Log3G10_v2(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v2(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v2(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v2(x), y, decimal=7) def test_domain_range_scale_log_encoding_Log3G10_v2(self): @@ -504,7 +510,7 @@ def test_domain_range_scale_log_encoding_Log3G10_v2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G10_v2(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -550,17 +556,17 @@ def test_n_dimensional_log_decoding_Log3G10_v2(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v2(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v2(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v2(y), x, decimal=7) def test_domain_range_scale_log_decoding_Log3G10_v2(self): @@ -575,7 +581,7 @@ def test_domain_range_scale_log_decoding_Log3G10_v2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G10_v2(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -623,15 +629,18 @@ def test_n_dimensional_log_encoding_Log3G12(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_Log3G12(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log3G12(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_Log3G12(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log3G12(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_Log3G12(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_Log3G12(x), y, decimal=7) def test_domain_range_scale_log_encoding_Log3G12(self): """ @@ -645,7 +654,7 @@ def test_domain_range_scale_log_encoding_Log3G12(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_Log3G12(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -693,15 +702,18 @@ def test_n_dimensional_log_decoding_Log3G12(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_Log3G12(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log3G12(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_Log3G12(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log3G12(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_Log3G12(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_Log3G12(y), x, decimal=7) def test_domain_range_scale_log_decoding_Log3G12(self): """ @@ -715,7 +727,7 @@ def test_domain_range_scale_log_decoding_Log3G12(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_Log3G12(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py index a6e574ddf2..b66040bcc5 100644 --- a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py @@ -63,17 +63,17 @@ def test_n_dimensional_cctf_encoding_ROMMRGB(self): X = np.tile(X, 6) X_ROMM = np.tile(X_ROMM, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_ROMMRGB(X), X_ROMM, decimal=7) X = np.reshape(X, (2, 3)) X_ROMM = np.reshape(X_ROMM, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_ROMMRGB(X), X_ROMM, decimal=7) X = np.reshape(X, (2, 3, 1)) X_ROMM = np.reshape(X_ROMM, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_ROMMRGB(X), X_ROMM, decimal=7) def test_domain_range_scale_cctf_encoding_ROMMRGB(self): @@ -88,7 +88,7 @@ def test_domain_range_scale_cctf_encoding_ROMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_ROMMRGB(X * factor), X_p * factor, decimal=7) @ignore_numpy_errors @@ -144,17 +144,17 @@ def test_n_dimensional_cctf_decoding_ROMMRGB(self): X_p = np.tile(X_p, 6) X = np.tile(X, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_ROMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3)) X = np.reshape(X, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_ROMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3, 1)) X = np.reshape(X, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_ROMMRGB(X_p), X, decimal=7) def test_domain_range_scale_cctf_decoding_ROMMRGB(self): @@ -169,7 +169,7 @@ def test_domain_range_scale_cctf_decoding_ROMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_ROMMRGB(X_p * factor), X * factor, decimal=7) @ignore_numpy_errors @@ -219,17 +219,17 @@ def test_n_dimensional_cctf_encoding_RIMMRGB(self): X = np.tile(X, 6) X_p = np.tile(X_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_RIMMRGB(X), X_p, decimal=7) X = np.reshape(X, (2, 3)) X_p = np.reshape(X_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_RIMMRGB(X), X_p, decimal=7) X = np.reshape(X, (2, 3, 1)) X_p = np.reshape(X_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_RIMMRGB(X), X_p, decimal=7) def test_domain_range_scale_cctf_encoding_RIMMRGB(self): @@ -244,7 +244,7 @@ def test_domain_range_scale_cctf_encoding_RIMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_encoding_RIMMRGB(X * factor), X_p * factor, decimal=7) @ignore_numpy_errors @@ -301,17 +301,17 @@ def test_n_dimensional_cctf_decoding_RIMMRGB(self): X_p = np.tile(X_p, 6) X = np.tile(X, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_RIMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3)) X = np.reshape(X, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_RIMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3, 1)) X = np.reshape(X, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_RIMMRGB(X_p), X, decimal=7) def test_domain_range_scale_cctf_decoding_RIMMRGB(self): @@ -326,7 +326,7 @@ def test_domain_range_scale_cctf_decoding_RIMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cctf_decoding_RIMMRGB(X_p * factor), X * factor, decimal=7) @ignore_numpy_errors @@ -376,17 +376,17 @@ def test_n_dimensional_log_encoding_ERIMMRGB(self): X = np.tile(X, 6) X_p = np.tile(X_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ERIMMRGB(X), X_p, decimal=7) X = np.reshape(X, (2, 3)) X_p = np.reshape(X_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ERIMMRGB(X), X_p, decimal=7) X = np.reshape(X, (2, 3, 1)) X_p = np.reshape(X_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ERIMMRGB(X), X_p, decimal=7) def test_domain_range_scale_log_encoding_ERIMMRGB(self): @@ -401,7 +401,7 @@ def test_domain_range_scale_log_encoding_ERIMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ERIMMRGB(X * factor), X_p * factor, decimal=7) @ignore_numpy_errors @@ -458,17 +458,17 @@ def test_n_dimensional_log_decoding_ERIMMRGB(self): X_p = np.tile(X_p, 6) X = np.tile(X, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ERIMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3)) X = np.reshape(X, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ERIMMRGB(X_p), X, decimal=7) X_p = np.reshape(X_p, (2, 3, 1)) X = np.reshape(X, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ERIMMRGB(X_p), X, decimal=7) def test_domain_range_scale_log_decoding_ERIMMRGB(self): @@ -483,7 +483,7 @@ def test_domain_range_scale_log_decoding_ERIMMRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ERIMMRGB(X_p * factor), X * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py index 7d3a631fb8..0267c42127 100644 --- a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py +++ b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py @@ -55,15 +55,18 @@ def test_n_dimensional_oetf_SMPTE240M(self): L_c = np.tile(L_c, 6) V_c = np.tile(V_c, 6) - np.testing.assert_almost_equal(oetf_SMPTE240M(L_c), V_c, decimal=7) + np.testing.assert_array_almost_equal( + oetf_SMPTE240M(L_c), V_c, decimal=7) L_c = np.reshape(L_c, (2, 3)) V_c = np.reshape(V_c, (2, 3)) - np.testing.assert_almost_equal(oetf_SMPTE240M(L_c), V_c, decimal=7) + np.testing.assert_array_almost_equal( + oetf_SMPTE240M(L_c), V_c, decimal=7) L_c = np.reshape(L_c, (2, 3, 1)) V_c = np.reshape(V_c, (2, 3, 1)) - np.testing.assert_almost_equal(oetf_SMPTE240M(L_c), V_c, decimal=7) + np.testing.assert_array_almost_equal( + oetf_SMPTE240M(L_c), V_c, decimal=7) def test_domain_range_scale_oetf_SMPTE240M(self): """ @@ -77,7 +80,7 @@ def test_domain_range_scale_oetf_SMPTE240M(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( oetf_SMPTE240M(L_c * factor), V_c * factor, decimal=7) @ignore_numpy_errors @@ -123,15 +126,18 @@ def test_n_dimensional_eotf_SMPTE240M(self): V_r = np.tile(V_r, 6) L_r = np.tile(L_r, 6) - np.testing.assert_almost_equal(eotf_SMPTE240M(V_r), L_r, decimal=7) + np.testing.assert_array_almost_equal( + eotf_SMPTE240M(V_r), L_r, decimal=7) V_r = np.reshape(V_r, (2, 3)) L_r = np.reshape(L_r, (2, 3)) - np.testing.assert_almost_equal(eotf_SMPTE240M(V_r), L_r, decimal=7) + np.testing.assert_array_almost_equal( + eotf_SMPTE240M(V_r), L_r, decimal=7) V_r = np.reshape(V_r, (2, 3, 1)) L_r = np.reshape(L_r, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_SMPTE240M(V_r), L_r, decimal=7) + np.testing.assert_array_almost_equal( + eotf_SMPTE240M(V_r), L_r, decimal=7) def test_domain_range_scale_eotf_SMPTE240M(self): """ @@ -145,7 +151,7 @@ def test_domain_range_scale_eotf_SMPTE240M(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_SMPTE240M(V_r * factor), L_r * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_sony_slog.py b/colour/models/rgb/transfer_functions/tests/test_sony_slog.py index ff6858d2f2..d3f66f6fd3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_sony_slog.py +++ b/colour/models/rgb/transfer_functions/tests/test_sony_slog.py @@ -74,15 +74,18 @@ def test_n_dimensional_log_encoding_SLog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_SLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_SLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_SLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog(x), y, decimal=7) def test_domain_range_scale_log_encoding_SLog(self): """ @@ -96,7 +99,7 @@ def test_domain_range_scale_log_encoding_SLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_SLog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -152,15 +155,18 @@ def test_n_dimensional_log_decoding_SLog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_SLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_SLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_SLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog(y), x, decimal=7) def test_domain_range_scale_log_decoding_SLog(self): """ @@ -174,7 +180,7 @@ def test_domain_range_scale_log_decoding_SLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_SLog(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -230,15 +236,18 @@ def test_n_dimensional_log_encoding_SLog2(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_SLog2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog2(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_SLog2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog2(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_SLog2(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog2(x), y, decimal=7) def test_domain_range_scale_log_encoding_SLog2(self): """ @@ -252,7 +261,7 @@ def test_domain_range_scale_log_encoding_SLog2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_SLog2(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -308,15 +317,18 @@ def test_n_dimensional_log_decoding_SLog2(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_SLog2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog2(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_SLog2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog2(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_SLog2(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog2(y), x, decimal=7) def test_domain_range_scale_log_decoding_SLog2(self): """ @@ -330,7 +342,7 @@ def test_domain_range_scale_log_decoding_SLog2(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_SLog2(y * factor), x * factor, decimal=7) @ignore_numpy_errors @@ -386,15 +398,18 @@ def test_n_dimensional_log_encoding_SLog3(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_SLog3(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog3(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_SLog3(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog3(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_SLog3(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_SLog3(x), y, decimal=7) def test_domain_range_scale_log_encoding_SLog3(self): """ @@ -408,7 +423,7 @@ def test_domain_range_scale_log_encoding_SLog3(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_SLog3(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -464,15 +479,18 @@ def test_n_dimensional_log_decoding_SLog3(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_SLog3(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog3(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_SLog3(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog3(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_SLog3(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_SLog3(y), x, decimal=7) def test_domain_range_scale_log_decoding_SLog3(self): """ @@ -486,7 +504,7 @@ def test_domain_range_scale_log_decoding_SLog3(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_SLog3(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_srgb.py b/colour/models/rgb/transfer_functions/tests/test_srgb.py index f2e900da4d..b43da9f9a5 100644 --- a/colour/models/rgb/transfer_functions/tests/test_srgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_srgb.py @@ -52,15 +52,18 @@ def test_n_dimensional_eotf_inverse_sRGB(self): L = np.tile(L, 6) V = np.tile(V, 6) - np.testing.assert_almost_equal(eotf_inverse_sRGB(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_sRGB(L), V, decimal=7) L = np.reshape(L, (2, 3)) V = np.reshape(V, (2, 3)) - np.testing.assert_almost_equal(eotf_inverse_sRGB(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_sRGB(L), V, decimal=7) L = np.reshape(L, (2, 3, 1)) V = np.reshape(V, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_inverse_sRGB(L), V, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_sRGB(L), V, decimal=7) def test_domain_range_scale_eotf_inverse_sRGB(self): """ @@ -74,7 +77,7 @@ def test_domain_range_scale_eotf_inverse_sRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_sRGB(L * factor), V * factor, decimal=7) @ignore_numpy_errors @@ -116,15 +119,15 @@ def test_n_dimensional_eotf_sRGB(self): V = np.tile(V, 6) L = np.tile(L, 6) - np.testing.assert_almost_equal(eotf_sRGB(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_sRGB(V), L, decimal=7) V = np.reshape(V, (2, 3)) L = np.reshape(L, (2, 3)) - np.testing.assert_almost_equal(eotf_sRGB(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_sRGB(V), L, decimal=7) V = np.reshape(V, (2, 3, 1)) L = np.reshape(L, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_sRGB(V), L, decimal=7) + np.testing.assert_array_almost_equal(eotf_sRGB(V), L, decimal=7) def test_domain_range_scale_eotf_sRGB(self): """ @@ -138,7 +141,7 @@ def test_domain_range_scale_eotf_sRGB(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_sRGB(V * factor), L * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_st_2084.py b/colour/models/rgb/transfer_functions/tests/test_st_2084.py index 246d577b22..6dfd180075 100644 --- a/colour/models/rgb/transfer_functions/tests/test_st_2084.py +++ b/colour/models/rgb/transfer_functions/tests/test_st_2084.py @@ -57,15 +57,18 @@ def test_n_dimensional_eotf_inverse_ST2084(self): C = np.tile(C, 6) N = np.tile(N, 6) - np.testing.assert_almost_equal(eotf_inverse_ST2084(C), N, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_ST2084(C), N, decimal=7) C = np.reshape(C, (2, 3)) N = np.reshape(N, (2, 3)) - np.testing.assert_almost_equal(eotf_inverse_ST2084(C), N, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_ST2084(C), N, decimal=7) C = np.reshape(C, (2, 3, 1)) N = np.reshape(N, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_inverse_ST2084(C), N, decimal=7) + np.testing.assert_array_almost_equal( + eotf_inverse_ST2084(C), N, decimal=7) def test_domain_range_scale_eotf_inverse_ST2084(self): """ @@ -79,7 +82,7 @@ def test_domain_range_scale_eotf_inverse_ST2084(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_inverse_ST2084(C * factor), N * factor, decimal=7) @ignore_numpy_errors @@ -124,15 +127,15 @@ def test_n_dimensional_eotf_ST2084(self): N = np.tile(N, 6) C = np.tile(C, 6) - np.testing.assert_almost_equal(eotf_ST2084(N), C, decimal=7) + np.testing.assert_array_almost_equal(eotf_ST2084(N), C, decimal=7) N = np.reshape(N, (2, 3)) C = np.reshape(C, (2, 3)) - np.testing.assert_almost_equal(eotf_ST2084(N), C, decimal=7) + np.testing.assert_array_almost_equal(eotf_ST2084(N), C, decimal=7) N = np.reshape(N, (2, 3, 1)) C = np.reshape(C, (2, 3, 1)) - np.testing.assert_almost_equal(eotf_ST2084(N), C, decimal=7) + np.testing.assert_array_almost_equal(eotf_ST2084(N), C, decimal=7) def test_domain_range_scale_eotf_ST2084(self): """ @@ -146,7 +149,7 @@ def test_domain_range_scale_eotf_ST2084(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( eotf_ST2084(N * factor), C * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/tests/test_viper_log.py b/colour/models/rgb/transfer_functions/tests/test_viper_log.py index 082d25c345..f0c80261f3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_viper_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_viper_log.py @@ -53,15 +53,18 @@ def test_n_dimensional_log_encoding_ViperLog(self): x = np.tile(x, 6) y = np.tile(y, 6) - np.testing.assert_almost_equal(log_encoding_ViperLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ViperLog(x), y, decimal=7) x = np.reshape(x, (2, 3)) y = np.reshape(y, (2, 3)) - np.testing.assert_almost_equal(log_encoding_ViperLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ViperLog(x), y, decimal=7) x = np.reshape(x, (2, 3, 1)) y = np.reshape(y, (2, 3, 1)) - np.testing.assert_almost_equal(log_encoding_ViperLog(x), y, decimal=7) + np.testing.assert_array_almost_equal( + log_encoding_ViperLog(x), y, decimal=7) def test_domain_range_scale_log_encoding_ViperLog(self): """ @@ -75,7 +78,7 @@ def test_domain_range_scale_log_encoding_ViperLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_encoding_ViperLog(x * factor), y * factor, decimal=7) @ignore_numpy_errors @@ -119,15 +122,18 @@ def test_n_dimensional_log_decoding_ViperLog(self): y = np.tile(y, 6) x = np.tile(x, 6) - np.testing.assert_almost_equal(log_decoding_ViperLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ViperLog(y), x, decimal=7) y = np.reshape(y, (2, 3)) x = np.reshape(x, (2, 3)) - np.testing.assert_almost_equal(log_decoding_ViperLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ViperLog(y), x, decimal=7) y = np.reshape(y, (2, 3, 1)) x = np.reshape(x, (2, 3, 1)) - np.testing.assert_almost_equal(log_decoding_ViperLog(y), x, decimal=7) + np.testing.assert_array_almost_equal( + log_decoding_ViperLog(y), x, decimal=7) def test_domain_range_scale_log_decoding_ViperLog(self): """ @@ -141,7 +147,7 @@ def test_domain_range_scale_log_decoding_ViperLog(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( log_decoding_ViperLog(y * factor), x * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/rgb/transfer_functions/viper_log.py b/colour/models/rgb/transfer_functions/viper_log.py index d57209790a..bbf3aec1ce 100644 --- a/colour/models/rgb/transfer_functions/viper_log.py +++ b/colour/models/rgb/transfer_functions/viper_log.py @@ -20,7 +20,7 @@ import colour.ndarray as np -from colour.utilities import from_range_1, to_domain_1 +from colour.utilities import from_range_1, to_domain_1, as_float __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -75,8 +75,15 @@ def log_encoding_ViperLog(x): x = to_domain_1(x) y = (1023 + 500 * np.log10(x)) / 1023 + y = from_range_1(y) - return from_range_1(y) + try: + if y.size == 1: + return as_float(y) + except Exception: + pass + + return y def log_decoding_ViperLog(y): @@ -122,5 +129,12 @@ def log_decoding_ViperLog(y): y = to_domain_1(y) x = 10 ** ((1023 * y - 1023) / 500) + x = from_range_1(x) + + try: + if x.size == 1: + return as_float(x) + except Exception: + pass - return from_range_1(x) + return x diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index bd6eb1665b..3964a2fa42 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -537,6 +537,10 @@ def RGB_to_YcCbcCrc(RGB, R = eotf_inverse_BT2020(R, is_12_bits_system=is_12_bits_system) B = eotf_inverse_BT2020(B, is_12_bits_system=is_12_bits_system) + if np.__name__ == 'cupy' and isinstance(B, float): + B = np.array(B) + Yc = np.array(Yc) + Cbc = np.where((B - Yc) <= 0, (B - Yc) / 1.9404, (B - Yc) / 1.5816) Crc = np.where((R - Yc) <= 0, (R - Yc) / 1.7184, (R - Yc) / 0.9936) Yc *= Y_max - Y_min diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index 983db05b0c..6862f1aa53 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -47,9 +47,10 @@ def setUp(self): Y_b = 20.0 surround = VIEWING_CONDITIONS_CIECAM02['Average'] specification = XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b, surround) - self._JMh = np.array( - [specification.J, specification.M, specification.h]) + [specification.J, + specification.M.item(), + specification.h.item()]) def test_JMh_CIECAM02_to_UCS_Luo2006(self): """ @@ -57,37 +58,37 @@ def test_JMh_CIECAM02_to_UCS_Luo2006(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), np.array([54.90433134, -0.08450395, -0.06854831]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), JMh_CIECAM02_to_CAM02LCD(self._JMh), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-SCD']), np.array([54.90433134, -0.08436178, -0.06843298]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-SCD']), JMh_CIECAM02_to_CAM02SCD(self._JMh), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-UCS']), np.array([54.90433134, -0.08442362, -0.06848314]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(self._JMh, COEFFICIENTS_UCS_LUO2006['CAM02-UCS']), JMh_CIECAM02_to_CAM02UCS(self._JMh), @@ -105,7 +106,7 @@ def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self): JMh = np.tile(JMh, (6, 1)) Jpapbp = np.tile(Jpapbp, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), Jpapbp, @@ -113,7 +114,7 @@ def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self): JMh = np.reshape(JMh, (2, 3, 3)) Jpapbp = np.reshape(Jpapbp, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), Jpapbp, @@ -133,7 +134,7 @@ def test_domain_range_scale_JMh_CIECAM02_to_UCS_Luo2006(self): (100, np.array([1, 1, 1 / 3.6]), 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JMh_CIECAM02_to_UCS_Luo2006( JMh * factor_a, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), Jpapbp * factor_b, @@ -166,14 +167,14 @@ def test_UCS_Luo2006_to_JMh_CIECAM02(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), np.array([41.73109113, 0.10873867, 219.04843202]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), @@ -181,14 +182,14 @@ def test_UCS_Luo2006_to_JMh_CIECAM02(self): np.array([54.90433134, -0.08442362, -0.06848314])), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-SCD']), np.array([41.73109113, 0.10892212, 219.04843202]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-SCD']), @@ -196,14 +197,14 @@ def test_UCS_Luo2006_to_JMh_CIECAM02(self): np.array([54.90433134, -0.08442362, -0.06848314])), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-UCS']), np.array([41.73109113, 0.10884218, 219.04843202]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( np.array([54.90433134, -0.08442362, -0.06848314]), COEFFICIENTS_UCS_LUO2006['CAM02-UCS']), @@ -223,7 +224,7 @@ def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self): Jpapbp = np.tile(Jpapbp, (6, 1)) JMh = np.tile(JMh, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), JMh, @@ -231,7 +232,7 @@ def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self): Jpapbp = np.reshape(Jpapbp, (2, 3, 3)) JMh = np.reshape(JMh, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), JMh, @@ -251,7 +252,7 @@ def test_domain_range_scale_UCS_Luo2006_to_JMh_CIECAM02(self): (100, 1, np.array([1, 1, 1 / 3.6]))) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_Luo2006_to_JMh_CIECAM02( Jpapbp * factor_a, COEFFICIENTS_UCS_LUO2006['CAM02-LCD']), diff --git a/colour/models/tests/test_cie_lab.py b/colour/models/tests/test_cie_lab.py index b3e1aaba81..ee8325382a 100644 --- a/colour/models/tests/test_cie_lab.py +++ b/colour/models/tests/test_cie_lab.py @@ -35,36 +35,36 @@ def test_XYZ_to_Lab(self): Tests :func:`colour.models.cie_lab.XYZ_to_Lab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([41.52787529, 52.63858304, 26.92317922]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([55.11636304, -41.08791787, 30.91825778]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([29.80565520, 20.01830466, -48.34913874]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.44757, 0.40745])), np.array([41.52787529, 38.48089305, -5.73295122]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.34570, 0.35850])), np.array([41.52787529, 51.19354174, 19.91843098]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.34570, 0.35850, 1.00000])), @@ -83,17 +83,17 @@ def test_n_dimensional_XYZ_to_Lab(self): XYZ = np.tile(XYZ, (6, 1)) Lab = np.tile(Lab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(XYZ, illuminant), Lab, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(XYZ, illuminant), Lab, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) Lab = np.reshape(Lab, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(XYZ, illuminant), Lab, decimal=7) def test_domain_range_scale_XYZ_to_Lab(self): @@ -109,7 +109,7 @@ def test_domain_range_scale_XYZ_to_Lab(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Lab(XYZ * factor_a, illuminant), Lab * factor_b, decimal=7) @@ -139,36 +139,36 @@ def test_Lab_to_XYZ(self): Tests :func:`colour.models.cie_lab.Lab_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(np.array([41.52787529, 52.63858304, 26.92317922])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(np.array([55.11636304, -41.08791787, 30.91825778])), np.array([0.14222010, 0.23042768, 0.10495772]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(np.array([29.80565520, 20.01830466, -48.34913874])), np.array([0.07818780, 0.06157201, 0.28099326]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ( np.array([41.52787529, 38.48089305, -5.73295122]), np.array([0.44757, 0.40745])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ( np.array([41.52787529, 51.19354174, 19.91843098]), np.array([0.34570, 0.35850])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ( np.array([41.52787529, 51.19354174, 19.91843098]), np.array([0.34570, 0.35850, 1.00000])), @@ -187,17 +187,17 @@ def test_n_dimensional_Lab_to_XYZ(self): Lab = np.tile(Lab, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(Lab, illuminant), XYZ, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(Lab, illuminant), XYZ, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(Lab, illuminant), XYZ, decimal=7) def test_domain_range_scale_Lab_to_XYZ(self): @@ -213,7 +213,7 @@ def test_domain_range_scale_Lab_to_XYZ(self): d_r = (('reference', 1, 1), (1, 0.01, 1), (100, 1, 100)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_XYZ(Lab * factor_a, illuminant), XYZ * factor_b, decimal=7) @@ -243,17 +243,17 @@ def test_Lab_to_LCHab(self): Tests :func:`colour.models.cie_lab.Lab_to_LCHab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_LCHab(np.array([41.52787529, 52.63858304, 26.92317922])), np.array([41.52787529, 59.12425901, 27.08848784]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_LCHab(np.array([55.11636304, -41.08791787, 30.91825778])), np.array([55.11636304, 51.42135412, 143.03889556]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_LCHab(np.array([29.80565520, 20.01830466, -48.34913874])), np.array([29.80565520, 52.32945383, 292.49133666]), decimal=7) @@ -269,11 +269,13 @@ def test_n_dimensional_Lab_to_LCHab(self): Lab = np.tile(Lab, (6, 1)) LCHab = np.tile(LCHab, (6, 1)) - np.testing.assert_almost_equal(Lab_to_LCHab(Lab), LCHab, decimal=7) + np.testing.assert_array_almost_equal( + Lab_to_LCHab(Lab), LCHab, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) LCHab = np.reshape(LCHab, (2, 3, 3)) - np.testing.assert_almost_equal(Lab_to_LCHab(Lab), LCHab, decimal=7) + np.testing.assert_array_almost_equal( + Lab_to_LCHab(Lab), LCHab, decimal=7) def test_domain_range_scale_Lab_to_LCHab(self): """ @@ -288,7 +290,7 @@ def test_domain_range_scale_Lab_to_LCHab(self): (100, 1, np.array([1, 1, 1 / 3.6]))) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_LCHab(Lab * factor_a), LCHab * factor_b, decimal=7) @ignore_numpy_errors @@ -316,17 +318,17 @@ def test_LCHab_to_Lab(self): Tests :func:`colour.models.cie_lab.LCHab_to_Lab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_Lab(np.array([41.52787529, 59.12425901, 27.08848784])), np.array([41.52787529, 52.63858304, 26.92317922]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_Lab(np.array([55.11636304, 51.42135412, 143.03889556])), np.array([55.11636304, -41.08791787, 30.91825778]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_Lab(np.array([29.80565520, 52.32945383, 292.49133666])), np.array([29.80565520, 20.01830466, -48.34913874]), decimal=7) @@ -342,11 +344,13 @@ def test_n_dimensional_LCHab_to_Lab(self): LCHab = np.tile(LCHab, (6, 1)) Lab = np.tile(Lab, (6, 1)) - np.testing.assert_almost_equal(LCHab_to_Lab(LCHab), Lab, decimal=7) + np.testing.assert_array_almost_equal( + LCHab_to_Lab(LCHab), Lab, decimal=7) LCHab = np.reshape(LCHab, (2, 3, 3)) Lab = np.reshape(Lab, (2, 3, 3)) - np.testing.assert_almost_equal(LCHab_to_Lab(LCHab), Lab, decimal=7) + np.testing.assert_array_almost_equal( + LCHab_to_Lab(LCHab), Lab, decimal=7) def test_domain_range_scale_LCHab_to_Lab(self): """ @@ -361,7 +365,7 @@ def test_domain_range_scale_LCHab_to_Lab(self): (100, np.array([1, 1, 1 / 3.6]), 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_Lab(LCHab * factor_a), Lab * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_cie_luv.py b/colour/models/tests/test_cie_luv.py index b190f3e854..9f6e8f7180 100644 --- a/colour/models/tests/test_cie_luv.py +++ b/colour/models/tests/test_cie_luv.py @@ -39,36 +39,36 @@ def test_XYZ_to_Luv(self): Tests :func:`colour.models.cie_luv.XYZ_to_Luv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([41.52787529, 96.83626054, 17.75210149]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([55.11636304, -37.59308176, 44.13768458]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([29.80565520, -10.96316802, -65.06751860]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.44757, 0.40745])), np.array([41.52787529, 65.45180940, -12.46626977]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.34570, 0.35850])), np.array([41.52787529, 90.70925962, 7.08455273]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.34570, 0.35850, 1.00000])), @@ -87,17 +87,17 @@ def test_n_dimensional_XYZ_to_Luv(self): XYZ = np.tile(XYZ, (6, 1)) Luv = np.tile(Luv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(XYZ, illuminant), Luv, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(XYZ, illuminant), Luv, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) Luv = np.reshape(Luv, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(XYZ, illuminant), Luv, decimal=7) def test_domain_range_scale_XYZ_to_Luv(self): @@ -113,7 +113,7 @@ def test_domain_range_scale_XYZ_to_Luv(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Luv(XYZ * factor_a, illuminant), Luv * factor_b, decimal=7) @@ -143,36 +143,36 @@ def test_Luv_to_XYZ(self): Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(np.array([41.52787529, 96.83626054, 17.75210149])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(np.array([55.11636304, -37.59308176, 44.13768458])), np.array([0.14222010, 0.23042768, 0.10495772]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(np.array([29.80565520, -10.96316802, -65.06751860])), np.array([0.07818780, 0.06157201, 0.28099326]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ( np.array([41.52787529, 65.45180940, -12.46626977]), np.array([0.44757, 0.40745])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ( np.array([41.52787529, 90.70925962, 7.08455273]), np.array([0.34570, 0.35850])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ( np.array([41.52787529, 90.70925962, 7.08455273]), np.array([0.34570, 0.35850, 1.00000])), @@ -191,17 +191,17 @@ def test_n_dimensional_Luv_to_XYZ(self): Luv = np.tile(Luv, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(Luv, illuminant), XYZ, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(Luv, illuminant), XYZ, decimal=7) Luv = np.reshape(Luv, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(Luv, illuminant), XYZ, decimal=7) def test_domain_range_scale_Luv_to_XYZ(self): @@ -217,7 +217,7 @@ def test_domain_range_scale_Luv_to_XYZ(self): d_r = (('reference', 1, 1), (1, 0.01, 1), (100, 1, 100)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_XYZ(Luv * factor_a, illuminant), XYZ * factor_b, decimal=7) @@ -247,36 +247,36 @@ def test_Luv_to_uv(self): Tests :func:`colour.models.cie_luv.Luv_to_uv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(np.array([41.52787529, 96.83626054, 17.75210149])), np.array([0.37720213, 0.50120264]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(np.array([55.11636304, -37.59308176, 44.13768458])), np.array([0.14536327, 0.52992069]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(np.array([29.80565520, -10.96316802, -65.06751860])), np.array([0.16953603, 0.30039234]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv( np.array([41.52787529, 65.45180940, -12.46626977]), np.array([0.44757, 0.40745])), np.array([0.37720213, 0.50120264]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv( np.array([41.52787529, 90.70925962, 7.08455273]), np.array([0.34570, 0.35850])), np.array([0.37720213, 0.50120264]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv( np.array([41.52787529, 90.70925962, 7.08455273]), np.array([0.34570, 0.35850, 1.00000])), @@ -295,17 +295,17 @@ def test_n_dimensional_Luv_to_uv(self): Luv = np.tile(Luv, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(Luv, illuminant), uv, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(Luv, illuminant), uv, decimal=7) Luv = np.reshape(Luv, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(Luv, illuminant), uv, decimal=7) def test_domain_range_scale_Luv_to_uv(self): @@ -321,7 +321,7 @@ def test_domain_range_scale_Luv_to_uv(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_uv(Luv * factor, illuminant), uv, decimal=7) @ignore_numpy_errors @@ -349,43 +349,43 @@ def test_uv_to_Luv(self): Tests :func:`colour.models.cie_luv.uv_to_Luv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(np.array([0.37720213, 0.50120264])), np.array([100.00000000, 233.18376036, 42.74743858]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(np.array([0.14536327, 0.52992069])), np.array([100.00000000, -68.20675764, 80.08090358]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(np.array([0.16953603, 0.30039234])), np.array([100.00000000, -36.78216964, -218.3059514]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv( np.array([0.37720213, 0.50120264]), np.array([0.44757, 0.40745])), np.array([100.00000000, 157.60933976, -30.01903705]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv( np.array([0.37720213, 0.50120264]), np.array([0.34570, 0.35850])), np.array([100.00000000, 218.42981284, 17.05975609]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv( np.array([0.37720213, 0.50120264]), np.array([0.34570, 0.35850, 1.00000])), np.array([100.00000000, 218.42981284, 17.05975609]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(np.array([0.37720213, 0.50120264]), Y=0.18), np.array([49.49610761, 115.41688496, -243.29048251]), decimal=7) @@ -402,17 +402,17 @@ def test_n_dimensional_uv_to_Luv(self): uv = np.tile(uv, (6, 1)) Luv = np.tile(Luv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(uv, illuminant), Luv, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(uv, illuminant), Luv, decimal=7) uv = np.reshape(uv, (2, 3, 2)) illuminant = np.reshape(illuminant, (2, 3, 2)) Luv = np.reshape(Luv, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(uv, illuminant), Luv, decimal=7) def test_domain_range_scale_uv_to_Luv(self): @@ -429,7 +429,7 @@ def test_domain_range_scale_uv_to_Luv(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_Luv(uv, illuminant, Y * factor_a), Luv * factor_b, decimal=7) @@ -459,17 +459,17 @@ def test_Luv_uv_to_xy(self): Tests :func:`colour.models.cie_luv.Luv_uv_to_xy` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_uv_to_xy(np.array([0.37720213, 0.50120264])), np.array([0.54369558, 0.32107944]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_uv_to_xy(np.array([0.14536327, 0.52992069])), np.array([0.29777734, 0.48246445]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_uv_to_xy(np.array([0.16953603, 0.30039234])), np.array([0.18582824, 0.14633764]), decimal=7) @@ -485,11 +485,11 @@ def test_n_dimensional_Luv_uv_to_xy(self): uv = np.tile(uv, (6, 1)) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal(Luv_uv_to_xy(uv), xy, decimal=7) + np.testing.assert_array_almost_equal(Luv_uv_to_xy(uv), xy, decimal=7) uv = np.reshape(uv, (2, 3, 2)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal(Luv_uv_to_xy(uv), xy, decimal=7) + np.testing.assert_array_almost_equal(Luv_uv_to_xy(uv), xy, decimal=7) @ignore_numpy_errors def test_nan_Luv_uv_to_xy(self): @@ -516,17 +516,17 @@ def test_xy_to_Luv_uv(self): Tests :func:`colour.models.cie_luv.xy_to_Luv_uv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_Luv_uv(np.array([0.54369558, 0.32107944])), np.array([0.37720213, 0.50120264]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_Luv_uv(np.array([0.29777734, 0.48246445])), np.array([0.14536327, 0.52992069]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_Luv_uv(np.array([0.18582824, 0.14633764])), np.array([0.16953603, 0.30039234]), decimal=7) @@ -542,11 +542,11 @@ def test_n_dimensional_xy_to_Luv_uv(self): xy = np.tile(xy, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal(xy_to_Luv_uv(xy), uv, decimal=7) + np.testing.assert_array_almost_equal(xy_to_Luv_uv(xy), uv, decimal=7) xy = np.reshape(xy, (2, 3, 2)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal(xy_to_Luv_uv(xy), uv, decimal=7) + np.testing.assert_array_almost_equal(xy_to_Luv_uv(xy), uv, decimal=7) @ignore_numpy_errors def test_nan_xy_to_Luv_uv(self): @@ -573,17 +573,17 @@ def test_Luv_to_LCHuv(self): Tests :func:`colour.models.cie_luv.Luv_to_LCHuv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_LCHuv(np.array([41.52787529, 96.83626054, 17.75210149])), np.array([41.52787529, 98.44997950, 10.38816348]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_LCHuv(np.array([55.11636304, -37.59308176, 44.13768458])), np.array([55.11636304, 57.97736624, 130.42180076]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_LCHuv(np.array([29.80565520, -10.96316802, -65.06751860])), np.array([29.80565520, 65.98464238, 260.43611196]), decimal=7) @@ -599,11 +599,13 @@ def test_n_dimensional_Luv_to_LCHuv(self): Luv = np.tile(Luv, (6, 1)) LCHuv = np.tile(LCHuv, (6, 1)) - np.testing.assert_almost_equal(Luv_to_LCHuv(Luv), LCHuv, decimal=7) + np.testing.assert_array_almost_equal( + Luv_to_LCHuv(Luv), LCHuv, decimal=7) Luv = np.reshape(Luv, (2, 3, 3)) LCHuv = np.reshape(LCHuv, (2, 3, 3)) - np.testing.assert_almost_equal(Luv_to_LCHuv(Luv), LCHuv, decimal=7) + np.testing.assert_array_almost_equal( + Luv_to_LCHuv(Luv), LCHuv, decimal=7) def test_domain_range_scale_Luv_to_LCHuv(self): """ @@ -618,7 +620,7 @@ def test_domain_range_scale_Luv_to_LCHuv(self): (100, 1, np.array([1, 1, 1 / 3.6]))) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Luv_to_LCHuv(Luv * factor_a), LCHuv * factor_b, decimal=7) @ignore_numpy_errors @@ -646,17 +648,17 @@ def test_LCHuv_to_Luv(self): Tests :func:`colour.models.cie_luv.LCHuv_to_Luv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHuv_to_Luv(np.array([41.52787529, 98.44997950, 10.38816348])), np.array([41.52787529, 96.83626054, 17.75210149]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHuv_to_Luv(np.array([55.11636304, 57.97736624, 130.42180076])), np.array([55.11636304, -37.59308176, 44.13768458]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHuv_to_Luv(np.array([29.80565520, 65.98464238, 260.43611196])), np.array([29.80565520, -10.96316802, -65.06751860]), decimal=7) @@ -672,11 +674,13 @@ def test_n_dimensional_LCHuv_to_Luv(self): Luv = np.tile(Luv, (6, 1)) LCHuv = np.tile(LCHuv, (6, 1)) - np.testing.assert_almost_equal(LCHuv_to_Luv(LCHuv), Luv, decimal=7) + np.testing.assert_array_almost_equal( + LCHuv_to_Luv(LCHuv), Luv, decimal=7) Luv = np.reshape(Luv, (2, 3, 3)) LCHuv = np.reshape(LCHuv, (2, 3, 3)) - np.testing.assert_almost_equal(LCHuv_to_Luv(LCHuv), Luv, decimal=7) + np.testing.assert_array_almost_equal( + LCHuv_to_Luv(LCHuv), Luv, decimal=7) def test_domain_range_scale_LCHuv_to_Lab(self): """ @@ -691,7 +695,7 @@ def test_domain_range_scale_LCHuv_to_Lab(self): (100, np.array([1, 1, 1 / 3.6]), 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHuv_to_Luv(LCHuv * factor_a), Luv * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_cie_ucs.py b/colour/models/tests/test_cie_ucs.py index 81198ccd39..e407ed1f58 100644 --- a/colour/models/tests/test_cie_ucs.py +++ b/colour/models/tests/test_cie_ucs.py @@ -37,17 +37,17 @@ def test_XYZ_to_UCS(self): Tests :func:`colour.models.cie_ucs.XYZ_to_UCS` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UCS(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.13769339, 0.12197225, 0.10537310]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UCS(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.09481340, 0.23042768, 0.32701033]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UCS(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([0.05212520, 0.06157201, 0.19376075]), decimal=7) @@ -63,11 +63,11 @@ def test_n_dimensional_XYZ_to_UCS(self): UCS = np.tile(UCS, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal(XYZ_to_UCS(XYZ), UCS, decimal=7) + np.testing.assert_array_almost_equal(XYZ_to_UCS(XYZ), UCS, decimal=7) UCS = np.reshape(UCS, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal(XYZ_to_UCS(XYZ), UCS, decimal=7) + np.testing.assert_array_almost_equal(XYZ_to_UCS(XYZ), UCS, decimal=7) def test_domain_range_scale_XYZ_to_UCS(self): """ @@ -81,7 +81,7 @@ def test_domain_range_scale_XYZ_to_UCS(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UCS(XYZ * factor), UCS * factor, decimal=7) @ignore_numpy_errors @@ -108,17 +108,17 @@ def test_UCS_to_XYZ(self): Tests :func:`colour.models.cie_ucs.UCS_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_XYZ(np.array([0.13769339, 0.12197225, 0.10537310])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_XYZ(np.array([0.09481340, 0.23042768, 0.32701033])), np.array([0.14222010, 0.23042768, 0.10495772]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_XYZ(np.array([0.05212520, 0.06157201, 0.19376075])), np.array([0.07818780, 0.06157201, 0.28099326]), decimal=7) @@ -134,11 +134,11 @@ def test_n_dimensional_UCS_to_XYZ(self): UCS = np.tile(UCS, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal(UCS_to_XYZ(UCS), XYZ, decimal=7) + np.testing.assert_array_almost_equal(UCS_to_XYZ(UCS), XYZ, decimal=7) UCS = np.reshape(UCS, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal(UCS_to_XYZ(UCS), XYZ, decimal=7) + np.testing.assert_array_almost_equal(UCS_to_XYZ(UCS), XYZ, decimal=7) def test_domain_range_scale_UCS_to_XYZ(self): """ @@ -152,7 +152,7 @@ def test_domain_range_scale_UCS_to_XYZ(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_XYZ(UCS * factor), XYZ * factor, decimal=7) @ignore_numpy_errors @@ -179,17 +179,17 @@ def test_UCS_to_uv(self): Tests :func:`colour.models.cie_ucs.UCS_to_uv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_uv(np.array([0.13769339, 0.12197225, 0.10537310])), np.array([0.37720213, 0.33413508]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_uv(np.array([0.09481340, 0.23042768, 0.32701033])), np.array([0.14536327, 0.35328046]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_uv(np.array([0.05212520, 0.06157201, 0.19376075])), np.array([0.16953602, 0.20026156]), decimal=7) @@ -205,11 +205,11 @@ def test_n_dimensional_UCS_to_uv(self): UCS = np.tile(UCS, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal(UCS_to_uv(UCS), uv, decimal=7) + np.testing.assert_array_almost_equal(UCS_to_uv(UCS), uv, decimal=7) UCS = np.reshape(UCS, (2, 3, 3)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal(UCS_to_uv(UCS), uv, decimal=7) + np.testing.assert_array_almost_equal(UCS_to_uv(UCS), uv, decimal=7) def test_domain_range_scale_UCS_to_uv(self): """ @@ -223,7 +223,7 @@ def test_domain_range_scale_UCS_to_uv(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_to_uv(UCS * factor), uv, decimal=7) @ignore_numpy_errors @@ -250,22 +250,22 @@ def test_uv_to_UCS(self): Tests :func:`colour.models.cie_ucs.uv_to_UCS` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_UCS(np.array([0.37720213, 0.33413508])), np.array([1.12889114, 1.00000000, 0.86391046]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_UCS(np.array([0.14536327, 0.35328046])), np.array([0.41146705, 1.00000000, 1.41914520]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_UCS(np.array([0.16953602, 0.20026156])), np.array([0.84657295, 1.00000000, 3.14689659]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_UCS(np.array([0.37720213, 0.33413508]), V=0.18), np.array([0.20320040, 0.18000000, 0.15550388]), decimal=7) @@ -281,11 +281,11 @@ def test_n_dimensional_uv_to_UCS(self): uv = np.tile(uv, (6, 1)) UCS = np.tile(UCS, (6, 1)) - np.testing.assert_almost_equal(uv_to_UCS(uv), UCS, decimal=7) + np.testing.assert_array_almost_equal(uv_to_UCS(uv), UCS, decimal=7) uv = np.reshape(uv, (2, 3, 2)) UCS = np.reshape(UCS, (2, 3, 3)) - np.testing.assert_almost_equal(uv_to_UCS(uv), UCS, decimal=7) + np.testing.assert_array_almost_equal(uv_to_UCS(uv), UCS, decimal=7) def test_domain_range_scale_uv_to_UCS(self): """ @@ -299,7 +299,7 @@ def test_domain_range_scale_uv_to_UCS(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_UCS(uv), UCS * factor, decimal=7) @ignore_numpy_errors @@ -326,17 +326,17 @@ def test_UCS_uv_to_xy(self): Tests :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_uv_to_xy(np.array([0.37720213, 0.33413508])), np.array([0.54369555, 0.32107941]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_uv_to_xy(np.array([0.14536327, 0.35328046])), np.array([0.29777734, 0.48246445]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UCS_uv_to_xy(np.array([0.16953602, 0.20026156])), np.array([0.18582823, 0.14633764]), decimal=7) @@ -352,11 +352,11 @@ def test_n_dimensional_UCS_uv_to_xy(self): uv = np.tile(uv, (6, 1)) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal(UCS_uv_to_xy(uv), xy, decimal=7) + np.testing.assert_array_almost_equal(UCS_uv_to_xy(uv), xy, decimal=7) uv = np.reshape(uv, (2, 3, 2)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal(UCS_uv_to_xy(uv), xy, decimal=7) + np.testing.assert_array_almost_equal(UCS_uv_to_xy(uv), xy, decimal=7) @ignore_numpy_errors def test_nan_UCS_uv_to_xy(self): @@ -383,17 +383,17 @@ def test_xy_to_UCS_uv(self): Tests :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_UCS_uv(np.array([0.54369555, 0.32107941])), np.array([0.37720213, 0.33413508]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_UCS_uv(np.array([0.29777734, 0.48246445])), np.array([0.14536327, 0.35328046]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_UCS_uv(np.array([0.18582823, 0.14633764])), np.array([0.16953602, 0.20026156]), decimal=7) @@ -409,11 +409,11 @@ def test_n_dimensional_xy_to_UCS_uv(self): xy = np.tile(xy, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal(xy_to_UCS_uv(xy), uv, decimal=7) + np.testing.assert_array_almost_equal(xy_to_UCS_uv(xy), uv, decimal=7) xy = np.reshape(xy, (2, 3, 2)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal(xy_to_UCS_uv(xy), uv, decimal=7) + np.testing.assert_array_almost_equal(xy_to_UCS_uv(xy), uv, decimal=7) @ignore_numpy_errors def test_nan_xy_to_UCS_uv(self): diff --git a/colour/models/tests/test_cie_uvw.py b/colour/models/tests/test_cie_uvw.py index e1869dc45c..8ff28585b2 100644 --- a/colour/models/tests/test_cie_uvw.py +++ b/colour/models/tests/test_cie_uvw.py @@ -33,36 +33,36 @@ def test_XYZ_to_UVW(self): Tests :func:`colour.models.cie_uvw.XYZ_to_UVW` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(np.array([0.20654008, 0.12197225, 0.05136952]) * 100), np.array([94.55035725, 11.55536523, 40.54757405]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(np.array([0.14222010, 0.23042768, 0.10495772]) * 100), np.array([-36.92762376, 28.90425105, 54.14071478]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(np.array([0.07818780, 0.06157201, 0.28099326]) * 100), np.array([-10.60111550, -41.94580000, 28.82134002]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, np.array([0.44757, 0.40745])), np.array([63.90676310, -8.11466183, 40.54757405]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, np.array([0.34570, 0.35850])), np.array([88.56798946, 4.61154385, 40.54757405]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, np.array([0.34570, 0.35850, 1.00000])), @@ -81,17 +81,17 @@ def test_n_dimensional_XYZ_to_UVW(self): XYZ = np.tile(XYZ, (6, 1)) UVW = np.tile(UVW, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(XYZ, illuminant), UVW, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(XYZ, illuminant), UVW, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) UVW = np.reshape(UVW, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(XYZ, illuminant), UVW, decimal=7) def test_domain_range_scale_XYZ_to_UVW(self): @@ -107,7 +107,7 @@ def test_domain_range_scale_XYZ_to_UVW(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_UVW(XYZ * factor, illuminant), UVW * factor, decimal=7) @@ -137,36 +137,36 @@ def test_UVW_to_XYZ(self): Tests :func:`colour.models.cie_uvw.UVW_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(np.array([94.55035725, 11.55536523, 40.54757405])), np.array([0.20654008, 0.12197225, 0.05136952]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(np.array([-36.92762376, 28.90425105, 54.14071478])), np.array([0.14222010, 0.23042768, 0.10495772]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(np.array([-10.60111550, -41.94580000, 28.82134002])), np.array([0.07818780, 0.06157201, 0.28099326]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ( np.array([63.90676310, -8.11466183, 40.54757405]), np.array([0.44757, 0.40745])), np.array([0.20654008, 0.12197225, 0.05136952]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ( np.array([88.56798946, 4.61154385, 40.54757405]), np.array([0.34570, 0.35850])), np.array([0.20654008, 0.12197225, 0.05136952]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ( np.array([88.56798946, 4.61154385, 40.54757405]), np.array([0.34570, 0.35850, 1.00000])), @@ -185,17 +185,17 @@ def test_n_dimensional_UVW_to_XYZ(self): XYZ = np.tile(XYZ, (6, 1)) UVW = np.tile(UVW, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(UVW, illuminant), XYZ, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(UVW, illuminant), XYZ, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) UVW = np.reshape(UVW, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(UVW, illuminant), XYZ, decimal=7) def test_domain_range_scale_UVW_to_XYZ(self): @@ -211,7 +211,7 @@ def test_domain_range_scale_UVW_to_XYZ(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( UVW_to_XYZ(UVW * factor, illuminant), XYZ * factor, decimal=7) diff --git a/colour/models/tests/test_cie_xyy.py b/colour/models/tests/test_cie_xyy.py index 4153685d79..3a1216124c 100644 --- a/colour/models/tests/test_cie_xyy.py +++ b/colour/models/tests/test_cie_xyy.py @@ -37,27 +37,27 @@ def test_XYZ_to_xyY(self): Tests :func:`colour.models.cie_xyy.XYZ_to_xyY` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.54369557, 0.32107944, 0.12197225]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.29777735, 0.48246446, 0.23042768]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([0.18582823, 0.14633764, 0.06157201]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(np.array([0.00000000, 0.00000000, 1.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY( np.array([ [0.20654008, 0.12197225, 0.05136952], @@ -83,17 +83,17 @@ def test_n_dimensional_XYZ_to_xyY(self): XYZ = np.tile(XYZ, (6, 1)) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(XYZ, illuminant), xyY, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(XYZ, illuminant), xyY, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(illuminant, (2, 3, 2)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(XYZ, illuminant), xyY, decimal=7) def test_domain_range_scale_XYZ_to_xyY(self): @@ -114,7 +114,7 @@ def test_domain_range_scale_XYZ_to_xyY(self): )) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xyY(XYZ * factor_a), xyY * factor_b, decimal=7) @ignore_numpy_errors @@ -142,27 +142,27 @@ def test_xyY_to_XYZ(self): Tests :func:`colour.models.cie_xyy.xyY_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ(np.array([0.54369557, 0.32107944, 0.12197225])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ(np.array([0.29777735, 0.48246446, 0.23042768])), np.array([0.14222010, 0.23042768, 0.10495772]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ(np.array([0.18582823, 0.14633764, 0.06157201])), np.array([0.07818780, 0.06157201, 0.28099326]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ(np.array([0.34567, 0.3585, 0.00000000])), np.array([0.00000000, 0.00000000, 0.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ( np.array([ [0.54369557, 0.32107944, 0.12197225], @@ -187,11 +187,11 @@ def test_n_dimensional_xyY_to_XYZ(self): xyY = np.tile(xyY, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal(xyY_to_XYZ(xyY), XYZ, decimal=7) + np.testing.assert_array_almost_equal(xyY_to_XYZ(xyY), XYZ, decimal=7) xyY = np.reshape(xyY, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal(xyY_to_XYZ(xyY), XYZ, decimal=7) + np.testing.assert_array_almost_equal(xyY_to_XYZ(xyY), XYZ, decimal=7) def test_domain_range_scale_xyY_to_XYZ(self): """ @@ -211,7 +211,7 @@ def test_domain_range_scale_xyY_to_XYZ(self): )) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_XYZ(xyY * factor_a), XYZ * factor_b, decimal=7) @ignore_numpy_errors @@ -238,22 +238,22 @@ def test_xyY_to_xy(self): Tests :func:`colour.models.cie_xyy.xyY_to_xy` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_xy(np.array([0.54369557, 0.32107944, 0.12197225])), np.array([0.54369557, 0.32107944]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_xy(np.array([0.29777735, 0.48246446, 0.23042768])), np.array([0.29777735, 0.48246446]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_xy(np.array([0.18582823, 0.14633764, 0.06157201])), np.array([0.18582823, 0.14633764]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_xy(np.array([0.31270, 0.32900])), np.array([0.31270000, 0.32900000]), decimal=7) @@ -269,11 +269,11 @@ def test_n_dimensional_xyY_to_xy(self): xyY = np.tile(xyY, (6, 1)) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal(xyY_to_xy(xyY), xy, decimal=7) + np.testing.assert_array_almost_equal(xyY_to_xy(xyY), xy, decimal=7) xyY = np.reshape(xyY, (2, 3, 3)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal(xyY_to_xy(xyY), xy, decimal=7) + np.testing.assert_array_almost_equal(xyY_to_xy(xyY), xy, decimal=7) def test_domain_range_scale_xyY_to_xy(self): """ @@ -289,7 +289,7 @@ def test_domain_range_scale_xyY_to_xy(self): d_r = (('reference', 1, 1), (1, 1, 1), (100, np.array([1, 1, 100]), 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_xy(xyY * factor_a), xy * factor_b, decimal=7) @ignore_numpy_errors @@ -316,27 +316,27 @@ def test_xy_to_xyY(self): Tests :func:`colour.models.cie_xyy.xy_to_xyY` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(np.array([0.54369557, 0.32107944])), np.array([0.54369557, 0.32107944, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(np.array([0.29777735, 0.48246446])), np.array([0.29777735, 0.48246446, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(np.array([0.18582823, 0.14633764])), np.array([0.18582823, 0.14633764, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(np.array([0.31270000, 0.32900000, 1.00000000])), np.array([0.31270000, 0.32900000, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(np.array([0.31270000, 0.32900000]), 100), np.array([0.31270000, 0.32900000, 100.00000000]), decimal=7) @@ -352,11 +352,11 @@ def test_n_dimensional_xy_to_xyY(self): xy = np.tile(xy, (6, 1)) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal(xy_to_xyY(xy), xyY, decimal=7) + np.testing.assert_array_almost_equal(xy_to_xyY(xy), xyY, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal(xy_to_xyY(xy), xyY, decimal=7) + np.testing.assert_array_almost_equal(xy_to_xyY(xy), xyY, decimal=7) def test_domain_range_scale_xy_to_xyY(self): """ @@ -376,7 +376,7 @@ def test_domain_range_scale_xy_to_xyY(self): )) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_xyY(xy * factor_a), xyY * factor_b, decimal=7) @ignore_numpy_errors @@ -403,22 +403,22 @@ def test_XYZ_to_xy(self): Tests :func:`colour.models.cie_xyy.XYZ_to_xy` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.54369557, 0.32107944]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.29777735, 0.48246446]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([0.18582823, 0.14633764]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(np.array([0.00000000, 0.00000000, 0.00000000])), np.array([0.31270000, 0.32900000]), decimal=7) @@ -435,17 +435,17 @@ def test_n_dimensional_XYZ_to_xy(self): XYZ = np.tile(XYZ, (6, 1)) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(XYZ, illuminant), xy, decimal=7) illuminant = np.tile(illuminant, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(XYZ, illuminant), xy, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) illuminant = np.reshape(xy, (2, 3, 2)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(XYZ, illuminant), xy, decimal=7) def test_domain_range_scale_XYZ_to_xy(self): @@ -462,7 +462,7 @@ def test_domain_range_scale_XYZ_to_xy(self): d_r = (('reference', 1), (1, 1), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_xy(XYZ * factor), xy, decimal=7) @ignore_numpy_errors @@ -490,22 +490,22 @@ def test_xy_to_XYZ(self): Tests :func:`colour.models.cie_xyy.xy_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_XYZ(np.array([0.54369557, 0.32107944])), np.array([1.69333661, 1.00000000, 0.42115742]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_XYZ(np.array([0.29777735, 0.48246446])), np.array([0.61720059, 1.00000000, 0.45549094]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_XYZ(np.array([0.18582823, 0.14633764])), np.array([1.26985942, 1.00000000, 4.56365245]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_XYZ(np.array([0.31270000, 0.32900000])), np.array([0.95045593, 1.00000000, 1.08905775]), decimal=7) @@ -521,11 +521,11 @@ def test_n_dimensional_xy_to_XYZ(self): xy = np.tile(xy, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal(xy_to_XYZ(xy), XYZ, decimal=7) + np.testing.assert_array_almost_equal(xy_to_XYZ(xy), XYZ, decimal=7) xy = np.reshape(xy, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal(xy_to_XYZ(xy), XYZ, decimal=7) + np.testing.assert_array_almost_equal(xy_to_XYZ(xy), XYZ, decimal=7) def test_domain_range_scale_xy_to_XYZ(self): """ @@ -545,7 +545,7 @@ def test_domain_range_scale_xy_to_XYZ(self): )) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_XYZ(xy * factor_a), XYZ * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_common.py b/colour/models/tests/test_common.py index 93079c85dc..b1624d34a7 100644 --- a/colour/models/tests/test_common.py +++ b/colour/models/tests/test_common.py @@ -33,17 +33,17 @@ def test_Jab_to_JCh(self): Tests :func:`colour.models.common.Jab_to_JCh` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Jab_to_JCh(np.array([41.52787529, 52.63858304, 26.92317922])), np.array([41.52787529, 59.12425901, 27.08848784]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Jab_to_JCh(np.array([55.11636304, -41.08791787, 30.91825778])), np.array([55.11636304, 51.42135412, 143.03889556]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Jab_to_JCh(np.array([29.80565520, 20.01830466, -48.34913874])), np.array([29.80565520, 52.32945383, 292.49133666]), decimal=7) @@ -59,11 +59,11 @@ def test_n_dimensional_Jab_to_JCh(self): Lab = np.tile(Lab, (6, 1)) LCHab = np.tile(LCHab, (6, 1)) - np.testing.assert_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7) + np.testing.assert_array_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) LCHab = np.reshape(LCHab, (2, 3, 3)) - np.testing.assert_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7) + np.testing.assert_array_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7) def test_domain_range_scale_Jab_to_JCh(self): """ @@ -78,7 +78,7 @@ def test_domain_range_scale_Jab_to_JCh(self): (100, 1, np.array([1, 1, 1 / 3.6]))) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Jab_to_JCh(Lab * factor_a), LCHab * factor_b, decimal=7) @ignore_numpy_errors @@ -105,17 +105,17 @@ def test_JCh_to_Jab(self): Tests :func:`colour.models.common.JCh_to_Jab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JCh_to_Jab(np.array([41.52787529, 59.12425901, 27.08848784])), np.array([41.52787529, 52.63858304, 26.92317922]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JCh_to_Jab(np.array([55.11636304, 51.42135412, 143.03889556])), np.array([55.11636304, -41.08791787, 30.91825778]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JCh_to_Jab(np.array([29.80565520, 52.32945383, 292.49133666])), np.array([29.80565520, 20.01830466, -48.34913874]), decimal=7) @@ -131,11 +131,11 @@ def test_n_dimensional_JCh_to_Jab(self): LCHab = np.tile(LCHab, (6, 1)) Lab = np.tile(Lab, (6, 1)) - np.testing.assert_almost_equal(JCh_to_Jab(LCHab), Lab, decimal=7) + np.testing.assert_array_almost_equal(JCh_to_Jab(LCHab), Lab, decimal=7) LCHab = np.reshape(LCHab, (2, 3, 3)) Lab = np.reshape(Lab, (2, 3, 3)) - np.testing.assert_almost_equal(JCh_to_Jab(LCHab), Lab, decimal=7) + np.testing.assert_array_almost_equal(JCh_to_Jab(LCHab), Lab, decimal=7) def test_domain_range_scale_JCh_to_Jab(self): """ @@ -150,7 +150,7 @@ def test_domain_range_scale_JCh_to_Jab(self): (100, np.array([1, 1, 1 / 3.6]), 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( JCh_to_Jab(LCHab * factor_a), Lab * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_din99.py b/colour/models/tests/test_din99.py index c6c08ad13c..fcc0357505 100644 --- a/colour/models/tests/test_din99.py +++ b/colour/models/tests/test_din99.py @@ -33,17 +33,17 @@ def test_Lab_to_DIN99(self): Tests :func:`colour.models.din99.Lab_to_DIN99` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_DIN99(np.array([41.52787529, 52.63858304, 26.92317922])), np.array([53.22821988, 28.41634656, 3.89839552]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_DIN99(np.array([55.11636304, -41.08791787, 30.91825778])), np.array([66.08943912, -17.35290106, 16.09690691]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_DIN99(np.array([29.80565520, 20.01830466, -48.34913874])), np.array([40.71533366, 3.48714163, -21.45321411]), decimal=7) @@ -59,11 +59,13 @@ def test_n_dimensional_Lab_to_DIN99(self): Lab = np.tile(Lab, (6, 1)) Lab_99 = np.tile(Lab_99, (6, 1)) - np.testing.assert_almost_equal(Lab_to_DIN99(Lab), Lab_99, decimal=7) + np.testing.assert_array_almost_equal( + Lab_to_DIN99(Lab), Lab_99, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) Lab_99 = np.reshape(Lab_99, (2, 3, 3)) - np.testing.assert_almost_equal(Lab_to_DIN99(Lab), Lab_99, decimal=7) + np.testing.assert_array_almost_equal( + Lab_to_DIN99(Lab), Lab_99, decimal=7) def test_domain_range_scale_Lab_to_DIN99(self): """ @@ -77,7 +79,7 @@ def test_domain_range_scale_Lab_to_DIN99(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Lab_to_DIN99(Lab * factor), Lab_99 * factor, decimal=7) @ignore_numpy_errors @@ -103,17 +105,17 @@ def test_DIN99_to_Lab(self): Tests :func:`colour.models.din99.DIN99_to_Lab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( DIN99_to_Lab(np.array([53.22821988, 28.41634656, 3.89839552])), np.array([41.52787529, 52.63858304, 26.92317922]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( DIN99_to_Lab(np.array([66.08943912, -17.35290106, 16.09690691])), np.array([55.11636304, -41.08791787, 30.91825778]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( DIN99_to_Lab(np.array([40.71533366, 3.48714163, -21.45321411])), np.array([29.80565520, 20.01830466, -48.34913874]), decimal=7) @@ -129,11 +131,13 @@ def test_n_dimensional_DIN99_to_Lab(self): Lab_99 = np.tile(Lab_99, (6, 1)) Lab = np.tile(Lab, (6, 1)) - np.testing.assert_almost_equal(DIN99_to_Lab(Lab_99), Lab, decimal=7) + np.testing.assert_array_almost_equal( + DIN99_to_Lab(Lab_99), Lab, decimal=7) Lab_99 = np.reshape(Lab_99, (2, 3, 3)) Lab = np.reshape(Lab, (2, 3, 3)) - np.testing.assert_almost_equal(DIN99_to_Lab(Lab_99), Lab, decimal=7) + np.testing.assert_array_almost_equal( + DIN99_to_Lab(Lab_99), Lab, decimal=7) def test_domain_range_scale_DIN99_to_Lab(self): """ @@ -147,7 +151,7 @@ def test_domain_range_scale_DIN99_to_Lab(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( DIN99_to_Lab(Lab_99 * factor), Lab * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_hdr_cie_lab.py b/colour/models/tests/test_hdr_cie_lab.py index dfb3c65c64..c90c38fb64 100644 --- a/colour/models/tests/test_hdr_cie_lab.py +++ b/colour/models/tests/test_hdr_cie_lab.py @@ -64,19 +64,19 @@ def test_n_dimensional_exponent_hdr_CIELab(self): Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) epsilon = np.tile(epsilon, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_CIELab(Y_s, Y_abs), epsilon, decimal=7) Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) epsilon = np.reshape(epsilon, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_CIELab(Y_s, Y_abs), epsilon, decimal=7) Y_s = np.reshape(Y_s, (2, 3, 1)) Y_abs = np.reshape(Y_abs, (2, 3, 1)) epsilon = np.reshape(epsilon, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_CIELab(Y_s, Y_abs), epsilon, decimal=7) def test_domain_range_scale_exponent_hdr_CIELab(self): @@ -92,7 +92,7 @@ def test_domain_range_scale_exponent_hdr_CIELab(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_CIELab(Y_s * factor, Y_abs), epsilon, decimal=7) @@ -119,19 +119,19 @@ def test_XYZ_to_hdr_CIELab(self): Tests :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([51.87002062, 60.47633850, 32.14551912]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.44757, 0.40745])), np.array([51.87002062, 44.49667330, -6.69619196]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab( np.array([0.20654008, 0.12197225, 0.05136952]), np.array([0.44757, 0.40745]), @@ -139,13 +139,13 @@ def test_XYZ_to_hdr_CIELab(self): np.array([31.99621114, 95.08564341, -14.14047055]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab( np.array([0.20654008, 0.12197225, 0.05136952]), Y_s=0.5), np.array([23.10388654, 59.31425004, 23.69960142]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab( np.array([0.20654008, 0.12197225, 0.05136952]), Y_abs=1000), np.array([29.77261805, 62.58315675, 27.31232673]), @@ -165,13 +165,13 @@ def test_n_dimensional_XYZ_to_hdr_CIELab(self): XYZ = np.tile(XYZ, (6, 1)) Lab_hdr = np.tile(Lab_hdr, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab(XYZ, illuminant, Y_s, Y_abs), Lab_hdr, decimal=7) illuminant = np.tile(illuminant, (6, 1)) Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab(XYZ, illuminant, Y_s, Y_abs), Lab_hdr, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -179,7 +179,7 @@ def test_n_dimensional_XYZ_to_hdr_CIELab(self): Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) Lab_hdr = np.reshape(Lab_hdr, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab(XYZ, illuminant, Y_s, Y_abs), Lab_hdr, decimal=7) def test_domain_range_scale_XYZ_to_hdr_CIELab(self): @@ -197,7 +197,7 @@ def test_domain_range_scale_XYZ_to_hdr_CIELab(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_CIELab(XYZ * factor_a, illuminant, Y_s * factor_a, Y_abs), Lab_hdr * factor_b, @@ -231,20 +231,20 @@ def test_hdr_CIELab_to_XYZ(self): Tests :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ( np.array([51.87002062, 60.47633850, 32.14551912])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ( np.array([51.87002062, 44.49667330, -6.69619196]), np.array([0.44757, 0.40745])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ( np.array([31.99621114, 95.08564341, -14.14047055]), np.array([0.44757, 0.40745]), @@ -252,13 +252,13 @@ def test_hdr_CIELab_to_XYZ(self): np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ( np.array([23.10388654, 59.31425004, 23.69960142]), Y_s=0.5), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ( np.array([29.77261805, 62.58315675, 27.31232673]), Y_abs=1000), np.array([0.20654008, 0.12197225, 0.05136952]), @@ -278,13 +278,13 @@ def test_n_dimensional_hdr_CIELab_to_XYZ(self): Lab_hdr = np.tile(Lab_hdr, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ(Lab_hdr, illuminant, Y_s, Y_abs), XYZ, decimal=7) illuminant = np.tile(illuminant, (6, 1)) Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ(Lab_hdr, illuminant, Y_s, Y_abs), XYZ, decimal=7) Lab_hdr = np.reshape(Lab_hdr, (2, 3, 3)) @@ -292,7 +292,7 @@ def test_n_dimensional_hdr_CIELab_to_XYZ(self): Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ(Lab_hdr, illuminant, Y_s, Y_abs), XYZ, decimal=7) def test_domain_range_scale_hdr_CIELab_to_XYZ(self): @@ -310,7 +310,7 @@ def test_domain_range_scale_hdr_CIELab_to_XYZ(self): d_r = (('reference', 1, 1, 1), (1, 0.01, 1, 1), (100, 1, 100, 100)) for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_CIELab_to_XYZ(Lab_hdr * factor_a, illuminant, Y_s * factor_b, Y_abs), XYZ * factor_c, diff --git a/colour/models/tests/test_hdr_ipt.py b/colour/models/tests/test_hdr_ipt.py index 38093494c1..88c140db08 100644 --- a/colour/models/tests/test_hdr_ipt.py +++ b/colour/models/tests/test_hdr_ipt.py @@ -34,19 +34,19 @@ def test_exponent_hdr_IPT(self): Tests :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition. """ - self.assertAlmostEqual( - exponent_hdr_IPT(0.2, 100), 0.482020919845900, places=7) + np.testing.assert_array_almost_equal( + exponent_hdr_IPT(0.2, 100), 0.482020919845900, decimal=7) - self.assertAlmostEqual( - exponent_hdr_IPT(0.4, 100), 0.667413581325092, places=7) - - self.assertAlmostEqual( + np.testing.assert_array_almost_equal( exponent_hdr_IPT(0.4, 100, method='Fairchild 2010'), 1.219933220992410, - places=7) + decimal=7) + + np.testing.assert_array_almost_equal( + exponent_hdr_IPT(0.2, 1000), 0.723031379768850, decimal=7) - self.assertAlmostEqual( - exponent_hdr_IPT(0.2, 1000), 0.723031379768850, places=7) + np.testing.assert_array_almost_equal( + exponent_hdr_IPT(0.2, 1000), 0.723031379768850, decimal=7) def test_n_dimensional_exponent_hdr_IPT(self): """ @@ -61,19 +61,19 @@ def test_n_dimensional_exponent_hdr_IPT(self): Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) epsilon = np.tile(epsilon, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_IPT(Y_s, Y_abs), epsilon, decimal=7) Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) epsilon = np.reshape(epsilon, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_IPT(Y_s, Y_abs), epsilon, decimal=7) Y_s = np.reshape(Y_s, (2, 3, 1)) Y_abs = np.reshape(Y_abs, (2, 3, 1)) epsilon = np.reshape(epsilon, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_IPT(Y_s, Y_abs), epsilon, decimal=7) def test_domain_range_scale_exponent_hdr_IPT(self): @@ -89,7 +89,7 @@ def test_domain_range_scale_exponent_hdr_IPT(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( exponent_hdr_IPT(Y_s * factor, Y_abs), epsilon, decimal=7) @ignore_numpy_errors @@ -114,25 +114,25 @@ def test_XYZ_to_hdr_IPT(self): Tests :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([48.39376346, 42.44990202, 22.01954033]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT( np.array([0.20654008, 0.12197225, 0.05136952]), method='Fairchild 2010'), np.array([30.02873147, 83.93845061, 34.90287382]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT( np.array([0.20654008, 0.12197225, 0.05136952]), Y_s=0.5), np.array([20.75088680, 37.98300971, 16.66974299]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT( np.array([0.07818780, 0.06157201, 0.28099326]), Y_abs=1000), np.array([23.83205010, -5.98739209, -32.74311745]), @@ -151,19 +151,19 @@ def test_n_dimensional_XYZ_to_hdr_IPT(self): XYZ = np.tile(XYZ, (6, 1)) IPT_hdr = np.tile(IPT_hdr, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT(XYZ, Y_s, Y_abs), IPT_hdr, decimal=7) Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT(XYZ, Y_s, Y_abs), IPT_hdr, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) IPT_hdr = np.reshape(IPT_hdr, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT(XYZ, Y_s, Y_abs), IPT_hdr, decimal=7) def test_domain_range_scale_XYZ_to_hdr_IPT(self): @@ -180,7 +180,7 @@ def test_domain_range_scale_XYZ_to_hdr_IPT(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_hdr_IPT(XYZ * factor_a, Y_s * factor_a, Y_abs), IPT_hdr * factor_b, decimal=7) @@ -212,25 +212,25 @@ def test_hdr_IPT_to_XYZ(self): Tests :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ(np.array([48.39376346, 42.44990202, 22.01954033])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ( np.array([30.02873147, 83.93845061, 34.90287382]), method='Fairchild 2010'), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ( np.array([20.75088680, 37.98300971, 16.66974299]), Y_s=0.5), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ( np.array([23.83205010, -5.98739209, -32.74311745]), Y_abs=1000), @@ -250,19 +250,19 @@ def test_n_dimensional_hdr_IPT_to_XYZ(self): IPT_hdr = np.tile(IPT_hdr, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ(IPT_hdr, Y_s, Y_abs), XYZ, decimal=7) Y_s = np.tile(Y_s, 6) Y_abs = np.tile(Y_abs, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ(IPT_hdr, Y_s, Y_abs), XYZ, decimal=7) IPT_hdr = np.reshape(IPT_hdr, (2, 3, 3)) Y_s = np.reshape(Y_s, (2, 3)) Y_abs = np.reshape(Y_abs, (2, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ(IPT_hdr, Y_s, Y_abs), XYZ, decimal=7) def test_domain_range_scale_hdr_IPT_to_XYZ(self): @@ -279,7 +279,7 @@ def test_domain_range_scale_hdr_IPT_to_XYZ(self): d_r = (('reference', 1, 1, 1), (1, 0.01, 1, 1), (100, 1, 100, 100)) for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( hdr_IPT_to_XYZ(IPT_hdr * factor_a, Y_s * factor_b, Y_abs), XYZ * factor_c, decimal=7) diff --git a/colour/models/tests/test_hunter_lab.py b/colour/models/tests/test_hunter_lab.py index 142dbc16d0..037482d250 100644 --- a/colour/models/tests/test_hunter_lab.py +++ b/colour/models/tests/test_hunter_lab.py @@ -40,19 +40,19 @@ def test_XYZ_to_K_ab_HunterLab1966(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_K_ab_HunterLab1966( np.array([0.20654008, 0.12197225, 0.05136952]) * 100), np.array([80.32152090, 14.59816495]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_K_ab_HunterLab1966( np.array([0.14222010, 0.23042768, 0.10495772]) * 100), np.array([66.65154834, 20.86664881]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_K_ab_HunterLab1966( np.array([0.07818780, 0.06157201, 0.28099326]) * 100), np.array([49.41960269, 34.14235426]), @@ -69,12 +69,12 @@ def test_n_dimensional_XYZ_to_K_ab_HunterLab1966(self): XYZ = np.tile(XYZ, (6, 1)) K_ab = np.tile(K_ab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_K_ab_HunterLab1966(XYZ), K_ab, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) K_ab = np.reshape(K_ab, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_K_ab_HunterLab1966(XYZ), K_ab, decimal=7) @ignore_numpy_errors @@ -101,19 +101,19 @@ def test_XYZ_to_Hunter_Lab(self): Tests :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100), np.array([34.92452577, 47.06189858, 14.38615107]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.14222010, 0.23042768, 0.10495772]) * 100), np.array([48.00288325, -28.98551622, 18.75564181]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.07818780, 0.06157201, 0.28099326]) * 100), np.array([24.81370791, 14.38300039, -53.25539126]), @@ -121,7 +121,7 @@ def test_XYZ_to_Hunter_Lab(self): h_i = TVS_ILLUMINANT_HUNTERLAB['CIE 1931 2 Degree Standard Observer'] A = h_i['A'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, A.XYZ_n, A.K_ab), @@ -129,14 +129,14 @@ def test_XYZ_to_Hunter_Lab(self): decimal=7) D65 = h_i['D65'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, D65.XYZ_n, D65.K_ab), np.array([34.92452577, 47.06189858, 14.38615107]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, D65.XYZ_n, @@ -160,19 +160,19 @@ def test_n_dimensional_XYZ_to_Hunter_Lab(self): XYZ = np.tile(XYZ, (6, 1)) Lab = np.tile(Lab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab(XYZ, XYZ_n, K_ab), Lab, decimal=7) XYZ_n = np.tile(XYZ_n, (6, 1)) K_ab = np.tile(K_ab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab(XYZ, XYZ_n, K_ab), Lab, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) XYZ_n = np.reshape(XYZ_n, (2, 3, 3)) K_ab = np.reshape(K_ab, (2, 3, 2)) Lab = np.reshape(Lab, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab(XYZ, XYZ_n, K_ab), Lab, decimal=7) def test_domain_range_scale_XYZ_to_Hunter_Lab(self): @@ -192,7 +192,7 @@ def test_domain_range_scale_XYZ_to_Hunter_Lab(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Lab(XYZ * factor, XYZ_n * factor, K_ab), Lab * factor, decimal=7) @@ -224,19 +224,19 @@ def test_Hunter_Lab_to_XYZ(self): Tests :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([34.92452577, 47.06189858, 14.38615107])), np.array([20.65400800, 12.19722500, 5.13695200]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([48.00288325, -28.98551622, 18.75564181])), np.array([14.22201000, 23.04276800, 10.49577200]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([24.81370791, 14.38300039, -53.25539126])), np.array([7.81878000, 6.15720100, 28.09932601]), @@ -244,7 +244,7 @@ def test_Hunter_Lab_to_XYZ(self): h_i = TVS_ILLUMINANT_HUNTERLAB['CIE 1931 2 Degree Standard Observer'] A = h_i['A'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([34.92452577, 35.04243086, -2.47688619]), A.XYZ_n, A.K_ab), @@ -252,14 +252,14 @@ def test_Hunter_Lab_to_XYZ(self): decimal=7) D65 = h_i['D65'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([34.92452577, 47.06189858, 14.38615107]), D65.XYZ_n, D65.K_ab), np.array([20.65400800, 12.19722500, 5.13695200]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ( np.array([34.92452577, 47.05669614, 14.38385238]), D65.XYZ_n, @@ -283,19 +283,19 @@ def test_n_dimensional_Hunter_Lab_to_XYZ(self): Lab = np.tile(Lab, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab), XYZ, decimal=7) K_ab = np.tile(K_ab, (6, 1)) XYZ_n = np.tile(XYZ_n, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab), XYZ, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) XYZ_n = np.reshape(XYZ_n, (2, 3, 3)) K_ab = np.reshape(K_ab, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab), XYZ, decimal=7) def test_domain_range_scale_Hunter_Lab_to_XYZ(self): @@ -315,7 +315,7 @@ def test_domain_range_scale_Hunter_Lab_to_XYZ(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Lab_to_XYZ(Lab * factor, XYZ_n * factor, K_ab), XYZ * factor, decimal=7) diff --git a/colour/models/tests/test_hunter_rdab.py b/colour/models/tests/test_hunter_rdab.py index 42482c9061..a86b8e1702 100644 --- a/colour/models/tests/test_hunter_rdab.py +++ b/colour/models/tests/test_hunter_rdab.py @@ -35,19 +35,19 @@ def test_XYZ_to_Hunter_Rdab(self): Tests :func:`colour.models.hunter_rdab.XYZ_to_Hunter_Rdab` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100), np.array([12.19722500, 57.12537874, 17.46241341]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.14222010, 0.23042768, 0.10495772]) * 100), np.array([23.04276800, -32.40057474, 20.96542183]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.07818780, 0.06157201, 0.28099326]) * 100), np.array([6.15720100, 18.13400284, -67.14408607]), @@ -55,7 +55,7 @@ def test_XYZ_to_Hunter_Rdab(self): h_i = TVS_ILLUMINANT_HUNTERLAB['CIE 1931 2 Degree Standard Observer'] A = h_i['A'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, A.XYZ_n, A.K_ab), @@ -63,14 +63,14 @@ def test_XYZ_to_Hunter_Rdab(self): decimal=7) D65 = h_i['D65'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, D65.XYZ_n, D65.K_ab), np.array([12.19722500, 57.12537874, 17.46241341]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab( np.array([0.20654008, 0.12197225, 0.05136952]) * 100, D65.XYZ_n, @@ -94,19 +94,19 @@ def test_n_dimensional_XYZ_to_Hunter_Rdab(self): XYZ = np.tile(XYZ, (6, 1)) R_d_ab = np.tile(R_d_ab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab(XYZ, XYZ_n, K_ab), R_d_ab, decimal=7) XYZ_n = np.tile(XYZ_n, (6, 1)) K_ab = np.tile(K_ab, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab(XYZ, XYZ_n, K_ab), R_d_ab, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) XYZ_n = np.reshape(XYZ_n, (2, 3, 3)) K_ab = np.reshape(K_ab, (2, 3, 2)) R_d_ab = np.reshape(R_d_ab, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab(XYZ, XYZ_n, K_ab), R_d_ab, decimal=7) def test_domain_range_scale_XYZ_to_Hunter_Rdab(self): @@ -126,7 +126,7 @@ def test_domain_range_scale_XYZ_to_Hunter_Rdab(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunter_Rdab(XYZ * factor, XYZ_n * factor, K_ab), R_d_ab * factor, decimal=7) @@ -158,19 +158,19 @@ def test_Hunter_Rdab_to_XYZ(self): Tests :func:`colour.models.hunter_rdab.Hunter_Rdab_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([12.19722500, 57.12537874, 17.46241341])), np.array([0.20654008, 0.12197225, 0.05136952]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([23.04276800, -32.40057474, 20.96542183])), np.array([0.14222010, 0.23042768, 0.10495772]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([6.15720100, 18.13400284, -67.14408607])), np.array([0.07818780, 0.06157201, 0.28099326]) * 100, @@ -178,7 +178,7 @@ def test_Hunter_Rdab_to_XYZ(self): h_i = TVS_ILLUMINANT_HUNTERLAB['CIE 1931 2 Degree Standard Observer'] A = h_i['A'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([12.19722500, 42.53572838, -3.00653110]), A.XYZ_n, A.K_ab), @@ -186,14 +186,14 @@ def test_Hunter_Rdab_to_XYZ(self): decimal=7) D65 = h_i['D65'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([12.19722500, 57.12537874, 17.46241341]), D65.XYZ_n, D65.K_ab), np.array([0.20654008, 0.12197225, 0.05136952]) * 100, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ( np.array([12.19722500, 57.11906384, 17.45962317]), D65.XYZ_n, @@ -217,19 +217,19 @@ def test_n_dimensional_Hunter_Rdab_to_XYZ(self): R_d_ab = np.tile(R_d_ab, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ(R_d_ab, XYZ_n, K_ab), XYZ, decimal=7) K_ab = np.tile(K_ab, (6, 1)) XYZ_n = np.tile(XYZ_n, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ(R_d_ab, XYZ_n, K_ab), XYZ, decimal=7) R_d_ab = np.reshape(R_d_ab, (2, 3, 3)) XYZ_n = np.reshape(XYZ_n, (2, 3, 3)) K_ab = np.reshape(K_ab, (2, 3, 2)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ(R_d_ab, XYZ_n, K_ab), XYZ, decimal=7) def test_domain_range_scale_Hunter_Rdab_to_XYZ(self): @@ -249,7 +249,7 @@ def test_domain_range_scale_Hunter_Rdab_to_XYZ(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( Hunter_Rdab_to_XYZ(R_d_ab * factor, XYZ_n * factor, K_ab), XYZ * factor, decimal=7) diff --git a/colour/models/tests/test_ipt.py b/colour/models/tests/test_ipt.py index 182c5371ca..447cd1635b 100644 --- a/colour/models/tests/test_ipt.py +++ b/colour/models/tests/test_ipt.py @@ -32,17 +32,17 @@ def test_XYZ_to_IPT(self): Tests :func:`colour.models.ipt.XYZ_to_IPT` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_IPT(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.38426191, 0.38487306, 0.18886838]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_IPT(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.49437481, -0.19251742, 0.18080304]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_IPT(np.array([0.07818780, 0.06157201, 0.28099326])), np.array([0.35167774, -0.07525627, -0.30921279]), decimal=7) @@ -58,11 +58,11 @@ def test_n_dimensional_XYZ_to_IPT(self): XYZ = np.tile(XYZ, (6, 1)) IPT = np.tile(IPT, (6, 1)) - np.testing.assert_almost_equal(XYZ_to_IPT(XYZ), IPT, decimal=7) + np.testing.assert_array_almost_equal(XYZ_to_IPT(XYZ), IPT, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) IPT = np.reshape(IPT, (2, 3, 3)) - np.testing.assert_almost_equal(XYZ_to_IPT(XYZ), IPT, decimal=7) + np.testing.assert_array_almost_equal(XYZ_to_IPT(XYZ), IPT, decimal=7) def test_domain_range_scale_XYZ_to_IPT(self): """ @@ -76,7 +76,7 @@ def test_domain_range_scale_XYZ_to_IPT(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_IPT(XYZ * factor), IPT * factor, decimal=7) @ignore_numpy_errors @@ -103,17 +103,17 @@ def test_IPT_to_XYZ(self): Tests :func:`colour.models.ipt.IPT_to_XYZ` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_to_XYZ(np.array([0.38426191, 0.38487306, 0.18886838])), np.array([0.20654008, 0.12197225, 0.05136952]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_to_XYZ(np.array([0.49437481, -0.19251742, 0.18080304])), np.array([0.14222010, 0.23042768, 0.10495772]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_to_XYZ(np.array([0.35167774, -0.07525627, -0.30921279])), np.array([0.07818780, 0.06157201, 0.28099326]), decimal=7) @@ -129,11 +129,11 @@ def test_n_dimensional_IPT_to_XYZ(self): IPT = np.tile(IPT, (6, 1)) XYZ = np.tile(XYZ, (6, 1)) - np.testing.assert_almost_equal(IPT_to_XYZ(IPT), XYZ, decimal=7) + np.testing.assert_array_almost_equal(IPT_to_XYZ(IPT), XYZ, decimal=7) IPT = np.reshape(IPT, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) - np.testing.assert_almost_equal(IPT_to_XYZ(IPT), XYZ, decimal=7) + np.testing.assert_array_almost_equal(IPT_to_XYZ(IPT), XYZ, decimal=7) def test_domain_range_scale_IPT_to_XYZ(self): """ @@ -147,7 +147,7 @@ def test_domain_range_scale_IPT_to_XYZ(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_to_XYZ(IPT * factor), XYZ * factor, decimal=7) @ignore_numpy_errors @@ -174,17 +174,17 @@ def test_IPT_hue_angle(self): Tests :func:`colour.models.ipt.IPT_hue_angle` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_hue_angle(np.array([0.20654008, 0.12197225, 0.05136952])), 22.838754548625527, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_hue_angle(np.array([0.14222010, 0.23042768, 0.10495772])), 24.488834912466245, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_hue_angle(np.array([0.07818780, 0.06157201, 0.28099326])), 77.640533743711813, decimal=7) @@ -200,11 +200,13 @@ def test_n_dimensional_IPT_hue_angle(self): IPT = np.tile(IPT, (6, 1)) hue = np.tile(hue, 6) - np.testing.assert_almost_equal(IPT_hue_angle(IPT), hue, decimal=7) + np.testing.assert_array_almost_equal( + IPT_hue_angle(IPT), hue, decimal=7) IPT = np.reshape(IPT, (2, 3, 3)) hue = np.reshape(hue, (2, 3)) - np.testing.assert_almost_equal(IPT_hue_angle(IPT), hue, decimal=7) + np.testing.assert_array_almost_equal( + IPT_hue_angle(IPT), hue, decimal=7) def test_domain_range_scale_IPT_hue_angle(self): """ @@ -218,7 +220,7 @@ def test_domain_range_scale_IPT_hue_angle(self): d_r = (('reference', 1, 1), (1, 1, 1 / 360), (100, 100, 1 / 3.6)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( IPT_hue_angle(IPT * factor_a), hue * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_jzazbz.py b/colour/models/tests/test_jzazbz.py index 29ffb0b949..4fe7a01f9e 100644 --- a/colour/models/tests/test_jzazbz.py +++ b/colour/models/tests/test_jzazbz.py @@ -33,17 +33,17 @@ def test_XYZ_to_JzAzBz(self): Tests :func:`colour.models.jzazbz.XYZ_to_JzAzBz` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_JzAzBz(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([0.00535048, 0.00924302, 0.00526007]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_JzAzBz(np.array([0.14222010, 0.23042768, 0.10495772])), np.array([0.00619681, -0.00608426, 0.00534077]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_JzAzBz(np.array([0.96907232, 1.00000000, 1.12179215])), np.array([0.01766826, 0.00064174, -0.00052906]), decimal=7) @@ -59,11 +59,13 @@ def test_n_dimensional_XYZ_to_JzAzBz(self): XYZ = np.tile(XYZ, (6, 1)) JzAzBz = np.tile(JzAzBz, (6, 1)) - np.testing.assert_almost_equal(XYZ_to_JzAzBz(XYZ), JzAzBz, decimal=7) + np.testing.assert_array_almost_equal( + XYZ_to_JzAzBz(XYZ), JzAzBz, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) JzAzBz = np.reshape(JzAzBz, (2, 3, 3)) - np.testing.assert_almost_equal(XYZ_to_JzAzBz(XYZ), JzAzBz, decimal=7) + np.testing.assert_array_almost_equal( + XYZ_to_JzAzBz(XYZ), JzAzBz, decimal=7) def test_domain_range_scale_XYZ_to_JzAzBz(self): """ @@ -77,7 +79,7 @@ def test_domain_range_scale_XYZ_to_JzAzBz(self): d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_JzAzBz(XYZ * factor), JzAzBz * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/models/tests/test_osa_ucs.py b/colour/models/tests/test_osa_ucs.py index ac3a47c973..cf6122985a 100644 --- a/colour/models/tests/test_osa_ucs.py +++ b/colour/models/tests/test_osa_ucs.py @@ -33,19 +33,19 @@ def test_XYZ_to_OSA_UCS(self): Tests :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_OSA_UCS( np.array([0.20654008, 0.12197225, 0.05136952]) * 100), np.array([-3.00499790, 2.99713697, -9.66784231]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_OSA_UCS( np.array([0.14222010, 0.23042768, 0.10495772]) * 100), np.array([-1.64657491, 4.59201565, 5.31738757]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_OSA_UCS( np.array([0.07818780, 0.06157201, 0.28099326]) * 100), np.array([-5.08589672, -7.91062749, 0.98107575]), @@ -62,11 +62,13 @@ def test_n_dimensional_XYZ_to_OSA_UCS(self): XYZ = np.tile(XYZ, (6, 1)) Ljg = np.tile(Ljg, (6, 1)) - np.testing.assert_almost_equal(XYZ_to_OSA_UCS(XYZ), Ljg, decimal=7) + np.testing.assert_array_almost_equal( + XYZ_to_OSA_UCS(XYZ), Ljg, decimal=7) XYZ = np.reshape(XYZ, (2, 3, 3)) Ljg = np.reshape(Ljg, (2, 3, 3)) - np.testing.assert_almost_equal(XYZ_to_OSA_UCS(XYZ), Ljg, decimal=7) + np.testing.assert_array_almost_equal( + XYZ_to_OSA_UCS(XYZ), Ljg, decimal=7) def test_domain_range_scale_XYZ_to_OSA_UCS(self): """ @@ -80,7 +82,7 @@ def test_domain_range_scale_XYZ_to_OSA_UCS(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_OSA_UCS(XYZ * factor), Ljg * factor, decimal=7) @ignore_numpy_errors @@ -162,7 +164,7 @@ def test_domain_range_scale_OSA_UCS_to_XYZ(self): d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( OSA_UCS_to_XYZ(Ljg * factor), XYZ * factor, decimal=7) @ignore_numpy_errors diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index f73cc319ad..a598d2a126 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -94,6 +94,18 @@ def __getattr__(self, attribute): failsafe = None if _NDIMENSIONAL_ARRAY_BACKEND == 'numpy': + if attribute in ['array', 'asarray']: + + def checkForCupy(*args, **kwargs): + args = list(args) + for i in range(len(args)): + if hasattr(self._cupy, 'ndarray') and \ + isinstance(args[i], self._cupy.ndarray): + args[i] = self._cupy.asnumpy(args[i]) + args = tuple(args) + return failsafe(*args, **kwargs) + + return checkForCupy return getattr(self._numpy, attribute) elif _NDIMENSIONAL_ARRAY_BACKEND == 'cupy' and self._cupy is not None: if attribute not in self._cupy_unsupported: diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index e49388ddd4..c2909f3631 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -12,7 +12,6 @@ from colour.notation.hexadecimal import (RGB_to_HEX, HEX_to_RGB) from colour.utilities import domain_range_scale, ignore_numpy_errors -np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 38af249e4b..42499a8b6a 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -800,17 +800,17 @@ def test_n_dimensional_munsell_value_Priest1920(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Priest1920(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Priest1920(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Priest1920(Y), V, decimal=7) def test_domain_range_scale_munsell_value_Priest1920(self): @@ -825,7 +825,7 @@ def test_domain_range_scale_munsell_value_Priest1920(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Priest1920(Y * factor_a), V * factor_b, decimal=7) @@ -879,17 +879,17 @@ def test_n_dimensional_munsell_value_Munsell1933(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Munsell1933(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Munsell1933(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Munsell1933(Y), V, decimal=7) def test_domain_range_scale_munsell_value_Munsell1933(self): @@ -904,7 +904,7 @@ def test_domain_range_scale_munsell_value_Munsell1933(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Munsell1933(Y * factor_a), V * factor_b, decimal=7) @@ -952,15 +952,18 @@ def test_n_dimensional_munsell_value_Moon1943(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(munsell_value_Moon1943(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Moon1943(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(munsell_value_Moon1943(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Moon1943(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal(munsell_value_Moon1943(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Moon1943(Y), V, decimal=7) def test_domain_range_scale_munsell_value_Moon1943(self): """ @@ -974,7 +977,7 @@ def test_domain_range_scale_munsell_value_Moon1943(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Moon1943(Y * factor_a), V * factor_b, decimal=7) @@ -1028,17 +1031,17 @@ def test_n_dimensional_munsell_value_Saunderson1944(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Saunderson1944(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Saunderson1944(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Saunderson1944(Y), V, decimal=7) def test_domain_range_scale_munsell_value_Saunderson1944(self): @@ -1053,7 +1056,7 @@ def test_domain_range_scale_munsell_value_Saunderson1944(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Saunderson1944(Y * factor_a), V * factor_b, decimal=7) @@ -1101,15 +1104,18 @@ def test_n_dimensional_munsell_value_Ladd1955(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal(munsell_value_Ladd1955(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Ladd1955(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal(munsell_value_Ladd1955(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Ladd1955(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal(munsell_value_Ladd1955(Y), V, decimal=7) + np.testing.assert_array_almost_equal( + munsell_value_Ladd1955(Y), V, decimal=7) def test_domain_range_scale_munsell_value_Ladd1955(self): """ @@ -1123,7 +1129,7 @@ def test_domain_range_scale_munsell_value_Ladd1955(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_Ladd1955(Y * factor_a), V * factor_b, decimal=7) @@ -1171,17 +1177,17 @@ def test_n_dimensional_munsell_value_McCamy1987(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_McCamy1987(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_McCamy1987(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_McCamy1987(Y), V, decimal=7) def test_domain_range_scale_munsell_value_McCamy1987(self): @@ -1196,7 +1202,7 @@ def test_domain_range_scale_munsell_value_McCamy1987(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_McCamy1987(Y * factor_a), V * factor_b, decimal=7) @@ -1244,17 +1250,17 @@ def test_n_dimensional_munsell_value_ASTMD1535(self): V = np.tile(V, 6) Y = np.tile(Y, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_ASTMD1535(Y), V, decimal=7) V = np.reshape(V, (2, 3)) Y = np.reshape(Y, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_ASTMD1535(Y), V, decimal=7) V = np.reshape(V, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_ASTMD1535(Y), V, decimal=7) def test_domain_range_scale_munsell_value_ASTMD1535(self): @@ -1269,7 +1275,7 @@ def test_domain_range_scale_munsell_value_ASTMD1535(self): d_r = (('reference', 1, 1), (1, 0.01, 0.1), (100, 1, 10)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_value_ASTMD1535(Y * factor_a), V * factor_b, decimal=7) @@ -1301,7 +1307,7 @@ def test_munsell_specification_to_xyY(self): as_float_array(list(MUNSELL_SPECIFICATIONS[..., 0])), as_float_array(list(MUNSELL_SPECIFICATIONS[..., 1])), ) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) specification, xyY = ( @@ -1313,7 +1319,7 @@ def test_munsell_specification_to_xyY(self): specification = tstack( [nan_array, specification, nan_array, nan_array]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) def test_n_dimensional_munsell_specification_to_xyY(self): @@ -1328,12 +1334,12 @@ def test_n_dimensional_munsell_specification_to_xyY(self): specification = np.tile(specification, (6, 1)) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) specification = np.reshape(specification, (2, 3, 4)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) specification = np.array([np.nan, 8.9, np.nan, np.nan]) @@ -1341,12 +1347,12 @@ def test_n_dimensional_munsell_specification_to_xyY(self): specification = np.tile(specification, (6, 1)) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) specification = np.reshape(specification, (2, 3, 4)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification), xyY, decimal=7) def test_domain_range_scale_munsell_specification_to_xyY(self): @@ -1366,7 +1372,7 @@ def test_domain_range_scale_munsell_specification_to_xyY(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xyY(specification * factor_a), xyY * factor_b, decimal=7) @@ -1410,7 +1416,7 @@ def test_domain_range_scale_munsell_colour_to_xyY(self): ) for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY * factor, decimal=7) @@ -1426,12 +1432,12 @@ def test_n_dimensional_munsell_colour_to_xyY(self): munsell_colour = np.tile(munsell_colour, 6) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) munsell_colour = np.reshape(munsell_colour, (2, 3)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) munsell_colour = 'N8.9' @@ -1439,12 +1445,12 @@ def test_n_dimensional_munsell_colour_to_xyY(self): munsell_colour = np.tile(munsell_colour, 6) xyY = np.tile(xyY, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) munsell_colour = np.reshape(munsell_colour, (2, 3)) xyY = np.reshape(xyY, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) @@ -1497,12 +1503,12 @@ def test_n_dimensional_xyY_to_munsell_specification(self): xyY = np.tile(xyY, (6, 1)) specification = np.tile(specification, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_munsell_specification(xyY), specification, decimal=7) xyY = np.reshape(xyY, (2, 3, 3)) specification = np.reshape(specification, (2, 3, 4)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xyY_to_munsell_specification(xyY), specification, decimal=7) def test_raise_exception_xyY_to_munsell_specification(self): @@ -1590,22 +1596,26 @@ def test_n_dimensional_xyY_to_munsell_colour(self): xyY = np.tile(xyY, (6, 1)) munsell_colour = np.tile(munsell_colour, 6) - np.testing.assert_equal(xyY_to_munsell_colour(xyY), munsell_colour) + np.testing.assert_array_equal( + xyY_to_munsell_colour(xyY), munsell_colour) xyY = np.reshape(xyY, (2, 3, 3)) munsell_colour = np.reshape(munsell_colour, (2, 3)) - np.testing.assert_equal(xyY_to_munsell_colour(xyY), munsell_colour) + np.testing.assert_array_equal( + xyY_to_munsell_colour(xyY), munsell_colour) xyY = list(CCS_ILLUMINANT_MUNSELL) + [1.0] munsell_colour = xyY_to_munsell_colour(xyY) xyY = np.tile(xyY, (6, 1)) munsell_colour = np.tile(munsell_colour, 6) - np.testing.assert_equal(xyY_to_munsell_colour(xyY), munsell_colour) + np.testing.assert_array_equal( + xyY_to_munsell_colour(xyY), munsell_colour) xyY = np.reshape(xyY, (2, 3, 3)) munsell_colour = np.reshape(munsell_colour, (2, 3)) - np.testing.assert_equal(xyY_to_munsell_colour(xyY), munsell_colour) + np.testing.assert_array_equal( + xyY_to_munsell_colour(xyY), munsell_colour) class TestParseMunsellColour(unittest.TestCase): @@ -1620,17 +1630,17 @@ def test_parse_munsell_colour(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( parse_munsell_colour('N5.2'), np.array([np.nan, 5.2, np.nan, np.nan]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( parse_munsell_colour('0YR 2.0/4.0'), np.array([0.0, 2.0, 4.0, 6]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( parse_munsell_colour('4.2YR 8.1/5.3'), np.array([4.2, 8.1, 5.3, 6]), decimal=7) @@ -1678,22 +1688,22 @@ def test_normalize_munsell_specification(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalize_munsell_specification((0.0, 2.0, 4.0, 6)), np.array([10.0, 2.0, 4.0, 7]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalize_munsell_specification((0.0, 2.0, 4.0, 8)), np.array([10.0, 2.0, 4.0, 9]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalize_munsell_specification((0, 2.0, 4.0, 10)), np.array([10.0, 2.0, 4.0, 1]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalize_munsell_specification(0.5), np.array([np.nan, 0.5, np.nan, np.nan]), decimal=7) @@ -1711,27 +1721,27 @@ def test_munsell_colour_to_munsell_specification(self): munsell_colour_to_munsell_specification` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_munsell_specification('0.0YR 2.0/4.0'), np.array([10.0, 2.0, 4.0, 7]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_munsell_specification('0.0RP 2.0/4.0'), np.array([10.0, 2.0, 4.0, 9]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_munsell_specification('10.0B 2.0/4.0'), np.array([10.0, 2.0, 4.0, 1]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_munsell_specification('N5.2'), np.array([np.nan, 5.2, np.nan, np.nan]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_colour_to_munsell_specification('0.0YR 2.0/0.0'), np.array([np.nan, 2.0, np.nan, np.nan]), decimal=7) @@ -1925,7 +1935,7 @@ def test_xy_from_renotation_ovoid(self): for i, (specification, _xyY) in enumerate(MUNSELL_EVEN_SPECIFICATIONS): if is_specification_in_renotation(specification): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_from_renotation_ovoid(specification), MUNSELL_XY_FROM_RENOTATION_OVOID[i], decimal=7) @@ -1943,31 +1953,31 @@ def test_LCHab_to_munsell_specification(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_munsell_specification( np.array([100.00000000, 21.57210357, 272.22819350])), np.array([5.618942638888882, 10.0, 4.314420714000000, 10]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_munsell_specification( np.array([100.00000000, 426.67945353, 72.39590835])), np.array([0.109974541666666, 10.0, 85.335890706000001, 5]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_munsell_specification( np.array([100.00000000, 74.05216981, 276.45318193])), np.array([6.792550536111119, 10.0, 14.810433961999999, 10]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_munsell_specification( np.array([100.00000000, 21.57210357, 0.00000000])), np.array([10.000000000000000, 10.0, 4.314420714000000, 8]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( LCHab_to_munsell_specification( np.array([100.00000000, 21.57210357, 36.00000000])), np.array([10.000000000000000, 10.0, 4.314420714000000, 7]), @@ -2007,13 +2017,13 @@ def test_munsell_specification_to_xy(self): """ for specification, xyY in MUNSELL_EVEN_SPECIFICATIONS: - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xy(specification), xyY[0:2], decimal=7) for specification, xyY in MUNSELL_GREYS_SPECIFICATIONS: - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( munsell_specification_to_xy(specification[0]), xyY[0:2], decimal=7) diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index 0ace5da868..40e2110066 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -25,7 +25,7 @@ from colour.colorimetry import (SPECTRAL_SHAPE_DEFAULT, SpectralDistribution) from colour.constants import CONSTANT_AVOGADRO -from colour.utilities import as_float_array, filter_kwargs +from colour.utilities import as_float, as_float_array, filter_kwargs __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -110,6 +110,12 @@ def air_refraction_index_Penndorf1957(wavelength): n /= 1.0e8 n += +1 + try: + if n.size == 1: + return as_float(n) + except Exception: + pass + return n @@ -141,6 +147,12 @@ def air_refraction_index_Edlen1966(wavelength): n /= 1.0e8 n += +1 + try: + if n.size == 1: + return as_float(n) + except Exception: + pass + return n @@ -173,6 +185,12 @@ def air_refraction_index_Peck1972(wavelength): n /= 1.0e8 n += +1 + try: + if n.size == 1: + return as_float(n) + except Exception: + pass + return n @@ -207,6 +225,12 @@ def air_refraction_index_Bodhaine1999( n = ((1 + 0.54 * ((CO2_c * 1e-6) - 300e-6)) * (air_refraction_index_Peck1972(wl) - 1) + 1) + try: + if n.size == 1: + return as_float(n) + except Exception: + pass + return n @@ -235,6 +259,12 @@ def N2_depolarisation(wavelength): N2 = 1.034 + 3.17 * 1.0e-4 * (1 / wl ** 2) + try: + if N2.size == 1: + return as_float(N2) + except Exception: + pass + return N2 @@ -264,6 +294,12 @@ def O2_depolarisation(wavelength): O2 = (1.096 + 1.385 * 1.0e-3 * (1 / wl ** 2) + 1.448 * 1.0e-4 * (1 / wl ** 4)) + try: + if O2.size == 1: + return as_float(O2) + except Exception: + pass + return O2 @@ -361,6 +397,12 @@ def F_air_Bates1984(wavelength): F_air = ( (78.084 * N2 + 20.946 * O2 + CO2 + Ar) / (78.084 + 20.946 + Ar + CO2)) + try: + if F_air.size == 1: + return as_float(F_air) + except Exception: + pass + return F_air @@ -397,6 +439,12 @@ def F_air_Bodhaine1999(wavelength, F_air = ((78.084 * N2 + 20.946 * O2 + 0.934 * 1 + CO2_c * 1.15) / (78.084 + 20.946 + 0.934 + CO2_c)) + try: + if F_air.size == 1: + return as_float(F_air) + except Exception: + pass + return F_air @@ -438,6 +486,12 @@ def molecular_density(temperature=CONSTANT_STANDARD_AIR_TEMPERATURE, N_s = (avogadro_constant / 22.4141) * (273.15 / T) * (1 / 1000) + try: + if N_s.size == 1: + return as_float(N_s) + except Exception: + pass + return N_s @@ -466,6 +520,13 @@ def mean_molecular_weights( CO2_c = CO2_concentration * 1.0e-6 m_a = 15.0556 * CO2_c + 28.9595 + + try: + if m_a.size == 1: + return as_float(m_a) + except Exception: + pass + return m_a @@ -512,6 +573,12 @@ def gravity_List1968(latitude=DEFAULT_LATITUDE, altitude=DEFAULT_ALTITUDE): (7.254e-11 + 1.0e-13 * cos2phi) * altitude ** 2 - (1.517e-17 + 6e-20 * cos2phi) * altitude ** 3) + try: + if g.size == 1: + return as_float(g) + except Exception: + pass + return g @@ -583,6 +650,12 @@ def scattering_cross_section( (n_s ** 2 + 2) ** 2)) sigma *= F_air + try: + if sigma.size == 1: + return as_float(sigma) + except Exception: + pass + return sigma @@ -659,6 +732,12 @@ def rayleigh_optical_depth( T_R = sigma * (P * avogadro_constant) / (m_a * g) + try: + if T_R.size == 1: + return as_float(T_R) + except Exception: + pass + return T_R diff --git a/colour/phenomena/tests/test_rayleigh.py b/colour/phenomena/tests/test_rayleigh.py index 634bb2c374..f8f349f299 100644 --- a/colour/phenomena/tests/test_rayleigh.py +++ b/colour/phenomena/tests/test_rayleigh.py @@ -499,17 +499,17 @@ def test_n_dimensional_air_refraction_index_Penndorf1957(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Penndorf1957(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Penndorf1957(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Penndorf1957(wl), n, decimal=7) @ignore_numpy_errors @@ -561,17 +561,17 @@ def test_n_dimensional_air_refraction_index_Edlen1966(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Edlen1966(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Edlen1966(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Edlen1966(wl), n, decimal=7) @ignore_numpy_errors @@ -617,17 +617,17 @@ def test_n_dimensional_air_refraction_index_Peck1972(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Peck1972(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Peck1972(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Peck1972(wl), n, decimal=7) @ignore_numpy_errors @@ -694,17 +694,17 @@ def test_n_dimensional_air_refraction_index_Bodhaine1999(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Bodhaine1999(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Bodhaine1999(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( air_refraction_index_Bodhaine1999(wl), n, decimal=7) @ignore_numpy_errors @@ -753,15 +753,18 @@ def test_n_dimensional_N2_depolarisation(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(N2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + N2_depolarisation(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(N2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + N2_depolarisation(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(N2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + N2_depolarisation(wl), n, decimal=7) @ignore_numpy_errors def test_nan_N2_depolarisation(self): @@ -804,15 +807,18 @@ def test_n_dimensional_O2_depolarisation(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(O2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + O2_depolarisation(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(O2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + O2_depolarisation(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(O2_depolarisation(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + O2_depolarisation(wl), n, decimal=7) @ignore_numpy_errors def test_nan_O2_depolarisation(self): @@ -849,15 +855,18 @@ def test_n_dimensional_F_air_Penndorf1957(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(F_air_Penndorf1957(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Penndorf1957(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(F_air_Penndorf1957(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Penndorf1957(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(F_air_Penndorf1957(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Penndorf1957(wl), n, decimal=7) @ignore_numpy_errors def test_nan_F_air_Penndorf1957(self): @@ -893,15 +902,15 @@ def test_n_dimensional_F_air_Young1981(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(F_air_Young1981(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Young1981(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(F_air_Young1981(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Young1981(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(F_air_Young1981(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Young1981(wl), n, decimal=7) @ignore_numpy_errors def test_nan_F_air_Young1981(self): @@ -944,15 +953,15 @@ def test_n_dimensional_F_air_Bates1984(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(F_air_Bates1984(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Bates1984(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(F_air_Bates1984(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Bates1984(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(F_air_Bates1984(wl), n, decimal=7) + np.testing.assert_array_almost_equal(F_air_Bates1984(wl), n, decimal=7) @ignore_numpy_errors def test_nan_F_air_Bates1984(self): @@ -1005,15 +1014,18 @@ def test_n_dimensional_F_air_Bodhaine1999(self): wl = np.tile(wl, 6) n = np.tile(n, 6) - np.testing.assert_almost_equal(F_air_Bodhaine1999(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Bodhaine1999(wl), n, decimal=7) wl = np.reshape(wl, (2, 3)) n = np.reshape(n, (2, 3)) - np.testing.assert_almost_equal(F_air_Bodhaine1999(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Bodhaine1999(wl), n, decimal=7) wl = np.reshape(wl, (2, 3, 1)) n = np.reshape(n, (2, 3, 1)) - np.testing.assert_almost_equal(F_air_Bodhaine1999(wl), n, decimal=7) + np.testing.assert_array_almost_equal( + F_air_Bodhaine1999(wl), n, decimal=7) @ignore_numpy_errors def test_nan_F_air_Bodhaine1999(self): @@ -1061,17 +1073,17 @@ def test_n_dimensional_molecular_density(self): temperature = np.tile(temperature, 6) N_s = np.tile(N_s, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( molecular_density(temperature), N_s, decimal=7) temperature = np.reshape(temperature, (2, 3)) N_s = np.reshape(N_s, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( molecular_density(temperature), N_s, decimal=7) temperature = np.reshape(temperature, (2, 3, 1)) N_s = np.reshape(N_s, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( molecular_density(temperature), N_s, decimal=7) @ignore_numpy_errors @@ -1115,17 +1127,17 @@ def test_n_dimensional_mean_molecular_weights(self): CO2_c = np.tile(CO2_c, 6) m_a = np.tile(m_a, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( mean_molecular_weights(CO2_c), m_a, decimal=7) CO2_c = np.reshape(CO2_c, (2, 3)) m_a = np.reshape(m_a, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( mean_molecular_weights(CO2_c), m_a, decimal=7) CO2_c = np.reshape(CO2_c, (2, 3, 1)) m_a = np.reshape(m_a, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( mean_molecular_weights(CO2_c), m_a, decimal=7) @ignore_numpy_errors @@ -1166,16 +1178,16 @@ def test_n_dimensional_gravity_List1968(self): """ g = 978.03560706 - np.testing.assert_almost_equal(gravity_List1968(), g, decimal=7) + np.testing.assert_array_almost_equal(gravity_List1968(), g, decimal=7) g = np.tile(g, 6) - np.testing.assert_almost_equal(gravity_List1968(), g, decimal=7) + np.testing.assert_array_almost_equal(gravity_List1968(), g, decimal=7) g = np.reshape(g, (2, 3)) - np.testing.assert_almost_equal(gravity_List1968(), g, decimal=7) + np.testing.assert_array_almost_equal(gravity_List1968(), g, decimal=7) g = np.reshape(g, (2, 3, 1)) - np.testing.assert_almost_equal(gravity_List1968(), g, decimal=7) + np.testing.assert_array_almost_equal(gravity_List1968(), g, decimal=7) @ignore_numpy_errors def test_nan_gravity_List1968(self): @@ -1259,15 +1271,15 @@ def test_n_dimensional_scattering_cross_section(self): sigma = scattering_cross_section(wl) sigma = np.tile(sigma, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( scattering_cross_section(wl), sigma, decimal=32) sigma = np.reshape(sigma, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( scattering_cross_section(wl), sigma, decimal=32) sigma = np.reshape(sigma, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( scattering_cross_section(wl), sigma, decimal=32) @ignore_numpy_errors @@ -1378,15 +1390,15 @@ def test_n_dimensional_rayleigh_optical_depth(self): T_R = rayleigh_optical_depth(wl) T_R = np.tile(T_R, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( rayleigh_optical_depth(wl), T_R, decimal=7) T_R = np.reshape(T_R, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( rayleigh_optical_depth(wl), T_R, decimal=7) T_R = np.reshape(T_R, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( rayleigh_optical_depth(wl), T_R, decimal=7) @ignore_numpy_errors @@ -1420,7 +1432,7 @@ def test_sd_rayleigh_scattering(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_rayleigh_scattering().values, DATA_SD_RAYLEIGH_SCATTERING, decimal=7) diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index d79715fe20..50b4a2d24d 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -36,9 +36,9 @@ XYZ_to_xy, xy_to_XYZ) from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Ohno2013 from colour.adaptation import chromatic_adaptation_VonKries -from colour.utilities import as_float_array, domain_range_scale, tsplit -from colour.utilities.documentation import (DocstringTuple, - is_documentation_building) +from colour.utilities import (as_float, as_float_array, domain_range_scale, + tsplit) +from colour.utilities.documentation import DocstringTuple __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -252,6 +252,12 @@ def colour_quality_scale(sd_test, additional_data=False, sd_test.name, Q_a, Q_f, Q_p, Q_g, Q_d, Q_as, (test_vs_colorimetry_data, reference_vs_colorimetry_data)) else: + try: + if Q_a.size == 1: + return as_float(Q_a) + except Exception: + pass + return Q_a @@ -442,7 +448,7 @@ def delta_E_RMS(cqs_data, attribute): return np.sqrt(1 / len(cqs_data) * np.sum( np.array([ - getattr(sample_data, attribute) ** 2 + as_float(getattr(sample_data, attribute)) ** 2 for sample_data in cqs_data.values() ]))) diff --git a/colour/quality/cri.py b/colour/quality/cri.py index 0174d52b6c..e51ed3b5a5 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -28,7 +28,7 @@ from colour.quality.datasets.tcs import INDEXES_TO_NAMES_TCS, SDS_TCS from colour.models import UCS_to_uv, XYZ_to_UCS, XYZ_to_xyY from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Robertson1968 -from colour.utilities import domain_range_scale +from colour.utilities import as_float, domain_range_scale __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -149,6 +149,12 @@ def colour_rendering_index(sd_test, additional_data=False): sd_test.name, Q_a, Q_as, (test_tcs_colorimetry_data, reference_tcs_colorimetry_data)) else: + try: + if Q_a.size == 1: + return as_float(Q_a) + except Exception: + pass + return Q_a diff --git a/colour/quality/ssi.py b/colour/quality/ssi.py index 047c97fc39..3cd54afc69 100644 --- a/colour/quality/ssi.py +++ b/colour/quality/ssi.py @@ -21,7 +21,7 @@ from colour.algebra import LinearInterpolator from colour.colorimetry import SpectralShape -from colour.utilities import zeros +from colour.utilities import as_float, zeros __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -121,4 +121,10 @@ def spectral_similarity_index(sd_test, sd_reference): SSI = np.around(100 - 32 * np.sqrt(m_v)) + try: + if SSI.size == 1: + return as_float(SSI) + except Exception: + pass + return SSI diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index c2b283dcbb..50cefac60c 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -376,7 +376,7 @@ def test_colour_quality_scale(self): additional_data=True, method='NIST CQS 7.4') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [ data.Q_a for _index, data in sorted(specification_r.Q_as.items()) @@ -661,7 +661,7 @@ def test_colour_quality_scale(self): additional_data=True, method='NIST CQS 9.0') - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [ data.Q_a for _index, data in sorted(specification_r.Q_as.items()) diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index dd1b2fdfc8..ff9cd43dae 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -331,7 +331,7 @@ def test_colour_rendering_index(self): specification_t = colour_rendering_index( SDS_ILLUMINANTS['FL1'], additional_data=True) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [ data.Q_a for _index, data in sorted(specification_r.Q_as.items()) diff --git a/colour/recovery/tests/test__init__.py b/colour/recovery/tests/test__init__.py index 6f59c6a812..c62fc4ce71 100644 --- a/colour/recovery/tests/test__init__.py +++ b/colour/recovery/tests/test__init__.py @@ -52,7 +52,7 @@ def test_domain_range_scale_XYZ_to_sd(self): for method, value in zip(m, v): for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( XYZ_to_sd(XYZ * factor_a, method), cmfs), value * factor_b, diff --git a/colour/recovery/tests/test_meng2015.py b/colour/recovery/tests/test_meng2015.py index 59e26c48fd..7f2251f6d6 100644 --- a/colour/recovery/tests/test_meng2015.py +++ b/colour/recovery/tests/test_meng2015.py @@ -42,7 +42,7 @@ def test_XYZ_to_sd_Meng2015(self): cmfs_c = cmfs.copy().align(shape) XYZ = np.array([0.21781186, 0.12541048, 0.04697113]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), cmfs_c) / 100, XYZ, @@ -51,20 +51,20 @@ def test_XYZ_to_sd_Meng2015(self): shape = SpectralShape(cmfs.shape.start, cmfs.shape.end, 10) cmfs_c = cmfs.copy().align(shape) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), cmfs_c) / 100, XYZ, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( XYZ_to_sd_Meng2015(XYZ, cmfs_c, SDS_ILLUMINANTS['D65']), cmfs_c, SDS_ILLUMINANTS['D65']) / 100, XYZ, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( XYZ_to_sd_Meng2015( XYZ, @@ -77,7 +77,7 @@ def test_XYZ_to_sd_Meng2015(self): shape = SpectralShape(400, 700, 5) cmfs_c = cmfs.copy().align(shape) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), cmfs_c) / 100, XYZ, @@ -111,7 +111,7 @@ def test_domain_range_scale_XYZ_to_sd_Meng2015(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( XYZ_to_sd_Meng2015(XYZ_i * factor_a)), XYZ_o * factor_b, diff --git a/colour/recovery/tests/test_smits1999.py b/colour/recovery/tests/test_smits1999.py index 850404054d..2a80cb1600 100644 --- a/colour/recovery/tests/test_smits1999.py +++ b/colour/recovery/tests/test_smits1999.py @@ -35,7 +35,7 @@ def test_RGB_to_sd_Smits1999(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999( np.array([0.21781186, 0.12541048, 0.04697113]))).values, @@ -45,7 +45,7 @@ def test_RGB_to_sd_Smits1999(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999( np.array([0.15434689, 0.22960951, 0.09620221]))).values, @@ -55,7 +55,7 @@ def test_RGB_to_sd_Smits1999(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999( np.array([0.07683480, 0.06006092, 0.25833845]))).values, @@ -65,7 +65,7 @@ def test_RGB_to_sd_Smits1999(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999(np.array([0.0, 1.0, 0.0]))).values, np.array([ @@ -74,7 +74,7 @@ def test_RGB_to_sd_Smits1999(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999(np.array([1.0, 1.0, 0.0]))).values, np.array([ @@ -83,7 +83,7 @@ def test_RGB_to_sd_Smits1999(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_to_sd_Smits1999( XYZ_to_RGB_Smits1999(np.array([0.5, 0.0, 1.0]))).values, np.array([ @@ -105,7 +105,7 @@ def test_domain_range_scale_RGB_to_sd_Smits1999(self): d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( sd_to_XYZ_integration( RGB_to_sd_Smits1999(RGB_i * factor_a)), XYZ_o * factor_b, diff --git a/colour/temperature/mccamy1992.py b/colour/temperature/mccamy1992.py index 19328dac1e..28fd1ba2d8 100644 --- a/colour/temperature/mccamy1992.py +++ b/colour/temperature/mccamy1992.py @@ -25,7 +25,8 @@ from scipy.optimize import minimize from colour.colorimetry import CCS_ILLUMINANTS -from colour.utilities import as_float_array, as_numeric, tsplit, usage_warning +from colour.utilities import (as_float_array, as_float, as_numeric, tsplit, + usage_warning) from colour.utilities.deprecation import handle_arguments_deprecation __author__ = 'Colour Developers' @@ -70,6 +71,12 @@ def xy_to_CCT_McCamy1992(xy): n = (x - 0.3320) / (y - 0.1858) CCT = -449 * n ** 3 + 3525 * n ** 2 - 6823.3 * n + 5520.33 + try: + if CCT.size == 1: + return as_float(CCT) + except Exception: + pass + return CCT diff --git a/colour/temperature/tests/test_cie_d.py b/colour/temperature/tests/test_cie_d.py index bb91624ad9..514ba6178a 100644 --- a/colour/temperature/tests/test_cie_d.py +++ b/colour/temperature/tests/test_cie_d.py @@ -68,11 +68,13 @@ def test_n_dimensional_xy_to_CCT_CIE_D(self): xy = np.tile(xy, (6, 1)) CCT = np.tile(CCT, 6) - np.testing.assert_almost_equal(xy_to_CCT_CIE_D(xy), CCT, decimal=7) + np.testing.assert_array_almost_equal( + xy_to_CCT_CIE_D(xy), CCT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) CCT = np.reshape(CCT, (2, 3)) - np.testing.assert_almost_equal(xy_to_CCT_CIE_D(xy), CCT, decimal=7) + np.testing.assert_array_almost_equal( + xy_to_CCT_CIE_D(xy), CCT, decimal=7) @ignore_numpy_errors def test_nan_xy_to_CCT_CIE_D(self): @@ -98,17 +100,17 @@ def test_CCT_to_xy_CIE_D(self): Tests :func:`colour.temperature.cie_d.CCT_to_xy_CIE_D` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_CIE_D(4000), np.array([0.382343625000000, 0.383766261015578]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_CIE_D(7000), np.array([0.305357431486880, 0.321646345474552]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_CIE_D(25000), np.array([0.24985367, 0.254799464210944]), decimal=7) @@ -124,11 +126,13 @@ def test_n_dimensional_CCT_to_xy_CIE_D(self): CCT = np.tile(CCT, 6) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal(CCT_to_xy_CIE_D(CCT), xy, decimal=7) + np.testing.assert_array_almost_equal( + CCT_to_xy_CIE_D(CCT), xy, decimal=7) CCT = np.reshape(CCT, (2, 3)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal(CCT_to_xy_CIE_D(CCT), xy, decimal=7) + np.testing.assert_array_almost_equal( + CCT_to_xy_CIE_D(CCT), xy, decimal=7) @ignore_numpy_errors def test_nan_CCT_to_xy_CIE_D(self): diff --git a/colour/temperature/tests/test_hernandez1999.py b/colour/temperature/tests/test_hernandez1999.py index 430a141076..1b06a50647 100644 --- a/colour/temperature/tests/test_hernandez1999.py +++ b/colour/temperature/tests/test_hernandez1999.py @@ -61,12 +61,12 @@ def test_n_dimensional_xy_to_CCT_Hernandez1999(self): xy = np.tile(xy, (6, 1)) CCT = np.tile(CCT, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_CCT_Hernandez1999(xy), CCT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) CCT = np.reshape(CCT, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_CCT_Hernandez1999(xy), CCT, decimal=7) @ignore_numpy_errors @@ -94,17 +94,17 @@ def test_CCT_to_xy_Hernandez1999(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Hernandez1999(6500.74204318, {'method': 'Nelder-Mead'}), np.array([0.31269943, 0.32900373]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Hernandez1999(2790.64222533, {'method': 'Nelder-Mead'}), np.array([0.42864308, 0.36754776]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Hernandez1999(64448.11092565, {'method': 'Nelder-Mead'}), np.array([0.08269106, 0.36612620]), decimal=7) @@ -120,12 +120,12 @@ def test_n_dimensional_CCT_to_xy_Hernandez1999(self): CCT = np.tile(CCT, 6) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Hernandez1999(CCT), xy, decimal=7) CCT = np.reshape(CCT, (2, 3)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Hernandez1999(CCT), xy, decimal=7) @ignore_numpy_errors diff --git a/colour/temperature/tests/test_kang2002.py b/colour/temperature/tests/test_kang2002.py index 3627b778a4..be42883792 100644 --- a/colour/temperature/tests/test_kang2002.py +++ b/colour/temperature/tests/test_kang2002.py @@ -69,11 +69,13 @@ def test_n_dimensional_xy_to_CCT_Kang2002(self): uv = np.tile(uv, (6, 1)) CCT = np.tile(CCT, 6) - np.testing.assert_almost_equal(xy_to_CCT_Kang2002(uv), CCT, decimal=7) + np.testing.assert_array_almost_equal( + xy_to_CCT_Kang2002(uv), CCT, decimal=7) uv = np.reshape(uv, (2, 3, 2)) CCT = np.reshape(CCT, (2, 3)) - np.testing.assert_almost_equal(xy_to_CCT_Kang2002(uv), CCT, decimal=7) + np.testing.assert_array_almost_equal( + xy_to_CCT_Kang2002(uv), CCT, decimal=7) @ignore_numpy_errors def test_nan_xy_to_CCT_Kang2002(self): @@ -100,17 +102,17 @@ def test_CCT_to_xy_Kang2002(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Kang2002(4000), np.array([0.380528282812500, 0.376733530961114]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Kang2002(7000), np.array([0.306374019533528, 0.316552869726577]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_Kang2002(25000), np.array([0.252472994438400, 0.252254791243654]), decimal=7) @@ -126,11 +128,13 @@ def test_n_dimensional_CCT_to_xy_Kang2002(self): CCT = np.tile(CCT, 6) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal(CCT_to_xy_Kang2002(CCT), xy, decimal=7) + np.testing.assert_array_almost_equal( + CCT_to_xy_Kang2002(CCT), xy, decimal=7) CCT = np.reshape(CCT, (2, 3)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal(CCT_to_xy_Kang2002(CCT), xy, decimal=7) + np.testing.assert_array_almost_equal( + CCT_to_xy_Kang2002(CCT), xy, decimal=7) @ignore_numpy_errors def test_nan_CCT_to_xy_Kang2002(self): diff --git a/colour/temperature/tests/test_krystek1985.py b/colour/temperature/tests/test_krystek1985.py index da06f283e5..6083fb283f 100644 --- a/colour/temperature/tests/test_krystek1985.py +++ b/colour/temperature/tests/test_krystek1985.py @@ -69,12 +69,12 @@ def test_n_dimensional_uv_to_CCT_Krystek1985(self): uv = np.tile(uv, (6, 1)) CCT = np.tile(CCT, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Krystek1985(uv), CCT, decimal=7) uv = np.reshape(uv, (2, 3, 2)) CCT = np.reshape(CCT, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Krystek1985(uv), CCT, decimal=7) @ignore_numpy_errors @@ -102,17 +102,17 @@ def test_CCT_to_uv_Krystek1985(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Krystek1985(1000), np.array([0.448087794140145, 0.354731965027727]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Krystek1985(7000), np.array([0.198152565091092, 0.307023596915037]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Krystek1985(15000), np.array([0.185675876767054, 0.282233658593898]), decimal=7) @@ -128,12 +128,12 @@ def test_n_dimensional_CCT_to_uv_Krystek1985(self): CCT = np.tile(CCT, 6) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Krystek1985(CCT), uv, decimal=7) CCT = np.reshape(CCT, (2, 3)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Krystek1985(CCT), uv, decimal=7) @ignore_numpy_errors diff --git a/colour/temperature/tests/test_mccamy1992.py b/colour/temperature/tests/test_mccamy1992.py index 1543f2a96d..afa724b534 100644 --- a/colour/temperature/tests/test_mccamy1992.py +++ b/colour/temperature/tests/test_mccamy1992.py @@ -61,12 +61,12 @@ def test_n_dimensional_xy_to_CCT_McCamy1992(self): xy = np.tile(xy, (6, 1)) CCT = np.tile(CCT, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_CCT_McCamy1992(xy), CCT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) CCT = np.reshape(CCT, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( xy_to_CCT_McCamy1992(xy), CCT, decimal=7) @ignore_numpy_errors @@ -94,17 +94,17 @@ def test_CCT_to_xy_McCamy1992(self): definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_McCamy1992(6505.08059131, {'method': 'Nelder-Mead'}), np.array([0.31269945, 0.32900411]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_McCamy1992(2857.28961266, {'method': 'Nelder-Mead'}), np.array([0.42350314, 0.36129253]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_McCamy1992(19501.61953130, {'method': 'Nelder-Mead'}), np.array([0.11173782, 0.36987375]), decimal=7) @@ -120,12 +120,12 @@ def test_n_dimensional_CCT_to_xy_McCamy1992(self): CCT = np.tile(CCT, 6) xy = np.tile(xy, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_McCamy1992(CCT), xy, decimal=7) CCT = np.reshape(CCT, (2, 3)) xy = np.reshape(xy, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_xy_McCamy1992(CCT), xy, decimal=7) @ignore_numpy_errors diff --git a/colour/temperature/tests/test_ohno2013.py b/colour/temperature/tests/test_ohno2013.py index 0b0d71d6fd..92d5734a42 100644 --- a/colour/temperature/tests/test_ohno2013.py +++ b/colour/temperature/tests/test_ohno2013.py @@ -55,7 +55,7 @@ def test_planckian_table(self): cmfs = MSDS_CMFS_STANDARD_OBSERVER[ 'CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( [(x.Ti, x.ui, x.vi, x.di) for x in planckian_table( np.array([0.1978, 0.3122]), cmfs, 1000, 1010, 10)], PLANCKIAN_TABLE) @@ -95,17 +95,17 @@ def test_uv_to_CCT_Ohno2013(self): cmfs = MSDS_CMFS_STANDARD_OBSERVER[ 'CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Ohno2013(np.array([0.1978, 0.3122]), cmfs), np.array([6507.47380460, 0.00322335]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Ohno2013(np.array([0.4328, 0.2883]), cmfs), np.array([1041.68315360, -0.06737802]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Ohno2013(np.array([0.2927, 0.2722]), cmfs, iterations=4), np.array([2452.15316417, -0.08437064]), decimal=7) @@ -121,12 +121,12 @@ def test_n_dimensional_uv_to_CCT_Ohno2013(self): uv = np.tile(uv, (6, 1)) CCT_D_uv = np.tile(CCT_D_uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Ohno2013(uv), CCT_D_uv, decimal=7) uv = np.reshape(uv, (2, 3, 2)) CCT_D_uv = np.reshape(CCT_D_uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Ohno2013(uv), CCT_D_uv, decimal=7) @ignore_numpy_errors @@ -157,17 +157,17 @@ def test_CCT_to_uv_Ohno2013(self): cmfs = MSDS_CMFS_STANDARD_OBSERVER[ 'CIE 1931 2 Degree Standard Observer'] - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Ohno2013(np.array([6507.47380460, 0.00322335]), cmfs), np.array([0.19779997, 0.31219997]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Ohno2013(np.array([1041.68315360, -0.06737802]), cmfs), np.array([0.43279885, 0.28830013]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Ohno2013(np.array([2452.15316417, -0.08437064]), cmfs), np.array([0.29247364, 0.27215157]), decimal=7) @@ -185,12 +185,12 @@ def test_n_dimensional_CCT_to_uv_Ohno2013(self): CCT_D_uv = np.tile(CCT_D_uv, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Ohno2013(CCT_D_uv, cmfs), uv, decimal=7) CCT_D_uv = np.reshape(CCT_D_uv, (2, 3, 2)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Ohno2013(CCT_D_uv, cmfs), uv, decimal=7) @ignore_numpy_errors diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index 75b9c4a69a..f28e573dd4 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -152,12 +152,12 @@ def test_n_dimensional_uv_to_CCT_Robertson1968(self): uv = np.tile(uv, (6, 1)) CCT_D_uv = np.tile(CCT_D_uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Robertson1968(uv), CCT_D_uv, decimal=7) uv = np.reshape(uv, (2, 3, 2)) CCT_D_uv = np.reshape(CCT_D_uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( uv_to_CCT_Robertson1968(uv), CCT_D_uv, decimal=7) @ignore_numpy_errors @@ -187,7 +187,7 @@ def test_CCT_to_uv_Robertson1968(self): """ for key, value in TEMPERATURE_DUV_TO_UV.items(): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Robertson1968(key), value, decimal=7) def test_n_dimensional_CCT_to_uv_Robertson1968(self): @@ -201,12 +201,12 @@ def test_n_dimensional_CCT_to_uv_Robertson1968(self): CCT_D_uv = np.tile(CCT_D_uv, (6, 1)) uv = np.tile(uv, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Robertson1968(CCT_D_uv), uv, decimal=7) CCT_D_uv = np.reshape(CCT_D_uv, (2, 3, 2)) uv = np.reshape(uv, (2, 3, 2)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CCT_to_uv_Robertson1968(CCT_D_uv), uv, decimal=7) @ignore_numpy_errors diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 84e050f5c6..a958078c3a 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -555,7 +555,6 @@ def interval(distribution, unique=True): >>> interval(y, False) array([ 1., 1., 1., 4.]) """ - distribution = as_float_array(distribution) i = np.arange(distribution.size - 1) diff --git a/colour/utilities/metrics.py b/colour/utilities/metrics.py index 12777245b7..8d0bd77cdb 100644 --- a/colour/utilities/metrics.py +++ b/colour/utilities/metrics.py @@ -66,8 +66,14 @@ def metric_mse(a, b, axis=None): >>> metric_mse(a, b) # doctest: +ELLIPSIS 0.0012714... """ - - return np.mean((as_float_array(a) - as_float_array(b)) ** 2, axis=axis) + metric = np.mean((as_float_array(a) - as_float_array(b)) ** 2, axis=axis) + try: + if metric.size == 1: + return metric.item() + except Exception: + pass + + return metric def metric_psnr(a, b, max_a=1, axis=None): diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 5b5e8915ba..335f0f8892 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -49,7 +49,8 @@ def test_as_array(self): Tests :func:`colour.utilities.array.as_array` definition. """ - np.testing.assert_equal(as_array([1, 2, 3]), np.array([1, 2, 3])) + np.testing.assert_array_almost_equal( + as_array([1, 2, 3]), np.array([1, 2, 3])) self.assertEqual( as_array([1, 2, 3], DEFAULT_FLOAT_DTYPE).dtype, @@ -70,7 +71,7 @@ def test_as_int_array(self): Tests :func:`colour.utilities.array.as_int_array` definition. """ - np.testing.assert_equal( + np.testing.assert_array_almost_equal( as_int_array([1.0, 2.0, 3.0]), np.array([1, 2, 3])) self.assertEqual(as_int_array([1, 2, 3]).dtype, DEFAULT_INT_DTYPE) @@ -87,7 +88,8 @@ def test_as_float_array(self): Tests :func:`colour.utilities.array.as_float_array` definition. """ - np.testing.assert_equal(as_float_array([1, 2, 3]), np.array([1, 2, 3])) + np.testing.assert_array_almost_equal( + as_float_array([1, 2, 3]), np.array([1, 2, 3])) self.assertEqual(as_float_array([1, 2, 3]).dtype, DEFAULT_FLOAT_DTYPE) @@ -107,7 +109,7 @@ def test_as_numeric(self): self.assertEqual(as_numeric(np.array([1])), 1.0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( as_numeric(np.array([1, 2, 3])), np.array([1.0, 2.0, 3.0])) self.assertIsInstance(as_numeric(1), DEFAULT_FLOAT_DTYPE) @@ -134,7 +136,7 @@ def test_as_int(self): self.assertEqual(as_int(np.array([1])), 1) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( as_int(np.array([1.0, 2.0, 3.0])), np.array([1, 2, 3])) self.assertEqual( @@ -158,7 +160,7 @@ def test_as_float(self): self.assertEqual(as_float(np.array([1])), 1.0) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( as_float(np.array([1, 2, 3])), np.array([1.0, 2.0, 3.0])) self.assertEqual( @@ -323,7 +325,8 @@ def test_as_namedtuple(self): NamedTuple)) a_r = np.array( - [tuple(a) for a in np.transpose((a_a, a_b, a_c)).tolist()], + [tuple(a) + for a in np.transpose(np.array((a_a, a_b, a_c))).tolist()], dtype=[(str('a'), str('f8')), (str('b'), str('f8')), (str('c'), str('f8'))]) # yapf: disable @@ -388,7 +391,7 @@ def test_closest(self): self.assertEqual(closest(a, 24.90), 25.40026416) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( closest(a, np.array([63.05, 51.15, 24.90])), np.array([62.70988028, 46.84480573, 25.40026416]), decimal=7) @@ -405,12 +408,12 @@ def test_normalise_maximum(self): Tests :func:`colour.utilities.array.normalise_maximum` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum(np.array([0.20654008, 0.12197225, 0.05136952])), np.array([1.00000000, 0.59055003, 0.24871454]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum( np.array([ [0.20654008, 0.12197225, 0.05136952], @@ -424,7 +427,7 @@ def test_normalise_maximum(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum( np.array([ [0.20654008, 0.12197225, 0.05136952], @@ -439,19 +442,19 @@ def test_normalise_maximum(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum( np.array([0.20654008, 0.12197225, 0.05136952]), factor=10), np.array([10.00000000, 5.90550028, 2.48714535]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum( np.array([-0.11518475, -0.10080000, 0.05089373])), np.array([0.00000000, 0.00000000, 1.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( normalise_maximum( np.array([-0.20654008, -0.12197225, 0.05136952]), clip=False), np.array([-4.02067374, -2.37440899, 1.00000000]), @@ -469,16 +472,16 @@ def test_interval(self): Tests :func:`colour.utilities.array.interval` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( interval(range(0, 10, 2)), np.array([2])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( interval(range(0, 10, 2), False), np.array([2, 2, 2, 2])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( interval([1, 2, 3, 4, 6, 6.5]), np.array([0.5, 1.0, 2.0])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( interval([1, 2, 3, 4, 6, 6.5], False), np.array([1.0, 1.0, 1.0, 2.0, 0.5])) @@ -531,15 +534,15 @@ def test_n_dimensional_in_array(self): support. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( in_array(np.array([0.50, 0.60]), np.linspace(0, 10, 101)).shape, np.array([2])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( in_array(np.array([[0.50, 0.60]]), np.linspace(0, 10, 101)).shape, np.array([1, 2])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( in_array(np.array([[0.50], [0.60]]), np.linspace(0, 10, 101)).shape, np.array([2, 1])) @@ -557,10 +560,11 @@ def test_tstack(self): """ a = 0 - np.testing.assert_almost_equal(tstack([a, a, a]), np.array([0, 0, 0])) + np.testing.assert_array_almost_equal( + tstack([a, a, a]), np.array([0, 0, 0])) a = np.arange(0, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tstack([a, a, a]), np.array([ [0, 0, 0], @@ -572,7 +576,7 @@ def test_tstack(self): ])) a = np.reshape(a, (1, 6)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tstack([a, a, a]), np.array([[ [0, 0, 0], @@ -584,7 +588,7 @@ def test_tstack(self): ]])) a = np.reshape(a, (1, 2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tstack([a, a, a]), np.array([[ [[0, 0, 0], [1, 1, 1], [2, 2, 2]], @@ -604,7 +608,7 @@ def test_tsplit(self): """ a = np.array([0, 0, 0]) - np.testing.assert_almost_equal(tsplit(a), np.array([0, 0, 0])) + np.testing.assert_array_almost_equal(tsplit(a), np.array([0, 0, 0])) a = np.array([ [0, 0, 0], [1, 1, 1], @@ -613,7 +617,7 @@ def test_tsplit(self): [4, 4, 4], [5, 5, 5], ]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tsplit(a), np.array([ [0, 1, 2, 3, 4, 5], @@ -624,7 +628,7 @@ def test_tsplit(self): a = np.array([ [[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]], ]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tsplit(a), np.array([ [[0, 1, 2, 3, 4, 5]], @@ -636,7 +640,7 @@ def test_tsplit(self): [[0, 0, 0], [1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4], [5, 5, 5]], ]]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( tsplit(a), np.array([ [[[0, 1, 2], [3, 4, 5]]], @@ -656,7 +660,7 @@ def test_row_as_diagonal(self): Tests :func:`colour.utilities.array.row_as_diagonal` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( row_as_diagonal(np.array( [[0.25891593, 0.07299478, 0.36586996], [0.30851087, 0.37131459, 0.16274825], @@ -705,7 +709,7 @@ def test_dot_vector(self): v = np.array([0.20654008, 0.12197225, 0.05136952]) v = np.tile(v, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( dot_vector(m, v), np.array([ [0.19540944, 0.06203965, 0.05279523], @@ -738,7 +742,7 @@ def test_dot_matrix(self): b = a - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( dot_matrix(a, b), np.array( [[[0.23424208, 1.04184824, -0.27609032], @@ -776,9 +780,9 @@ def test_orient(self): a = np.tile(np.arange(5), (5, 1)) - np.testing.assert_almost_equal(orient(a, 'Null'), a, decimal=7) + np.testing.assert_array_almost_equal(orient(a, 'Null'), a, decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( orient(a, 'Flip'), np.array([ [4, 3, 2, 1, 0], @@ -789,7 +793,7 @@ def test_orient(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( orient(a, 'Flop'), np.array([ [0, 1, 2, 3, 4], @@ -800,7 +804,7 @@ def test_orient(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( orient(a, '90 CW'), np.array([ [0, 0, 0, 0, 0], @@ -811,7 +815,7 @@ def test_orient(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( orient(a, '90 CCW'), np.array([ [4, 4, 4, 4, 4], @@ -822,7 +826,7 @@ def test_orient(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( orient(a, '180'), np.array([ [4, 3, 2, 1, 0], @@ -869,7 +873,7 @@ def test_linear_conversion(self): Tests :func:`colour.utilities.array.linear_conversion` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( linear_conversion( np.linspace(0, 1, 10), np.array([0, 1]), np.array([1, np.pi])), np.array([ @@ -890,7 +894,7 @@ def test_lerp(self): Tests :func:`colour.utilities.array.lerp` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( lerp( np.linspace(0, 1, 10), np.linspace(0, 2, 10), @@ -923,10 +927,10 @@ def test_fill_nan(self): """ a = np.array([0.1, 0.2, np.nan, 0.4, 0.5]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( fill_nan(a), np.array([0.1, 0.2, 0.3, 0.4, 0.5]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( fill_nan(a, method='Constant', default=8.0), np.array([0.1, 0.2, 8.0, 0.4, 0.5]), decimal=7) @@ -964,7 +968,7 @@ def test_zeros(self): Tests :func:`colour.utilities.array.zeros` definition. """ - np.testing.assert_equal(zeros(3), np.zeros(3)) + np.testing.assert_array_almost_equal(zeros(3), np.zeros(3)) class TestOnes(unittest.TestCase): @@ -978,7 +982,7 @@ def test_ones(self): Tests :func:`colour.utilities.array.ones` definition. """ - np.testing.assert_equal(ones(3), np.ones(3)) + np.testing.assert_array_almost_equal(ones(3), np.ones(3)) class TestFull(unittest.TestCase): @@ -992,7 +996,7 @@ def test_full(self): Tests :func:`colour.utilities.array.full` definition. """ - np.testing.assert_equal(full(3, 0.5), np.full(3, 0.5)) + np.testing.assert_array_almost_equal(full(3, 0.5), np.full(3, 0.5)) class TestIndexAlongLastAxis(unittest.TestCase): diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index 6a374a91fd..200eee6d32 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -23,7 +23,7 @@ from colour.constants import DEFAULT_INT_DTYPE from colour.models import (Lab_to_XYZ, RGB_to_XYZ, XYZ_to_Lab, XYZ_to_RGB) from colour.volume import is_within_pointer_gamut, is_within_visible_spectrum -from colour.utilities import as_float_array, multiprocessing_pool +from colour.utilities import as_float, as_float_array, multiprocessing_pool __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -174,8 +174,13 @@ def RGB_colourspace_limits(colourspace, Lab = np.array(Lab) limits = [] - for i in np.arange(3): - limits.append((np.min(Lab[..., i]), np.max(Lab[..., i]))) + if np.__name__ == 'cupy': + for i in np.arange(3): + limits.append((as_float(np.min(Lab[..., i])), + as_float(np.max(Lab[..., i])))) + else: + for i in np.arange(3): + limits.append((np.min(Lab[..., i]), np.max(Lab[..., i]))) return np.array(limits) @@ -254,7 +259,16 @@ def RGB_colourspace_volume_MonteCarlo( Lab_volume = np.product([np.sum(np.abs(x)) for x in limits]) - return Lab_volume * np.sum(results) / (process_samples * processes) + result = Lab_volume * np.sum(np.array(results)) / \ + (process_samples * processes) + + try: + if result.size == 1: + return as_float(result) + except Exception: + pass + + return result def RGB_colourspace_volume_coverage_MonteCarlo( diff --git a/colour/volume/tests/test_macadam_limits.py b/colour/volume/tests/test_macadam_limits.py index 1c032c8e23..718e8a23e3 100644 --- a/colour/volume/tests/test_macadam_limits.py +++ b/colour/volume/tests/test_macadam_limits.py @@ -57,11 +57,13 @@ def test_n_dimensional_is_within_macadam_limits(self): a = np.tile(a, (6, 1)) b = np.tile(b, 6) - np.testing.assert_almost_equal(is_within_macadam_limits(a, 'A'), b) + np.testing.assert_array_almost_equal( + is_within_macadam_limits(a, 'A'), b) a = np.reshape(a, (2, 3, 3)) b = np.reshape(b, (2, 3)) - np.testing.assert_almost_equal(is_within_macadam_limits(a, 'A'), b) + np.testing.assert_array_almost_equal( + is_within_macadam_limits(a, 'A'), b) def test_raise_exception_is_within_macadam_limits(self): """ diff --git a/colour/volume/tests/test_mesh.py b/colour/volume/tests/test_mesh.py index da22a9c65f..f8e34b7b24 100644 --- a/colour/volume/tests/test_mesh.py +++ b/colour/volume/tests/test_mesh.py @@ -73,11 +73,13 @@ def test_n_dimensional_is_within_mesh_volume(self): a = np.tile(a, (6, 1)) b = np.tile(b, 6) - np.testing.assert_almost_equal(is_within_mesh_volume(a, self._mesh), b) + np.testing.assert_array_almost_equal( + is_within_mesh_volume(a, self._mesh), b) a = np.reshape(a, (2, 3, 3)) b = np.reshape(b, (2, 3)) - np.testing.assert_almost_equal(is_within_mesh_volume(a, self._mesh), b) + np.testing.assert_array_almost_equal( + is_within_mesh_volume(a, self._mesh), b) @ignore_numpy_errors def test_nan_is_within_mesh_volume(self): diff --git a/colour/volume/tests/test_pointer_gamut.py b/colour/volume/tests/test_pointer_gamut.py index a825146a64..b68f59fdf6 100644 --- a/colour/volume/tests/test_pointer_gamut.py +++ b/colour/volume/tests/test_pointer_gamut.py @@ -57,11 +57,11 @@ def test_n_dimensional_is_within_pointer_gamut(self): a = np.tile(a, (6, 1)) b = np.tile(b, 6) - np.testing.assert_almost_equal(is_within_pointer_gamut(a), b) + np.testing.assert_array_almost_equal(is_within_pointer_gamut(a), b) a = np.reshape(a, (2, 3, 3)) b = np.reshape(b, (2, 3)) - np.testing.assert_almost_equal(is_within_pointer_gamut(a), b) + np.testing.assert_array_almost_equal(is_within_pointer_gamut(a), b) @ignore_numpy_errors def test_nan_is_within_pointer_gamut(self): diff --git a/colour/volume/tests/test_rgb.py b/colour/volume/tests/test_rgb.py index 213ca49276..1f3b32b49a 100644 --- a/colour/volume/tests/test_rgb.py +++ b/colour/volume/tests/test_rgb.py @@ -60,7 +60,7 @@ def test_RGB_colourspace_limits(self): Tests :func:`colour.volume.rgb.RGB_colourspace_limits` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_limits(RGB_COLOURSPACE_BT709), np.array([ [0.00000000, 100.00000000], @@ -69,7 +69,7 @@ def test_RGB_colourspace_limits(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_limits(RGB_COLOURSPACE_BT2020), np.array([ [0.00000000, 100.00000000], @@ -78,7 +78,7 @@ def test_RGB_colourspace_limits(self): ]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_limits(RGB_COLOURSPACE_ACES2065_1), np.array([ [-58.9920208, 102.4721629], @@ -130,7 +130,7 @@ def test_RGB_colourspace_volume_coverage_MonteCarlo(self): RGB_colourspace_volume_coverage_MonteCarlo` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_volume_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, is_within_pointer_gamut, @@ -157,7 +157,7 @@ def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self): RGB_colourspace_pointer_gamut_coverage_MonteCarlo` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_pointer_gamut_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, 10e3, @@ -183,7 +183,7 @@ def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self): RGB_colourspace_visible_spectrum_coverage_MonteCarlo` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( RGB_colourspace_visible_spectrum_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, 10e3, diff --git a/colour/volume/tests/test_spectrum.py b/colour/volume/tests/test_spectrum.py index 6ed5ef3e18..62ef57b31b 100644 --- a/colour/volume/tests/test_spectrum.py +++ b/colour/volume/tests/test_spectrum.py @@ -159,11 +159,11 @@ def test_n_dimensional_is_within_visible_spectrum(self): a = np.tile(a, (6, 1)) b = np.tile(b, 6) - np.testing.assert_almost_equal(is_within_visible_spectrum(a), b) + np.testing.assert_array_almost_equal(is_within_visible_spectrum(a), b) a = np.reshape(a, (2, 3, 3)) b = np.reshape(b, (2, 3)) - np.testing.assert_almost_equal(is_within_visible_spectrum(a), b) + np.testing.assert_array_almost_equal(is_within_visible_spectrum(a), b) @ignore_numpy_errors def test_nan_is_within_visible_spectrum(self): From 784e17e5a814dd962eac1a9ca37b83d322f1eb96 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Mon, 17 Aug 2020 10:45:12 +0200 Subject: [PATCH 08/17] Fixes for the temperature module --- colour/algebra/interpolation.py | 11 +- colour/colorimetry/tristimulus.py | 2 +- colour/continuous/multi_signals.py | 3 +- colour/continuous/signal.py | 3 +- colour/ndarray/backend.py | 5 +- colour/notation/tests/test_munsell.py | 8 + colour/recovery/meng2015.py | 25 +- colour/temperature/hernandez1999.py | 13 +- colour/temperature/krystek1985.py | 10 + colour/temperature/mccamy1992.py | 13 +- colour/utilities/array.py | 3 +- dpalsd[p | 1419 +++++++++++++++++++++++++ 12 files changed, 1494 insertions(+), 21 deletions(-) create mode 100644 dpalsd[p diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 5f3d8c172f..f3cd9d8c25 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -848,7 +848,7 @@ def x(self, value): """ if value is not None: - value = np.atleast_1d(value).astype(self._dtype) + value = np.array(np.atleast_1d(value).astype(self._dtype)) assert value.ndim == 1, ( '"x" independent variable must have exactly one dimension!') @@ -882,7 +882,7 @@ def y(self, value): """ if value is not None: - value = np.atleast_1d(value).astype(self._dtype) + value = np.array(np.atleast_1d(value).astype(self._dtype)) assert value.ndim == 1, ( '"y" dependent variable must have exactly one dimension!') @@ -907,7 +907,7 @@ def __call__(self, x): x = np.atleast_1d(x).astype(self._dtype) - xi = as_float(self._evaluate(x)) + xi = as_float(self._evaluate(np.array(x))) return xi @@ -1069,13 +1069,12 @@ def x(self, value): """ if value is not None: - value = np.atleast_1d(value).astype(self._dtype) + value = np.array(np.atleast_1d(value).astype(self._dtype)) assert value.ndim == 1, ( '"x" independent variable must have exactly one dimension!') value_interval = interval(value)[0] - xp1 = value[0] - value_interval * 2 xp2 = value[0] - value_interval xp3 = value[-1] + value_interval @@ -1116,7 +1115,7 @@ def y(self, value): """ if value is not None: - value = np.atleast_1d(value).astype(self._dtype) + value = np.array(np.atleast_1d(value).astype(self._dtype)) assert value.ndim == 1, ( '"y" dependent variable must have exactly one dimension!') diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 1151ab37bc..9c51a1aadb 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -489,7 +489,7 @@ def sd_to_XYZ_integration( sd = sd.copy().align(cmfs.shape) S = np.array(illuminant.values) - x_bar, y_bar, z_bar = tsplit(cmfs.values) + x_bar, y_bar, z_bar = tsplit(np.array(cmfs.values)) R = np.array(sd.values) dw = cmfs.shape.interval diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 24eb3f17c6..cd79c13dcc 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -352,7 +352,8 @@ def range(self): """ if self._signals: - return tstack([signal.range for signal in self._signals.values()]) + return tstack( + [np.array(signal.range) for signal in self._signals.values()]) @range.setter def range(self, value): diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index f5cb6f809d..c5c399e251 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -309,7 +309,8 @@ def domain(self, value): 'have different size, "range" variable will be ' 'resized to "domain" variable shape!'.format( self.name)) - self._range = np.resize(self._range, value.shape) + self._range = np.resize( + np.array(self._range), value.shape) self._domain = value self._create_function() diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index a598d2a126..bdf4a51388 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -25,7 +25,7 @@ ] _NDIMENSIONAL_ARRAY_BACKEND = os.environ.get( - 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Numpy').lower() + 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Cupy').lower() def get_ndimensional_array_backend(): @@ -33,7 +33,7 @@ def get_ndimensional_array_backend(): return _NDIMENSIONAL_ARRAY_BACKEND -def _set_ndimensional_array_backend(backend='Numpy'): +def _set_ndimensional_array_backend(backend='Cupy'): global _NDIMENSIONAL_ARRAY_BACKEND backend = str(backend).lower() @@ -103,6 +103,7 @@ def checkForCupy(*args, **kwargs): isinstance(args[i], self._cupy.ndarray): args[i] = self._cupy.asnumpy(args[i]) args = tuple(args) + return failsafe(*args, **kwargs) return checkForCupy diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 42499a8b6a..b56cff8158 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -113,6 +113,11 @@ def _generate_unit_tests_specifications(): # pragma: no cover return specifications, specifications_r +cupy = False +if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True + MUNSELL_SPECIFICATIONS = np.array([ [[7.18927191, 5.34025196, 16.05861170, 3.00000000], [0.16623068, 0.45684550, 0.22399519]], @@ -765,6 +770,9 @@ def _generate_unit_tests_specifications(): # pragma: no cover [0.4320, 0.3118], ] +if cupy is True: + np.set_ndimensional_array_backend('cupy') + class TestMunsellValuePriest1920(unittest.TestCase): """ diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 67791609f3..00ccd6f6f2 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -166,6 +166,13 @@ def XYZ_to_sd_Meng2015( ], }, **kwargs).get('optimisation_kwargs', optimisation_kwargs) + cupy = False + + if np.__name__ == 'cupy': + XYZ = np.asnumpy(XYZ) + np.set_ndimensional_array_backend('numpy') + cupy = True + XYZ = to_domain_1(XYZ) if illuminant.shape != cmfs.shape: @@ -180,7 +187,6 @@ def objective_function(a): """ Objective function. """ - return np.sum(np.diff(a) ** 2) def constraint_function(a): @@ -192,7 +198,7 @@ def constraint_function(a): return sd_to_XYZ_integration( sd, cmfs=cmfs, illuminant=illuminant) - XYZ - wavelengths = sd.wavelengths + wavelengths = np.array(sd.wavelengths) bins = wavelengths.size optimisation_settings = { @@ -209,14 +215,19 @@ def constraint_function(a): if optimisation_kwargs is not None: optimisation_settings.update(optimisation_kwargs) - result = minimize(objective_function, sd.values, **optimisation_settings) - + result = minimize(objective_function, np.array(sd.values), + **optimisation_settings) if not result.success: raise RuntimeError( 'Optimization failed for {0} after {1} iterations: "{2}".'.format( XYZ, result.nit, result.message)) + name = 'Meng (2015) - {0}'.format(XYZ) + returned = result.x + if cupy is True: + np.set_ndimensional_array_backend('cupy') + returned = np.array(returned) + wavelengths = np.array(wavelengths) + return SpectralDistribution( - from_range_100(result.x * 100), - wavelengths, - name='Meng (2015) - {0}'.format(XYZ)) + from_range_100(returned * 100), wavelengths, name=name) diff --git a/colour/temperature/hernandez1999.py b/colour/temperature/hernandez1999.py index 049125b524..65c64c93d4 100644 --- a/colour/temperature/hernandez1999.py +++ b/colour/temperature/hernandez1999.py @@ -140,6 +140,12 @@ def CCT_to_xy_Hernandez1999(CCT, optimisation_kwargs=None, **kwargs): 'computation methods but should be avoided for practical ' 'applications.') + cupy = False + if np.__name__ == 'cupy': + cupy = True + CCT = np.asnumpy(CCT) + np.set_ndimensional_array_backend('numpy') + CCT = as_float_array(CCT) shape = list(CCT.shape) CCT = np.atleast_1d(CCT.reshape([-1, 1])) @@ -165,9 +171,14 @@ def objective_function(xy, CCT): CCT = as_float_array([ minimize( objective_function, - x0=CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65'], + x0=np.array( + CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']), args=(CCT_i, ), **optimisation_settings).x for CCT_i in CCT ]) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + CCT = np.array(CCT) + return as_numeric(CCT.reshape(shape + [2])) diff --git a/colour/temperature/krystek1985.py b/colour/temperature/krystek1985.py index f747a11f53..4270422fea 100644 --- a/colour/temperature/krystek1985.py +++ b/colour/temperature/krystek1985.py @@ -85,6 +85,12 @@ def uv_to_CCT_Krystek1985(uv, optimisation_kwargs=None, **kwargs): 6504.3894290... """ + cupy = False + if np.__name__ == 'cupy': + cupy = True + uv = np.asnumpy(uv) + np.set_ndimensional_array_backend('numpy') + optimisation_kwargs = handle_arguments_deprecation({ 'ArgumentRenamed': [['optimisation_parameters', 'optimisation_kwargs'] ], @@ -120,6 +126,10 @@ def objective_function(CCT, uv): **optimisation_settings).x for uv_i in uv ]) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + CCT = np.array(CCT) + return as_numeric(CCT.reshape(shape[:-1])) diff --git a/colour/temperature/mccamy1992.py b/colour/temperature/mccamy1992.py index 28fd1ba2d8..5e0cd99355 100644 --- a/colour/temperature/mccamy1992.py +++ b/colour/temperature/mccamy1992.py @@ -134,6 +134,12 @@ def CCT_to_xy_McCamy1992(CCT, optimisation_kwargs=None, **kwargs): 'correlated colour temperature computation methods but ' 'should be avoided for practical applications.') + cupy = False + if np.__name__ == 'cupy': + cupy = True + CCT = np.asnumpy(CCT) + np.set_ndimensional_array_backend('numpy') + CCT = as_float_array(CCT) shape = list(CCT.shape) CCT = np.atleast_1d(CCT.reshape([-1, 1])) @@ -159,9 +165,14 @@ def objective_function(xy, CCT): CCT = as_float_array([ minimize( objective_function, - x0=CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65'], + x0=np.array( + CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']), args=(CCT_i, ), **optimisation_settings).x for CCT_i in CCT ]) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + CCT = np.array(CCT) + return as_numeric(CCT.reshape(shape + [2])) diff --git a/colour/utilities/array.py b/colour/utilities/array.py index a958078c3a..1c19f23ccc 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -555,10 +555,11 @@ def interval(distribution, unique=True): >>> interval(y, False) array([ 1., 1., 1., 4.]) """ + distribution = as_float_array(distribution) i = np.arange(distribution.size - 1) - differences = np.abs(distribution[i + 1] - distribution[i]) + if unique: return np.unique(differences) else: diff --git a/dpalsd[p b/dpalsd[p new file mode 100644 index 0000000000..5dac69711d --- /dev/null +++ b/dpalsd[p @@ -0,0 +1,1419 @@ +commit 271c52154cac0491e0fb83396f87e4eb492de282 (HEAD -> feature/ndarray_backend, origin/feature/ndarray_backend) +Author: Omar Wagih +Date: Tue Aug 11 17:31:22 2020 +0200 + + Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube + +diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py +index 83b5fb08..e067b376 100644 +--- a/colour/adaptation/tests/test_cie1994.py ++++ b/colour/adaptation/tests/test_cie1994.py +@@ -35,7 +35,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994( + XYZ_1=np.array([28.00, 21.26, 5.27]), + xy_o1=np.array([0.44760, 0.40740]), +@@ -46,7 +46,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + np.array([24.03379521, 21.15621214, 17.64301199]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994( + XYZ_1=np.array([21.77, 19.18, 16.73]), + xy_o1=np.array([0.31270, 0.32900]), +@@ -57,7 +57,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + np.array([21.12891746, 19.42980532, 19.49577765]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994( + XYZ_1=np.array([0.07818780, 0.06157201, 0.28099326]) * 100, + xy_o1=np.array([0.31270, 0.32900]), +@@ -85,7 +85,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): +  + XYZ_1 = np.tile(XYZ_1, (6, 1)) + XYZ_2 = np.tile(XYZ_2, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), + XYZ_2, + decimal=7) +@@ -95,7 +95,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + Y_o = np.tile(Y_o, 6) + E_o1 = np.tile(E_o1, 6) + E_o2 = np.tile(E_o2, 6) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), + XYZ_2, + decimal=7) +@@ -107,7 +107,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + E_o1 = np.reshape(E_o1, (2, 3)) + E_o2 = np.reshape(E_o2, (2, 3)) + XYZ_2 = np.reshape(XYZ_2, (2, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), + XYZ_2, + decimal=7) +@@ -130,7 +130,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): + d_r = (('reference', 1), (1, 0.01), (100, 1)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_CIE1994(XYZ_1 * factor, xy_o1, xy_o2, + Y_o * factor, E_o1, E_o2), + XYZ_2 * factor, +diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py +index c1081a6a..05e31baf 100644 +--- a/colour/adaptation/tests/test_cmccat2000.py ++++ b/colour/adaptation/tests/test_cmccat2000.py +@@ -41,7 +41,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition unit tests methods. + chromatic_adaptation_forward_CMCCAT2000` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000( + np.array([22.48, 22.74, 8.54]), + np.array([111.15, 100.00, 35.20]), +@@ -49,7 +49,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition. + np.array([19.52698326, 23.06833960, 24.97175229]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000( + np.array([0.14222010, 0.23042768, 0.10495772]) * 100, + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -58,7 +58,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition. + np.array([17.90511171, 22.75299363, 3.79837384]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000( + np.array([0.07818780, 0.06157201, 0.28099326]) * 100, + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -84,7 +84,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays +  + XYZ = np.tile(XYZ, (6, 1)) + XYZ_c = np.tile(XYZ_c, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ_c, +@@ -94,7 +94,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays + XYZ_wr = np.tile(XYZ_wr, (6, 1)) + L_A1 = np.tile(L_A1, 6) + L_A2 = np.tile(L_A2, 6) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ_c, +@@ -106,7 +106,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays + L_A1 = np.reshape(L_A1, (2, 3)) + L_A2 = np.reshape(L_A2, (2, 3)) + XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ_c, +@@ -130,7 +130,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition domain and range scale + d_r = (('reference', 1), (1, 0.01), (100, 1)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_forward_CMCCAT2000( + XYZ * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, + L_A2), +@@ -168,7 +168,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition unit tests methods. + chromatic_adaptation_inverse_CMCCAT2000` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000( + np.array([19.52698326, 23.06833960, 24.97175229]), + np.array([111.15, 100.00, 35.20]), +@@ -176,7 +176,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition. + np.array([22.48, 22.74, 8.54]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000( + np.array([17.90511171, 22.75299363, 3.79837384]), + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -185,7 +185,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition. + np.array([0.14222010, 0.23042768, 0.10495772]) * 100, + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000( + np.array([6.76564344, 5.86585763, 18.40577315]), + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -211,7 +211,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays +  + XYZ_c = np.tile(XYZ_c, (6, 1)) + XYZ = np.tile(XYZ, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ, +@@ -221,7 +221,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays + XYZ_wr = np.tile(XYZ_wr, (6, 1)) + L_A1 = np.tile(L_A1, 6) + L_A2 = np.tile(L_A2, 6) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ, +@@ -233,7 +233,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays + L_A1 = np.reshape(L_A1, (2, 3)) + L_A2 = np.reshape(L_A2, (2, 3)) + XYZ = np.reshape(XYZ, (2, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, + L_A2), + XYZ, +@@ -257,7 +257,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition domain and range scale + d_r = (('reference', 1), (1, 0.01), (100, 1)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_inverse_CMCCAT2000( + XYZ_c * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, + L_A2), +diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py +index 4f52bf45..1fdf535f 100644 +--- a/colour/adaptation/tests/test_fairchild1990.py ++++ b/colour/adaptation/tests/test_fairchild1990.py +@@ -35,7 +35,7 @@ chromatic_adaptation_Fairchild1990` definition unit tests methods. + chromatic_adaptation_Fairchild1990` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990( + np.array([19.53, 23.07, 24.97]), + np.array([111.15, 100.00, 35.20]), +@@ -43,7 +43,7 @@ chromatic_adaptation_Fairchild1990` definition. + np.array([23.32526349, 23.32455819, 76.11593750]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990( + np.array([0.14222010, 0.23042768, 0.10495772]) * 100, + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -51,7 +51,7 @@ chromatic_adaptation_Fairchild1990` definition. + np.array([19.28089326, 22.91583715, 3.42923503]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990( + np.array([0.07818780, 0.06157201, 0.28099326]) * 100, + np.array([0.95045593, 1.00000000, 1.08905775]) * 100, +@@ -73,7 +73,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. +  + XYZ_1 = np.tile(XYZ_1, (6, 1)) + XYZ_c = np.tile(XYZ_c, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), + XYZ_c, + decimal=7) +@@ -81,7 +81,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. + XYZ_n = np.tile(XYZ_n, (6, 1)) + XYZ_r = np.tile(XYZ_r, (6, 1)) + Y_n = np.tile(Y_n, 6) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), + XYZ_c, + decimal=7) +@@ -91,7 +91,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. + XYZ_r = np.reshape(XYZ_r, (2, 3, 3)) + Y_n = np.reshape(Y_n, (2, 3)) + XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), + XYZ_c, + decimal=7) +@@ -111,7 +111,7 @@ chromatic_adaptation_Fairchild1990` definition domain and range scale support. + d_r = (('reference', 1), (1, 0.01), (100, 1)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_Fairchild1990( + XYZ_1 * factor, XYZ_n * factor, XYZ_r * factor, Y_n), + XYZ_c * factor, +diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py +index 3f80eb3e..5e0d63b0 100644 +--- a/colour/adaptation/tests/test_vonkries.py ++++ b/colour/adaptation/tests/test_vonkries.py +@@ -39,7 +39,7 @@ chromatic_adaptation_matrix_VonKries` definition unit tests methods. + chromatic_adaptation_matrix_VonKries` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([0.96429568, 1.00000000, 0.82510460])), +@@ -50,7 +50,7 @@ chromatic_adaptation_matrix_VonKries` definition. + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([1.09846607, 1.00000000, 0.35582280])), +@@ -61,7 +61,7 @@ chromatic_adaptation_matrix_VonKries` definition. + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([0.99144661, 1.00000000, 0.67315942])), +@@ -71,7 +71,7 @@ chromatic_adaptation_matrix_VonKries` definition. + np.array([0.95045593, 1.00000000, 1.08905775]))), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([0.96429568, 1.00000000, 0.82510460]), +@@ -83,7 +83,7 @@ chromatic_adaptation_matrix_VonKries` definition. + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([0.96429568, 1.00000000, 0.82510460]), +@@ -95,7 +95,7 @@ chromatic_adaptation_matrix_VonKries` definition. + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + np.array([0.95045593, 1.00000000, 1.08905775]), + np.array([0.96429568, 1.00000000, 0.82510460]), +@@ -133,13 +133,13 @@ chromatic_adaptation_matrix_VonKries` definition n-dimensional arrays support. + XYZ_w = np.tile(XYZ_w, (6, 1)) + XYZ_wr = np.tile(XYZ_wr, (6, 1)) + M = np.reshape(np.tile(M, (6, 1)), (6, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) +  + XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) + XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) + M = np.reshape(M, (2, 3, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) +  + def test_domain_range_scale_chromatic_adaptation_VonKries(self): +@@ -156,7 +156,7 @@ chromatic_adaptation_matrix_VonKries` definition domain and range scale + d_r = (('reference', 1), (1, 1), (100, 0.01)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_matrix_VonKries( + XYZ_w * factor, XYZ_wr * factor), + M, +@@ -189,7 +189,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.20654008, 0.12197225, 0.05136952]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -197,7 +197,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + np.array([0.21638819, 0.12570000, 0.03847494]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.14222010, 0.23042768, 0.10495772]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -205,7 +205,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + np.array([0.18673833, 0.23111171, 0.03285972]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.07818780, 0.06157201, 0.28099326]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -213,7 +213,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + np.array([0.06385467, 0.05509729, 0.17506386]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.20654008, 0.12197225, 0.05136952]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -222,7 +222,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + np.array([0.20954755, 0.12197225, 0.03891917]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.20654008, 0.12197225, 0.05136952]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -231,7 +231,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + np.array([0.21666003, 0.12604777, 0.03855068]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries( + np.array([0.20654008, 0.12197225, 0.05136952]), + np.array([0.95045593, 1.00000000, 1.08905775]), +@@ -255,7 +255,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + XYZ_w = np.tile(XYZ_w, (6, 1)) + XYZ_wr = np.tile(XYZ_wr, (6, 1)) + XYZ_a = np.tile(XYZ_a, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), + XYZ_a, + decimal=7) +@@ -264,7 +264,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) + XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) + XYZ_a = np.reshape(XYZ_a, (2, 3, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), + XYZ_a, + decimal=7) +@@ -283,7 +283,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): + d_r = (('reference', 1), (1, 1), (100, 0.01)) + for scale, factor in d_r: + with domain_range_scale(scale): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + chromatic_adaptation_VonKries(XYZ * factor, XYZ_w * factor, + XYZ_wr * factor), + XYZ_a * factor, +diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py +index 5b8caf58..867892e4 100644 +--- a/colour/algebra/geometry.py ++++ b/colour/algebra/geometry.py +@@ -41,7 +41,7 @@ import colour.ndarray as np + from collections import namedtuple +  + from colour.utilities import (CaseInsensitiveMapping, as_float_array, ones, +- tsplit, tstack) ++ tsplit, tstack, as_float) +  + __author__ = 'Colour Developers' + __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' +@@ -112,7 +112,12 @@ def euclidean_distance(a, b): + 451.7133019... + """ +  +- return np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) ++ distance = np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) ++ ++ if np.__name__ == 'cupy': ++ return as_float(distance) ++ ++ return distance +  +  + def extend_line_segment(a, b, distance=1): +@@ -518,12 +523,20 @@ def ellipse_fitting_Halir1998(a): + M = S1 + np.dot(S2, T) + M = np.array([M[2, :] / 2, -M[1, :], M[0, :] / 2]) +  +- _w, v = np.linalg.eig(M) ++ if np.__name__ == 'cupy': ++ Mnp = np.asnumpy(M) ++ np.set_ndimensional_array_backend('numpy') ++ _w, v = np.linalg.eig(Mnp) ++ np.set_ndimensional_array_backend('cupy') ++ _w = np.array(_w) ++ v = np.array(v) ++ else: ++ _w, v = np.linalg.eig(M) +  + A1 = v[:, np.nonzero(4 * v[0, :] * v[2, :] - v[1, :] ** 2 > 0)[0]] + A2 = np.dot(T, A1) +  +- A = np.ravel([A1, A2]) ++ A = np.ravel(np.array([A1, A2])) +  + return A +  +diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py +index 2fe19ab8..5f3d8c17 100644 +--- a/colour/algebra/interpolation.py ++++ b/colour/algebra/interpolation.py +@@ -1204,6 +1204,9 @@ class SpragueInterpolator(object): + y = (a0p + a1p * X + a2p * X ** 2 + a3p * X ** 3 + a4p * X ** 4 + + a5p * X ** 5) +  ++ if np.__name__ == 'cupy': ++ return as_float(y) ++ + return y +  + def _validate_dimensions(self): +@@ -1246,13 +1249,24 @@ class CubicSplineInterpolator(scipy.interpolate.interp1d): + if np.__name__ == 'cupy': + args = list(args) + for i in range(len(args)): +- if isinstance(args[i], np.ndarray): ++ if isinstance(args[i], (np.ndarray, tuple)): + args[i] = np.asnumpy(args[i]) + args = tuple(args) +  + super(CubicSplineInterpolator, self).__init__( + kind='cubic', *args, **kwargs) +  ++ def __call__(self, *args, **kwargs): ++ ++ if np.__name__ == 'cupy': ++ args = list(args) ++ for i in range(len(args)): ++ if isinstance(args[i], (np.ndarray, tuple)): ++ args[i] = np.asnumpy(args[i]) ++ args = tuple(args) ++ ++ return super(CubicSplineInterpolator, self).__call__(*args, **kwargs) ++ +  + class PchipInterpolator(scipy.interpolate.PchipInterpolator): + """ +diff --git a/colour/algebra/regression.py b/colour/algebra/regression.py +index afbc7c9c..9da2eb5c 100644 +--- a/colour/algebra/regression.py ++++ b/colour/algebra/regression.py +@@ -66,4 +66,17 @@ def least_square_mapping_MoorePenrose(y, x): + y = np.atleast_2d(y) + x = np.atleast_2d(x) +  ++ if np.__name__ == 'cupy': ++ x = np.asnumpy(x) ++ y = np.asnumpy(y) ++ np.set_ndimensional_array_backend('numpy') ++ try: ++ pinv_y = np.linalg.pinv(np.transpose(y)) ++ result = np.dot(np.transpose(x), pinv_y) ++ np.set_ndimensional_array_backend('cupy') ++ except Exception: ++ np.set_ndimensional_array_backend('cupy') ++ raise ++ return np.array(result) ++ + return np.dot(np.transpose(x), np.linalg.pinv(np.transpose(y))) +diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py +index 98d474fe..100615bc 100644 +--- a/colour/algebra/tests/test_common.py ++++ b/colour/algebra/tests/test_common.py +@@ -111,17 +111,17 @@ class TestSpow(unittest.TestCase): +  + self.assertEqual(spow(-2, 2), -4.0) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + spow([2, -2, -2, 0], [2, 2, 0.15, 0]), + np.array([4.00000000, -4.00000000, -1.10956947, 0.00000000]), + decimal=7) +  + with spow_enable(True): +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + spow(-2, 0.15), -1.10956947, decimal=7) +  + with spow_enable(False): +- np.testing.assert_equal(spow(-2, 0.15), np.nan) ++ np.testing.assert_array_equal(spow(-2, 0.15), np.nan) +  +  + if __name__ == '__main__': +diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py +index af75d527..302b6853 100644 +--- a/colour/algebra/tests/test_extrapolation.py ++++ b/colour/algebra/tests/test_extrapolation.py +@@ -104,13 +104,13 @@ class TestExtrapolator(unittest.TestCase): +  + extrapolator = Extrapolator( + LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7]))) +- np.testing.assert_almost_equal(extrapolator((4, 8)), (4, 8)) ++ np.testing.assert_array_almost_equal(extrapolator((4, 8)), (4, 8)) + self.assertEqual(extrapolator(4), 4) +  + extrapolator = Extrapolator( + LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), + method='Constant') +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extrapolator((0.1, 0.2, 8, 9)), (1, 1, 3, 3)) + self.assertEqual(extrapolator(0.1), 1.) +  +@@ -118,7 +118,7 @@ class TestExtrapolator(unittest.TestCase): + LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), + method='Constant', + left=0) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extrapolator((0.1, 0.2, 8, 9)), (0, 0, 3, 3)) + self.assertEqual(extrapolator(0.1), 0) +  +@@ -126,20 +126,20 @@ class TestExtrapolator(unittest.TestCase): + LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), + method='Constant', + right=0) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extrapolator((0.1, 0.2, 8, 9)), (1, 1, 0, 0)) + self.assertEqual(extrapolator(9), 0) +  + extrapolator = Extrapolator( + CubicSplineInterpolator( + np.array([3, 4, 5, 6]), np.array([1, 2, 3, 4]))) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) + self.assertEqual(extrapolator(9), 7) +  + extrapolator = Extrapolator( + PchipInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3]))) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) + self.assertEqual(extrapolator(9), 7.) +  +diff --git a/colour/algebra/tests/test_geometry.py b/colour/algebra/tests/test_geometry.py +index 81862a06..59f7a855 100644 +--- a/colour/algebra/tests/test_geometry.py ++++ b/colour/algebra/tests/test_geometry.py +@@ -42,17 +42,17 @@ class TestNormaliseVector(unittest.TestCase): + Tests :func:`colour.algebra.geometry.normalise_vector` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + normalise_vector(np.array([0.20654008, 0.12197225, 0.05136952])), + np.array([0.84197033, 0.49722560, 0.20941026]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + normalise_vector(np.array([0.14222010, 0.23042768, 0.10495772])), + np.array([0.48971705, 0.79344877, 0.36140872]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + normalise_vector(np.array([0.07818780, 0.06157201, 0.28099326])), + np.array([0.26229003, 0.20655044, 0.94262445]), + decimal=7) +@@ -103,13 +103,13 @@ class TestEuclideanDistance(unittest.TestCase): + a = np.tile(a, (6, 1)) + b = np.tile(b, (6, 1)) + distance = np.tile(distance, 6) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + euclidean_distance(a, b), distance, decimal=7) +  + a = np.reshape(a, (2, 3, 3)) + b = np.reshape(b, (2, 3, 3)) + distance = np.reshape(distance, (2, 3)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + euclidean_distance(a, b), distance, decimal=7) +  + @ignore_numpy_errors +@@ -138,21 +138,21 @@ class TestExtendLineSegment(unittest.TestCase): + Tests :func:`colour.algebra.geometry.extend_line_segment` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extend_line_segment( + np.array([0.95694934, 0.13720932]), + np.array([0.28382835, 0.60608318])), + np.array([-0.5367248, 1.17765341]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extend_line_segment( + np.array([0.95694934, 0.13720932]), + np.array([0.28382835, 0.60608318]), 5), + np.array([-3.81893739, 3.46393435]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + extend_line_segment( + np.array([0.95694934, 0.13720932]), + np.array([0.28382835, 0.60608318]), -1), +@@ -185,7 +185,7 @@ class TestIntersectLineSegments(unittest.TestCase): +  + s = intersect_line_segments(l_1, l_2) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + s.xy, + np.array([[[np.nan, np.nan], [0.22791841, 0.60064309], + [np.nan, np.nan], [np.nan, np.nan]], +@@ -220,13 +220,13 @@ class TestEllipseCoefficientsCanonicalForm(unittest.TestCase): + ellipse_coefficients_canonical_form` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + ellipse_coefficients_canonical_form( + np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5])), + np.array([0.5, 0.5, 2, 1, 45]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + ellipse_coefficients_canonical_form( + np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0])), + np.array([0.0, 0.0, 1, 1, 0]), +@@ -245,12 +245,12 @@ class TestEllipseCoefficientsGeneralForm(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + ellipse_coefficients_general_form(np.array([0.5, 0.5, 2, 1, 45])), + np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + ellipse_coefficients_general_form(np.array([0.0, 0.0, 1, 1, 0])), + np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0]), + decimal=7) +@@ -268,13 +268,13 @@ class TestPointAtAngleOnEllipse(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + point_at_angle_on_ellipse( + np.array([0, 90, 180, 270]), np.array([0.0, 0.0, 2, 1, 0])), + np.array([[2, 0], [0, 1], [-2, 0], [0, -1]]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + point_at_angle_on_ellipse( + np.linspace(0, 360, 10), np.array([0.5, 0.5, 2, 1, 45])), + np.array([ +@@ -304,7 +304,7 @@ class TestEllipseFittingHalir1998(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + ellipse_fitting_Halir1998( + np.array([[2, 0], [0, 1], [-2, 0], [0, -1]])), + np.array([ +diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py +index 12e0baaa..3d19e96c 100644 +--- a/colour/algebra/tests/test_interpolation.py ++++ b/colour/algebra/tests/test_interpolation.py +@@ -10,22 +10,22 @@ References + """ +  + from __future__ import division, unicode_literals +- +-import colour.ndarray as np +-import os +-import unittest +-from itertools import permutations +- +-from colour.algebra.interpolation import vertices_and_relative_coordinates ++from colour.utilities import ignore_numpy_errors ++from colour.io import read_LUT ++from colour.algebra import random_triplet_generator + from colour.algebra import ( + kernel_nearest_neighbour, kernel_linear, kernel_sinc, kernel_lanczos, + kernel_cardinal_spline, KernelInterpolator, NearestNeighbourInterpolator, + LinearInterpolator, SpragueInterpolator, CubicSplineInterpolator, + PchipInterpolator, NullInterpolator, lagrange_coefficients, + table_interpolation_trilinear, table_interpolation_tetrahedral) +-from colour.algebra import random_triplet_generator +-from colour.io import read_LUT +-from colour.utilities import ignore_numpy_errors ++from colour.algebra.interpolation import vertices_and_relative_coordinates ++ ++import colour.ndarray as np ++import os ++import unittest ++from itertools import permutations ++np.set_ndimensional_array_backend('cupy') +  + __author__ = 'Colour Developers' + __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' +@@ -171,7 +171,7 @@ class TestKernelNearestNeighbour(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_nearest_neighbour(np.linspace(-5, 5, 25)), + np.array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, +@@ -191,7 +191,7 @@ class TestKernelLinear(unittest.TestCase): + Tests :func:`colour.algebra.interpolation.kernel_linear` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_linear(np.linspace(-5, 5, 25)), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -214,7 +214,7 @@ class TestKernelSinc(unittest.TestCase): + Tests :func:`colour.algebra.interpolation.kernel_sinc` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_sinc(np.linspace(-5, 5, 25)), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -225,7 +225,7 @@ class TestKernelSinc(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_sinc(np.linspace(-5, 5, 25), 1), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -248,7 +248,7 @@ class TestKernelLanczos(unittest.TestCase): + Tests :func:`colour.algebra.interpolation.kernel_lanczos` definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_lanczos(np.linspace(-5, 5, 25)), + np.array([ + 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, +@@ -261,7 +261,7 @@ class TestKernelLanczos(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_lanczos(np.linspace(-5, 5, 25), 1), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -285,7 +285,7 @@ class TestKernelCardinalSpline(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_cardinal_spline(np.linspace(-5, 5, 25)), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -296,7 +296,7 @@ class TestKernelCardinalSpline(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_cardinal_spline(np.linspace(-5, 5, 25), 0, 1), + np.array([ + 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, +@@ -344,7 +344,7 @@ class TestKernelInterpolator(unittest.TestCase): + x = y = np.linspace(0, 1, 10) + kernel_interpolator = KernelInterpolator(x, y) +  +- np.testing.assert_equal(kernel_interpolator.x, x) ++ np.testing.assert_array_equal(kernel_interpolator.x, x) +  + def test_y(self): + """ +@@ -355,7 +355,7 @@ class TestKernelInterpolator(unittest.TestCase): + x = y = np.linspace(0, 1, 10) + kernel_interpolator = KernelInterpolator(x, y) +  +- np.testing.assert_equal(kernel_interpolator.y, y) ++ np.testing.assert_array_equal(kernel_interpolator.y, y) +  + def test_window(self): + """ +@@ -430,7 +430,7 @@ padding_kwargs` property. + x_i = np.linspace(11, 25, 25) +  + kernel_interpolator = KernelInterpolator(x, y) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_interpolator(x_i), + np.array([ + 4.43848790, 4.26286480, 3.64640076, 2.77982023, 2.13474499, +@@ -442,7 +442,7 @@ padding_kwargs` property. + decimal=7) +  + kernel_interpolator = KernelInterpolator(x, y, kernel=kernel_sinc) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_interpolator(x_i), + np.array([ + 4.43848790, 4.47570010, 3.84353906, 3.05959493, 2.53514958, +@@ -454,7 +454,7 @@ padding_kwargs` property. + decimal=7) +  + kernel_interpolator = KernelInterpolator(x, y, window=1) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_interpolator(x_i), + np.array([ + 4.43848790, 4.96712277, 4.09584229, 3.23991575, 2.80418924, +@@ -467,7 +467,7 @@ padding_kwargs` property. +  + kernel_interpolator = KernelInterpolator( + x, y, window=1, kernel_kwargs={'a': 1}) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_interpolator(x_i), + np.array([ + 4.43848790, 3.34379320, 3.62463711, 2.34585418, 2.04767083, +@@ -483,7 +483,7 @@ padding_kwargs` property. + 'pad_width': (3, 3), + 'mode': 'mean' + }) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + kernel_interpolator(x_i), + np.array([ + 4.4384879, 4.35723245, 3.62918155, 2.77471295, 2.13474499, +@@ -500,12 +500,12 @@ padding_kwargs` property. + y = np.sin(x_1 / len(x_1) * np.pi * 6) / (x_1 / len(x_1)) + x_i = np.linspace(1, 9, 25) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + KernelInterpolator(x_1, y)(x_i), + KernelInterpolator(x_2, y)(x_i * 10), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + KernelInterpolator(x_1, y)(x_i), + KernelInterpolator(x_3, y)(x_i / 10), + decimal=7) +@@ -630,7 +630,7 @@ class TestLinearInterpolator(unittest.TestCase): + linear_interpolator(value), + places=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + linear_interpolator( + np.arange(0, + len(POINTS_DATA_A) - 1 + interval, interval)), +@@ -720,7 +720,7 @@ class TestSpragueInterpolator(unittest.TestCase): + sprague_interpolator(value), + places=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + sprague_interpolator( + np.arange(0, + len(POINTS_DATA_A) - 1 + interval, interval)), +@@ -773,12 +773,16 @@ CubicSplineInterpolator.__call__` method. + - This class is a wrapper around *scipy.interpolate.interp1d* class + and is assumed to be unit tested thoroughly. + """ +- +- np.testing.assert_almost_equal( ++ print( ++ np.linspace(0, 1, ++ len(POINTS_DATA_A) * 2), ++ type(np.linspace(0, 1, ++ len(POINTS_DATA_A) * 2))) ++ np.testing.assert_array_almost_equal( + CubicSplineInterpolator( + np.linspace(0, 1, len(POINTS_DATA_A)), +- POINTS_DATA_A)(np.linspace(0, 1, +- len(POINTS_DATA_A) * 2)), ++ np.array(POINTS_DATA_A))(np.linspace(0, 1, ++ len(POINTS_DATA_A) * 2)), + CUBIC_SPLINE_INTERPOLATED_POINTS_DATA_A_X2_SAMPLES) +  +  +@@ -844,7 +848,7 @@ class TestNullInterpolator(unittest.TestCase): + x = y = np.linspace(0, 1, 10) + null_interpolator = NullInterpolator(x, y) +  +- np.testing.assert_equal(null_interpolator.x, x) ++ np.testing.assert_array_equal(null_interpolator.x, x) +  + def test_y(self): + """ +@@ -855,7 +859,7 @@ class TestNullInterpolator(unittest.TestCase): + x = y = np.linspace(0, 1, 10) + null_interpolator = NullInterpolator(x, y) +  +- np.testing.assert_equal(null_interpolator.y, y) ++ np.testing.assert_array_equal(null_interpolator.y, y) +  + def test_absolute_tolerance(self): + """ +@@ -866,7 +870,8 @@ absolute_tolerance` property. + x = y = np.linspace(0, 1, 10) + null_interpolator = NullInterpolator(x, y, absolute_tolerance=0.1) +  +- np.testing.assert_equal(null_interpolator.absolute_tolerance, 0.1) ++ np.testing.assert_array_equal(null_interpolator.absolute_tolerance, ++ 0.1) +  + def test_relative_tolerance(self): + """ +@@ -877,7 +882,8 @@ relative_tolerance` property. + x = y = np.linspace(0, 1, 10) + null_interpolator = NullInterpolator(x, y, relative_tolerance=0.1) +  +- np.testing.assert_equal(null_interpolator.relative_tolerance, 0.1) ++ np.testing.assert_array_equal(null_interpolator.relative_tolerance, ++ 0.1) +  + def test_default(self): + """ +@@ -888,7 +894,7 @@ default` property. + x = y = np.linspace(0, 1, 10) + null_interpolator = NullInterpolator(x, y, default=0) +  +- np.testing.assert_equal(null_interpolator.default, 0) ++ np.testing.assert_array_equal(null_interpolator.default, 0) +  + def test_raise_exception___init__(self): + """ +@@ -907,12 +913,12 @@ default` property. +  + x = np.arange(len(POINTS_DATA_A)) + null_interpolator = NullInterpolator(x, POINTS_DATA_A) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), + np.array([np.nan, 12.46, 9.51, np.nan])) +  + null_interpolator = NullInterpolator(x, POINTS_DATA_A, 0.25, 0.25) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), + np.array([12.32, 12.46, 9.51, 4.33])) +  +@@ -968,11 +974,15 @@ class TestLagrangeCoefficients(unittest.TestCase): + :cite:`Fairman1985b` + """ +  +- lc = [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)] +- np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_A, decimal=7) ++ lc = np.array( ++ [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)]) ++ np.testing.assert_array_almost_equal( ++ lc, LAGRANGE_COEFFICIENTS_A, decimal=7) +  +- lc = [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)] +- np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_B, decimal=7) ++ lc = np.array( ++ [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)]) ++ np.testing.assert_array_almost_equal( ++ lc, LAGRANGE_COEFFICIENTS_B, decimal=7) +  +  + class TestVerticesAndRelativeCoordinates(unittest.TestCase): +@@ -992,7 +1002,7 @@ vertices_and_relative_coordinates` definition. + V_xyz = random_triplet_generator(4, random_state=prng) + vertices, V_xyzr = vertices_and_relative_coordinates(V_xyz, LUT_TABLE) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + vertices, + np.array([ + [ +@@ -1044,7 +1054,7 @@ vertices_and_relative_coordinates` definition. + [1.13122500, 0.29792000, 0.29792000], + ], + ])) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + V_xyzr, + np.array([ + [0.90108952, 0.09318647, 0.75894709], +@@ -1070,7 +1080,7 @@ table_interpolation_trilinear` definition. +  + V_xyz = random_triplet_generator(16, random_state=prng) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + table_interpolation_trilinear(V_xyz, LUT_TABLE), + np.array([ + [1.07937594, -0.02773926, 0.55498254], +@@ -1108,7 +1118,7 @@ table_interpolation_tetrahedral` definition. +  + V_xyz = random_triplet_generator(16, random_state=prng) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + table_interpolation_tetrahedral(V_xyz, LUT_TABLE), + np.array([ + [1.08039215, -0.02840092, 0.55855303], +diff --git a/colour/algebra/tests/test_random.py b/colour/algebra/tests/test_random.py +index 75f62f2c..921a10df 100644 +--- a/colour/algebra/tests/test_random.py ++++ b/colour/algebra/tests/test_random.py +@@ -61,7 +61,7 @@ class TestRandomTripletGenerator(unittest.TestCase): + """ +  + prng = np.random.RandomState(4) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + RANDOM_TRIPLETS, + random_triplet_generator(10, random_state=prng), + decimal=7) +diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py +index f9b1f9ff..f1b23d9a 100644 +--- a/colour/algebra/tests/test_regression.py ++++ b/colour/algebra/tests/test_regression.py +@@ -36,7 +36,7 @@ least_square_mapping_MoorePenrose` definition. + y = prng.random_sample((24, 3)) + x = y + (prng.random_sample((24, 3)) - 0.5) * 0.5 +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + least_square_mapping_MoorePenrose(y, x), + np.array([ + [1.05263767, 0.13780789, -0.22763399], +@@ -47,7 +47,7 @@ least_square_mapping_MoorePenrose` definition. +  + y = prng.random_sample((4, 3, 2)) + x = y + (prng.random_sample((4, 3, 2)) - 0.5) * 0.5 +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + least_square_mapping_MoorePenrose(y, x), + np.array([ + [ +diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py +index d13fdd0b..a093636c 100644 +--- a/colour/appearance/ciecam02.py ++++ b/colour/appearance/ciecam02.py +@@ -39,7 +39,7 @@ from colour.constants import EPSILON + from colour.utilities import ( + CaseInsensitiveMapping, as_float_array, as_int_array, as_namedtuple, + as_float, from_range_degrees, dot_matrix, dot_vector, from_range_100, ones, +- to_domain_100, to_domain_degrees, tsplit, tstack, zeros) ++ to_domain_100, to_domain_degrees, tsplit, tstack, zeros, as_int) +  + __author__ = 'Colour Developers' + __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' +@@ -994,7 +994,16 @@ def hue_quadrature(h): +  + # *np.searchsorted* returns an erroneous index if a *nan* is used as input. + h[np.asarray(np.isnan(h))] = 0 +- i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) ++ ++ if np.__name__ == 'cupy': ++ hnp = np.asnumpy(h) ++ h_inp = np.asnumpy(h_i) ++ np.set_ndimensional_array_backend('numpy') ++ i = as_int_array(np.searchsorted(h_inp, hnp, side='left') - 1) ++ np.set_ndimensional_array_backend('cupy') ++ i = as_int(i) ++ else: ++ i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) +  + h_ii = h_i[i] + e_ii = e_i[i] +diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py +index 5bb4e8d2..b2c5d2c4 100644 +--- a/colour/biochemistry/michaelis_menten.py ++++ b/colour/biochemistry/michaelis_menten.py +@@ -17,7 +17,8 @@ References +  + from __future__ import division, unicode_literals +  +-from colour.utilities import as_float_array ++from colour.utilities import as_float_array, as_float ++import colour.ndarray as np +  + __author__ = 'Colour Developers' + __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' +@@ -72,6 +73,9 @@ def reaction_rate_MichealisMenten(S, V_max, K_m): +  + v = (V_max * S) / (K_m + S) +  ++ if np.__name__ == 'cupy' and v.size == 1: ++ return as_float(v) ++ + return v +  +  +@@ -100,10 +104,6 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): + ---------- + :cite:`Wikipedia2003d` +  +- Notes +- ----- +- On CuPy, this returns an array even for length of 1. +- + Examples + -------- + >>> substrate_concentration_MichealisMenten(0.961538461538461, 2.5, 0.8) +@@ -117,4 +117,7 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): +  + S = (v * K_m) / (V_max - v) +  ++ if np.__name__ == 'cupy' and S.size == 1: ++ return as_float(S) ++ + return S +diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py +index 9f39ae7a..f22524c9 100644 +--- a/colour/biochemistry/tests/test_michaelis_menten.py ++++ b/colour/biochemistry/tests/test_michaelis_menten.py +@@ -67,19 +67,19 @@ reaction_rate_MichealisMenten` definition n-dimensional arrays +  + v = np.tile(v, (6, 1)) + S = np.tile(S, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) +  + V_max = np.tile(V_max, (6, 1)) + K_m = np.tile(K_m, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) +  + v = np.reshape(v, (2, 3, 1)) + V_max = np.reshape(V_max, (2, 3, 1)) + K_m = np.reshape(K_m, (2, 3, 1)) + S = np.reshape(S, (2, 3, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) +  + @ignore_numpy_errors +@@ -139,14 +139,14 @@ substrate_concentration_MichealisMenten` definition n-dimensional arrays +  + S = np.tile(S, (6, 1)) + v = np.tile(v, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + substrate_concentration_MichealisMenten(S, V_max, K_m), + v, + decimal=7) +  + V_max = np.tile(V_max, (6, 1)) + K_m = np.tile(K_m, (6, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + substrate_concentration_MichealisMenten(S, V_max, K_m), + v, + decimal=7) +@@ -155,7 +155,7 @@ substrate_concentration_MichealisMenten` definition n-dimensional arrays + V_max = np.reshape(V_max, (2, 3, 1)) + K_m = np.reshape(K_m, (2, 3, 1)) + v = np.reshape(v, (2, 3, 1)) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + substrate_concentration_MichealisMenten(S, V_max, K_m), + v, + decimal=7) +diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py +index 3f3541b2..06c70c82 100644 +--- a/colour/blindness/tests/test_machado2009.py ++++ b/colour/blindness/tests/test_machado2009.py +@@ -41,43 +41,43 @@ anomalous_trichromacy_cmfs_Machado2009` definition. + """ +  + cmfs = LMS_CMFS.get('Smith & Pokorny 1975 Normal Trichromats') +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, + np.array([0, 0, 0], ))[450], + cmfs[450], + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, + np.array([1, 0, 0], ))[450], + np.array([0.03631700, 0.06350000, 0.91000000]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, + np.array([0, 1, 0], ))[450], + np.array([0.03430000, 0.06178404, 0.91000000]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, + np.array([0, 0, 1], ))[450], + np.array([0.03430000, 0.06350000, 0.92270240]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( + [10, 0, 0], ))[450], + np.array([0.05447001, 0.06350000, 0.91000000]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( + [0, 10, 0], ))[450], + np.array([0.03430000, 0.04634036, 0.91000000]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( + [0, 0, 10], ))[450], + np.array([0.03430000, 0.06350000, 1.00000000]), +@@ -98,7 +98,7 @@ anomalous_trichromacy_matrix_Machado2009` definition. +  + cmfs = LMS_CMFS.get('Smith & Pokorny 1975 Normal Trichromats') + primaries = DISPLAY_RGB_PRIMARIES['Typical CRT Brainard 1997'] +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + anomalous_trichromacy_matrix_Machado2009(cmfs, primaries, + np.array([0, 0, 0])), + np.identity(3), +@@ -159,7 +159,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): + definition. + """ +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + cvd_matrix_Machado2009('Protanomaly', 0.0), + np.array([ + [1, 0, 0], +@@ -168,7 +168,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + cvd_matrix_Machado2009('Deuteranomaly', 0.1), + np.array([ + [0.86643500, 0.17770400, -0.04413900], +@@ -177,7 +177,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + cvd_matrix_Machado2009('Tritanomaly', 1.0), + np.array([ + [1.25552800, -0.07674900, -0.17877900], +@@ -186,7 +186,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): + ]), + decimal=7) +  +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + cvd_matrix_Machado2009('Tritanomaly', 0.55), + np.array([ + [1.06088700, -0.01504350, -0.04584350], +diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py +index 09337bad..4c41c30c 100644 +--- a/colour/characterisation/correction.py ++++ b/colour/characterisation/correction.py +@@ -215,6 +215,7 @@ def polynomial_expansion_Finlayson2015(RGB, + 0.1051335...]) + """ +  ++ RGB = np.array(RGB) + R, G, B = tsplit(RGB) +  + # TODO: Generalise polynomial expansion. +@@ -772,6 +773,8 @@ def colour_correction_Vandermonde(RGB, M_T, M_R, degree=1): + array([ 0.2128689..., 0.1106242..., 0.036213 ...]) + """ +  ++ M_T = np.array((M_T)) ++ M_R = np.array((M_R)) + RGB = as_float_array(RGB) + shape = RGB.shape +  +diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py +index d7ae029e..324b5571 100644 +--- a/colour/characterisation/tests/test_aces_it.py ++++ b/colour/characterisation/tests/test_aces_it.py +@@ -64,39 +64,39 @@ sd_to_aces_relative_exposure_values` definition. +  + shape = ACES_RICD.shape + grey_reflector = sd_constant(0.18, shape) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + sd_to_aces_relative_exposure_values(grey_reflector), + np.array([0.18, 0.18, 0.18]), + decimal=7) +  + perfect_reflector = sd_ones(shape) +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + sd_to_aces_relative_exposure_values(perfect_reflector), + np.array([0.97783784, 0.97783784, 0.97783784]), + decimal=7) +  + dark_skin = COLOURCHECKER_SDS['ColorChecker N Ohta']['dark skin'] +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + sd_to_aces_relative_exposure_values(dark_skin), + np.array([0.11718149, 0.08663609, 0.05897268]), + decimal=7) +  + dark_skin = COLOURCHECKER_SDS['ColorChecker N Ohta']['dark skin'] +- np.testing.assert_almost_equal( ++ np.testing.assert_array_almost_equal( + sd_to_aces_relative_exposure_values(dark_skin, + ILLUMINANT_SDS['A']), + np.array([0.13583991, 0.09431845, 0.05928214]), + decimal=7) +  + dark_skin = COLOU \ No newline at end of file From 35fa8d3115c23a7f203c8a7623e8702297e2ba7e Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Mon, 17 Aug 2020 10:45:48 +0200 Subject: [PATCH 09/17] Fixes for the temperature module --- dpalsd[p | 1419 ------------------------------------------------------ 1 file changed, 1419 deletions(-) delete mode 100644 dpalsd[p diff --git a/dpalsd[p b/dpalsd[p deleted file mode 100644 index 5dac69711d..0000000000 --- a/dpalsd[p +++ /dev/null @@ -1,1419 +0,0 @@ -commit 271c52154cac0491e0fb83396f87e4eb492de282 (HEAD -> feature/ndarray_backend, origin/feature/ndarray_backend) -Author: Omar Wagih -Date: Tue Aug 11 17:31:22 2020 +0200 - - Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube - -diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py -index 83b5fb08..e067b376 100644 ---- a/colour/adaptation/tests/test_cie1994.py -+++ b/colour/adaptation/tests/test_cie1994.py -@@ -35,7 +35,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994( - XYZ_1=np.array([28.00, 21.26, 5.27]), - xy_o1=np.array([0.44760, 0.40740]), -@@ -46,7 +46,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - np.array([24.03379521, 21.15621214, 17.64301199]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994( - XYZ_1=np.array([21.77, 19.18, 16.73]), - xy_o1=np.array([0.31270, 0.32900]), -@@ -57,7 +57,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - np.array([21.12891746, 19.42980532, 19.49577765]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994( - XYZ_1=np.array([0.07818780, 0.06157201, 0.28099326]) * 100, - xy_o1=np.array([0.31270, 0.32900]), -@@ -85,7 +85,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): -  - XYZ_1 = np.tile(XYZ_1, (6, 1)) - XYZ_2 = np.tile(XYZ_2, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), - XYZ_2, - decimal=7) -@@ -95,7 +95,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - Y_o = np.tile(Y_o, 6) - E_o1 = np.tile(E_o1, 6) - E_o2 = np.tile(E_o2, 6) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), - XYZ_2, - decimal=7) -@@ -107,7 +107,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - E_o1 = np.reshape(E_o1, (2, 3)) - E_o2 = np.reshape(E_o2, (2, 3)) - XYZ_2 = np.reshape(XYZ_2, (2, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), - XYZ_2, - decimal=7) -@@ -130,7 +130,7 @@ class TestChromaticAdaptationCIE1994(unittest.TestCase): - d_r = (('reference', 1), (1, 0.01), (100, 1)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_CIE1994(XYZ_1 * factor, xy_o1, xy_o2, - Y_o * factor, E_o1, E_o2), - XYZ_2 * factor, -diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py -index c1081a6a..05e31baf 100644 ---- a/colour/adaptation/tests/test_cmccat2000.py -+++ b/colour/adaptation/tests/test_cmccat2000.py -@@ -41,7 +41,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition unit tests methods. - chromatic_adaptation_forward_CMCCAT2000` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000( - np.array([22.48, 22.74, 8.54]), - np.array([111.15, 100.00, 35.20]), -@@ -49,7 +49,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition. - np.array([19.52698326, 23.06833960, 24.97175229]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000( - np.array([0.14222010, 0.23042768, 0.10495772]) * 100, - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -58,7 +58,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition. - np.array([17.90511171, 22.75299363, 3.79837384]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000( - np.array([0.07818780, 0.06157201, 0.28099326]) * 100, - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -84,7 +84,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays -  - XYZ = np.tile(XYZ, (6, 1)) - XYZ_c = np.tile(XYZ_c, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ_c, -@@ -94,7 +94,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays - XYZ_wr = np.tile(XYZ_wr, (6, 1)) - L_A1 = np.tile(L_A1, 6) - L_A2 = np.tile(L_A2, 6) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ_c, -@@ -106,7 +106,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays - L_A1 = np.reshape(L_A1, (2, 3)) - L_A2 = np.reshape(L_A2, (2, 3)) - XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ_c, -@@ -130,7 +130,7 @@ chromatic_adaptation_forward_CMCCAT2000` definition domain and range scale - d_r = (('reference', 1), (1, 0.01), (100, 1)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_forward_CMCCAT2000( - XYZ * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, - L_A2), -@@ -168,7 +168,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition unit tests methods. - chromatic_adaptation_inverse_CMCCAT2000` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000( - np.array([19.52698326, 23.06833960, 24.97175229]), - np.array([111.15, 100.00, 35.20]), -@@ -176,7 +176,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition. - np.array([22.48, 22.74, 8.54]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000( - np.array([17.90511171, 22.75299363, 3.79837384]), - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -185,7 +185,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition. - np.array([0.14222010, 0.23042768, 0.10495772]) * 100, - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000( - np.array([6.76564344, 5.86585763, 18.40577315]), - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -211,7 +211,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays -  - XYZ_c = np.tile(XYZ_c, (6, 1)) - XYZ = np.tile(XYZ, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ, -@@ -221,7 +221,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays - XYZ_wr = np.tile(XYZ_wr, (6, 1)) - L_A1 = np.tile(L_A1, 6) - L_A2 = np.tile(L_A2, 6) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ, -@@ -233,7 +233,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays - L_A1 = np.reshape(L_A1, (2, 3)) - L_A2 = np.reshape(L_A2, (2, 3)) - XYZ = np.reshape(XYZ, (2, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000(XYZ_c, XYZ_w, XYZ_wr, L_A1, - L_A2), - XYZ, -@@ -257,7 +257,7 @@ chromatic_adaptation_inverse_CMCCAT2000` definition domain and range scale - d_r = (('reference', 1), (1, 0.01), (100, 1)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_inverse_CMCCAT2000( - XYZ_c * factor, XYZ_w * factor, XYZ_wr * factor, L_A1, - L_A2), -diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py -index 4f52bf45..1fdf535f 100644 ---- a/colour/adaptation/tests/test_fairchild1990.py -+++ b/colour/adaptation/tests/test_fairchild1990.py -@@ -35,7 +35,7 @@ chromatic_adaptation_Fairchild1990` definition unit tests methods. - chromatic_adaptation_Fairchild1990` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990( - np.array([19.53, 23.07, 24.97]), - np.array([111.15, 100.00, 35.20]), -@@ -43,7 +43,7 @@ chromatic_adaptation_Fairchild1990` definition. - np.array([23.32526349, 23.32455819, 76.11593750]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990( - np.array([0.14222010, 0.23042768, 0.10495772]) * 100, - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -51,7 +51,7 @@ chromatic_adaptation_Fairchild1990` definition. - np.array([19.28089326, 22.91583715, 3.42923503]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990( - np.array([0.07818780, 0.06157201, 0.28099326]) * 100, - np.array([0.95045593, 1.00000000, 1.08905775]) * 100, -@@ -73,7 +73,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. -  - XYZ_1 = np.tile(XYZ_1, (6, 1)) - XYZ_c = np.tile(XYZ_c, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), - XYZ_c, - decimal=7) -@@ -81,7 +81,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. - XYZ_n = np.tile(XYZ_n, (6, 1)) - XYZ_r = np.tile(XYZ_r, (6, 1)) - Y_n = np.tile(Y_n, 6) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), - XYZ_c, - decimal=7) -@@ -91,7 +91,7 @@ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. - XYZ_r = np.reshape(XYZ_r, (2, 3, 3)) - Y_n = np.reshape(Y_n, (2, 3)) - XYZ_c = np.reshape(XYZ_c, (2, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n), - XYZ_c, - decimal=7) -@@ -111,7 +111,7 @@ chromatic_adaptation_Fairchild1990` definition domain and range scale support. - d_r = (('reference', 1), (1, 0.01), (100, 1)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_Fairchild1990( - XYZ_1 * factor, XYZ_n * factor, XYZ_r * factor, Y_n), - XYZ_c * factor, -diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py -index 3f80eb3e..5e0d63b0 100644 ---- a/colour/adaptation/tests/test_vonkries.py -+++ b/colour/adaptation/tests/test_vonkries.py -@@ -39,7 +39,7 @@ chromatic_adaptation_matrix_VonKries` definition unit tests methods. - chromatic_adaptation_matrix_VonKries` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([0.96429568, 1.00000000, 0.82510460])), -@@ -50,7 +50,7 @@ chromatic_adaptation_matrix_VonKries` definition. - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([1.09846607, 1.00000000, 0.35582280])), -@@ -61,7 +61,7 @@ chromatic_adaptation_matrix_VonKries` definition. - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([0.99144661, 1.00000000, 0.67315942])), -@@ -71,7 +71,7 @@ chromatic_adaptation_matrix_VonKries` definition. - np.array([0.95045593, 1.00000000, 1.08905775]))), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([0.96429568, 1.00000000, 0.82510460]), -@@ -83,7 +83,7 @@ chromatic_adaptation_matrix_VonKries` definition. - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([0.96429568, 1.00000000, 0.82510460]), -@@ -95,7 +95,7 @@ chromatic_adaptation_matrix_VonKries` definition. - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - np.array([0.95045593, 1.00000000, 1.08905775]), - np.array([0.96429568, 1.00000000, 0.82510460]), -@@ -133,13 +133,13 @@ chromatic_adaptation_matrix_VonKries` definition n-dimensional arrays support. - XYZ_w = np.tile(XYZ_w, (6, 1)) - XYZ_wr = np.tile(XYZ_wr, (6, 1)) - M = np.reshape(np.tile(M, (6, 1)), (6, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) -  - XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) - XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) - M = np.reshape(M, (2, 3, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr), M, decimal=7) -  - def test_domain_range_scale_chromatic_adaptation_VonKries(self): -@@ -156,7 +156,7 @@ chromatic_adaptation_matrix_VonKries` definition domain and range scale - d_r = (('reference', 1), (1, 1), (100, 0.01)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_matrix_VonKries( - XYZ_w * factor, XYZ_wr * factor), - M, -@@ -189,7 +189,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.20654008, 0.12197225, 0.05136952]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -197,7 +197,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - np.array([0.21638819, 0.12570000, 0.03847494]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.14222010, 0.23042768, 0.10495772]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -205,7 +205,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - np.array([0.18673833, 0.23111171, 0.03285972]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.07818780, 0.06157201, 0.28099326]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -213,7 +213,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - np.array([0.06385467, 0.05509729, 0.17506386]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.20654008, 0.12197225, 0.05136952]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -222,7 +222,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - np.array([0.20954755, 0.12197225, 0.03891917]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.20654008, 0.12197225, 0.05136952]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -231,7 +231,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - np.array([0.21666003, 0.12604777, 0.03855068]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries( - np.array([0.20654008, 0.12197225, 0.05136952]), - np.array([0.95045593, 1.00000000, 1.08905775]), -@@ -255,7 +255,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - XYZ_w = np.tile(XYZ_w, (6, 1)) - XYZ_wr = np.tile(XYZ_wr, (6, 1)) - XYZ_a = np.tile(XYZ_a, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), - XYZ_a, - decimal=7) -@@ -264,7 +264,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) - XYZ_wr = np.reshape(XYZ_wr, (2, 3, 3)) - XYZ_a = np.reshape(XYZ_a, (2, 3, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr), - XYZ_a, - decimal=7) -@@ -283,7 +283,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): - d_r = (('reference', 1), (1, 1), (100, 0.01)) - for scale, factor in d_r: - with domain_range_scale(scale): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - chromatic_adaptation_VonKries(XYZ * factor, XYZ_w * factor, - XYZ_wr * factor), - XYZ_a * factor, -diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py -index 5b8caf58..867892e4 100644 ---- a/colour/algebra/geometry.py -+++ b/colour/algebra/geometry.py -@@ -41,7 +41,7 @@ import colour.ndarray as np - from collections import namedtuple -  - from colour.utilities import (CaseInsensitiveMapping, as_float_array, ones, -- tsplit, tstack) -+ tsplit, tstack, as_float) -  - __author__ = 'Colour Developers' - __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' -@@ -112,7 +112,12 @@ def euclidean_distance(a, b): - 451.7133019... - """ -  -- return np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) -+ distance = np.linalg.norm(as_float_array(a) - as_float_array(b), axis=-1) -+ -+ if np.__name__ == 'cupy': -+ return as_float(distance) -+ -+ return distance -  -  - def extend_line_segment(a, b, distance=1): -@@ -518,12 +523,20 @@ def ellipse_fitting_Halir1998(a): - M = S1 + np.dot(S2, T) - M = np.array([M[2, :] / 2, -M[1, :], M[0, :] / 2]) -  -- _w, v = np.linalg.eig(M) -+ if np.__name__ == 'cupy': -+ Mnp = np.asnumpy(M) -+ np.set_ndimensional_array_backend('numpy') -+ _w, v = np.linalg.eig(Mnp) -+ np.set_ndimensional_array_backend('cupy') -+ _w = np.array(_w) -+ v = np.array(v) -+ else: -+ _w, v = np.linalg.eig(M) -  - A1 = v[:, np.nonzero(4 * v[0, :] * v[2, :] - v[1, :] ** 2 > 0)[0]] - A2 = np.dot(T, A1) -  -- A = np.ravel([A1, A2]) -+ A = np.ravel(np.array([A1, A2])) -  - return A -  -diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py -index 2fe19ab8..5f3d8c17 100644 ---- a/colour/algebra/interpolation.py -+++ b/colour/algebra/interpolation.py -@@ -1204,6 +1204,9 @@ class SpragueInterpolator(object): - y = (a0p + a1p * X + a2p * X ** 2 + a3p * X ** 3 + a4p * X ** 4 + - a5p * X ** 5) -  -+ if np.__name__ == 'cupy': -+ return as_float(y) -+ - return y -  - def _validate_dimensions(self): -@@ -1246,13 +1249,24 @@ class CubicSplineInterpolator(scipy.interpolate.interp1d): - if np.__name__ == 'cupy': - args = list(args) - for i in range(len(args)): -- if isinstance(args[i], np.ndarray): -+ if isinstance(args[i], (np.ndarray, tuple)): - args[i] = np.asnumpy(args[i]) - args = tuple(args) -  - super(CubicSplineInterpolator, self).__init__( - kind='cubic', *args, **kwargs) -  -+ def __call__(self, *args, **kwargs): -+ -+ if np.__name__ == 'cupy': -+ args = list(args) -+ for i in range(len(args)): -+ if isinstance(args[i], (np.ndarray, tuple)): -+ args[i] = np.asnumpy(args[i]) -+ args = tuple(args) -+ -+ return super(CubicSplineInterpolator, self).__call__(*args, **kwargs) -+ -  - class PchipInterpolator(scipy.interpolate.PchipInterpolator): - """ -diff --git a/colour/algebra/regression.py b/colour/algebra/regression.py -index afbc7c9c..9da2eb5c 100644 ---- a/colour/algebra/regression.py -+++ b/colour/algebra/regression.py -@@ -66,4 +66,17 @@ def least_square_mapping_MoorePenrose(y, x): - y = np.atleast_2d(y) - x = np.atleast_2d(x) -  -+ if np.__name__ == 'cupy': -+ x = np.asnumpy(x) -+ y = np.asnumpy(y) -+ np.set_ndimensional_array_backend('numpy') -+ try: -+ pinv_y = np.linalg.pinv(np.transpose(y)) -+ result = np.dot(np.transpose(x), pinv_y) -+ np.set_ndimensional_array_backend('cupy') -+ except Exception: -+ np.set_ndimensional_array_backend('cupy') -+ raise -+ return np.array(result) -+ - return np.dot(np.transpose(x), np.linalg.pinv(np.transpose(y))) -diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py -index 98d474fe..100615bc 100644 ---- a/colour/algebra/tests/test_common.py -+++ b/colour/algebra/tests/test_common.py -@@ -111,17 +111,17 @@ class TestSpow(unittest.TestCase): -  - self.assertEqual(spow(-2, 2), -4.0) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - spow([2, -2, -2, 0], [2, 2, 0.15, 0]), - np.array([4.00000000, -4.00000000, -1.10956947, 0.00000000]), - decimal=7) -  - with spow_enable(True): -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - spow(-2, 0.15), -1.10956947, decimal=7) -  - with spow_enable(False): -- np.testing.assert_equal(spow(-2, 0.15), np.nan) -+ np.testing.assert_array_equal(spow(-2, 0.15), np.nan) -  -  - if __name__ == '__main__': -diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py -index af75d527..302b6853 100644 ---- a/colour/algebra/tests/test_extrapolation.py -+++ b/colour/algebra/tests/test_extrapolation.py -@@ -104,13 +104,13 @@ class TestExtrapolator(unittest.TestCase): -  - extrapolator = Extrapolator( - LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7]))) -- np.testing.assert_almost_equal(extrapolator((4, 8)), (4, 8)) -+ np.testing.assert_array_almost_equal(extrapolator((4, 8)), (4, 8)) - self.assertEqual(extrapolator(4), 4) -  - extrapolator = Extrapolator( - LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), - method='Constant') -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extrapolator((0.1, 0.2, 8, 9)), (1, 1, 3, 3)) - self.assertEqual(extrapolator(0.1), 1.) -  -@@ -118,7 +118,7 @@ class TestExtrapolator(unittest.TestCase): - LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), - method='Constant', - left=0) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extrapolator((0.1, 0.2, 8, 9)), (0, 0, 3, 3)) - self.assertEqual(extrapolator(0.1), 0) -  -@@ -126,20 +126,20 @@ class TestExtrapolator(unittest.TestCase): - LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), - method='Constant', - right=0) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extrapolator((0.1, 0.2, 8, 9)), (1, 1, 0, 0)) - self.assertEqual(extrapolator(9), 0) -  - extrapolator = Extrapolator( - CubicSplineInterpolator( - np.array([3, 4, 5, 6]), np.array([1, 2, 3, 4]))) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) - self.assertEqual(extrapolator(9), 7) -  - extrapolator = Extrapolator( - PchipInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3]))) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extrapolator((0.1, 0.2, 8.0, 9.0)), (-1.9, -1.8, 6.0, 7.0)) - self.assertEqual(extrapolator(9), 7.) -  -diff --git a/colour/algebra/tests/test_geometry.py b/colour/algebra/tests/test_geometry.py -index 81862a06..59f7a855 100644 ---- a/colour/algebra/tests/test_geometry.py -+++ b/colour/algebra/tests/test_geometry.py -@@ -42,17 +42,17 @@ class TestNormaliseVector(unittest.TestCase): - Tests :func:`colour.algebra.geometry.normalise_vector` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - normalise_vector(np.array([0.20654008, 0.12197225, 0.05136952])), - np.array([0.84197033, 0.49722560, 0.20941026]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - normalise_vector(np.array([0.14222010, 0.23042768, 0.10495772])), - np.array([0.48971705, 0.79344877, 0.36140872]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - normalise_vector(np.array([0.07818780, 0.06157201, 0.28099326])), - np.array([0.26229003, 0.20655044, 0.94262445]), - decimal=7) -@@ -103,13 +103,13 @@ class TestEuclideanDistance(unittest.TestCase): - a = np.tile(a, (6, 1)) - b = np.tile(b, (6, 1)) - distance = np.tile(distance, 6) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - euclidean_distance(a, b), distance, decimal=7) -  - a = np.reshape(a, (2, 3, 3)) - b = np.reshape(b, (2, 3, 3)) - distance = np.reshape(distance, (2, 3)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - euclidean_distance(a, b), distance, decimal=7) -  - @ignore_numpy_errors -@@ -138,21 +138,21 @@ class TestExtendLineSegment(unittest.TestCase): - Tests :func:`colour.algebra.geometry.extend_line_segment` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extend_line_segment( - np.array([0.95694934, 0.13720932]), - np.array([0.28382835, 0.60608318])), - np.array([-0.5367248, 1.17765341]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extend_line_segment( - np.array([0.95694934, 0.13720932]), - np.array([0.28382835, 0.60608318]), 5), - np.array([-3.81893739, 3.46393435]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - extend_line_segment( - np.array([0.95694934, 0.13720932]), - np.array([0.28382835, 0.60608318]), -1), -@@ -185,7 +185,7 @@ class TestIntersectLineSegments(unittest.TestCase): -  - s = intersect_line_segments(l_1, l_2) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - s.xy, - np.array([[[np.nan, np.nan], [0.22791841, 0.60064309], - [np.nan, np.nan], [np.nan, np.nan]], -@@ -220,13 +220,13 @@ class TestEllipseCoefficientsCanonicalForm(unittest.TestCase): - ellipse_coefficients_canonical_form` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - ellipse_coefficients_canonical_form( - np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5])), - np.array([0.5, 0.5, 2, 1, 45]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - ellipse_coefficients_canonical_form( - np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0])), - np.array([0.0, 0.0, 1, 1, 0]), -@@ -245,12 +245,12 @@ class TestEllipseCoefficientsGeneralForm(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - ellipse_coefficients_general_form(np.array([0.5, 0.5, 2, 1, 45])), - np.array([2.5, -3.0, 2.5, -1.0, -1.0, -3.5]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - ellipse_coefficients_general_form(np.array([0.0, 0.0, 1, 1, 0])), - np.array([1.0, 0.0, 1.0, 0.0, 0.0, -1.0]), - decimal=7) -@@ -268,13 +268,13 @@ class TestPointAtAngleOnEllipse(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - point_at_angle_on_ellipse( - np.array([0, 90, 180, 270]), np.array([0.0, 0.0, 2, 1, 0])), - np.array([[2, 0], [0, 1], [-2, 0], [0, -1]]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - point_at_angle_on_ellipse( - np.linspace(0, 360, 10), np.array([0.5, 0.5, 2, 1, 45])), - np.array([ -@@ -304,7 +304,7 @@ class TestEllipseFittingHalir1998(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - ellipse_fitting_Halir1998( - np.array([[2, 0], [0, 1], [-2, 0], [0, -1]])), - np.array([ -diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py -index 12e0baaa..3d19e96c 100644 ---- a/colour/algebra/tests/test_interpolation.py -+++ b/colour/algebra/tests/test_interpolation.py -@@ -10,22 +10,22 @@ References - """ -  - from __future__ import division, unicode_literals -- --import colour.ndarray as np --import os --import unittest --from itertools import permutations -- --from colour.algebra.interpolation import vertices_and_relative_coordinates -+from colour.utilities import ignore_numpy_errors -+from colour.io import read_LUT -+from colour.algebra import random_triplet_generator - from colour.algebra import ( - kernel_nearest_neighbour, kernel_linear, kernel_sinc, kernel_lanczos, - kernel_cardinal_spline, KernelInterpolator, NearestNeighbourInterpolator, - LinearInterpolator, SpragueInterpolator, CubicSplineInterpolator, - PchipInterpolator, NullInterpolator, lagrange_coefficients, - table_interpolation_trilinear, table_interpolation_tetrahedral) --from colour.algebra import random_triplet_generator --from colour.io import read_LUT --from colour.utilities import ignore_numpy_errors -+from colour.algebra.interpolation import vertices_and_relative_coordinates -+ -+import colour.ndarray as np -+import os -+import unittest -+from itertools import permutations -+np.set_ndimensional_array_backend('cupy') -  - __author__ = 'Colour Developers' - __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' -@@ -171,7 +171,7 @@ class TestKernelNearestNeighbour(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_nearest_neighbour(np.linspace(-5, 5, 25)), - np.array([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, -@@ -191,7 +191,7 @@ class TestKernelLinear(unittest.TestCase): - Tests :func:`colour.algebra.interpolation.kernel_linear` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_linear(np.linspace(-5, 5, 25)), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -214,7 +214,7 @@ class TestKernelSinc(unittest.TestCase): - Tests :func:`colour.algebra.interpolation.kernel_sinc` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_sinc(np.linspace(-5, 5, 25)), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -225,7 +225,7 @@ class TestKernelSinc(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_sinc(np.linspace(-5, 5, 25), 1), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -248,7 +248,7 @@ class TestKernelLanczos(unittest.TestCase): - Tests :func:`colour.algebra.interpolation.kernel_lanczos` definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_lanczos(np.linspace(-5, 5, 25)), - np.array([ - 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, -@@ -261,7 +261,7 @@ class TestKernelLanczos(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_lanczos(np.linspace(-5, 5, 25), 1), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -285,7 +285,7 @@ class TestKernelCardinalSpline(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_cardinal_spline(np.linspace(-5, 5, 25)), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -296,7 +296,7 @@ class TestKernelCardinalSpline(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_cardinal_spline(np.linspace(-5, 5, 25), 0, 1), - np.array([ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -@@ -344,7 +344,7 @@ class TestKernelInterpolator(unittest.TestCase): - x = y = np.linspace(0, 1, 10) - kernel_interpolator = KernelInterpolator(x, y) -  -- np.testing.assert_equal(kernel_interpolator.x, x) -+ np.testing.assert_array_equal(kernel_interpolator.x, x) -  - def test_y(self): - """ -@@ -355,7 +355,7 @@ class TestKernelInterpolator(unittest.TestCase): - x = y = np.linspace(0, 1, 10) - kernel_interpolator = KernelInterpolator(x, y) -  -- np.testing.assert_equal(kernel_interpolator.y, y) -+ np.testing.assert_array_equal(kernel_interpolator.y, y) -  - def test_window(self): - """ -@@ -430,7 +430,7 @@ padding_kwargs` property. - x_i = np.linspace(11, 25, 25) -  - kernel_interpolator = KernelInterpolator(x, y) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_interpolator(x_i), - np.array([ - 4.43848790, 4.26286480, 3.64640076, 2.77982023, 2.13474499, -@@ -442,7 +442,7 @@ padding_kwargs` property. - decimal=7) -  - kernel_interpolator = KernelInterpolator(x, y, kernel=kernel_sinc) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_interpolator(x_i), - np.array([ - 4.43848790, 4.47570010, 3.84353906, 3.05959493, 2.53514958, -@@ -454,7 +454,7 @@ padding_kwargs` property. - decimal=7) -  - kernel_interpolator = KernelInterpolator(x, y, window=1) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_interpolator(x_i), - np.array([ - 4.43848790, 4.96712277, 4.09584229, 3.23991575, 2.80418924, -@@ -467,7 +467,7 @@ padding_kwargs` property. -  - kernel_interpolator = KernelInterpolator( - x, y, window=1, kernel_kwargs={'a': 1}) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_interpolator(x_i), - np.array([ - 4.43848790, 3.34379320, 3.62463711, 2.34585418, 2.04767083, -@@ -483,7 +483,7 @@ padding_kwargs` property. - 'pad_width': (3, 3), - 'mode': 'mean' - }) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - kernel_interpolator(x_i), - np.array([ - 4.4384879, 4.35723245, 3.62918155, 2.77471295, 2.13474499, -@@ -500,12 +500,12 @@ padding_kwargs` property. - y = np.sin(x_1 / len(x_1) * np.pi * 6) / (x_1 / len(x_1)) - x_i = np.linspace(1, 9, 25) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - KernelInterpolator(x_1, y)(x_i), - KernelInterpolator(x_2, y)(x_i * 10), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - KernelInterpolator(x_1, y)(x_i), - KernelInterpolator(x_3, y)(x_i / 10), - decimal=7) -@@ -630,7 +630,7 @@ class TestLinearInterpolator(unittest.TestCase): - linear_interpolator(value), - places=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - linear_interpolator( - np.arange(0, - len(POINTS_DATA_A) - 1 + interval, interval)), -@@ -720,7 +720,7 @@ class TestSpragueInterpolator(unittest.TestCase): - sprague_interpolator(value), - places=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - sprague_interpolator( - np.arange(0, - len(POINTS_DATA_A) - 1 + interval, interval)), -@@ -773,12 +773,16 @@ CubicSplineInterpolator.__call__` method. - - This class is a wrapper around *scipy.interpolate.interp1d* class - and is assumed to be unit tested thoroughly. - """ -- -- np.testing.assert_almost_equal( -+ print( -+ np.linspace(0, 1, -+ len(POINTS_DATA_A) * 2), -+ type(np.linspace(0, 1, -+ len(POINTS_DATA_A) * 2))) -+ np.testing.assert_array_almost_equal( - CubicSplineInterpolator( - np.linspace(0, 1, len(POINTS_DATA_A)), -- POINTS_DATA_A)(np.linspace(0, 1, -- len(POINTS_DATA_A) * 2)), -+ np.array(POINTS_DATA_A))(np.linspace(0, 1, -+ len(POINTS_DATA_A) * 2)), - CUBIC_SPLINE_INTERPOLATED_POINTS_DATA_A_X2_SAMPLES) -  -  -@@ -844,7 +848,7 @@ class TestNullInterpolator(unittest.TestCase): - x = y = np.linspace(0, 1, 10) - null_interpolator = NullInterpolator(x, y) -  -- np.testing.assert_equal(null_interpolator.x, x) -+ np.testing.assert_array_equal(null_interpolator.x, x) -  - def test_y(self): - """ -@@ -855,7 +859,7 @@ class TestNullInterpolator(unittest.TestCase): - x = y = np.linspace(0, 1, 10) - null_interpolator = NullInterpolator(x, y) -  -- np.testing.assert_equal(null_interpolator.y, y) -+ np.testing.assert_array_equal(null_interpolator.y, y) -  - def test_absolute_tolerance(self): - """ -@@ -866,7 +870,8 @@ absolute_tolerance` property. - x = y = np.linspace(0, 1, 10) - null_interpolator = NullInterpolator(x, y, absolute_tolerance=0.1) -  -- np.testing.assert_equal(null_interpolator.absolute_tolerance, 0.1) -+ np.testing.assert_array_equal(null_interpolator.absolute_tolerance, -+ 0.1) -  - def test_relative_tolerance(self): - """ -@@ -877,7 +882,8 @@ relative_tolerance` property. - x = y = np.linspace(0, 1, 10) - null_interpolator = NullInterpolator(x, y, relative_tolerance=0.1) -  -- np.testing.assert_equal(null_interpolator.relative_tolerance, 0.1) -+ np.testing.assert_array_equal(null_interpolator.relative_tolerance, -+ 0.1) -  - def test_default(self): - """ -@@ -888,7 +894,7 @@ default` property. - x = y = np.linspace(0, 1, 10) - null_interpolator = NullInterpolator(x, y, default=0) -  -- np.testing.assert_equal(null_interpolator.default, 0) -+ np.testing.assert_array_equal(null_interpolator.default, 0) -  - def test_raise_exception___init__(self): - """ -@@ -907,12 +913,12 @@ default` property. -  - x = np.arange(len(POINTS_DATA_A)) - null_interpolator = NullInterpolator(x, POINTS_DATA_A) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), - np.array([np.nan, 12.46, 9.51, np.nan])) -  - null_interpolator = NullInterpolator(x, POINTS_DATA_A, 0.25, 0.25) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - null_interpolator(np.array([0.75, 2.0, 3.0, 4.75])), - np.array([12.32, 12.46, 9.51, 4.33])) -  -@@ -968,11 +974,15 @@ class TestLagrangeCoefficients(unittest.TestCase): - :cite:`Fairman1985b` - """ -  -- lc = [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)] -- np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_A, decimal=7) -+ lc = np.array( -+ [lagrange_coefficients(i, 3) for i in np.linspace(0.05, 0.95, 19)]) -+ np.testing.assert_array_almost_equal( -+ lc, LAGRANGE_COEFFICIENTS_A, decimal=7) -  -- lc = [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)] -- np.testing.assert_almost_equal(lc, LAGRANGE_COEFFICIENTS_B, decimal=7) -+ lc = np.array( -+ [lagrange_coefficients(i, 4) for i in np.linspace(1.05, 1.95, 19)]) -+ np.testing.assert_array_almost_equal( -+ lc, LAGRANGE_COEFFICIENTS_B, decimal=7) -  -  - class TestVerticesAndRelativeCoordinates(unittest.TestCase): -@@ -992,7 +1002,7 @@ vertices_and_relative_coordinates` definition. - V_xyz = random_triplet_generator(4, random_state=prng) - vertices, V_xyzr = vertices_and_relative_coordinates(V_xyz, LUT_TABLE) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - vertices, - np.array([ - [ -@@ -1044,7 +1054,7 @@ vertices_and_relative_coordinates` definition. - [1.13122500, 0.29792000, 0.29792000], - ], - ])) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - V_xyzr, - np.array([ - [0.90108952, 0.09318647, 0.75894709], -@@ -1070,7 +1080,7 @@ table_interpolation_trilinear` definition. -  - V_xyz = random_triplet_generator(16, random_state=prng) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - table_interpolation_trilinear(V_xyz, LUT_TABLE), - np.array([ - [1.07937594, -0.02773926, 0.55498254], -@@ -1108,7 +1118,7 @@ table_interpolation_tetrahedral` definition. -  - V_xyz = random_triplet_generator(16, random_state=prng) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - table_interpolation_tetrahedral(V_xyz, LUT_TABLE), - np.array([ - [1.08039215, -0.02840092, 0.55855303], -diff --git a/colour/algebra/tests/test_random.py b/colour/algebra/tests/test_random.py -index 75f62f2c..921a10df 100644 ---- a/colour/algebra/tests/test_random.py -+++ b/colour/algebra/tests/test_random.py -@@ -61,7 +61,7 @@ class TestRandomTripletGenerator(unittest.TestCase): - """ -  - prng = np.random.RandomState(4) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - RANDOM_TRIPLETS, - random_triplet_generator(10, random_state=prng), - decimal=7) -diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py -index f9b1f9ff..f1b23d9a 100644 ---- a/colour/algebra/tests/test_regression.py -+++ b/colour/algebra/tests/test_regression.py -@@ -36,7 +36,7 @@ least_square_mapping_MoorePenrose` definition. - y = prng.random_sample((24, 3)) - x = y + (prng.random_sample((24, 3)) - 0.5) * 0.5 -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - least_square_mapping_MoorePenrose(y, x), - np.array([ - [1.05263767, 0.13780789, -0.22763399], -@@ -47,7 +47,7 @@ least_square_mapping_MoorePenrose` definition. -  - y = prng.random_sample((4, 3, 2)) - x = y + (prng.random_sample((4, 3, 2)) - 0.5) * 0.5 -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - least_square_mapping_MoorePenrose(y, x), - np.array([ - [ -diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py -index d13fdd0b..a093636c 100644 ---- a/colour/appearance/ciecam02.py -+++ b/colour/appearance/ciecam02.py -@@ -39,7 +39,7 @@ from colour.constants import EPSILON - from colour.utilities import ( - CaseInsensitiveMapping, as_float_array, as_int_array, as_namedtuple, - as_float, from_range_degrees, dot_matrix, dot_vector, from_range_100, ones, -- to_domain_100, to_domain_degrees, tsplit, tstack, zeros) -+ to_domain_100, to_domain_degrees, tsplit, tstack, zeros, as_int) -  - __author__ = 'Colour Developers' - __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' -@@ -994,7 +994,16 @@ def hue_quadrature(h): -  - # *np.searchsorted* returns an erroneous index if a *nan* is used as input. - h[np.asarray(np.isnan(h))] = 0 -- i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) -+ -+ if np.__name__ == 'cupy': -+ hnp = np.asnumpy(h) -+ h_inp = np.asnumpy(h_i) -+ np.set_ndimensional_array_backend('numpy') -+ i = as_int_array(np.searchsorted(h_inp, hnp, side='left') - 1) -+ np.set_ndimensional_array_backend('cupy') -+ i = as_int(i) -+ else: -+ i = as_int_array(np.searchsorted(h_i, h, side='left') - 1) -  - h_ii = h_i[i] - e_ii = e_i[i] -diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py -index 5bb4e8d2..b2c5d2c4 100644 ---- a/colour/biochemistry/michaelis_menten.py -+++ b/colour/biochemistry/michaelis_menten.py -@@ -17,7 +17,8 @@ References -  - from __future__ import division, unicode_literals -  --from colour.utilities import as_float_array -+from colour.utilities import as_float_array, as_float -+import colour.ndarray as np -  - __author__ = 'Colour Developers' - __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' -@@ -72,6 +73,9 @@ def reaction_rate_MichealisMenten(S, V_max, K_m): -  - v = (V_max * S) / (K_m + S) -  -+ if np.__name__ == 'cupy' and v.size == 1: -+ return as_float(v) -+ - return v -  -  -@@ -100,10 +104,6 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): - ---------- - :cite:`Wikipedia2003d` -  -- Notes -- ----- -- On CuPy, this returns an array even for length of 1. -- - Examples - -------- - >>> substrate_concentration_MichealisMenten(0.961538461538461, 2.5, 0.8) -@@ -117,4 +117,7 @@ def substrate_concentration_MichealisMenten(v, V_max, K_m): -  - S = (v * K_m) / (V_max - v) -  -+ if np.__name__ == 'cupy' and S.size == 1: -+ return as_float(S) -+ - return S -diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py -index 9f39ae7a..f22524c9 100644 ---- a/colour/biochemistry/tests/test_michaelis_menten.py -+++ b/colour/biochemistry/tests/test_michaelis_menten.py -@@ -67,19 +67,19 @@ reaction_rate_MichealisMenten` definition n-dimensional arrays -  - v = np.tile(v, (6, 1)) - S = np.tile(S, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) -  - V_max = np.tile(V_max, (6, 1)) - K_m = np.tile(K_m, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) -  - v = np.reshape(v, (2, 3, 1)) - V_max = np.reshape(V_max, (2, 3, 1)) - K_m = np.reshape(K_m, (2, 3, 1)) - S = np.reshape(S, (2, 3, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) -  - @ignore_numpy_errors -@@ -139,14 +139,14 @@ substrate_concentration_MichealisMenten` definition n-dimensional arrays -  - S = np.tile(S, (6, 1)) - v = np.tile(v, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - substrate_concentration_MichealisMenten(S, V_max, K_m), - v, - decimal=7) -  - V_max = np.tile(V_max, (6, 1)) - K_m = np.tile(K_m, (6, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - substrate_concentration_MichealisMenten(S, V_max, K_m), - v, - decimal=7) -@@ -155,7 +155,7 @@ substrate_concentration_MichealisMenten` definition n-dimensional arrays - V_max = np.reshape(V_max, (2, 3, 1)) - K_m = np.reshape(K_m, (2, 3, 1)) - v = np.reshape(v, (2, 3, 1)) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - substrate_concentration_MichealisMenten(S, V_max, K_m), - v, - decimal=7) -diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py -index 3f3541b2..06c70c82 100644 ---- a/colour/blindness/tests/test_machado2009.py -+++ b/colour/blindness/tests/test_machado2009.py -@@ -41,43 +41,43 @@ anomalous_trichromacy_cmfs_Machado2009` definition. - """ -  - cmfs = LMS_CMFS.get('Smith & Pokorny 1975 Normal Trichromats') -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, - np.array([0, 0, 0], ))[450], - cmfs[450], - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, - np.array([1, 0, 0], ))[450], - np.array([0.03631700, 0.06350000, 0.91000000]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, - np.array([0, 1, 0], ))[450], - np.array([0.03430000, 0.06178404, 0.91000000]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, - np.array([0, 0, 1], ))[450], - np.array([0.03430000, 0.06350000, 0.92270240]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( - [10, 0, 0], ))[450], - np.array([0.05447001, 0.06350000, 0.91000000]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( - [0, 10, 0], ))[450], - np.array([0.03430000, 0.04634036, 0.91000000]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array( - [0, 0, 10], ))[450], - np.array([0.03430000, 0.06350000, 1.00000000]), -@@ -98,7 +98,7 @@ anomalous_trichromacy_matrix_Machado2009` definition. -  - cmfs = LMS_CMFS.get('Smith & Pokorny 1975 Normal Trichromats') - primaries = DISPLAY_RGB_PRIMARIES['Typical CRT Brainard 1997'] -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - anomalous_trichromacy_matrix_Machado2009(cmfs, primaries, - np.array([0, 0, 0])), - np.identity(3), -@@ -159,7 +159,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): - definition. - """ -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - cvd_matrix_Machado2009('Protanomaly', 0.0), - np.array([ - [1, 0, 0], -@@ -168,7 +168,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - cvd_matrix_Machado2009('Deuteranomaly', 0.1), - np.array([ - [0.86643500, 0.17770400, -0.04413900], -@@ -177,7 +177,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - cvd_matrix_Machado2009('Tritanomaly', 1.0), - np.array([ - [1.25552800, -0.07674900, -0.17877900], -@@ -186,7 +186,7 @@ class TestCvdMatrixMachado2009(unittest.TestCase): - ]), - decimal=7) -  -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - cvd_matrix_Machado2009('Tritanomaly', 0.55), - np.array([ - [1.06088700, -0.01504350, -0.04584350], -diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py -index 09337bad..4c41c30c 100644 ---- a/colour/characterisation/correction.py -+++ b/colour/characterisation/correction.py -@@ -215,6 +215,7 @@ def polynomial_expansion_Finlayson2015(RGB, - 0.1051335...]) - """ -  -+ RGB = np.array(RGB) - R, G, B = tsplit(RGB) -  - # TODO: Generalise polynomial expansion. -@@ -772,6 +773,8 @@ def colour_correction_Vandermonde(RGB, M_T, M_R, degree=1): - array([ 0.2128689..., 0.1106242..., 0.036213 ...]) - """ -  -+ M_T = np.array((M_T)) -+ M_R = np.array((M_R)) - RGB = as_float_array(RGB) - shape = RGB.shape -  -diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py -index d7ae029e..324b5571 100644 ---- a/colour/characterisation/tests/test_aces_it.py -+++ b/colour/characterisation/tests/test_aces_it.py -@@ -64,39 +64,39 @@ sd_to_aces_relative_exposure_values` definition. -  - shape = ACES_RICD.shape - grey_reflector = sd_constant(0.18, shape) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - sd_to_aces_relative_exposure_values(grey_reflector), - np.array([0.18, 0.18, 0.18]), - decimal=7) -  - perfect_reflector = sd_ones(shape) -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - sd_to_aces_relative_exposure_values(perfect_reflector), - np.array([0.97783784, 0.97783784, 0.97783784]), - decimal=7) -  - dark_skin = COLOURCHECKER_SDS['ColorChecker N Ohta']['dark skin'] -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - sd_to_aces_relative_exposure_values(dark_skin), - np.array([0.11718149, 0.08663609, 0.05897268]), - decimal=7) -  - dark_skin = COLOURCHECKER_SDS['ColorChecker N Ohta']['dark skin'] -- np.testing.assert_almost_equal( -+ np.testing.assert_array_almost_equal( - sd_to_aces_relative_exposure_values(dark_skin, - ILLUMINANT_SDS['A']), - np.array([0.13583991, 0.09431845, 0.05928214]), - decimal=7) -  - dark_skin = COLOU \ No newline at end of file From 9ded38865d7eae023cc1e958c8889c2a2477b1ac Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Mon, 17 Aug 2020 11:22:37 +0200 Subject: [PATCH 10/17] Fixes for models/rgb/derivation --- colour/geometry/primitives.py | 6 ++++++ colour/models/rgb/derivation.py | 11 +++++++++++ colour/ndarray/backend.py | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index 1f6616b748..e35b08e60c 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -108,6 +108,9 @@ def primitive_grid(width=1, [1 0]] """ + if np.__name__ == 'cupy': + raise NotImplementedError + axis = PLANE_TO_AXIS_MAPPING.get(axis, axis).lower() x_grid = width_segments @@ -290,6 +293,9 @@ def primitive_cube(width=1, [21 20]] """ + if np.__name__ == 'cupy': + raise NotImplementedError + planes = (sorted(list( PLANE_TO_AXIS_MAPPING.values())) if planes is None else [ PLANE_TO_AXIS_MAPPING.get(plane, plane).lower() for plane in planes diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index 5a66cd4169..dc69f56f4a 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -110,11 +110,22 @@ def normalised_primary_matrix(primaries, whitepoint): whitepoint = xy_to_XYZ(whitepoint) + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + whitepoint = np.array(whitepoint) + primaries = np.array(primaries) + cupy = True + coefficients = np.dot(np.linalg.inv(primaries), whitepoint) coefficients = np.diagflat(coefficients) npm = np.dot(primaries, coefficients) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + npm = np.array(npm) + return npm diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index bdf4a51388..017d5fe546 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -25,7 +25,7 @@ ] _NDIMENSIONAL_ARRAY_BACKEND = os.environ.get( - 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Cupy').lower() + 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Numpy').lower() def get_ndimensional_array_backend(): @@ -33,7 +33,7 @@ def get_ndimensional_array_backend(): return _NDIMENSIONAL_ARRAY_BACKEND -def _set_ndimensional_array_backend(backend='Cupy'): +def _set_ndimensional_array_backend(backend='Numpy'): global _NDIMENSIONAL_ARRAY_BACKEND backend = str(backend).lower() From 104bb5838e1fdb6cdbb52fd42ffe582fa1987677 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Thu, 20 Aug 2020 10:02:37 +0200 Subject: [PATCH 11/17] Fixes for appearance, quality and phenomenal --- colour/appearance/tests/common.py | 2 +- colour/appearance/tests/test_atd95.py | 2 +- colour/appearance/tests/test_cam16.py | 6 +++--- colour/appearance/tests/test_ciecam02.py | 7 +++---- colour/appearance/tests/test_hunt.py | 6 +++--- colour/appearance/tests/test_llab.py | 4 ++-- colour/appearance/tests/test_nayatani95.py | 3 +-- colour/appearance/tests/test_rlab.py | 2 +- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/colour/appearance/tests/common.py b/colour/appearance/tests/common.py index dadf18bc56..41fd1dc941 100644 --- a/colour/appearance/tests/common.py +++ b/colour/appearance/tests/common.py @@ -143,7 +143,7 @@ def check_specification_attribute(self, case, data, attribute, expected): atol=0.01, verbose=False) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value, expected, decimal=1, err_msg=error_message) def check_model_consistency(self, data, output_attributes): diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index d7a0c1b60e..cc8fc6348b 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -89,7 +89,7 @@ def test_domain_range_scale_XYZ_to_ATD95(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_ATD95(XYZ * factor_a, XYZ_0 * factor_a, Y_0, k_1, k_2), specification * factor_b, diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index 10bde7fdee..be65e59576 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -102,7 +102,7 @@ def test_domain_range_scale_XYZ_to_CAM16(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_CAM16(XYZ * factor_a, XYZ_w * factor_a, L_A, Y_b, surround)[:-1], specification * factor_b, @@ -226,7 +226,7 @@ def check_specification_attribute(self, case, data, attribute, expected): atol=0.01, verbose=False) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value, expected, decimal=1, err_msg=error_message) @ignore_numpy_errors @@ -254,7 +254,7 @@ def test_domain_range_scale_CAM16_to_XYZ(self): ) for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CAM16_to_XYZ(specification[:-1] * factor_a, XYZ_w * factor_b, L_A, Y_b, surround), XYZ * factor_c, diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index 1ee270b560..938ff98aad 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -10,7 +10,6 @@ from itertools import permutations from unittest import TestCase - from colour.appearance import ( VIEWING_CONDITIONS_CIECAM02, InductionFactors_CIECAM02, CAM_Specification_CIECAM02, XYZ_to_CIECAM02, CIECAM02_to_XYZ) @@ -99,7 +98,7 @@ def test_domain_range_scale_XYZ_to_CIECAM02(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_CIECAM02(XYZ * factor_a, XYZ_w * factor_a, L_A, Y_b, surround)[:-1], specification * factor_b, @@ -223,7 +222,7 @@ def check_specification_attribute(self, case, data, attribute, expected): atol=0.01, verbose=False) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( value, expected, decimal=1, err_msg=error_message) @ignore_numpy_errors @@ -251,7 +250,7 @@ def test_domain_range_scale_CIECAM02_to_XYZ(self): ) for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( CIECAM02_to_XYZ(specification[:-1] * factor_a, XYZ_w * factor_b, L_A, Y_b, surround), XYZ * factor_c, diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index 3451ca644a..272887dedd 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -94,7 +94,7 @@ def test_domain_range_scale_XYZ_to_Hunt(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunt( XYZ * factor_a, XYZ_w * factor_a, @@ -102,7 +102,7 @@ def test_domain_range_scale_XYZ_to_Hunt(self): L_A, surround, CCT_w=CCT_w)[:-2], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors @@ -149,7 +149,7 @@ def test_XYZ_p_CIECAM02_to_XYZ(self): surround = VIEWING_CONDITIONS_HUNT['Normal Scenes'] CCT_w = 6504.0 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Hunt( XYZ, XYZ_w, diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 67385c5607..662fe0af0a 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -131,7 +131,7 @@ def test_colourspace_conversion_matrices_precision(self): for _ in range(100000): result = llab.MATRIX_RGB_TO_XYZ_LLAB.dot(result) result = llab.MATRIX_XYZ_TO_RGB_LLAB.dot(result) - np.testing.assert_almost_equal(start, result, decimal=7) + np.testing.assert_array_almost_equal(start, result, decimal=7) def test_domain_range_scale_XYZ_to_LLAB(self): """ @@ -153,7 +153,7 @@ def test_domain_range_scale_XYZ_to_LLAB(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_LLAB(XYZ * factor_a, XYZ_0 * factor_a, Y_b, L, surround)[:5], specification * factor_b, diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index 1638f3434a..e74191cbe6 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -10,7 +10,6 @@ from itertools import permutations from unittest import TestCase - from colour.appearance import XYZ_to_Nayatani95 from colour.appearance.tests.common import ColourAppearanceModelTest from colour.utilities import domain_range_scale, ignore_numpy_errors, tstack @@ -87,7 +86,7 @@ def test_domain_range_scale_XYZ_to_Nayatani95(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_Nayatani95(XYZ * factor_a, XYZ_n * factor_a, Y_o, E_o, E_or)[:6], specification * factor_b, diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index b5870e527c..72489c4263 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -87,7 +87,7 @@ def test_domain_range_scale_XYZ_to_RLAB(self): ) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( XYZ_to_RLAB(XYZ * factor_a, XYZ_n * factor_a, Y_n, sigma, D)[:4], specification * factor_b, From bb3d5389bcb24be8ed5d70c7ddfc8ba3a9a291fc Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Thu, 20 Aug 2020 10:06:24 +0200 Subject: [PATCH 12/17] Fixes for appearance, quality and phenomenal --- colour/adaptation/tests/test__init__.py | 10 +- .../coordinates/tests/test_transformations.py | 64 +++++------ colour/algebra/tests/test_interpolation.py | 6 +- colour/appearance/hunt.py | 100 +++++++++++++++++- colour/colorimetry/tristimulus.py | 18 +++- colour/continuous/multi_signals.py | 43 ++++++-- colour/continuous/signal.py | 40 +++++-- colour/corresponding/prediction.py | 11 +- colour/graph/tests/test_conversion.py | 4 +- colour/io/luts/sony_spi3d.py | 7 +- colour/models/hdr_cie_lab.py | 3 +- colour/phenomena/rayleigh.py | 1 + colour/quality/cqs.py | 3 +- colour/utilities/array.py | 4 +- colour/utilities/tests/test_array.py | 6 +- 15 files changed, 245 insertions(+), 75 deletions(-) diff --git a/colour/adaptation/tests/test__init__.py b/colour/adaptation/tests/test__init__.py index 825697cc0a..8086b3a010 100644 --- a/colour/adaptation/tests/test__init__.py +++ b/colour/adaptation/tests/test__init__.py @@ -37,14 +37,14 @@ def test_chromatic_adaptation(self): XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) XYZ_w = np.array([0.95045593, 1.00000000, 1.08905775]) XYZ_wr = np.array([0.96429568, 1.00000000, 0.82510460]) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation(XYZ, XYZ_w, XYZ_wr), np.array([0.21638819, 0.12570000, 0.03847494]), decimal=7) Y_o = 0.2 E_o = 1000 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation( XYZ, XYZ_w, @@ -57,14 +57,14 @@ def test_chromatic_adaptation(self): decimal=7) L_A = 200 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation( XYZ, XYZ_w, XYZ_wr, method='CMCCAT2000', L_A1=L_A, L_A2=L_A), np.array([0.21498829, 0.12474711, 0.03910138]), decimal=7) Y_n = 200 - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation( XYZ, XYZ_w, XYZ_wr, method='Fairchild 1990', Y_n=Y_n), np.array([0.21394049, 0.12262315, 0.03891917]), @@ -103,7 +103,7 @@ def test_domain_range_scale_chromatic_adaptation(self): for method, value in zip(m, v): for scale, factor in d_r: with domain_range_scale(scale): - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( chromatic_adaptation( XYZ * factor, XYZ_w * factor, diff --git a/colour/algebra/coordinates/tests/test_transformations.py b/colour/algebra/coordinates/tests/test_transformations.py index d895aeb6da..3674011200 100644 --- a/colour/algebra/coordinates/tests/test_transformations.py +++ b/colour/algebra/coordinates/tests/test_transformations.py @@ -41,17 +41,17 @@ def test_cartesian_to_spherical(self): cartesian_to_spherical` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_spherical(np.array([3, 1, 6])), np.array([6.78232998, 0.48504979, 0.32175055]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_spherical(np.array([-1, 9, 16])), np.array([18.38477631, 0.51501513, 1.68145355]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_spherical(np.array([6.3434, -0.9345, 18.5675])), np.array([19.64342307, 0.33250603, -0.14626640]), decimal=7) @@ -67,12 +67,12 @@ def test_n_dimensional_cartesian_to_spherical(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7) @ignore_numpy_errors @@ -101,19 +101,19 @@ def test_spherical_to_cartesian(self): spherical_to_cartesian` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spherical_to_cartesian( np.array([6.78232998, 0.48504979, 0.32175055])), np.array([3.00000000, 0.99999999, 6.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spherical_to_cartesian( np.array([18.38477631, 0.51501513, 1.68145355])), np.array([-1.00000003, 9.00000007, 15.99999996]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spherical_to_cartesian( np.array([19.64342307, 0.33250603, -0.14626640])), np.array([6.34339996, -0.93449999, 18.56750001]), @@ -130,12 +130,12 @@ def test_n_dimensional_spherical_to_cartesian(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spherical_to_cartesian(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( spherical_to_cartesian(a_i), a_o, decimal=7) @ignore_numpy_errors @@ -164,17 +164,17 @@ def test_cartesian_to_polar(self): cartesian_to_polar` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_polar(np.array([3, 1])), np.array([3.16227766, 0.32175055]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_polar(np.array([-1, 9])), np.array([9.05538514, 1.68145355]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_polar(np.array([6.3434, -0.9345])), np.array([6.41186508, -0.14626640]), decimal=7) @@ -190,11 +190,13 @@ def test_n_dimensional_cartesian_to_polar(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal(cartesian_to_polar(a_i), a_o, decimal=7) + np.testing.assert_array_almost_equal( + cartesian_to_polar(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 2)) a_o = np.reshape(a_o, (2, 3, 2)) - np.testing.assert_almost_equal(cartesian_to_polar(a_i), a_o, decimal=7) + np.testing.assert_array_almost_equal( + cartesian_to_polar(a_i), a_o, decimal=7) @ignore_numpy_errors def test_nan_cartesian_to_polar(self): @@ -222,17 +224,17 @@ def test_polar_to_cartesian(self): polar_to_cartesian` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polar_to_cartesian(np.array([0.32175055, 1.08574654])), np.array([0.15001697, 0.28463718]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polar_to_cartesian(np.array([1.68145355, 1.05578119])), np.array([0.82819662, 1.46334425]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( polar_to_cartesian(np.array([-0.14626640, 1.23829030])), np.array([-0.04774323, -0.13825500]), decimal=7) @@ -248,11 +250,13 @@ def test_n_dimensional_polar_to_cartesian(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal(polar_to_cartesian(a_i), a_o, decimal=7) + np.testing.assert_array_almost_equal( + polar_to_cartesian(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 2)) a_o = np.reshape(a_o, (2, 3, 2)) - np.testing.assert_almost_equal(polar_to_cartesian(a_i), a_o, decimal=7) + np.testing.assert_array_almost_equal( + polar_to_cartesian(a_i), a_o, decimal=7) @ignore_numpy_errors def test_nan_polar_to_cartesian(self): @@ -280,17 +284,17 @@ def test_cartesian_to_cylindrical(self): cartesian_to_cylindrical` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_cylindrical(np.array([3, 1, 6])), np.array([3.16227766, 0.32175055, 6.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_cylindrical(np.array([-1, 9, 16])), np.array([9.05538514, 1.68145355, 16.00000000]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_cylindrical(np.array([6.3434, -0.9345, 18.5675])), np.array([6.41186508, -0.14626640, 18.56750000]), decimal=7) @@ -306,12 +310,12 @@ def test_n_dimensional_cartesian_to_cylindrical(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_cylindrical(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cartesian_to_cylindrical(a_i), a_o, decimal=7) @ignore_numpy_errors @@ -340,19 +344,19 @@ def test_cylindrical_to_cartesian(self): cylindrical_to_cartesian` definition. """ - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cylindrical_to_cartesian( np.array([0.32175055, 1.08574654, 6.78232998])), np.array([0.15001697, 0.28463718, 6.78232998]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cylindrical_to_cartesian( np.array([1.68145355, 1.05578119, 18.38477631])), np.array([0.82819662, 1.46334425, 18.38477631]), decimal=7) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cylindrical_to_cartesian( np.array([-0.14626640, 1.23829030, 19.64342307])), np.array([-0.04774323, -0.13825500, 19.64342307]), @@ -369,12 +373,12 @@ def test_n_dimensional_cylindrical_to_cartesian(self): a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cylindrical_to_cartesian(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( cylindrical_to_cartesian(a_i), a_o, decimal=7) @ignore_numpy_errors diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index 7b4c10c312..deec8fed04 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -773,11 +773,7 @@ def test__call__(self): - This class is a wrapper around *scipy.interpolate.interp1d* class and is assumed to be unit tested thoroughly. """ - print( - np.linspace(0, 1, - len(POINTS_DATA_A) * 2), - type(np.linspace(0, 1, - len(POINTS_DATA_A) * 2))) + np.testing.assert_array_almost_equal( CubicSplineInterpolator( np.linspace(0, 1, len(DATA_POINTS_A)), diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index e3005bb63b..43ee58926d 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -24,9 +24,10 @@ from collections import namedtuple from colour.algebra import spow -from colour.utilities import ( - CaseInsensitiveMapping, as_float_array, dot_vector, from_range_degrees, - ones, to_domain_100, tsplit, tstack, usage_warning, zeros) +from colour.utilities import (CaseInsensitiveMapping, as_float, as_float_array, + dot_vector, from_range_degrees, ones, + to_domain_100, tsplit, tstack, usage_warning, + zeros) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -490,6 +491,12 @@ def luminance_level_adaptation_factor(L_A): k4 = k ** 4 F_L = 0.2 * k4 * (5 * L_A) + 0.1 * (1 - k4) ** 2 * spow(5 * L_A, 1 / 3) + try: + if F_L.size == 1: + return (F_L).item() + except Exception: + pass + return F_L @@ -521,6 +528,12 @@ def illuminant_scotopic_luminance(L_A, CCT): CCT = 2.26 * L_A * spow((CCT / 4000) - 0.4, 1 / 3) + try: + if CCT.size == 1: + return (CCT).item() + except Exception: + pass + return CCT @@ -577,6 +590,12 @@ def f_n(x): x_p = spow(x, 0.73) x_m = 40 * (x_p / (x_p + 2)) + try: + if x_m.size == 1: + return (x_m).item() + except Exception: + pass + return x_m @@ -761,6 +780,12 @@ def achromatic_post_adaptation_signal(rgb): A = 2 * r + g + (1 / 20) * b - 3.05 + 1 + try: + if A.size == 1: + return (A).item() + except Exception: + pass + return A @@ -828,6 +853,13 @@ def hue_angle(C): hue = (180 * np.arctan2(0.5 * (C_2 - C_3) / 4.5, C_1 - (C_2 / 11)) / np.pi) % 360 + + try: + if hue.size == 1: + return (hue).item() + except Exception: + pass + return hue @@ -861,6 +893,12 @@ def eccentricity_factor(hue): x = np.where(hue < 20.14, 0.856 - (hue / 20.14) * 0.056, x) x = np.where(hue > 237.53, 0.856 + 0.344 * (360 - hue) / (360 - 237.53), x) + try: + if x.size == 1: + return (x).item() + except Exception: + pass + return x @@ -889,6 +927,12 @@ def low_luminance_tritanopia_factor(L_A): F_t = L_A / (L_A + 0.1) + try: + if F_t.size == 1: + return (F_t).item() + except Exception: + pass + return F_t @@ -939,6 +983,12 @@ def yellowness_blueness_response(C, e_s, N_c, N_cb, F_t): M_yb = ( 100 * (0.5 * (C_2 - C_3) / 4.5) * (e_s * (10 / 13) * N_c * N_cb * F_t)) + try: + if M_yb.size == 1: + return (M_yb).item() + except Exception: + pass + return M_yb @@ -983,6 +1033,12 @@ def redness_greenness_response(C, e_s, N_c, N_cb): M_rg = 100 * (C_1 - (C_2 / 11)) * (e_s * (10 / 13) * N_c * N_cb) + try: + if M_rg.size == 1: + return (M_rg).item() + except Exception: + pass + return M_rg @@ -1015,6 +1071,12 @@ def overall_chromatic_response(M_yb, M_rg): M = spow((M_yb ** 2) + (M_rg ** 2), 0.5) + try: + if M.size == 1: + return (M).item() + except Exception: + pass + return M @@ -1048,6 +1110,12 @@ def saturation_correlate(M, rgb_a): s = 50 * M / np.sum(rgb_a, axis=-1) + try: + if M.size == 1: + return (M).item() + except Exception: + pass + return s @@ -1106,6 +1174,12 @@ def achromatic_signal(L_AS, S, S_w, N_bb, A_a): # Computing achromatic signal :math:`A`. A = N_bb * (A_a - 1 + A_S - 0.3 + np.sqrt((1 + (0.3 ** 2)))) + try: + if A.size == 1: + return (A).item() + except Exception: + pass + return A @@ -1149,6 +1223,12 @@ def brightness_correlate(A, A_w, M, N_b): Q = spow(7 * (A + (M / 100)), 0.6) * N_1 - N_2 + try: + if Q.size == 1: + return (Q).item() + except Exception: + pass + return Q @@ -1190,6 +1270,12 @@ def lightness_correlate(Y_b, Y_w, Q, Q_w): Z = 1 + spow(Y_b / Y_w, 0.5) J = 100 * spow(Q / Q_w, Z) + try: + if J.size == 1: + return (J).item() + except Exception: + pass + return J @@ -1235,6 +1321,12 @@ def chroma_correlate(s, Y_b, Y_w, Q, Q_w): C_94 = (2.44 * spow(s, 0.69) * (spow(Q / Q_w, Y_b / Y_w)) * (1.64 - spow(0.29, Y_b / Y_w))) + try: + if C_94.size == 1: + return (C_94).item() + except Exception: + pass + return C_94 @@ -1267,4 +1359,4 @@ def colourfulness_correlate(F_L, C_94): M_94 = spow(F_L, 0.15) * C_94 - return M_94 + return as_float(M_94) diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 9c51a1aadb..179c9ffe27 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -746,8 +746,8 @@ def sd_to_XYZ_ASTME308( sd.align(SpectralShape(sd.shape.start - 20, sd.shape.end + 20, 10)) for i in range(2): sd[sd.wavelengths[i]] = ( - 3 * sd.values[i + 2] - - 3 * sd.values[i + 4] + sd.values[i + 6]) # yapf: disable + 3 * sd.values[i + 2] - + 3 * sd.values[i + 4] + sd.values[i + 6]) # yapf: disable i_e = len(sd.domain) - 1 - i sd[sd.wavelengths[i_e]] = ( sd.values[i_e - 6] - 3 * sd.values[i_e - 4] + @@ -907,6 +907,15 @@ def sd_to_XYZ( if _CACHE_SD_TO_XYZ is None: _CACHE_SD_TO_XYZ = {} + cupy = False + if np.__name__ == 'cupy': + cupy = True + if isinstance(illuminant, np.ndarray): + illuminant = np.asnumpy(illuminant) + if isinstance(illuminant, tuple): + illuminant = tuple(np.asnumpy(illuminant)) + np.set_ndimensional_array_backend('numpy') + hash_key = tuple([ hash(arg) for arg in (sd, cmfs, illuminant, k, method, tuple(kwargs.items()), get_domain_range_scale()) @@ -919,6 +928,11 @@ def sd_to_XYZ( XYZ = _CACHE_SD_TO_XYZ[hash_key] = function( sd, cmfs, illuminant, k=k, **filter_kwargs(function, **kwargs)) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + _SD_TO_XYZ_CACHE[hash_key] = np.array(_SD_TO_XYZ_CACHE[hash_key]) + XYZ = np.array(XYZ) + return XYZ diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index cd79c13dcc..9987bcbdb5 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -636,9 +636,20 @@ def __str__(self): [ 8. 90. 100. 110.] [ 9. 100. 110. 120.]] """ - + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True try: - return str(np.hstack([self.domain[:, np.newaxis], self.range])) + string = str( + np.hstack([ + np.array(self.domain[:, np.newaxis]), + np.array(self.range) + ])) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + + return string except TypeError: return super(MultiSignals, self).__str__() @@ -674,10 +685,17 @@ def __repr__(self): extrapolator=Extrapolator, extrapolator_kwargs={...) """ + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True try: representation = repr( - np.hstack([self.domain[:, np.newaxis], self.range])) + np.hstack([ + np.array(self.domain[:, np.newaxis]), + np.array(self.range) + ])) representation = representation.replace('array', self.__class__.__name__) representation = representation.replace( @@ -700,6 +718,9 @@ def __repr__(self): self.extrapolator, repr(self.extrapolator_kwargs)) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return representation except TypeError: return super(MultiSignals, self).__repr__() @@ -714,15 +735,25 @@ def __hash__(self): Object hash. """ - return hash(( - self.domain.tostring(), - self.range.tostring(), + cupy = False + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') + + hashed = hash(( + np.array(self.domain).tostring(), + np.array(self.range).tostring(), self.interpolator.__name__, repr(self.interpolator_kwargs), self.extrapolator.__name__, repr(self.extrapolator_kwargs), )) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + + return hashed + def __getitem__(self, x): """ Returns the corresponding range :math:`y` variable for independent diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index c5c399e251..0f166b6e40 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -537,9 +537,17 @@ def __str__(self): [ 8. 90.] [ 9. 100.]] """ - + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True try: - return str(tstack([self.domain, self.range])) + string = str( + np.hstack([np.array(self.domain), + np.array(self.range)])) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return string except TypeError: return super(Signal, self).__str__() @@ -571,9 +579,15 @@ def __repr__(self): extrapolator=Extrapolator, extrapolator_kwargs={...}) """ + cupy = False + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True try: - representation = repr(tstack([self.domain, self.range])) + representation = repr( + tstack([np.array(self.domain), + np.array(self.range)])) representation = representation.replace('array', self.__class__.__name__) representation = representation.replace( @@ -591,6 +605,9 @@ def __repr__(self): self.extrapolator.__name__, repr(self.extrapolator_kwargs)) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return representation except TypeError: return super(Signal, self).__repr__() @@ -604,16 +621,25 @@ def __hash__(self): int Object hash. """ - - return hash(( - self.domain.tostring(), - self.range.tostring(), + cupy = False + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') + + hashed = hash(( + np.array(self.domain).tostring(), + np.array(self.range).tostring(), self.interpolator.__name__, repr(self.interpolator_kwargs), self.extrapolator.__name__, repr(self.extrapolator_kwargs), )) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + + return hashed + def __getitem__(self, x): """ Returns the corresponding range :math:`y` variable for independent diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index e34a3a10d8..b8f67694ed 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -191,7 +191,7 @@ def convert_experiment_results_Breneman1987(experiment): '"Breneman (1987)" experiment result must be one of "{0}"!'.format( valid_experiment_results)) - samples_luminance = [ + samples_luminance = np.array([ 0.270, 0.090, 0.270, @@ -204,7 +204,7 @@ def convert_experiment_results_Breneman1987(experiment): 0.090, 0.270, 0.090, - ] + ]) experiment_results = list(BRENEMAN_EXPERIMENTS[experiment]) illuminant_chromaticities = experiment_results.pop(0) @@ -212,9 +212,10 @@ def convert_experiment_results_Breneman1987(experiment): B_r = B_t = 0.3 XYZ_t, XYZ_r = xy_to_XYZ( - np.hstack( - [Luv_uv_to_xy(illuminant_chromaticities[1:3]), - full([2, 1], Y_r)])) / Y_r + np.hstack([ + Luv_uv_to_xy(illuminant_chromaticities[1:3]), + full((2, 1), Y_r, dtype=np.int) + ])) / Y_r xyY_cr, xyY_ct = [], [] for i, experiment_result in enumerate(experiment_results): diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 570825badf..460e53e203 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -111,8 +111,8 @@ def test_convert_direct_keyword_argument_passing(self): """ a = np.array([0.20654008, 0.12197225, 0.05136952]) - illuminant = CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][ - 'D50'] + illuminant = np.array( + CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']) np.testing.assert_array_almost_equal( convert( a, 'CIE XYZ', 'CIE xyY', diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 6425e605c2..afdb00fb49 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -97,16 +97,19 @@ def read_LUT_SonySPI3D(path): indexes.append(as_int_array(tokens[:3])) table.append(as_float_array(tokens[3:])) + indexes = as_int_array(indexes) + sorting_indexes = np.lexsort((indexes[:, 2], indexes[:, 1], indexes[:, 0])) + if np.__name__ == 'cupy': assert np.array_equal( - indexes, + indexes[sorting_indexes], np.array( np.around(LUT3D.linear_table(size) * (size - 1)), dtype=np.int64).reshape( (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' else: assert np.array_equal( - indexes, + indexes[sorting_indexes], DEFAULT_INT_DTYPE( np.around(LUT3D.linear_table(size) * (size - 1))).reshape( (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 46948f7ac0..78497bacad 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -33,7 +33,8 @@ from colour.utilities import (as_float, as_float_array, domain_range_scale, from_range_1, from_range_100, to_domain_1, to_domain_100, tsplit, tstack) -from colour.utilities.documentation import DocstringTuple +from colour.utilities.documentation import (DocstringTuple, + is_documentation_building) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index 40e2110066..ef1185f5a8 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -1222,6 +1222,7 @@ def sd_rayleigh_scattering( """ if not (isinstance(avogadro_constant, np.ndarray)): avogadro_constant = float(avogadro_constant) + wavelengths = shape.range() return SpectralDistribution( data=dict( diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 50b4a2d24d..de44e0bde8 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -38,7 +38,8 @@ from colour.adaptation import chromatic_adaptation_VonKries from colour.utilities import (as_float, as_float_array, domain_range_scale, tsplit) -from colour.utilities.documentation import DocstringTuple +from colour.utilities.documentation import (DocstringTuple, + is_documentation_building) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 1c19f23ccc..e763099036 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -1230,7 +1230,7 @@ def ones(shape, dtype=None, order='C'): return np.ones(shape, dtype) -def full(shape, fill_value, dtype=None, order='C'): +def full(shape, fill_value, dtype=None): """ Simple wrapper around :func:`np.full` definition to create arrays with the active type defined by the:attr:`colour.constant.DEFAULT_FLOAT_DTYPE` @@ -1265,7 +1265,7 @@ def full(shape, fill_value, dtype=None, order='C'): if dtype is None: dtype = DEFAULT_FLOAT_DTYPE - return np.full(shape, fill_value, dtype, order) + return np.full(shape, fill_value, dtype) def index_along_last_axis(a, indexes): diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 335f0f8892..eb3787e911 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -1025,7 +1025,7 @@ def test_index_along_last_axis(self): indexes = np.array([[[0, 1], [0, 1]], [[2, 1], [2, 1]], [[2, 1], [2, 0]]]) - np.testing.assert_equal( + np.testing.assert_array_equal( index_along_last_axis(a, indexes), np.array([[[0.51090627, 0.80587656], [0.84085977, 0.79308353]], [[0.20199051, 0.84189245], [0.01612045, 0.58905552]], @@ -1039,11 +1039,11 @@ def test_compare_with_argmin_argmax(self): a = np.random.random((2, 3, 4, 5, 6, 7)) - np.testing.assert_equal( + np.testing.assert_array_equal( index_along_last_axis(a, np.argmin(a, axis=-1)), np.min( a, axis=-1)) - np.testing.assert_equal( + np.testing.assert_array_equal( index_along_last_axis(a, np.argmax(a, axis=-1)), np.max( a, axis=-1)) From a6a4737c861730b4eefb0e23934708b086a3c652 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Thu, 20 Aug 2020 13:58:34 +0200 Subject: [PATCH 13/17] Tests for models, appearance and algebra --- colour/algebra/tests/test_interpolation.py | 1 - colour/appearance/atd95.py | 16 +++- colour/appearance/cam16.py | 11 ++- colour/appearance/ciecam02.py | 9 ++ colour/appearance/hunt.py | 93 ++----------------- colour/appearance/llab.py | 13 ++- colour/appearance/rlab.py | 6 +- colour/appearance/tests/test_atd95.py | 2 +- colour/appearance/tests/test_cam16.py | 9 +- colour/appearance/tests/test_ciecam02.py | 7 +- colour/appearance/tests/test_hunt.py | 2 +- colour/appearance/tests/test_llab.py | 2 +- colour/appearance/tests/test_nayatani95.py | 2 +- colour/appearance/tests/test_rlab.py | 2 +- colour/continuous/tests/test_multi_signal.py | 10 +- colour/difference/delta_e.py | 8 +- colour/models/rgb/derivation.py | 11 ++- colour/models/rgb/tests/test_derivation.py | 9 +- .../models/rgb/tests/test_rgb_colourspace.py | 2 +- .../rgb/transfer_functions/canon_log.py | 6 ++ colour/models/rgb/transfer_functions/log.py | 3 +- .../rgb/transfer_functions/tests/test_log.py | 18 ++-- colour/models/tests/test_cam02_ucs.py | 4 +- 23 files changed, 108 insertions(+), 138 deletions(-) diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index deec8fed04..335cc0504f 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -25,7 +25,6 @@ import os import unittest from itertools import permutations -np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/appearance/atd95.py b/colour/appearance/atd95.py index 3a4a7f5d84..97d6f9701a 100644 --- a/colour/appearance/atd95.py +++ b/colour/appearance/atd95.py @@ -31,8 +31,9 @@ from collections import namedtuple from colour.algebra import spow -from colour.utilities import (as_float_array, dot_vector, from_range_degrees, - to_domain_100, tsplit, tstack) +from colour.utilities import (as_float, as_float_array, dot_vector, + from_range_degrees, to_domain_100, tsplit, + tstack) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -226,6 +227,17 @@ def XYZ_to_ATD95(XYZ, XYZ_0, Y_0, k_1, k_2, sigma=300): # modulus of the :math:`H`, thus :math:`H` can exceed 360 degrees. H = T_2 / D_2 + if np.__name__ == 'cupy': + H = as_float(H) + C = as_float(C) + Br = as_float(Br) + A_1 = as_float(A_1) + D_1 = as_float(D_1) + T_1 = as_float(T_1) + A_2 = as_float(A_2) + T_2 = as_float(T_2) + D_2 = as_float(D_2) + return CAM_Specification_ATD95( from_range_degrees(H), C, Br, A_1, T_1, D_1, A_2, T_2, D_2) diff --git a/colour/appearance/cam16.py b/colour/appearance/cam16.py index 6f7ed9c8f3..2709b4e1e4 100644 --- a/colour/appearance/cam16.py +++ b/colour/appearance/cam16.py @@ -36,7 +36,7 @@ post_adaptation_non_linear_response_compression_matrix, saturation_correlate, temporary_magnitude_quantity_inverse, viewing_condition_dependent_parameters) -from colour.utilities import (CaseInsensitiveMapping, as_float_array, +from colour.utilities import (CaseInsensitiveMapping, as_float, as_float_array, as_namedtuple, dot_vector, from_range_100, from_range_degrees, ones, to_domain_100, to_domain_degrees, tsplit) @@ -309,6 +309,15 @@ def XYZ_to_CAM16(XYZ, # Computing the correlate of *saturation* :math:`s`. s = saturation_correlate(M, Q) + if np.__name__ == 'cupy': + J = as_float(J) + C = as_float(C) + h = as_float(h) + s = as_float(s) + Q = as_float(Q) + M = as_float(M) + H = as_float(H) + return CAM_Specification_CAM16( from_range_100(J), from_range_100(C), from_range_degrees(h), from_range_100(s), from_range_100(Q), from_range_100(M), diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index b6bd68c116..84ae813931 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -330,6 +330,15 @@ def XYZ_to_CIECAM02(XYZ, # Computing the correlate of *saturation* :math:`s`. s = saturation_correlate(M, Q) + if np.__name__ == 'cupy': + J = as_float(J) + C = as_float(C) + h = as_float(h) + s = as_float(s) + Q = as_float(Q) + M = as_float(M) + H = as_float(H) + return CAM_Specification_CIECAM02( from_range_100(J), from_range_100(C), from_range_degrees(h), from_range_100(s), from_range_100(Q), from_range_100(M), diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 43ee58926d..cf65397431 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -491,12 +491,6 @@ def luminance_level_adaptation_factor(L_A): k4 = k ** 4 F_L = 0.2 * k4 * (5 * L_A) + 0.1 * (1 - k4) ** 2 * spow(5 * L_A, 1 / 3) - try: - if F_L.size == 1: - return (F_L).item() - except Exception: - pass - return F_L @@ -528,12 +522,6 @@ def illuminant_scotopic_luminance(L_A, CCT): CCT = 2.26 * L_A * spow((CCT / 4000) - 0.4, 1 / 3) - try: - if CCT.size == 1: - return (CCT).item() - except Exception: - pass - return CCT @@ -590,12 +578,6 @@ def f_n(x): x_p = spow(x, 0.73) x_m = 40 * (x_p / (x_p + 2)) - try: - if x_m.size == 1: - return (x_m).item() - except Exception: - pass - return x_m @@ -780,12 +762,6 @@ def achromatic_post_adaptation_signal(rgb): A = 2 * r + g + (1 / 20) * b - 3.05 + 1 - try: - if A.size == 1: - return (A).item() - except Exception: - pass - return A @@ -854,11 +830,8 @@ def hue_angle(C): hue = (180 * np.arctan2(0.5 * (C_2 - C_3) / 4.5, C_1 - (C_2 / 11)) / np.pi) % 360 - try: - if hue.size == 1: - return (hue).item() - except Exception: - pass + if np.__name__ == 'cupy' and hue.size == 1: + hue = hue.item() return hue @@ -893,12 +866,6 @@ def eccentricity_factor(hue): x = np.where(hue < 20.14, 0.856 - (hue / 20.14) * 0.056, x) x = np.where(hue > 237.53, 0.856 + 0.344 * (360 - hue) / (360 - 237.53), x) - try: - if x.size == 1: - return (x).item() - except Exception: - pass - return x @@ -927,12 +894,6 @@ def low_luminance_tritanopia_factor(L_A): F_t = L_A / (L_A + 0.1) - try: - if F_t.size == 1: - return (F_t).item() - except Exception: - pass - return F_t @@ -983,12 +944,6 @@ def yellowness_blueness_response(C, e_s, N_c, N_cb, F_t): M_yb = ( 100 * (0.5 * (C_2 - C_3) / 4.5) * (e_s * (10 / 13) * N_c * N_cb * F_t)) - try: - if M_yb.size == 1: - return (M_yb).item() - except Exception: - pass - return M_yb @@ -1033,12 +988,6 @@ def redness_greenness_response(C, e_s, N_c, N_cb): M_rg = 100 * (C_1 - (C_2 / 11)) * (e_s * (10 / 13) * N_c * N_cb) - try: - if M_rg.size == 1: - return (M_rg).item() - except Exception: - pass - return M_rg @@ -1071,12 +1020,6 @@ def overall_chromatic_response(M_yb, M_rg): M = spow((M_yb ** 2) + (M_rg ** 2), 0.5) - try: - if M.size == 1: - return (M).item() - except Exception: - pass - return M @@ -1110,11 +1053,8 @@ def saturation_correlate(M, rgb_a): s = 50 * M / np.sum(rgb_a, axis=-1) - try: - if M.size == 1: - return (M).item() - except Exception: - pass + if np.__name__ == 'cupy' and s.size == 1: + s = s.item() return s @@ -1174,12 +1114,6 @@ def achromatic_signal(L_AS, S, S_w, N_bb, A_a): # Computing achromatic signal :math:`A`. A = N_bb * (A_a - 1 + A_S - 0.3 + np.sqrt((1 + (0.3 ** 2)))) - try: - if A.size == 1: - return (A).item() - except Exception: - pass - return A @@ -1223,11 +1157,8 @@ def brightness_correlate(A, A_w, M, N_b): Q = spow(7 * (A + (M / 100)), 0.6) * N_1 - N_2 - try: - if Q.size == 1: - return (Q).item() - except Exception: - pass + if np.__name__ == 'cupy' and Q.size == 1: + Q = Q.item() return Q @@ -1270,12 +1201,6 @@ def lightness_correlate(Y_b, Y_w, Q, Q_w): Z = 1 + spow(Y_b / Y_w, 0.5) J = 100 * spow(Q / Q_w, Z) - try: - if J.size == 1: - return (J).item() - except Exception: - pass - return J @@ -1321,12 +1246,6 @@ def chroma_correlate(s, Y_b, Y_w, Q, Q_w): C_94 = (2.44 * spow(s, 0.69) * (spow(Q / Q_w, Y_b / Y_w)) * (1.64 - spow(0.29, Y_b / Y_w))) - try: - if C_94.size == 1: - return (C_94).item() - except Exception: - pass - return C_94 diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index adf2b8e7cc..0a22cafc73 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -32,7 +32,7 @@ from collections import namedtuple from colour.algebra import polar_to_cartesian, spow -from colour.utilities import (CaseInsensitiveMapping, as_float_array, +from colour.utilities import (CaseInsensitiveMapping, as_float, as_float_array, dot_vector, from_range_degrees, to_domain_100, tsplit, tstack) @@ -325,8 +325,17 @@ def XYZ_to_LLAB( # ------------------------------------------------------------------------- A_L, B_L = tsplit(final_opponent_signals(C_L, h_L)) + if np.__name__ == 'cupy': + L_L = as_float(L_L) + Ch_L = as_float(Ch_L) + h_L = as_float(h_L) + s_L = as_float(s_L) + C_L = as_float(C_L) + A_L = as_float(A_L) + B_L = as_float(B_L) + return CAM_Specification_LLAB(L_L, Ch_L, from_range_degrees(h_L), s_L, C_L, - None, A_L, B_L) + None, A_L, B_L) def XYZ_to_RGB_LLAB(XYZ): diff --git a/colour/appearance/rlab.py b/colour/appearance/rlab.py index b7a772e999..364177b2ff 100644 --- a/colour/appearance/rlab.py +++ b/colour/appearance/rlab.py @@ -26,7 +26,7 @@ from colour.algebra import spow from colour.appearance.hunt import MATRIX_XYZ_TO_HPE, XYZ_to_rgb -from colour.utilities import (CaseInsensitiveMapping, as_float_array, +from colour.utilities import (CaseInsensitiveMapping, as_float, as_float_array, dot_matrix, dot_vector, from_range_degrees, to_domain_100, tsplit, row_as_diagonal) @@ -261,11 +261,11 @@ def XYZ_to_RLAB(XYZ, bR = 170 * (spow(Y_ref, sigma) - spow(Z_ref, sigma)) # Computing the *hue* angle :math:`h^R`. - hR = np.degrees(np.arctan2(bR, aR)) % 360 + hR = as_float(np.degrees(np.arctan2(bR, aR)) % 360) # TODO: Implement hue composition computation. # Computing the correlate of *chroma* :math:`C^R`. - CR = np.hypot(aR, bR) + CR = as_float(np.hypot(aR, bR)) # Computing the correlate of *saturation* :math:`s^R`. sR = CR / LR diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index cc8fc6348b..5b54b23c24 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -92,7 +92,7 @@ def test_domain_range_scale_XYZ_to_ATD95(self): np.testing.assert_array_almost_equal( XYZ_to_ATD95(XYZ * factor_a, XYZ_0 * factor_a, Y_0, k_1, k_2), - specification * factor_b, + np.array(specification[:]) * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index be65e59576..8dd24f8881 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -105,7 +105,7 @@ def test_domain_range_scale_XYZ_to_CAM16(self): np.testing.assert_array_almost_equal( XYZ_to_CAM16(XYZ * factor_a, XYZ_w * factor_a, L_A, Y_b, surround)[:-1], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors @@ -243,7 +243,6 @@ def test_domain_range_scale_CAM16_to_XYZ(self): surround = VIEWING_CONDITIONS_CAM16['Average'] specification = XYZ_to_CAM16(XYZ_i, XYZ_w, L_A, Y_b, surround) XYZ = CAM16_to_XYZ(specification, XYZ_w, L_A, Y_b, surround) - d_r = ( ('reference', 1, 1, 1), (1, @@ -252,11 +251,13 @@ def test_domain_range_scale_CAM16_to_XYZ(self): ]), 0.01, 0.01), (100, np.array([1, 1, 100 / 360, 1, 1, 1, 100 / 360]), 1, 1), ) + for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): np.testing.assert_array_almost_equal( - CAM16_to_XYZ(specification[:-1] * factor_a, - XYZ_w * factor_b, L_A, Y_b, surround), + CAM16_to_XYZ( + np.array(specification[:-1]) * factor_a, + XYZ_w * factor_b, L_A, Y_b, surround), XYZ * factor_c, decimal=7) diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index 938ff98aad..63cd20b9e7 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -101,7 +101,7 @@ def test_domain_range_scale_XYZ_to_CIECAM02(self): np.testing.assert_array_almost_equal( XYZ_to_CIECAM02(XYZ * factor_a, XYZ_w * factor_a, L_A, Y_b, surround)[:-1], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors @@ -251,8 +251,9 @@ def test_domain_range_scale_CIECAM02_to_XYZ(self): for scale, factor_a, factor_b, factor_c in d_r: with domain_range_scale(scale): np.testing.assert_array_almost_equal( - CIECAM02_to_XYZ(specification[:-1] * factor_a, - XYZ_w * factor_b, L_A, Y_b, surround), + CIECAM02_to_XYZ( + np.array(specification[:-1]) * factor_a, + XYZ_w * factor_b, L_A, Y_b, surround), XYZ * factor_c, decimal=7) diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index 272887dedd..653c46a773 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -86,7 +86,7 @@ def test_domain_range_scale_XYZ_to_Hunt(self): CCT_w = 6504.0 specification = XYZ_to_Hunt( XYZ, XYZ_w, XYZ_b, L_A, surround, CCT_w=CCT_w)[:-2] - + print(specification, np.__name__) d_r = ( ('reference', 1, 1), (1, 0.01, np.array([1, 1, 1 / 360, 1, 1, 1])), diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 662fe0af0a..7dfe2881b7 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -156,7 +156,7 @@ def test_domain_range_scale_XYZ_to_LLAB(self): np.testing.assert_array_almost_equal( XYZ_to_LLAB(XYZ * factor_a, XYZ_0 * factor_a, Y_b, L, surround)[:5], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index e74191cbe6..3fdcc60a3c 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -89,7 +89,7 @@ def test_domain_range_scale_XYZ_to_Nayatani95(self): np.testing.assert_array_almost_equal( XYZ_to_Nayatani95(XYZ * factor_a, XYZ_n * factor_a, Y_o, E_o, E_or)[:6], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index 72489c4263..519b6305c2 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -90,7 +90,7 @@ def test_domain_range_scale_XYZ_to_RLAB(self): np.testing.assert_array_almost_equal( XYZ_to_RLAB(XYZ * factor_a, XYZ_n * factor_a, Y_n, sigma, D)[:4], - specification * factor_b, + np.array(specification) * factor_b, decimal=7) @ignore_numpy_errors diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index 500b1755a3..a63ddf1f94 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -313,9 +313,11 @@ def test__init__(self): np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_2) - multi_signals = MultiSignals(dict(zip(self._domain_2, self._range_2))) - np.testing.assert_array_equal(multi_signals.domain, self._domain_2) - np.testing.assert_array_equal(multi_signals.range, self._range_2) + if np.__name__ == 'numpy': + multi_signals = MultiSignals( + dict(zip(self._domain_2, self._range_2))) + np.testing.assert_array_equal(multi_signals.domain, self._domain_2) + np.testing.assert_array_equal(multi_signals.range, self._range_2) multi_signals = MultiSignals(multi_signals) np.testing.assert_array_equal(multi_signals.domain, self._domain_2) @@ -334,7 +336,7 @@ class NotSignal(Signal): np.testing.assert_array_equal(multi_signals.range, self._range_1[:, np.newaxis]) - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import DataFrame, Series multi_signals = MultiSignals( diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 53b9b83995..10f83103ea 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -38,7 +38,7 @@ import colour.ndarray as np from colour.algebra import euclidean_distance -from colour.utilities import to_domain_100, tsplit +from colour.utilities import as_float, to_domain_100, tsplit from colour.utilities.documentation import (DocstringFloat, is_documentation_building) __author__ = 'Colour Developers' @@ -223,7 +223,7 @@ def delta_E_CIE1994(Lab_1, Lab_2, textiles=False): try: if d_E.size == 1: - return d_E.item() + return as_float(d_E) except Exception: pass @@ -372,7 +372,7 @@ def delta_E_CIE2000(Lab_1, Lab_2, textiles=False): try: if d_E.size == 1: - return d_E.item() + return as_float(d_E) except Exception: pass @@ -470,7 +470,7 @@ def delta_E_CMC(Lab_1, Lab_2, l=2, c=1): # noqa try: if d_E.size == 1: - return d_E.item() + return as_float(d_E) except Exception: pass diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index dc69f56f4a..48fd5e47d5 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -116,11 +116,14 @@ def normalised_primary_matrix(primaries, whitepoint): whitepoint = np.array(whitepoint) primaries = np.array(primaries) cupy = True + try: + coefficients = np.dot(np.linalg.inv(primaries), whitepoint) + coefficients = np.diagflat(coefficients) - coefficients = np.dot(np.linalg.inv(primaries), whitepoint) - coefficients = np.diagflat(coefficients) - - npm = np.dot(primaries, coefficients) + npm = np.dot(primaries, coefficients) + except Exception: + np.set_ndimensional_array_backend('cupy') + raise if cupy is True: np.set_ndimensional_array_backend('cupy') diff --git a/colour/models/rgb/tests/test_derivation.py b/colour/models/rgb/tests/test_derivation.py index b710365d64..c257ae93d1 100644 --- a/colour/models/rgb/tests/test_derivation.py +++ b/colour/models/rgb/tests/test_derivation.py @@ -10,6 +10,7 @@ import unittest from itertools import permutations from six import text_type +from numpy.linalg import LinAlgError from colour.models import ( normalised_primary_matrix, chromatically_adapted_primaries, @@ -135,7 +136,7 @@ def test_nan_normalised_primary_matrix(self): W = np.array(case) try: normalised_primary_matrix(P, W) - except np.linalg.linalg.LinAlgError: + except LinAlgError: pass @@ -337,8 +338,8 @@ def test_n_dimensional_RGB_luminance(self): n_dimensional arrays support. """ - RGB = np.array([0.18, 0.18, 0.18]), - P = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]), + RGB = np.array([0.18, 0.18, 0.18]) + P = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]) W = np.array([0.32168, 0.33767]) Y = RGB_luminance(RGB, P, W) @@ -366,7 +367,7 @@ def test_nan_RGB_luminance(self): W = np.array(case[0:2]) try: RGB_luminance(RGB, P, W) - except np.linalg.linalg.LinAlgError: + except LinAlgError: pass diff --git a/colour/models/rgb/tests/test_rgb_colourspace.py b/colour/models/rgb/tests/test_rgb_colourspace.py index 876c47aa54..9ee64972d9 100644 --- a/colour/models/rgb/tests/test_rgb_colourspace.py +++ b/colour/models/rgb/tests/test_rgb_colourspace.py @@ -786,7 +786,7 @@ def test_RGB_to_RGB(self): np.array([0.60983062, 0.67896356, 0.50435764]), decimal=7) - np.testing.assert_equal( + np.testing.assert_array_equal( RGB_to_RGB( np.array([0.21931722, 0.06950287, 0.04694832]), aces_2065_1_colourspace, diff --git a/colour/models/rgb/transfer_functions/canon_log.py b/colour/models/rgb/transfer_functions/canon_log.py index b57b856cdb..67747c6b61 100644 --- a/colour/models/rgb/transfer_functions/canon_log.py +++ b/colour/models/rgb/transfer_functions/canon_log.py @@ -204,6 +204,9 @@ def log_decoding_CanonLog(clog, clog = (legal_to_full(clog, bit_depth) if in_normalised_code_value else clog) + if np.__name__ == 'cupy': + clog = np.array(clog) + x = np.where( clog < 0.0730597, -(10 ** ((0.0730597 - clog) / 0.529136) - 1) / 10.1596, @@ -359,6 +362,9 @@ def log_decoding_CanonLog2(clog2, clog2 = (legal_to_full(clog2, bit_depth) if in_normalised_code_value else clog2) + if np.__name__ == 'cupy': + clog2 = np.array(clog2) + x = np.where( clog2 < 0.035388128, -(10 ** ((0.035388128 - clog2) / 0.281863093) - 1) / 87.09937546, diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index 76935577a2..544b038637 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -39,7 +39,8 @@ from __future__ import division, unicode_literals import colour.ndarray as np -from colour.utilities import as_float, from_range_1, to_domain_1 +from colour.utilities import (as_float, as_float_array, from_range_1, + to_domain_1) __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/models/rgb/transfer_functions/tests/test_log.py b/colour/models/rgb/transfer_functions/tests/test_log.py index 50e9bddd8e..983a24a4f9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_log.py @@ -81,17 +81,17 @@ def test_n_dimensional_logarithmic_function_basic(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_basic(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_basic(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_basic(a, style), a_p, decimal=7) def test_raise_exception_logarithmic_function_basic(self): @@ -208,17 +208,17 @@ def test_n_dimensional_logarithmic_function_quasilog(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_quasilog(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_quasilog(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_quasilog(a, style), a_p, decimal=7) def test_raise_exception_logarithmic_function_quasilog(self): @@ -351,17 +351,17 @@ def test_n_dimensional_logarithmic_function_camera(self): a = np.tile(a, 6) a_p = np.tile(a_p, 6) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_camera(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3)) a_p = np.reshape(a_p, (2, 3)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_camera(a, style), a_p, decimal=7) a = np.reshape(a, (2, 3, 1)) a_p = np.reshape(a_p, (2, 3, 1)) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( logarithmic_function_camera(a, style), a_p, decimal=7) def test_raise_exception_logarithmic_function_camera(self): diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index 6862f1aa53..b7059f62a9 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -48,9 +48,7 @@ def setUp(self): surround = VIEWING_CONDITIONS_CIECAM02['Average'] specification = XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b, surround) self._JMh = np.array( - [specification.J, - specification.M.item(), - specification.h.item()]) + [specification.J, specification.M, specification.h]) def test_JMh_CIECAM02_to_UCS_Luo2006(self): """ From b98c24ef3f0f210eb6a4dc0016dc771b89ad9044 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Sat, 22 Aug 2020 02:43:22 +0200 Subject: [PATCH 14/17] Fixed the switches between cupy and numpy, turned jakob2019 to ndarray instead of numpy, redefined the as_float for numpy to avoid the zero division error, currently all tests work on numpy and some of them do not work on cupy as shared in the document --- colour/adaptation/vonkries.py | 2 +- colour/algebra/geometry.py | 8 +++- colour/algebra/tests/test_common.py | 12 +++-- colour/appearance/ciecam02.py | 5 +- colour/characterisation/aces_it.py | 4 +- colour/colorimetry/tristimulus.py | 4 +- colour/continuous/multi_signals.py | 5 ++ colour/continuous/signal.py | 8 ++-- colour/continuous/tests/test_multi_signal.py | 31 ++++++------ colour/continuous/tests/test_signal.py | 36 +++++++++----- colour/corresponding/prediction.py | 2 +- colour/geometry/tests/test_primitives.py | 1 - colour/graph/tests/test_conversion.py | 2 +- colour/io/luts/cinespace_csp.py | 48 +++++++++++-------- colour/io/luts/resolve_cube.py | 7 +-- colour/io/luts/sony_spi1d.py | 10 ++-- colour/io/luts/sony_spi3d.py | 21 +++++--- colour/models/osa_ucs.py | 4 +- colour/models/rgb/derivation.py | 4 +- colour/recovery/jakob2019.py | 2 +- colour/recovery/meng2015.py | 2 + colour/recovery/tests/test_jakob2019.py | 2 +- colour/temperature/robertson1968.py | 4 +- .../temperature/tests/test_robertson1968.py | 2 +- colour/utilities/array.py | 14 +++--- colour/utilities/metrics.py | 2 +- 26 files changed, 151 insertions(+), 91 deletions(-) diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index 3417149bff..f544a55f67 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -102,7 +102,7 @@ def chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr, transform='CAT02'): XYZ_w = to_domain_1(XYZ_w) XYZ_wr = to_domain_1(XYZ_wr) - M = np.array(CHROMATIC_ADAPTATION_TRANSFORMS.get(transform)) + M = CHROMATIC_ADAPTATION_TRANSFORMS.get(transform) if M is None: raise KeyError( diff --git a/colour/algebra/geometry.py b/colour/algebra/geometry.py index 867892e435..020d494a12 100644 --- a/colour/algebra/geometry.py +++ b/colour/algebra/geometry.py @@ -526,7 +526,13 @@ def ellipse_fitting_Halir1998(a): if np.__name__ == 'cupy': Mnp = np.asnumpy(M) np.set_ndimensional_array_backend('numpy') - _w, v = np.linalg.eig(Mnp) + + try: + _w, v = np.linalg.eig(Mnp) + except Exception: + np.set_ndimensional_array_backend('cupy') + raise + np.set_ndimensional_array_backend('cupy') _w = np.array(_w) v = np.array(v) diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py index 6459ffe214..047ca3b282 100644 --- a/colour/algebra/tests/test_common.py +++ b/colour/algebra/tests/test_common.py @@ -139,15 +139,17 @@ def test_smoothstep_function(self): Tests :func:`colour.algebra.common.smoothstep_function` definition. """ - self.assertEqual(smoothstep_function(0.5), 0.5) - self.assertEqual(smoothstep_function(0.25), 0.15625) - self.assertEqual(smoothstep_function(0.75), 0.84375) + np.testing.assert_array_almost_equal(smoothstep_function(0.5), 0.5) + np.testing.assert_array_almost_equal( + smoothstep_function(0.25), 0.15625) + np.testing.assert_array_almost_equal( + smoothstep_function(0.75), 0.84375) x = np.linspace(-2, 2, 5) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( smoothstep_function(x), np.array([28.00000, 5.00000, 0.00000, 1.00000, -4.00000])) - np.testing.assert_almost_equal( + np.testing.assert_array_almost_equal( smoothstep_function(x, -2, 2, clip=True), np.array([0.00000, 0.15625, 0.50000, 0.84375, 1.00000])) diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 84ae813931..47a5c93135 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -1045,7 +1045,10 @@ def hue_quadrature(h): hnp = np.asnumpy(h) h_inp = np.asnumpy(h_i) np.set_ndimensional_array_backend('numpy') - i = as_int_array(np.searchsorted(h_inp, hnp, side='left') - 1) + try: + i = as_int_array(np.searchsorted(h_inp, hnp, side='left') - 1) + except Exception: + np.set_ndimensional_array_backend('cupy') np.set_ndimensional_array_backend('cupy') i = as_int(i) else: diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index dea3fc144b..33127cda3f 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -168,8 +168,8 @@ def sd_to_aces_relative_exposure_values( if illuminant.shape != MSDS_ACES_RICD.shape: illuminant = illuminant.copy().align(shape) - s_v = sd.values - i_v = illuminant.values + s_v = np.array(sd.values) + i_v = np.array(illuminant.values) r_bar, g_bar, b_bar = tsplit(MSDS_ACES_RICD.values) diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 179c9ffe27..4cef030db5 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -921,7 +921,9 @@ def sd_to_XYZ( tuple(kwargs.items()), get_domain_range_scale()) ]) if hash_key in _CACHE_SD_TO_XYZ: - return _CACHE_SD_TO_XYZ[hash_key] + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return np.array(_CACHE_SD_TO_XYZ[hash_key]) function = SD_TO_XYZ_METHODS[method] diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 9987bcbdb5..372e6f1245 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -646,11 +646,14 @@ def __str__(self): np.array(self.domain[:, np.newaxis]), np.array(self.range) ])) + if cupy is True: np.set_ndimensional_array_backend('cupy') return string except TypeError: + if cupy is True: + np.set_ndimensional_array_backend('cupy') return super(MultiSignals, self).__str__() def __repr__(self): @@ -723,6 +726,8 @@ def __repr__(self): return representation except TypeError: + if cupy is True: + np.set_ndimensional_array_backend('cupy') return super(MultiSignals, self).__repr__() def __hash__(self): diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 0f166b6e40..c292e29d62 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -542,13 +542,13 @@ def __str__(self): np.set_ndimensional_array_backend('numpy') cupy = True try: - string = str( - np.hstack([np.array(self.domain), - np.array(self.range)])) + string = str(tstack([np.array(self.domain), np.array(self.range)])) if cupy is True: np.set_ndimensional_array_backend('cupy') return string except TypeError: + if cupy is True: + np.set_ndimensional_array_backend('cupy') return super(Signal, self).__str__() def __repr__(self): @@ -610,6 +610,8 @@ def __repr__(self): return representation except TypeError: + if cupy is True: + np.set_ndimensional_array_backend('cupy') return super(Signal, self).__repr__() def __hash__(self): diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index a63ddf1f94..74c1fca6ae 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -770,22 +770,23 @@ def test_multi_signals_unpack_data(self): np.testing.assert_array_equal(signals[1].range, self._range_1 + 10) np.testing.assert_array_equal(signals[2].range, self._range_1 + 20) - signals = MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2))) - self.assertListEqual(list(signals.keys()), [0, 1, 2]) - np.testing.assert_array_equal(signals[0].range, self._range_1) - np.testing.assert_array_equal(signals[1].range, self._range_1 + 10) - np.testing.assert_array_equal(signals[2].range, self._range_1 + 20) + if np.__name__ == 'numpy': + signals = MultiSignals.multi_signals_unpack_data( + dict(zip(self._domain_2, self._range_2))) + self.assertListEqual(list(signals.keys()), [0, 1, 2]) + np.testing.assert_array_equal(signals[0].range, self._range_1) + np.testing.assert_array_equal(signals[1].range, self._range_1 + 10) + np.testing.assert_array_equal(signals[2].range, self._range_1 + 20) - signals = MultiSignals.multi_signals_unpack_data( - MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)))) - self.assertListEqual(list(signals.keys()), [0, 1, 2]) - np.testing.assert_array_equal(signals[0].range, self._range_1) - np.testing.assert_array_equal(signals[1].range, self._range_1 + 10) - np.testing.assert_array_equal(signals[2].range, self._range_1 + 20) + signals = MultiSignals.multi_signals_unpack_data( + MultiSignals.multi_signals_unpack_data( + dict(zip(self._domain_2, self._range_2)))) + self.assertListEqual(list(signals.keys()), [0, 1, 2]) + np.testing.assert_array_equal(signals[0].range, self._range_1) + np.testing.assert_array_equal(signals[1].range, self._range_1 + 10) + np.testing.assert_array_equal(signals[2].range, self._range_1 + 20) - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import DataFrame, Series signals = MultiSignals.multi_signals_unpack_data( @@ -853,7 +854,7 @@ def test_to_dataframe(self): method. """ - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import DataFrame data = dict(zip(['a', 'b', 'c'], tsplit(self._range_2))) diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index d94ae65aa2..f4eb0968ca 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -224,15 +224,16 @@ def test__init__(self): np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) - signal = Signal(dict(zip(self._domain, self._range))) - np.testing.assert_array_equal(signal.domain, self._domain) - np.testing.assert_array_equal(signal.range, self._range) + if np.__name__ == 'numpy': + signal = Signal(dict(zip(self._domain, self._range))) + np.testing.assert_array_equal(signal.domain, self._domain) + np.testing.assert_array_equal(signal.range, self._range) signal = Signal(signal) np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import Series signal = Signal(Series(dict(zip(self._domain, self._range)))) @@ -250,7 +251,19 @@ def test__str__(self): """ Tests :func:`colour.continuous.signal.Signal.__str__` method. """ - + print(str(self._signal)) + print( + textwrap.dedent(""" + [[ 0. 10.] + [ 1. 20.] + [ 2. 30.] + [ 3. 40.] + [ 4. 50.] + [ 5. 60.] + [ 6. 70.] + [ 7. 80.] + [ 8. 90.] + [ 9. 100.]]""")[1:]) self.assertEqual( str(self._signal), textwrap.dedent(""" @@ -574,17 +587,18 @@ def test_signal_unpack_data(self): np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) - domain, range_ = Signal.signal_unpack_data( - dict(zip(self._domain, self._range))) - np.testing.assert_array_equal(range_, self._range) - np.testing.assert_array_equal(domain, self._domain) + if np.__name__ == 'numpy': + domain, range_ = Signal.signal_unpack_data( + dict(zip(self._domain, self._range))) + np.testing.assert_array_equal(range_, self._range) + np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( Signal(self._range, self._domain)) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import Series domain, range_ = Signal.signal_unpack_data( @@ -633,7 +647,7 @@ def test_to_series(self): Tests :func:`colour.continuous.signal.Signal.to_series` method. """ - if is_pandas_installed(): + if np.__name__ == 'numpy' and is_pandas_installed(): from pandas import Series self.assertEqual( diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index b8f67694ed..1e7540ecf9 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -185,7 +185,7 @@ def convert_experiment_results_Breneman1987(experiment): 0.3, {}) """ - + print('sdddddddd') valid_experiment_results = (1, 2, 3, 4, 6, 8, 9, 11, 12) assert experiment in valid_experiment_results, ( '"Breneman (1987)" experiment result must be one of "{0}"!'.format( diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index d33ac9f744..aa6c836419 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -9,7 +9,6 @@ import colour.ndarray as np import unittest -np.set_ndimensional_array_backend('cupy') __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 460e53e203..af5718b050 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -120,7 +120,7 @@ def test_convert_direct_keyword_argument_passing(self): convert(a, 'CIE XYZ', 'CIE xyY', illuminant=illuminant), decimal=7) - if six.PY3: # pragma: no cover + if np.__name__ == 'numpy' and six.PY3: # pragma: no cover # Illuminant "ndarray" is converted to tuple here so that it can # be hashed by the "sd_to_XYZ" definition, this should never occur # in practical application. diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 1e23be00af..ab1bca3a5a 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -274,10 +274,6 @@ def write_LUT_Cinespace(LUT, path, decimals=7): ... comments=['A first comment.', 'A second comment.']) >>> write_LUT_Cinespace(LUT, 'My_LUT.cube') # doctest: +SKIP """ - cupy = False - if np.__name__ == 'cupy': - np.set_ndimensional_array_backend('numpy') - cupy = True has_3D, has_3x1D, non_uniform = False, False, False @@ -319,6 +315,21 @@ def write_LUT_Cinespace(LUT, path, decimals=7): if has_3D: assert 2 <= LUT[1].size <= 256, 'Cube size must be in domain [2, 256]!' + domain0 = LUT[0].domain + table0 = LUT[0].table + + domain1 = LUT[1].domain + table1 = LUT[1].table + + cupy = False + if np.__name__ == 'cupy': + domain0 = np.asnumpy(domain0) + table0 = np.asnumpy(table0) + domain1 = np.asnumpy(domain1) + table1 = np.asnumpy(table1) + np.set_ndimensional_array_backend('numpy') + cupy = True + def _ragged_size(table): """ Return the ragged size of given table. @@ -372,9 +383,9 @@ def _format_tuple(array): if has_3x1D: for i in range(3): if LUT[0].is_domain_explicit(): - size = _ragged_size(LUT[0].domain)[i] - table_min = np.nanmin(LUT[0].table) - table_max = np.nanmax(LUT[0].table) + size = _ragged_size(domain0)[i] + table_min = np.nanmin(table0) + table_max = np.nanmax(table0) else: size = LUT[0].size @@ -382,18 +393,17 @@ def _format_tuple(array): for j in range(size): if LUT[0].is_domain_explicit(): - entry = LUT[0].domain[j][i] + entry = domain0[j][i] else: - entry = ( - LUT[0].domain[0][i] + j * - (LUT[0].domain[1][i] - LUT[0].domain[0][i]) / - (LUT[0].size - 1)) + entry = (domain0[0][i] + + j * (domain0[1][i] - domain0[0][i]) / + (LUT[0].size - 1)) csp_file.write('{0:.{1}f} '.format(entry, decimals)) csp_file.write('\n') for j in range(size): - entry = LUT[0].table[j][i] + entry = table0[j][i] if non_uniform: entry -= table_min entry /= (table_max - table_min) @@ -404,8 +414,7 @@ def _format_tuple(array): for i in range(3): csp_file.write('2\n') csp_file.write('{0}\n'.format( - _format_tuple( - [LUT[1].domain[0][i], LUT[1].domain[1][i]]))) + _format_tuple([domain1[0][i], domain1[1][i]]))) csp_file.write('{0:.{2}f} {1:.{2}f}\n'.format( 0, 1, decimals)) if non_uniform: @@ -416,9 +425,8 @@ def _format_tuple(array): csp_file.write('{0}\n'.format(_format_array(row))) else: csp_file.write('\n{0} {1} {2}\n'.format( - LUT[1].table.shape[0], LUT[1].table.shape[1], - LUT[1].table.shape[2])) - table = LUT[1].table.reshape([-1, 3], order='F') + table1.shape[0], table1.shape[1], table1.shape[2])) + table = table1.reshape([-1, 3], order='F') for row in table: csp_file.write('{0}\n'.format(_format_array(row))) @@ -427,10 +435,10 @@ def _format_tuple(array): for i in range(3): csp_file.write('2\n') csp_file.write('{0}\n'.format( - _format_tuple([LUT[0].domain[0][i], LUT[0].domain[1][i]]))) + _format_tuple([domain0[0][i], domain0[1][i]]))) csp_file.write('0.0 1.0\n') csp_file.write('\n{0}\n'.format(LUT[0].size)) - table = LUT[0].table + table = table0 for row in table: csp_file.write('{0}\n'.format(_format_array(row))) diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index 6aa918cf6c..8ee5b4307d 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -273,9 +273,6 @@ def write_LUT_ResolveCube(LUT, path, decimals=7): """ cupy = False - if np.__name__ == 'cupy': - np.set_ndimensional_array_backend('numpy') - cupy = True has_3D, has_3x1D = False, False @@ -318,6 +315,10 @@ def write_LUT_ResolveCube(LUT, path, decimals=7): if has_3D: assert 2 <= LUT[1].size <= 256, 'Cube size must be in domain [2, 256]!' + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + cupy = True + def _format_array(array): """ Formats given array as a *Resolve* *.cube* data row. diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index fa77fd0941..5a2ab8c94a 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -195,17 +195,17 @@ def write_LUT_SonySPI1D(LUT, path, decimals=7): table = LUT.table cupy = False + if not (is_1D): + domain = np.unique(domain) + + assert len(domain) == 2, 'Non-uniform "LUT" domain is unsupported!' + if np.__name__ == 'cupy': domain = np.asnumpy(domain) table = np.asnumpy(table) np.set_ndimensional_array_backend('numpy') cupy = True - if not (is_1D): - domain = np.unique(domain) - - assert len(domain) == 2, 'Non-uniform "LUT" domain is unsupported!' - def _format_array(array): """ Formats given array as a *Sony* *.spi1d* data row. diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index afdb00fb49..d1348f8872 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -98,9 +98,15 @@ def read_LUT_SonySPI3D(path): table.append(as_float_array(tokens[3:])) indexes = as_int_array(indexes) - sorting_indexes = np.lexsort((indexes[:, 2], indexes[:, 1], indexes[:, 0])) if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + indexes = np.array(indexes) + sorting_indexes = np.lexsort((indexes[:, 2], indexes[:, 1], + indexes[:, 0])) + np.set_ndimensional_array_backend('cupy') + indexes = np.array(indexes) + sorting_indexes = np.array(sorting_indexes) assert np.array_equal( indexes[sorting_indexes], np.array( @@ -108,6 +114,8 @@ def read_LUT_SonySPI3D(path): dtype=np.int64).reshape( (-1, 3))), 'Indexes do not match expected "LUT3D" indexes!' else: + sorting_indexes = np.lexsort((indexes[:, 2], indexes[:, 1], + indexes[:, 0])) assert np.array_equal( indexes[sorting_indexes], DEFAULT_INT_DTYPE( @@ -172,6 +180,12 @@ def write_LUT_SonySPI3D(LUT, path, decimals=7): indexTable = LUT.linear_table(LUT.size) cupy = False + + assert np.array_equal(domain, np.array([ + [0, 0, 0], + [1, 1, 1], + ])), '"LUT" domain must be [[0, 0, 0], [1, 1, 1]]!' + if np.__name__ == 'cupy': domain = np.asnumpy(domain) table = np.asnumpy(table) @@ -179,11 +193,6 @@ def write_LUT_SonySPI3D(LUT, path, decimals=7): np.set_ndimensional_array_backend('numpy') cupy = True - assert np.array_equal(domain, np.array([ - [0, 0, 0], - [1, 1, 1], - ])), '"LUT" domain must be [[0, 0, 0], [1, 1, 1]]!' - def _format_array(array): """ Formats given array as a *Sony* *.spi3d* data row. diff --git a/colour/models/osa_ucs.py b/colour/models/osa_ucs.py index fb7ee0c732..6d93b65125 100644 --- a/colour/models/osa_ucs.py +++ b/colour/models/osa_ucs.py @@ -227,7 +227,9 @@ def error_function(XYZ, Ljg): fmin(error_function, x_0, (Ljg_i, ), **optimisation_settings) for Ljg_i in Ljg ]) - if cupy: + + if cupy is True: np.set_ndimensional_array_backend('cupy') XYZ = np.array(XYZ) + return from_range_100(XYZ.reshape(shape)) diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index 48fd5e47d5..e10b1e5947 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -121,8 +121,10 @@ def normalised_primary_matrix(primaries, whitepoint): coefficients = np.diagflat(coefficients) npm = np.dot(primaries, coefficients) + except Exception: - np.set_ndimensional_array_backend('cupy') + if cupy is True: + np.set_ndimensional_array_backend('cupy') raise if cupy is True: diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index dfffe7df21..98a44fcefd 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -20,7 +20,7 @@ from __future__ import division, print_function, unicode_literals -import numpy as np +import colour.ndarray as np import struct from scipy.optimize import minimize from scipy.interpolate import RegularGridInterpolator diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 00ccd6f6f2..96c409c966 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -218,6 +218,8 @@ def constraint_function(a): result = minimize(objective_function, np.array(sd.values), **optimisation_settings) if not result.success: + if cupy is True: + np.set_ndimensional_array_backend('cupy') raise RuntimeError( 'Optimization failed for {0} after {1} iterations: "{2}".'.format( XYZ, result.nit, result.message)) diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index d5f1f6ec0a..d97e60c15b 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import os import shutil import tempfile diff --git a/colour/temperature/robertson1968.py b/colour/temperature/robertson1968.py index 7a7c2a86b4..abf26b4743 100644 --- a/colour/temperature/robertson1968.py +++ b/colour/temperature/robertson1968.py @@ -39,7 +39,7 @@ import colour.ndarray as np from collections import namedtuple -from colour.utilities import as_float_array, tsplit +from colour.utilities import as_float, as_float_array, tsplit __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -182,7 +182,7 @@ def _uv_to_CCT_Robertson1968(uv): last_du = du last_dv = dv - return np.array([T, -D_uv]) + return np.array([as_float(T), as_float(-D_uv)]) def uv_to_CCT_Robertson1968(uv): diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index f28e573dd4..76a05fa19c 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -5,7 +5,7 @@ from __future__ import division, unicode_literals -import numpy as np +import colour.ndarray as np import unittest from itertools import permutations diff --git a/colour/utilities/array.py b/colour/utilities/array.py index e763099036..85559be9fb 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -270,12 +270,14 @@ def as_float(a, dtype=None): assert dtype in np.sctypes['float'], ( '"dtype" must be one of the following types: {0}'.format( np.sctypes['float'])) - try: - # TODO: Change to "DEFAULT_INT_DTYPE" when and if - # https://github.com/numpy/numpy/issues/11956 is addressed. - return float(a) - except TypeError: - return as_float_array(a, dtype) + + if np.__name__ == 'cupy': + try: + return float(a) + except TypeError: + return as_float_array(a, dtype) + + return dtype(a) def set_float_precision(dtype=DEFAULT_FLOAT_DTYPE): diff --git a/colour/utilities/metrics.py b/colour/utilities/metrics.py index 8d0bd77cdb..f2978811dc 100644 --- a/colour/utilities/metrics.py +++ b/colour/utilities/metrics.py @@ -68,7 +68,7 @@ def metric_mse(a, b, axis=None): """ metric = np.mean((as_float_array(a) - as_float_array(b)) ** 2, axis=axis) try: - if metric.size == 1: + if np.__name__ == 'cupy' and metric.size == 1: return metric.item() except Exception: pass From 7d1a75ca4e9103f50b5c23d5dbc7cc9b1d0b0983 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Mon, 24 Aug 2020 12:10:31 +0200 Subject: [PATCH 15/17] Fixes for the munsell code, still have one test to pass --- colour/ndarray/backend.py | 4 +- colour/notation/munsell.py | 159 +++++++++++++++++--------- colour/notation/tests/test_munsell.py | 42 +++++-- 3 files changed, 140 insertions(+), 65 deletions(-) diff --git a/colour/ndarray/backend.py b/colour/ndarray/backend.py index 017d5fe546..bdf4a51388 100644 --- a/colour/ndarray/backend.py +++ b/colour/ndarray/backend.py @@ -25,7 +25,7 @@ ] _NDIMENSIONAL_ARRAY_BACKEND = os.environ.get( - 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Numpy').lower() + 'COLOUR_SCIENCE__NDIMENSIONAL_ARRAY_BACKEND', 'Cupy').lower() def get_ndimensional_array_backend(): @@ -33,7 +33,7 @@ def get_ndimensional_array_backend(): return _NDIMENSIONAL_ARRAY_BACKEND -def _set_ndimensional_array_backend(backend='Numpy'): +def _set_ndimensional_array_backend(backend='Cupy'): global _NDIMENSIONAL_ARRAY_BACKEND backend = str(backend).lower() diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 0809be7dee..bbbce42dac 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -124,8 +124,7 @@ cartesian_to_cylindrical, euclidean_distance, polar_to_cartesian, spow) from colour.colorimetry import CCS_ILLUMINANTS, luminance_ASTMD1535 -from colour.constants import (DEFAULT_FLOAT_DTYPE, DEFAULT_INT_DTYPE, - INTEGER_THRESHOLD, FLOATING_POINT_NUMBER_PATTERN) +from colour.constants import (INTEGER_THRESHOLD, FLOATING_POINT_NUMBER_PATTERN) from colour.models import Lab_to_LCHab, XYZ_to_Lab, XYZ_to_xy, xyY_to_XYZ from colour.volume import is_within_macadam_limits from colour.notation import MUNSELL_COLOURS_ALL @@ -277,9 +276,9 @@ def _munsell_maximum_chromas_from_renotation(): for munsell_colour in MUNSELL_COLOURS_ALL: hue, value, chroma, code = munsell_colour_to_munsell_specification( MUNSELL_COLOUR_FORMAT.format(*munsell_colour[0])) - index = (hue, value, code) + index = (as_float(hue), as_float(value), as_float(code)) if index in chromas: - chroma = max(chromas[index], chroma) + chroma = as_float(max(chromas[index], as_float(chroma))) chromas[index] = chroma @@ -753,9 +752,9 @@ def _munsell_specification_to_xyY(specification): else: specification = to_domain_10(specification, _domain_range_scale_factor()) - hue, value, chroma, code = ([as_float(i) for i in specification[0:3]] + - [DEFAULT_INT_DTYPE(specification[-1])]) - + hue, value, chroma, code = ( + [as_float(i) + for i in specification[0:3]] + [as_float(specification[-1])]) assert 0 <= hue <= 10, ( '"{0}" specification hue must be normalised to domain ' '[0, 10]!'.format(specification)) @@ -763,6 +762,9 @@ def _munsell_specification_to_xyY(specification): '"{0}" specification value must be normalised to domain ' '[0, 10]!'.format(specification)) + hue, value, chroma, code = as_float(hue), as_float(value), as_float( + chroma), as_float(code) + with domain_range_scale('ignore'): Y = luminance_ASTMD1535(value) @@ -791,11 +793,16 @@ def _munsell_specification_to_xyY(specification): Y_plus = luminance_ASTMD1535(value_plus) x = LinearInterpolator( - np.ravel([Y_minus, Y_plus]), np.ravel([x_minus, x_plus]))(Y) + np.ravel(np.array([Y_minus, Y_plus])), + np.ravel(np.array([x_minus, x_plus])))(Y) y = LinearInterpolator( - np.ravel([Y_minus, Y_plus]), np.ravel([y_minus, y_plus]))(Y) + np.ravel(np.array([Y_minus, Y_plus])), + np.ravel(np.array([y_minus, y_plus])))(Y) - return np.array([x, y, from_range_1(Y / 100)]) + return np.array( + [as_float(x), + as_float(y), + as_float(from_range_1(Y / 100))]) def munsell_specification_to_xyY(specification): @@ -895,6 +902,11 @@ def munsell_colour_to_xyY(munsell_colour): array([ 0.31006 , 0.31616 , 0.7461345...]) """ + cupy = False + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) shape = list(munsell_colour.shape) @@ -903,6 +915,10 @@ def munsell_colour_to_xyY(munsell_colour): for a in np.ravel(munsell_colour) ]) + if cupy is True: + np.set_ndimensional_array_backend('cupy') + specification = np.array(specification) + return munsell_specification_to_xyY( from_range_10( specification.reshape(shape + [4]), _domain_range_scale_factor())) @@ -961,7 +977,7 @@ def _xyY_to_munsell_specification(xyY): Xr, Yr, Zr = xyY_to_XYZ([xi, yi, Y]) XYZ = np.array([X, Y, Z]) - XYZr = np.array([(1 / Yr) * Xr, 1, (1 / Yr) * Zr]) + XYZr = np.array([as_float((1 / Yr) * Xr), 1, as_float((1 / Yr) * Zr)]) Lab = XYZ_to_Lab(XYZ, XYZ_to_xy(XYZr)) LCHab = Lab_to_LCHab(Lab) @@ -993,13 +1009,14 @@ def _xyY_to_munsell_specification(xyY): rho_current, phi_current, _z_current = cartesian_to_cylindrical( (x_current - x_center, y_current - y_center, Y_center)) - phi_current = np.degrees(phi_current) - phi_current_difference = (360 - phi_input + phi_current) % 360 + phi_current = as_float(np.degrees(phi_current)) + phi_current_difference = as_float( + (360 - phi_input + phi_current) % 360) if phi_current_difference > 180: phi_current_difference -= 360 phi_differences = [phi_current_difference] - hue_angles = [hue_angle_current] + hue_angles = [as_float(hue_angle_current)] hue_angles_differences = [0] iterations_maximum_inner = 16 @@ -1038,14 +1055,15 @@ def _xyY_to_munsell_specification(xyY): if extrapolate is False: rho_inner, phi_inner, _z_inner = cartesian_to_cylindrical( (x_inner - x_center, y_inner - y_center, Y_center)) - phi_inner = np.degrees(phi_inner) + phi_inner = as_float(np.degrees(phi_inner)) phi_inner_difference = ((360 - phi_input + phi_inner) % 360) if phi_inner_difference > 180: phi_inner_difference -= 360 - phi_differences.append(phi_inner_difference) - hue_angles.append(hue_angle_inner) - hue_angles_differences.append(hue_angle_difference_inner) + phi_differences.append(as_float(phi_inner_difference)) + hue_angles.append(as_float(hue_angle_inner)) + hue_angles_differences.append( + as_float(hue_angle_difference_inner)) phi_differences = np.array(phi_differences) hue_angles_differences = np.array(hue_angles_differences) @@ -1062,7 +1080,12 @@ def _xyY_to_munsell_specification(xyY): hue_angle_new = (hue_angle_current + hue_angle_difference_new) % 360 hue_new, code_new = hue_angle_to_hue(hue_angle_new) - specification_current = [hue_new, value, chroma_current, code_new] + specification_current = [ + as_float(hue_new), + as_float(value), + as_float(chroma_current), + as_float(code_new) + ] with domain_range_scale('ignore'): x_current, y_current, _Y_current = _munsell_specification_to_xyY( @@ -1074,7 +1097,7 @@ def _xyY_to_munsell_specification(xyY): if difference < convergence_threshold: return from_range_10( np.array(specification_current), - np.array([10, 10, chroma_scale, 10])) + np.array([10, 10, as_float(chroma_scale), 10])) # TODO: Consider refactoring implementation. hue_current, _value_current, chroma_current, code_current = ( @@ -1096,8 +1119,8 @@ def _xyY_to_munsell_specification(xyY): rho_current, phi_current, _z_current = cartesian_to_cylindrical( (x_current - x_center, y_current - y_center, Y_center)) - rho_bounds = [rho_current] - chroma_bounds = [chroma_current] + rho_bounds = [as_float(rho_current)] + chroma_bounds = [as_float(chroma_current)] iterations_maximum_inner = 16 iterations_inner = 0 @@ -1123,8 +1146,8 @@ def _xyY_to_munsell_specification(xyY): rho_inner, phi_inner, _z_inner = cartesian_to_cylindrical( (x_inner - x_center, y_inner - y_center, Y_center)) - rho_bounds.append(rho_inner) - chroma_bounds.append(chroma_inner) + rho_bounds.append(as_float(rho_inner)) + chroma_bounds.append(as_float(chroma_inner)) rho_bounds = np.array(rho_bounds) chroma_bounds = np.array(chroma_bounds) @@ -1135,7 +1158,12 @@ def _xyY_to_munsell_specification(xyY): chroma_bounds = chroma_bounds[rhos_bounds_indexes] chroma_new = LinearInterpolator(rho_bounds, chroma_bounds)(rho_input) - specification_current = [hue_current, value, chroma_new, code_current] + specification_current = [ + as_float(hue_current), + as_float(value), + as_float(chroma_new), + as_float(code_current) + ] with domain_range_scale('ignore'): x_current, y_current, _Y_current = _munsell_specification_to_xyY( @@ -1274,9 +1302,19 @@ def xyY_to_munsell_colour(xyY, a, hue_decimals, value_decimals, chroma_decimals) for a in specification.reshape([-1, 4]) ] + + cupy = False + if np.__name__ == 'cupy': + cupy = True + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) + munsell_colour = np.array(munsell_colour).reshape(shape[:-1]) munsell_colour = str(munsell_colour) if shape == [4] else munsell_colour + if cupy is True: + np.set_ndimensional_array_backend('cupy') + return munsell_colour @@ -1313,7 +1351,7 @@ def parse_munsell_colour(munsell_colour): if match: return as_float_array([ np.nan, - DEFAULT_FLOAT_DTYPE(match.group('value')), + as_float(match.group('value')), np.nan, np.nan, ]) @@ -1322,9 +1360,9 @@ def parse_munsell_colour(munsell_colour): MUNSELL_COLOUR_PATTERN, munsell_colour, flags=re.IGNORECASE) if match: return as_float_array([ - DEFAULT_FLOAT_DTYPE(match.group('hue')), - DEFAULT_FLOAT_DTYPE(match.group('value')), - DEFAULT_FLOAT_DTYPE(match.group('chroma')), + as_float(match.group('hue')), + as_float(match.group('value')), + as_float(match.group('chroma')), MUNSELL_HUE_LETTER_CODES.get(match.group('letter').upper()), ]) @@ -1391,7 +1429,7 @@ def normalize_munsell_specification(specification): value = as_numeric(specification[~np.isnan(specification)]) - return as_float_array([np.nan, value, np.nan, np.nan]) + return as_float_array([np.nan, as_float(value), np.nan, np.nan]) else: hue, value, chroma, code = specification @@ -1400,9 +1438,14 @@ def normalize_munsell_specification(specification): hue, code = 10, (code + 1) % 10 if chroma == 0: - return as_float_array([np.nan, value, np.nan, np.nan]) + return as_float_array([np.nan, as_float(value), np.nan, np.nan]) else: - return as_float_array([hue, value, chroma, code]) + return as_float_array([ + as_float(hue), + as_float(value), + as_float(chroma), + as_float(code) + ]) def munsell_colour_to_munsell_specification(munsell_colour): @@ -1470,12 +1513,14 @@ def munsell_specification_to_munsell_colour(specification, if is_grey_munsell_colour(specification): hue, value, chroma, code = normalize_munsell_specification( specification) - + hue, value, chroma, code = as_float(hue), as_float(value), as_float( + chroma), as_float(code) return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) else: rounding_decimals = (hue_decimals, value_decimals, chroma_decimals, 1) + hue, value, chroma, code = [ - round(component, rounding_decimals[i]) + round(as_float(component), rounding_decimals[i]) for i, component in enumerate(specification) ] code_values = MUNSELL_HUE_LETTER_CODES.values() @@ -1635,7 +1680,8 @@ def bounding_hues_from_renotation(hue, code): code_cw = code code_ccw = code - return as_float_array([(hue_cw, code_cw), (hue_ccw, code_ccw)]) + return as_float_array([(as_float(hue_cw), as_float(code_cw)), + (as_float(hue_ccw), as_float(code_ccw))]) def hue_to_hue_angle(hue, code): @@ -1800,7 +1846,8 @@ def interpolation_method_from_renotation_ovoid(specification): interpolation_method = 0 else: hue, value, chroma, code = specification - + hue, value, chroma, code = as_float(hue), as_float(value), as_float( + chroma), as_float(code) assert 0 <= value <= 10, ( '"{0}" specification value must be normalised to domain ' '[0, 10]!'.format(specification)) @@ -2091,7 +2138,8 @@ def xy_from_renotation_ovoid(specification): return CCS_ILLUMINANT_MUNSELL else: hue, value, chroma, code = specification - + hue, value, chroma, code = as_float(hue), as_float(value), as_float( + chroma), as_float(code) assert 1 <= value <= 9, ( '"{0}" specification value must be normalised to domain ' '[1, 9]!'.format(specification)) @@ -2167,21 +2215,22 @@ def xy_from_renotation_ovoid(specification): if interpolation_method == 'linear': x = LinearInterpolator( - np.ravel([lower_hue_angle, upper_hue_angle]), - np.ravel([x_minus, x_plus]))(hue_angle) + np.ravel(np.array([lower_hue_angle, upper_hue_angle])), + np.ravel(np.array([x_minus, x_plus])))(hue_angle) y = LinearInterpolator( - np.ravel([lower_hue_angle, upper_hue_angle]), - np.ravel([y_minus, y_plus]))(hue_angle) + np.ravel(np.array([lower_hue_angle, upper_hue_angle])), + np.ravel(np.array([y_minus, y_plus])))(hue_angle) elif interpolation_method == 'radial': theta = LinearInterpolator( - np.ravel([lower_hue_angle, upper_hue_angle]), - np.ravel([phi_minus, phi_plus]))(hue_angle) + np.ravel(np.array([lower_hue_angle, upper_hue_angle])), + np.ravel(np.array([phi_minus, phi_plus])))(hue_angle) rho = LinearInterpolator( - np.ravel([lower_hue_angle, upper_hue_angle]), - np.ravel([rho_minus, rho_plus]))(hue_angle) + np.ravel(np.array([lower_hue_angle, upper_hue_angle])), + np.ravel(np.array([rho_minus, rho_plus])))(hue_angle) x, y = tsplit( - polar_to_cartesian(np.ravel([rho, np.radians(theta)])) + + polar_to_cartesian( + np.ravel(np.array([rho, as_float(np.radians(theta))]))) + as_float_array([x_grey, y_grey])) return as_float_array([x, y]) @@ -2238,14 +2287,14 @@ def LCHab_to_munsell_specification(LCHab): else: code = 8 - hue = LinearInterpolator((0, 36), (0, 10))(Hab % 36) + hue = as_float(LinearInterpolator((0, 36), (0, 10))(Hab % 36)) if hue == 0: hue = 10 - value = L / 10 - chroma = C / 5 + value = as_float(L / 10) + chroma = as_float(C / 5) - return as_float_array([hue, value, chroma, code]) + return as_float_array([hue, value, chroma, as_float(code)]) def maximum_chroma_from_renotation(hue, value, code): @@ -2316,9 +2365,10 @@ def maximum_chroma_from_renotation(hue, value, code): L9 = luminance_ASTMD1535(9) L10 = luminance_ASTMD1535(10) - max_chroma = min( - LinearInterpolator((L9, L10), (ma_limit_mcw, 0))(L), - LinearInterpolator((L9, L10), (ma_limit_mccw, 0))(L)) + max_chroma = as_float( + min( + LinearInterpolator((L9, L10), (ma_limit_mcw, 0))(L), + LinearInterpolator((L9, L10), (ma_limit_mccw, 0))(L))) return max_chroma @@ -2358,7 +2408,8 @@ def munsell_specification_to_xy(specification): return CCS_ILLUMINANT_MUNSELL else: hue, value, chroma, code = specification - + hue, value, chroma, code = as_float(hue), as_float(value), as_float( + chroma), as_float(code) assert 0 <= value <= 10, ( '"{0}" specification value must be normalised to domain ' '[0, 10]!'.format(specification)) diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index b56cff8158..976898dcf2 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -1438,7 +1438,14 @@ def test_n_dimensional_munsell_colour_to_xyY(self): munsell_colour = '4.2YR 8.1/5.3' xyY = munsell_colour_to_xyY(munsell_colour) - munsell_colour = np.tile(munsell_colour, 6) + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) + munsell_colour = np.tile(munsell_colour, 6) + np.set_ndimensional_array_backend('cupy') + else: + munsell_colour = np.tile(munsell_colour, 6) + xyY = np.tile(xyY, (6, 1)) np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) @@ -1450,8 +1457,14 @@ def test_n_dimensional_munsell_colour_to_xyY(self): munsell_colour = 'N8.9' xyY = munsell_colour_to_xyY(munsell_colour) + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) + munsell_colour = np.tile(munsell_colour, 6) + np.set_ndimensional_array_backend('cupy') + else: + munsell_colour = np.tile(munsell_colour, 6) - munsell_colour = np.tile(munsell_colour, 6) xyY = np.tile(xyY, (6, 1)) np.testing.assert_array_almost_equal( munsell_colour_to_xyY(munsell_colour), xyY, decimal=7) @@ -1534,7 +1547,7 @@ def test_domain_range_scale_xyY_to_munsell_specification(self): definition domain and range scale support. """ - xyY = [0.16623068, 0.45684550, 0.22399519] + xyY = np.array([0.16623068, 0.45684550, 0.22399519]) specification = xyY_to_munsell_specification(xyY) d_r = ( @@ -1589,7 +1602,6 @@ def test_domain_range_scale_xyY_to_munsell_colour(self): ) for scale, factor in d_r: with domain_range_scale(scale): - print(scale, factor) self.assertEqual( xyY_to_munsell_colour(xyY * factor), munsell_colour) @@ -1603,7 +1615,14 @@ def test_n_dimensional_xyY_to_munsell_colour(self): munsell_colour = xyY_to_munsell_colour(xyY) xyY = np.tile(xyY, (6, 1)) - munsell_colour = np.tile(munsell_colour, 6) + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) + munsell_colour = np.tile(munsell_colour, 6) + np.set_ndimensional_array_backend('cupy') + else: + munsell_colour = np.tile(munsell_colour, 6) + np.testing.assert_array_equal( xyY_to_munsell_colour(xyY), munsell_colour) @@ -1611,12 +1630,17 @@ def test_n_dimensional_xyY_to_munsell_colour(self): munsell_colour = np.reshape(munsell_colour, (2, 3)) np.testing.assert_array_equal( xyY_to_munsell_colour(xyY), munsell_colour) - - xyY = list(CCS_ILLUMINANT_MUNSELL) + [1.0] + xyY = list(CCS_ILLUMINANT_MUNSELL) + [np.array(1.0)] munsell_colour = xyY_to_munsell_colour(xyY) - xyY = np.tile(xyY, (6, 1)) - munsell_colour = np.tile(munsell_colour, 6) + xyY = np.tile(np.array(xyY), (6, 1)) + if np.__name__ == 'cupy': + np.set_ndimensional_array_backend('numpy') + munsell_colour = np.array(munsell_colour) + munsell_colour = np.tile(munsell_colour, 6) + np.set_ndimensional_array_backend('cupy') + else: + munsell_colour = np.tile(munsell_colour, 6) np.testing.assert_array_equal( xyY_to_munsell_colour(xyY), munsell_colour) From 21687f97363d023f055ea18fdaca57f855dc98e5 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Mon, 24 Aug 2020 14:24:08 +0200 Subject: [PATCH 16/17] Rebasing to current develop branch --- colour/algebra/tests/test_interpolation.py | 2 +- colour/colorimetry/tests/test_dominant.py | 10 ---------- colour/colorimetry/tests/test_tristimulus.py | 5 ----- colour/colorimetry/tristimulus.py | 2 +- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index 335cc0504f..1665efe21a 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -776,7 +776,7 @@ def test__call__(self): np.testing.assert_array_almost_equal( CubicSplineInterpolator( np.linspace(0, 1, len(DATA_POINTS_A)), - np.array(POINTS_DATA_A))(np.linspace(0, 1, + np.array(DATA_POINTS_A))(np.linspace(0, 1, len(DATA_POINTS_A) * 2)), DATA_POINTS_A_CUBIC_SPLINE_INTERPOLATED_X2_SAMPLES) diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index 69c1626525..d1dac167ba 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -333,30 +333,20 @@ def test_n_dimensional_excitation_purity(self): xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) P_e = np.tile(P_e, 6) -<<<<<<< HEAD np.testing.assert_array_almost_equal( excitation_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, decimal=7) -======= - np.testing.assert_array_almost_equal( - excitation_purity(xy, xy_n, CIE_2_1931_CMFS), P_e, decimal=7) ->>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) P_e = np.reshape(P_e, (2, 3)) -<<<<<<< HEAD np.testing.assert_array_almost_equal( excitation_purity(xy, xy_n, CMFS_STANDARD_OBSERVER_2_DEGREE_CIE1931), P_e, decimal=7) -======= - np.testing.assert_array_almost_equal( - excitation_purity(xy, xy_n, CIE_2_1931_CMFS), P_e, decimal=7) ->>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube @ignore_numpy_errors def test_nan_excitation_purity(self): diff --git a/colour/colorimetry/tests/test_tristimulus.py b/colour/colorimetry/tests/test_tristimulus.py index 75ca1b7f98..0efd51051d 100644 --- a/colour/colorimetry/tests/test_tristimulus.py +++ b/colour/colorimetry/tests/test_tristimulus.py @@ -611,13 +611,8 @@ def test_sd_to_XYZ_tristimulus_weighting_factors_ASTME308(self): np.array([14.46341867, 10.85820227, 2.04697034]), decimal=7) -<<<<<<< HEAD cmfs = MSDS_CMFS['CIE 1964 10 Degree Standard Observer'] np.testing.assert_array_almost_equal( -======= - cmfs = CMFS['CIE 1964 10 Degree Standard Observer'] - np.testing.assert_array_almost_equal( ->>>>>>> Fixes for tests of all submodules, all submodules now work except these functions, continous/signal-Multisignal, rgb/derivation, temperature CCT_to_xy, XYZto_sd_Meng2015, notation/munsell and primitive_grid/cube sd_to_XYZ_tristimulus_weighting_factors_ASTME308( SD_SAMPLE, cmfs, SDS_ILLUMINANTS['C']), np.array([10.77005571, 9.44877491, 6.62428210]), diff --git a/colour/colorimetry/tristimulus.py b/colour/colorimetry/tristimulus.py index 4cef030db5..1b41920983 100644 --- a/colour/colorimetry/tristimulus.py +++ b/colour/colorimetry/tristimulus.py @@ -932,7 +932,7 @@ def sd_to_XYZ( if cupy is True: np.set_ndimensional_array_backend('cupy') - _SD_TO_XYZ_CACHE[hash_key] = np.array(_SD_TO_XYZ_CACHE[hash_key]) + _CACHE_SD_TO_XYZ[hash_key] = np.array(_CACHE_SD_TO_XYZ[hash_key]) XYZ = np.array(XYZ) return XYZ From 249e8c9535a436b4a346481eb5a36f63318351a0 Mon Sep 17 00:00:00 2001 From: Omar Wagih Date: Wed, 26 Aug 2020 14:54:10 +0200 Subject: [PATCH 17/17] Redefined the as_float function for cupy, made the as_float code for several functions more compact --- colour/colorimetry/whiteness.py | 22 ++--- colour/constants/common.py | 2 +- colour/difference/delta_e.py | 21 ++--- colour/io/tests/test_image.py | 12 +-- colour/models/hdr_cie_lab.py | 7 +- .../models/rgb/transfer_functions/cineon.py | 14 +-- .../rgb/transfer_functions/filmic_pro.py | 7 +- colour/models/rgb/transfer_functions/gopro.py | 14 +-- .../rgb/transfer_functions/itur_bt_1886.py | 14 +-- .../models/rgb/transfer_functions/panalog.py | 14 +-- .../rgb/transfer_functions/pivoted_log.py | 14 +-- .../models/rgb/transfer_functions/red_log.py | 58 ++++-------- .../rgb/transfer_functions/viper_log.py | 14 +-- colour/notation/munsell.py | 15 ++- colour/phenomena/rayleigh.py | 91 ++++++------------- colour/quality/cqs.py | 7 +- colour/quality/cri.py | 7 +- colour/quality/ssi.py | 7 +- colour/temperature/mccamy1992.py | 7 +- colour/utilities/array.py | 9 +- colour/utilities/metrics.py | 10 +- colour/volume/rgb.py | 7 +- 22 files changed, 121 insertions(+), 252 deletions(-) diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index d534349854..cf89b9a547 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -45,6 +45,7 @@ from __future__ import division, unicode_literals +import colour.ndarray as np from colour.utilities import (CaseInsensitiveMapping, get_domain_range_scale, filter_kwargs, from_range_100, to_domain_100, tsplit, tstack, as_float) @@ -120,11 +121,8 @@ def whiteness_Berger1959(XYZ, XYZ_0): WI = from_range_100(WI) - try: - if WI.size == 1: - return as_float(WI) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(WI) return WI @@ -185,11 +183,8 @@ def whiteness_Taube1960(XYZ, XYZ_0): WI = 400 * (Z / Z_0) - 3 * Y WI = from_range_100(WI) - try: - if WI.size == 1: - return as_float(WI) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(WI) return WI @@ -306,11 +301,8 @@ def whiteness_ASTME313(XYZ): WI = from_range_100(WI) - try: - if WI.size == 1: - return as_float(WI) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(WI) return WI diff --git a/colour/constants/common.py b/colour/constants/common.py index b7b3bd85b8..966febdc77 100644 --- a/colour/constants/common.py +++ b/colour/constants/common.py @@ -9,7 +9,7 @@ from __future__ import division, unicode_literals import os -import colour.ndarray as np +import numpy as np from colour.utilities.documentation import (DocstringFloat, is_documentation_building) diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 10f83103ea..876db897d0 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -221,11 +221,8 @@ def delta_E_CIE1994(Lab_1, Lab_2, textiles=False): d_E = np.sqrt(L + C + H) - try: - if d_E.size == 1: - return as_float(d_E) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(d_E) return d_E @@ -370,11 +367,8 @@ def delta_E_CIE2000(Lab_1, Lab_2, textiles=False): (delta_C_prime / (k_C * s_C)) * (delta_H_prime / (k_H * s_H)) * r_T) - try: - if d_E.size == 1: - return as_float(d_E) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(d_E) return d_E @@ -468,10 +462,7 @@ def delta_E_CMC(Lab_1, Lab_2, l=2, c=1): # noqa d_E = np.sqrt(v_1 ** 2 + v_2 ** 2 + (delta_H2 / (v_3 * v_3))) - try: - if d_E.size == 1: - return as_float(d_E) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(d_E) return d_E diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index 2d8b4efb2f..da4516026c 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -48,10 +48,10 @@ def test_convert_bit_depth(self): a = np.around(np.linspace(0, 1, 10) * 255).astype('uint8') self.assertIs(convert_bit_depth(a, 'uint8').dtype, np.dtype('uint8')) - np.testing.assert_equal(convert_bit_depth(a, 'uint8'), a) + np.testing.assert_array_equal(convert_bit_depth(a, 'uint8'), a) self.assertIs(convert_bit_depth(a, 'uint16').dtype, np.dtype('uint16')) - np.testing.assert_equal( + np.testing.assert_array_equal( convert_bit_depth(a, 'uint16'), np.array([ 0, 7196, 14649, 21845, 29041, 36494, 43690, 50886, 58339, 65535 @@ -87,12 +87,12 @@ def test_convert_bit_depth(self): a = np.around(np.linspace(0, 1, 10) * 65535).astype('uint16') self.assertIs(convert_bit_depth(a, 'uint8').dtype, np.dtype('uint8')) - np.testing.assert_equal( + np.testing.assert_array_equal( convert_bit_depth(a, 'uint8'), np.array([0, 28, 56, 85, 113, 141, 170, 198, 226, 255])) self.assertIs(convert_bit_depth(a, 'uint16').dtype, np.dtype('uint16')) - np.testing.assert_equal(convert_bit_depth(a, 'uint16'), a) + np.testing.assert_array_equal(convert_bit_depth(a, 'uint16'), a) self.assertIs( convert_bit_depth(a, 'float16').dtype, np.dtype('float16')) @@ -124,12 +124,12 @@ def test_convert_bit_depth(self): a = np.linspace(0, 1, 10, dtype=np.float64) self.assertIs(convert_bit_depth(a, 'uint8').dtype, np.dtype('uint8')) - np.testing.assert_equal( + np.testing.assert_array_equal( convert_bit_depth(a, 'uint8'), np.array([0, 28, 57, 85, 113, 142, 170, 198, 227, 255])) self.assertIs(convert_bit_depth(a, 'uint16').dtype, np.dtype('uint16')) - np.testing.assert_equal( + np.testing.assert_array_equal( convert_bit_depth(a, 'uint16'), np.array([ 0, 7282, 14563, 21845, 29127, 36408, 43690, 50972, 58253, 65535 diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 78497bacad..ab14716a1b 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -123,11 +123,8 @@ def exponent_hdr_CIELab(Y_s, Y_abs, method='Fairchild 2011'): else: epsilon /= sf * lf - try: - if epsilon.size == 1: - return as_float(epsilon) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(epsilon) return epsilon diff --git a/colour/models/rgb/transfer_functions/cineon.py b/colour/models/rgb/transfer_functions/cineon.py index d6e5e59b9a..240c1dda77 100644 --- a/colour/models/rgb/transfer_functions/cineon.py +++ b/colour/models/rgb/transfer_functions/cineon.py @@ -79,11 +79,8 @@ def log_encoding_Cineon(x, black_offset=10 ** ((95 - 685) / 300)): y = ((685 + 300 * np.log10(x * (1 - black_offset) + black_offset)) / 1023) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -135,10 +132,7 @@ def log_decoding_Cineon(y, black_offset=10 ** ((95 - 685) / 300)): x = ((10 ** ((1023 * y - 685) / 300) - black_offset) / (1 - black_offset)) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/models/rgb/transfer_functions/filmic_pro.py b/colour/models/rgb/transfer_functions/filmic_pro.py index f0ac975e72..27c467399d 100644 --- a/colour/models/rgb/transfer_functions/filmic_pro.py +++ b/colour/models/rgb/transfer_functions/filmic_pro.py @@ -86,11 +86,8 @@ def log_encoding_FilmicPro6(t): y = 0.371 * (np.sqrt(t) + 0.28257 * np.log(t) + 1.69542) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y diff --git a/colour/models/rgb/transfer_functions/gopro.py b/colour/models/rgb/transfer_functions/gopro.py index b8470ff4c9..3655b12e42 100644 --- a/colour/models/rgb/transfer_functions/gopro.py +++ b/colour/models/rgb/transfer_functions/gopro.py @@ -77,11 +77,8 @@ def log_encoding_Protune(x): y = np.log(x * 112 + 1) / np.log(113) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -131,10 +128,7 @@ def log_decoding_Protune(y): x = (113 ** y - 1) / 112 x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/models/rgb/transfer_functions/itur_bt_1886.py b/colour/models/rgb/transfer_functions/itur_bt_1886.py index cdaa760cba..fec435ba4f 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1886.py @@ -92,11 +92,8 @@ def eotf_inverse_BT1886(L, L_B=0, L_W=1): V = (L / a) ** gamma_d - b V = from_range_1(V) - try: - if V.size == 1: - return as_float(V) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(V) return V @@ -160,10 +157,7 @@ def eotf_BT1886(V, L_B=0, L_W=1): L = a * np.maximum(V + b, 0) ** gamma L = from_range_1(L) - try: - if L.size == 1: - return as_float(L) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(L) return L diff --git a/colour/models/rgb/transfer_functions/panalog.py b/colour/models/rgb/transfer_functions/panalog.py index 5e526448f9..3d398faf74 100644 --- a/colour/models/rgb/transfer_functions/panalog.py +++ b/colour/models/rgb/transfer_functions/panalog.py @@ -84,11 +84,8 @@ def log_encoding_Panalog(x, black_offset=10 ** ((64 - 681) / 444)): y = (681 + 444 * np.log10(x * (1 - black_offset) + black_offset)) / 1023 y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -145,10 +142,7 @@ def log_decoding_Panalog(y, black_offset=10 ** ((64 - 681) / 444)): x = (10 ** ((1023 * y - 681) / 444) - black_offset) / (1 - black_offset) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/models/rgb/transfer_functions/pivoted_log.py b/colour/models/rgb/transfer_functions/pivoted_log.py index 62eec13e87..38ccb90861 100644 --- a/colour/models/rgb/transfer_functions/pivoted_log.py +++ b/colour/models/rgb/transfer_functions/pivoted_log.py @@ -90,11 +90,8 @@ def log_encoding_PivotedLog(x, (density_per_code_value / negative_gamma)) / 1023) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -157,10 +154,7 @@ def log_decoding_PivotedLog(y, (density_per_code_value / negative_gamma)) * linear_reference) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/models/rgb/transfer_functions/red_log.py b/colour/models/rgb/transfer_functions/red_log.py index e756f6d6e0..1787d3c447 100644 --- a/colour/models/rgb/transfer_functions/red_log.py +++ b/colour/models/rgb/transfer_functions/red_log.py @@ -105,11 +105,8 @@ def log_encoding_REDLog(x, black_offset=10 ** ((0 - 1023) / 511)): y = (1023 + 511 * np.log10(x * (1 - black_offset) + black_offset)) / 1023 y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -161,11 +158,8 @@ def log_decoding_REDLog(y, black_offset=10 ** ((0 - 1023) / 511)): x = ((10 ** ((1023 * y - 1023) / 511)) - black_offset) / (1 - black_offset) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x @@ -305,11 +299,8 @@ def log_encoding_Log3G10_v1(x): y = np.sign(x) * 0.222497 * np.log10((np.abs(x) * 169.379333) + 1) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -359,11 +350,8 @@ def log_decoding_Log3G10_v1(y): x = (np.sign(y) * (10.0 ** (np.abs(y) / 0.222497) - 1) / 169.379333) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x @@ -415,13 +403,8 @@ def log_encoding_Log3G10_v2(x): y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass - - return y + if np.__name__ == 'cupy': + return as_float(y) return y @@ -471,11 +454,8 @@ def log_decoding_Log3G10_v2(y): x = (np.sign(y) * (10.0 ** (np.abs(y) / 0.224282) - 1) / 155.975327) - 0.01 x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x @@ -705,11 +685,8 @@ def log_encoding_Log3G12(x): y = np.sign(x) * 0.184904 * np.log10((np.abs(x) * 347.189667) + 1) y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -759,10 +736,7 @@ def log_decoding_Log3G12(y): x = np.sign(y) * (10.0 ** (np.abs(y) / 0.184904) - 1) / 347.189667 x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/models/rgb/transfer_functions/viper_log.py b/colour/models/rgb/transfer_functions/viper_log.py index bbf3aec1ce..3479a23de1 100644 --- a/colour/models/rgb/transfer_functions/viper_log.py +++ b/colour/models/rgb/transfer_functions/viper_log.py @@ -77,11 +77,8 @@ def log_encoding_ViperLog(x): y = (1023 + 500 * np.log10(x)) / 1023 y = from_range_1(y) - try: - if y.size == 1: - return as_float(y) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(y) return y @@ -131,10 +128,7 @@ def log_decoding_ViperLog(y): x = 10 ** ((1023 * y - 1023) / 500) x = from_range_1(x) - try: - if x.size == 1: - return as_float(x) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(x) return x diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index bbbce42dac..a3b741bbd0 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -124,7 +124,8 @@ cartesian_to_cylindrical, euclidean_distance, polar_to_cartesian, spow) from colour.colorimetry import CCS_ILLUMINANTS, luminance_ASTMD1535 -from colour.constants import (INTEGER_THRESHOLD, FLOATING_POINT_NUMBER_PATTERN) +from colour.constants import (DEFAULT_INT_DTYPE, INTEGER_THRESHOLD, + FLOATING_POINT_NUMBER_PATTERN) from colour.models import Lab_to_LCHab, XYZ_to_Lab, XYZ_to_xy, xyY_to_XYZ from colour.volume import is_within_macadam_limits from colour.notation import MUNSELL_COLOURS_ALL @@ -752,9 +753,15 @@ def _munsell_specification_to_xyY(specification): else: specification = to_domain_10(specification, _domain_range_scale_factor()) - hue, value, chroma, code = ( - [as_float(i) - for i in specification[0:3]] + [as_float(specification[-1])]) + if np.__name__ == 'cupy': + nspec = np.asnumpy(specification[-1]) + hue, value, chroma, code = ( + [as_float(i) + for i in specification[0:3]] + [DEFAULT_INT_DTYPE(nspec)]) + else: + intspec = DEFAULT_INT_DTYPE(specification[-1]) + hue, value, chroma, code = ( + [as_float(i) for i in specification[0:3]] + [intspec]) assert 0 <= hue <= 10, ( '"{0}" specification hue must be normalised to domain ' '[0, 10]!'.format(specification)) diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index ef1185f5a8..053516cc17 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -110,11 +110,8 @@ def air_refraction_index_Penndorf1957(wavelength): n /= 1.0e8 n += +1 - try: - if n.size == 1: - return as_float(n) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(n) return n @@ -147,11 +144,8 @@ def air_refraction_index_Edlen1966(wavelength): n /= 1.0e8 n += +1 - try: - if n.size == 1: - return as_float(n) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(n) return n @@ -185,11 +179,8 @@ def air_refraction_index_Peck1972(wavelength): n /= 1.0e8 n += +1 - try: - if n.size == 1: - return as_float(n) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(n) return n @@ -225,11 +216,8 @@ def air_refraction_index_Bodhaine1999( n = ((1 + 0.54 * ((CO2_c * 1e-6) - 300e-6)) * (air_refraction_index_Peck1972(wl) - 1) + 1) - try: - if n.size == 1: - return as_float(n) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(n) return n @@ -259,11 +247,8 @@ def N2_depolarisation(wavelength): N2 = 1.034 + 3.17 * 1.0e-4 * (1 / wl ** 2) - try: - if N2.size == 1: - return as_float(N2) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(N2) return N2 @@ -294,11 +279,8 @@ def O2_depolarisation(wavelength): O2 = (1.096 + 1.385 * 1.0e-3 * (1 / wl ** 2) + 1.448 * 1.0e-4 * (1 / wl ** 4)) - try: - if O2.size == 1: - return as_float(O2) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(O2) return O2 @@ -397,11 +379,8 @@ def F_air_Bates1984(wavelength): F_air = ( (78.084 * N2 + 20.946 * O2 + CO2 + Ar) / (78.084 + 20.946 + Ar + CO2)) - try: - if F_air.size == 1: - return as_float(F_air) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(F_air) return F_air @@ -439,11 +418,8 @@ def F_air_Bodhaine1999(wavelength, F_air = ((78.084 * N2 + 20.946 * O2 + 0.934 * 1 + CO2_c * 1.15) / (78.084 + 20.946 + 0.934 + CO2_c)) - try: - if F_air.size == 1: - return as_float(F_air) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(F_air) return F_air @@ -486,11 +462,8 @@ def molecular_density(temperature=CONSTANT_STANDARD_AIR_TEMPERATURE, N_s = (avogadro_constant / 22.4141) * (273.15 / T) * (1 / 1000) - try: - if N_s.size == 1: - return as_float(N_s) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(N_s) return N_s @@ -521,11 +494,8 @@ def mean_molecular_weights( m_a = 15.0556 * CO2_c + 28.9595 - try: - if m_a.size == 1: - return as_float(m_a) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(m_a) return m_a @@ -573,11 +543,8 @@ def gravity_List1968(latitude=DEFAULT_LATITUDE, altitude=DEFAULT_ALTITUDE): (7.254e-11 + 1.0e-13 * cos2phi) * altitude ** 2 - (1.517e-17 + 6e-20 * cos2phi) * altitude ** 3) - try: - if g.size == 1: - return as_float(g) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(g) return g @@ -650,11 +617,8 @@ def scattering_cross_section( (n_s ** 2 + 2) ** 2)) sigma *= F_air - try: - if sigma.size == 1: - return as_float(sigma) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(sigma) return sigma @@ -732,11 +696,8 @@ def rayleigh_optical_depth( T_R = sigma * (P * avogadro_constant) / (m_a * g) - try: - if T_R.size == 1: - return as_float(T_R) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(T_R) return T_R diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index de44e0bde8..9bc11de402 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -253,11 +253,8 @@ def colour_quality_scale(sd_test, additional_data=False, sd_test.name, Q_a, Q_f, Q_p, Q_g, Q_d, Q_as, (test_vs_colorimetry_data, reference_vs_colorimetry_data)) else: - try: - if Q_a.size == 1: - return as_float(Q_a) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(Q_a) return Q_a diff --git a/colour/quality/cri.py b/colour/quality/cri.py index e51ed3b5a5..f85a9e3c6f 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -149,11 +149,8 @@ def colour_rendering_index(sd_test, additional_data=False): sd_test.name, Q_a, Q_as, (test_tcs_colorimetry_data, reference_tcs_colorimetry_data)) else: - try: - if Q_a.size == 1: - return as_float(Q_a) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(Q_a) return Q_a diff --git a/colour/quality/ssi.py b/colour/quality/ssi.py index 3cd54afc69..ace6006d42 100644 --- a/colour/quality/ssi.py +++ b/colour/quality/ssi.py @@ -121,10 +121,7 @@ def spectral_similarity_index(sd_test, sd_reference): SSI = np.around(100 - 32 * np.sqrt(m_v)) - try: - if SSI.size == 1: - return as_float(SSI) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(SSI) return SSI diff --git a/colour/temperature/mccamy1992.py b/colour/temperature/mccamy1992.py index 5e0cd99355..34a417855e 100644 --- a/colour/temperature/mccamy1992.py +++ b/colour/temperature/mccamy1992.py @@ -71,11 +71,8 @@ def xy_to_CCT_McCamy1992(xy): n = (x - 0.3320) / (y - 0.1858) CCT = -449 * n ** 3 + 3525 * n ** 2 - 6823.3 * n + 5520.33 - try: - if CCT.size == 1: - return as_float(CCT) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(CCT) return CCT diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 85559be9fb..3464ebd555 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -273,9 +273,12 @@ def as_float(a, dtype=None): if np.__name__ == 'cupy': try: - return float(a) - except TypeError: - return as_float_array(a, dtype) + if a.size == 1: + return dtype(np.asnumpy(a)) + else: + return as_float_array(a, dtype) + except Exception: + return a return dtype(a) diff --git a/colour/utilities/metrics.py b/colour/utilities/metrics.py index f2978811dc..6d1e9b310a 100644 --- a/colour/utilities/metrics.py +++ b/colour/utilities/metrics.py @@ -21,7 +21,7 @@ import colour.ndarray as np -from colour.utilities import as_float_array +from colour.utilities import as_float, as_float_array __author__ = 'Colour Developers' __copyright__ = 'Copyright (C) 2013-2020 - Colour Developers' @@ -67,11 +67,9 @@ def metric_mse(a, b, axis=None): 0.0012714... """ metric = np.mean((as_float_array(a) - as_float_array(b)) ** 2, axis=axis) - try: - if np.__name__ == 'cupy' and metric.size == 1: - return metric.item() - except Exception: - pass + + if np.__name__ == 'cupy': + return as_float(metric) return metric diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index 200eee6d32..c744e8f6ff 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -262,11 +262,8 @@ def RGB_colourspace_volume_MonteCarlo( result = Lab_volume * np.sum(np.array(results)) / \ (process_samples * processes) - try: - if result.size == 1: - return as_float(result) - except Exception: - pass + if np.__name__ == 'cupy': + return as_float(result) return result