diff --git a/colour/adaptation/__init__.py b/colour/adaptation/__init__.py index d31e7f518f..92168edf54 100644 --- a/colour/adaptation/__init__.py +++ b/colour/adaptation/__init__.py @@ -295,7 +295,7 @@ def chromatic_adaptation( array([ 0.2152436..., 0.1253522..., 0.0388406...]) """ - method = validate_method(method, CHROMATIC_ADAPTATION_METHODS) + method = validate_method(method, tuple(CHROMATIC_ADAPTATION_METHODS)) function = CHROMATIC_ADAPTATION_METHODS[method] diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index eb9feb2f89..1c9e7d3877 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -379,7 +379,7 @@ def chromatic_adaptation_CMCCAT2000( direction = validate_method( direction, - ["Forward", "Inverse"], + ("Forward", "Inverse"), '"{0}" direction is invalid, it must be one of {1}!', ) diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index 4a7243a27d..98a5ae8dfb 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -120,7 +120,7 @@ def matrix_chromatic_adaptation_VonKries( transform = validate_method( transform, - CHROMATIC_ADAPTATION_TRANSFORMS, + tuple(CHROMATIC_ADAPTATION_TRANSFORMS), '"{0}" chromatic adaptation transform is invalid, ' "it must be one of {1}!", ) diff --git a/colour/adaptation/zhai2018.py b/colour/adaptation/zhai2018.py index e3a1ca91e4..ca0c91ef76 100644 --- a/colour/adaptation/zhai2018.py +++ b/colour/adaptation/zhai2018.py @@ -149,7 +149,7 @@ def chromatic_adaptation_Zhai2018( Y_wd = XYZ_wd[..., 1][..., None] Y_wo = XYZ_wo[..., 1][..., None] - transform = validate_method(transform, ["CAT02", "CAT16"]) + transform = validate_method(transform, ("CAT02", "CAT16")) M = CHROMATIC_ADAPTATION_TRANSFORMS[transform] RGB_b = vector_dot(M, XYZ_b) diff --git a/colour/algebra/common.py b/colour/algebra/common.py index 87300c45f0..b3cefcaf88 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -74,16 +74,18 @@ """ -def get_sdiv_mode() -> Literal[ - "Numpy", - "Ignore", - "Warning", - "Raise", - "Ignore Zero Conversion", - "Warning Zero Conversion", - "Ignore Limit Conversion", - "Warning Limit Conversion", -]: +def get_sdiv_mode() -> ( + Literal[ + "Numpy", + "Ignore", + "Warning", + "Raise", + "Ignore Zero Conversion", + "Warning Zero Conversion", + "Ignore Limit Conversion", + "Warning Limit Conversion", + ] +): """ Return *Colour* safe division mode. @@ -156,7 +158,7 @@ def set_sdiv_mode( ], validate_method( mode, - [ + ( "Numpy", "Ignore", "Warning", @@ -165,7 +167,7 @@ def set_sdiv_mode( "Warning Zero Conversion", "Ignore Limit Conversion", "Warning Limit Conversion", - ], + ), ), ) @@ -305,7 +307,7 @@ def sdiv(a: ArrayLike, b: ArrayLike) -> NDArrayFloat: mode = validate_method( _SDIV_MODE, - [ + ( "Numpy", "Ignore", "Warning", @@ -314,7 +316,7 @@ def sdiv(a: ArrayLike, b: ArrayLike) -> NDArrayFloat: "Warning Zero Conversion", "Ignore Limit Conversion", "Warning Limit Conversion", - ], + ), ) if mode == "numpy": diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 85dc34fa52..bae3aa7676 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -222,7 +222,7 @@ def method(self, value: Literal["Linear", "Constant"] | str): f'"method" property: "{value}" type is not "str"!', ) - value = validate_method(value, ["Linear", "Constant"]) + value = validate_method(value, ("Linear", "Constant")) self._method = value diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 205b748bcb..a9a6958dc3 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -2040,6 +2040,6 @@ def table_interpolation( [ 1.1178206..., 0.1762039..., 0.2209534...]]) """ - method = validate_method(method, TABLE_INTERPOLATION_METHODS) + method = validate_method(method, tuple(TABLE_INTERPOLATION_METHODS)) return TABLE_INTERPOLATION_METHODS[method](V_xyz, table) diff --git a/colour/appearance/hke.py b/colour/appearance/hke.py index 1194dd2df5..e09d4162b9 100644 --- a/colour/appearance/hke.py +++ b/colour/appearance/hke.py @@ -115,7 +115,7 @@ def HelmholtzKohlrausch_effect_object_Nayatani1997( u, v = tsplit(uv) u_c, v_c = tsplit(uv_c) - method = validate_method(method, HKE_NAYATANI1997_METHODS) + method = validate_method(method, tuple(HKE_NAYATANI1997_METHODS)) K_Br = coefficient_K_Br_Nayatani1997(L_a) q = coefficient_q_Nayatani1997(np.arctan2(v - v_c, u - u_c)) diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py index 7ec4dc6160..2bbfb86615 100644 --- a/colour/biochemistry/michaelis_menten.py +++ b/colour/biochemistry/michaelis_menten.py @@ -217,7 +217,9 @@ def reaction_rate_MichaelisMenten( 1.0360547... """ - method = validate_method(method, REACTION_RATE_MICHAELISMENTEN_METHODS) + method = validate_method( + method, tuple(REACTION_RATE_MICHAELISMENTEN_METHODS) + ) function = REACTION_RATE_MICHAELISMENTEN_METHODS[method] @@ -392,7 +394,7 @@ def substrate_concentration_MichaelisMenten( """ method = validate_method( - method, SUBSTRATE_CONCENTRATION_MICHAELISMENTEN_METHODS + method, tuple(SUBSTRATE_CONCENTRATION_MICHAELISMENTEN_METHODS) ) function = SUBSTRATE_CONCENTRATION_MICHAELISMENTEN_METHODS[method] diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 829a826907..1486b6c640 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -670,7 +670,7 @@ def polynomial_expansion( array([ 0.1722481..., 0.0917066..., 0.0641693..., 0.0010136..., 1...]) """ - method = validate_method(method, POLYNOMIAL_EXPANSION_METHODS) + method = validate_method(method, tuple(POLYNOMIAL_EXPANSION_METHODS)) function = POLYNOMIAL_EXPANSION_METHODS[method] @@ -941,7 +941,7 @@ def matrix_colour_correction( [-0.0631495..., 0.0921247..., 0.9713415...]]) """ - method = validate_method(method, MATRIX_COLOUR_CORRECTION_METHODS) + method = validate_method(method, tuple(MATRIX_COLOUR_CORRECTION_METHODS)) function = MATRIX_COLOUR_CORRECTION_METHODS[method] @@ -1190,7 +1190,9 @@ def apply_matrix_colour_correction( array([ 0.1793456..., 0.1003392..., 0.0617218...]) """ - method = validate_method(method, APPLY_MATRIX_COLOUR_CORRECTION_METHODS) + method = validate_method( + method, tuple(APPLY_MATRIX_COLOUR_CORRECTION_METHODS) + ) function = APPLY_MATRIX_COLOUR_CORRECTION_METHODS[method] @@ -1469,7 +1471,7 @@ def colour_correction( array([ 0.1334872..., 0.0843921..., 0.0599014...]) """ - method = validate_method(method, COLOUR_CORRECTION_METHODS) + method = validate_method(method, tuple(COLOUR_CORRECTION_METHODS)) function = COLOUR_CORRECTION_METHODS[method] diff --git a/colour/colorimetry/correction.py b/colour/colorimetry/correction.py index 7aa40bac2f..5ceb6e0899 100644 --- a/colour/colorimetry/correction.py +++ b/colour/colorimetry/correction.py @@ -176,6 +176,6 @@ def bandpass_correction( {'method': 'Constant', 'left': None, 'right': None}) """ - method = validate_method(method, BANDPASS_CORRECTION_METHODS) + method = validate_method(method, tuple(BANDPASS_CORRECTION_METHODS)) return BANDPASS_CORRECTION_METHODS[method](sd) diff --git a/colour/colorimetry/generation.py b/colour/colorimetry/generation.py index 481438e791..795e52e510 100644 --- a/colour/colorimetry/generation.py +++ b/colour/colorimetry/generation.py @@ -541,7 +541,7 @@ def sd_gaussian( 0.3678794... """ - method = validate_method(method, SD_GAUSSIAN_METHODS) + method = validate_method(method, tuple(SD_GAUSSIAN_METHODS)) return SD_GAUSSIAN_METHODS[method]( mu_peak_wavelength, sigma_fwhm, shape, **kwargs @@ -673,7 +673,7 @@ def sd_single_led( 1... """ - method = validate_method(method, SD_SINGLE_LED_METHODS) + method = validate_method(method, tuple(SD_SINGLE_LED_METHODS)) return SD_SINGLE_LED_METHODS[method]( peak_wavelength, fwhm, shape, **kwargs @@ -851,7 +851,7 @@ def sd_multi_leds( 0.1295132... """ - method = validate_method(method, SD_MULTI_LEDS_METHODS) + method = validate_method(method, tuple(SD_MULTI_LEDS_METHODS)) return SD_MULTI_LEDS_METHODS[method]( peak_wavelengths, fwhm, peak_power_ratios, shape, **kwargs diff --git a/colour/colorimetry/lefs.py b/colour/colorimetry/lefs.py index f343847cde..ffad271153 100644 --- a/colour/colorimetry/lefs.py +++ b/colour/colorimetry/lefs.py @@ -93,11 +93,11 @@ def mesopic_weighting_function( source = validate_method( source, - ["Blue Heavy", "Red Heavy"], + ("Blue Heavy", "Red Heavy"), '"{0}" light source colour temperature is invalid, ' "it must be one of {1}!", ) - method = validate_method(method, ["MOVE", "LRC"]) + method = validate_method(method, ("MOVE", "LRC")) mesopic_x_luminance_values = sorted(DATA_MESOPIC_X.keys()) index = mesopic_x_luminance_values.index( diff --git a/colour/colorimetry/lightness.py b/colour/colorimetry/lightness.py index 0200229629..492ec9f4ab 100644 --- a/colour/colorimetry/lightness.py +++ b/colour/colorimetry/lightness.py @@ -424,7 +424,7 @@ def lightness_Fairchild2011( """ Y = to_domain_1(Y) - method = validate_method(method, ["hdr-CIELAB", "hdr-IPT"]) + method = validate_method(method, ("hdr-CIELAB", "hdr-IPT")) maximum_perception = 247 if method == "hdr-cielab" else 246 @@ -498,7 +498,7 @@ def lightness_Abebe2017( Y = as_float_array(Y) Y_n = as_float_array(Y_n) - method = validate_method(method, ["Michaelis-Menten", "Stevens"]) + method = validate_method(method, ("Michaelis-Menten", "Stevens")) Y_Y_n = Y / Y_n if method == "stevens": @@ -630,7 +630,7 @@ def lightness( """ Y = as_float_array(Y) - method = validate_method(method, LIGHTNESS_METHODS) + method = validate_method(method, tuple(LIGHTNESS_METHODS)) function = LIGHTNESS_METHODS[method] diff --git a/colour/colorimetry/luminance.py b/colour/colorimetry/luminance.py index ca7f5f099d..738d920f34 100644 --- a/colour/colorimetry/luminance.py +++ b/colour/colorimetry/luminance.py @@ -432,7 +432,7 @@ def luminance_Fairchild2011( """ L_hdr = to_domain_100(L_hdr) - method = validate_method(method, ["hdr-CIELAB", "hdr-IPT"]) + method = validate_method(method, ("hdr-CIELAB", "hdr-IPT")) maximum_perception = 247 if method == "hdr-cielab" else 246 @@ -508,7 +508,7 @@ def luminance_Abebe2017( L = as_float_array(L) Y_n = as_float_array(Y_n) - method = validate_method(method, ["Michaelis-Menten", "Stevens"]) + method = validate_method(method, ("Michaelis-Menten", "Stevens")) if method == "stevens": Y = np.where( @@ -644,7 +644,7 @@ def luminance( """ LV = as_float_array(LV) - method = validate_method(method, LUMINANCE_METHODS) + method = validate_method(method, tuple(LUMINANCE_METHODS)) function = LUMINANCE_METHODS[method] diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 47deed982d..d92ef4b9f0 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -2803,7 +2803,7 @@ def reshape_sd( """ method = validate_method( - method, valid_methods=["Align", "Extrapolate", "Interpolate", "Trim"] + method, valid_methods=("Align", "Extrapolate", "Interpolate", "Trim") ) # Handling dict-like keyword arguments. diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index 63c14577f1..433492c696 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -255,7 +255,7 @@ def lagrange_coefficients_ASTME2022( interval_type = validate_method( interval_type, - ["Boundary", "Inner"], + ("Boundary", "Inner"), '"{0}" interval type is invalid, it must be one of {1}!', ) @@ -1243,7 +1243,7 @@ def sd_to_XYZ( cmfs, illuminant, illuminant_default="E" ) - method = validate_method(method, SD_TO_XYZ_METHODS) + method = validate_method(method, tuple(SD_TO_XYZ_METHODS)) global _CACHE_SD_TO_XYZ # noqa: PLW0602 @@ -2019,7 +2019,7 @@ class on the last / tail axis as follows: [ 24.6452277..., 26.0809382..., 27.7106399...]]) """ - method = validate_method(method, MSDS_TO_XYZ_METHODS) + method = validate_method(method, tuple(MSDS_TO_XYZ_METHODS)) function = MSDS_TO_XYZ_METHODS[method] diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index 748e55b146..9f10b0d892 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -543,7 +543,7 @@ def whiteness( XYZ = as_float_array(XYZ) XYZ_0 = as_float_array(XYZ_0) - method = validate_method(method, WHITENESS_METHODS) + method = validate_method(method, tuple(WHITENESS_METHODS)) kwargs.update({"XYZ": XYZ, "XYZ_0": XYZ_0}) diff --git a/colour/colorimetry/yellowness.py b/colour/colorimetry/yellowness.py index 0070b45f6d..9c089b518d 100644 --- a/colour/colorimetry/yellowness.py +++ b/colour/colorimetry/yellowness.py @@ -352,7 +352,7 @@ def yellowness( 10.2999999... """ - method = validate_method(method, YELLOWNESS_METHODS) + method = validate_method(method, tuple(YELLOWNESS_METHODS)) function = YELLOWNESS_METHODS[method] diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 1ee32cd0d7..5f151787a8 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -1608,7 +1608,7 @@ def fill_nan( [ 9. 100. 110. 120.]] """ - method = validate_method(method, ["Interpolation", "Constant"]) + method = validate_method(method, ("Interpolation", "Constant")) for signal in self._signals.values(): signal.fill_nan(method, default) diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 89a9da87e4..9142e23fca 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -1270,7 +1270,7 @@ def fill_nan( [ 9. 100.]] """ - method = validate_method(method, ["Interpolation", "Constant"]) + method = validate_method(method, ("Interpolation", "Constant")) self._fill_domain_nan(method, default) self._fill_range_nan(method, default) diff --git a/colour/contrast/__init__.py b/colour/contrast/__init__.py index df37517304..281be06643 100644 --- a/colour/contrast/__init__.py +++ b/colour/contrast/__init__.py @@ -142,7 +142,7 @@ def contrast_sensitivity_function( 360.8691122... """ - method = validate_method(method, CONTRAST_SENSITIVITY_METHODS) + method = validate_method(method, tuple(CONTRAST_SENSITIVITY_METHODS)) function = CONTRAST_SENSITIVITY_METHODS[method] diff --git a/colour/difference/__init__.py b/colour/difference/__init__.py index f5f3e2fa1e..d5e7950942 100644 --- a/colour/difference/__init__.py +++ b/colour/difference/__init__.py @@ -217,7 +217,7 @@ def delta_E( 0.0001034... """ - method = validate_method(method, DELTA_E_METHODS) + method = validate_method(method, tuple(DELTA_E_METHODS)) function = DELTA_E_METHODS[method] diff --git a/colour/difference/huang2015.py b/colour/difference/huang2015.py index a4dd9f468b..b7b24e5e8f 100644 --- a/colour/difference/huang2015.py +++ b/colour/difference/huang2015.py @@ -125,7 +125,7 @@ def power_function_Huang2015( coefficients = validate_method( coefficients, - COEFFICIENTS_HUANG2015, + tuple(COEFFICIENTS_HUANG2015), '"{0}" coefficients are invalid, they must be one of {1}!', ) diff --git a/colour/difference/stress.py b/colour/difference/stress.py index dfa3bb6adb..c4541fc29b 100644 --- a/colour/difference/stress.py +++ b/colour/difference/stress.py @@ -138,7 +138,7 @@ def index_stress( 0.1211709... """ - method = validate_method(method, INDEX_STRESS_METHODS) + method = validate_method(method, tuple(INDEX_STRESS_METHODS)) function = INDEX_STRESS_METHODS[method] diff --git a/colour/geometry/ellipse.py b/colour/geometry/ellipse.py index 580f99de01..b0e2d71029 100644 --- a/colour/geometry/ellipse.py +++ b/colour/geometry/ellipse.py @@ -337,7 +337,7 @@ def ellipse_fitting( array([-0., -0., 2., 1., 0.]) """ - method = validate_method(method, ELLIPSE_FITTING_METHODS) + method = validate_method(method, tuple(ELLIPSE_FITTING_METHODS)) function = ELLIPSE_FITTING_METHODS[method] diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index bda4385dbe..1697dd7279 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -590,7 +590,7 @@ def primitive( [1 0]] """ - method = validate_method(method, PRIMITIVE_METHODS) + method = validate_method(method, tuple(PRIMITIVE_METHODS)) function = PRIMITIVE_METHODS[method] diff --git a/colour/geometry/section.py b/colour/geometry/section.py index 5de5678a11..dced5bffdc 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -226,7 +226,7 @@ def hull_section( axis = validate_method( axis, - ["+z", "+x", "+y"], + ("+z", "+x", "+y"), '"{0}" axis is invalid, it must be one of {1}!', ) diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 2ab5c7b282..b2da578ceb 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -89,7 +89,7 @@ def primitive_vertices_quad_mpl( axis = MAPPING_PLANE_TO_AXIS.get(axis, axis).lower() axis = validate_method( - axis, ["+x", "+y", "+z"], '"{0}" axis invalid, it must be one of {1}!' + axis, ("+x", "+y", "+z"), '"{0}" axis invalid, it must be one of {1}!' ) u, v = tsplit(origin) @@ -396,7 +396,7 @@ def primitive_vertices_sphere( axis = MAPPING_PLANE_TO_AXIS.get(axis, axis).lower() axis = validate_method( - axis, ["+x", "+y", "+z"], '"{0}" axis invalid, it must be one of {1}!' + axis, ("+x", "+y", "+z"), '"{0}" axis invalid, it must be one of {1}!' ) if not intermediate: @@ -605,7 +605,7 @@ def primitive_vertices( [ 3.7493994...e-33, 6.1232340...e-17, -5.0000000...e-01]]]) """ - method = validate_method(method, PRIMITIVE_VERTICES_METHODS) + method = validate_method(method, tuple(PRIMITIVE_VERTICES_METHODS)) function = PRIMITIVE_VERTICES_METHODS[method] diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index 71b1822a52..048ab0b966 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -1145,7 +1145,7 @@ def describe_conversion_path( source, target = source.lower(), target.lower() mode = validate_method( mode, - ["Short", "Long", "Extended"], + ("Short", "Long", "Extended"), '"{0}" mode is invalid, it must be one of {1}!', ) diff --git a/colour/io/image.py b/colour/io/image.py index c85c2077e0..a5747a6edb 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -426,7 +426,7 @@ def read_image( dtype('float32') """ # noqa: D405, D407, D410, D411, D414 - method = validate_method(method, READ_IMAGE_METHODS) + method = validate_method(method, tuple(READ_IMAGE_METHODS)) if ( method == "openimageio" and not is_openimageio_installed() @@ -756,7 +756,7 @@ def write_image( True """ # noqa: D405, D407, D410, D411, D414 - method = validate_method(method, WRITE_IMAGE_METHODS) + method = validate_method(method, tuple(WRITE_IMAGE_METHODS)) if ( method == "openimageio" and not is_openimageio_installed() diff --git a/colour/io/luts/__init__.py b/colour/io/luts/__init__.py index 57bc9701d0..40c5aeb6f2 100644 --- a/colour/io/luts/__init__.py +++ b/colour/io/luts/__init__.py @@ -221,7 +221,7 @@ def read_LUT( method, MAPPING_EXTENSION_TO_LUT_FORMAT[os.path.splitext(path)[-1]] ) - method = validate_method(method, LUT_READ_METHODS) + method = validate_method(method, tuple(LUT_READ_METHODS)) function = LUT_READ_METHODS[method] @@ -341,7 +341,7 @@ def write_LUT( method, MAPPING_EXTENSION_TO_LUT_FORMAT[os.path.splitext(path)[-1]] ) - method = validate_method(method, LUT_WRITE_METHODS) + method = validate_method(method, tuple(LUT_WRITE_METHODS)) if method == "iridas cube" and isinstance(LUT, LUTSequence): method = "resolve cube" diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 27c35c06ca..29f4dc618b 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -1111,7 +1111,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: """ direction = validate_method( - kwargs.get("direction", "Forward"), ["Forward", "Inverse"] + kwargs.get("direction", "Forward"), ("Forward", "Inverse") ) interpolator = kwargs.get("interpolator", LinearInterpolator) @@ -1646,7 +1646,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: """ direction = validate_method( - kwargs.get("direction", "Forward"), ["Forward", "Inverse"] + kwargs.get("direction", "Forward"), ("Forward", "Inverse") ) interpolator = kwargs.get("interpolator", LinearInterpolator) @@ -2305,7 +2305,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: """ direction = validate_method( - kwargs.get("direction", "Forward"), ["Forward", "Inverse"] + kwargs.get("direction", "Forward"), ("Forward", "Inverse") ) interpolator = kwargs.get( diff --git a/colour/models/din99.py b/colour/models/din99.py index 72f041d246..1af6cca1be 100644 --- a/colour/models/din99.py +++ b/colour/models/din99.py @@ -142,7 +142,7 @@ def Lab_to_DIN99( """ c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8 = DIN99_METHODS[ - validate_method(str(method), DIN99_METHODS) + validate_method(method, tuple(DIN99_METHODS)) ] L, a, b = tsplit(to_domain_100(Lab)) @@ -233,7 +233,7 @@ def DIN99_to_Lab( """ c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8 = DIN99_METHODS[ - validate_method(str(method), DIN99_METHODS) + validate_method(method, tuple(DIN99_METHODS)) ] L_99, a_99, b_99 = tsplit(to_domain_100(Lab_99)) diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 146399e888..2a6f98093a 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -234,13 +234,13 @@ def RGB_to_ICtCp( RGB = as_float_array(RGB) method = validate_method( method, - [ + ( "Dolby 2016", "ITU-R BT.2100-1 HLG", "ITU-R BT.2100-1 PQ", "ITU-R BT.2100-2 HLG", "ITU-R BT.2100-2 PQ", - ], + ), ) is_hlg_method = "hlg" in method @@ -367,13 +367,13 @@ def ICtCp_to_RGB( ICtCp = as_float_array(ICtCp) method = validate_method( method, - [ + ( "Dolby 2016", "ITU-R BT.2100-1 HLG", "ITU-R BT.2100-1 PQ", "ITU-R BT.2100-2 HLG", "ITU-R BT.2100-2 PQ", - ], + ), ) is_hlg_method = "hlg" in method diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 7b2a01be24..6cccb455bc 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -1059,7 +1059,7 @@ def XYZ_to_RGB( if isinstance(colourspace, str): colourspace = validate_method( colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) colourspace = RGB_COLOURSPACES[colourspace] @@ -1207,7 +1207,7 @@ def RGB_to_XYZ( if isinstance(colourspace, str): colourspace = validate_method( colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) colourspace = RGB_COLOURSPACES[colourspace] @@ -1300,7 +1300,7 @@ def matrix_RGB_to_RGB( if isinstance(input_colourspace, str): input_colourspace = validate_method( input_colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) input_colourspace = cast( @@ -1310,7 +1310,7 @@ def matrix_RGB_to_RGB( if isinstance(output_colourspace, str): output_colourspace = validate_method( output_colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) output_colourspace = cast( @@ -1423,7 +1423,7 @@ def RGB_to_RGB( if isinstance(input_colourspace, str): input_colourspace = validate_method( input_colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) input_colourspace = cast( @@ -1433,7 +1433,7 @@ def RGB_to_RGB( if isinstance(output_colourspace, str): output_colourspace = validate_method( output_colourspace, - RGB_COLOURSPACES, + tuple(RGB_COLOURSPACES), '"{0}" "RGB" colourspace is invalid, it must be one of {1}!', ) output_colourspace = cast( diff --git a/colour/models/rgb/transfer_functions/__init__.py b/colour/models/rgb/transfer_functions/__init__.py index 2c5abf6c7e..d3af07c5d5 100644 --- a/colour/models/rgb/transfer_functions/__init__.py +++ b/colour/models/rgb/transfer_functions/__init__.py @@ -495,7 +495,7 @@ def log_encoding( function = validate_method( function, - LOG_ENCODINGS, + tuple(LOG_ENCODINGS), '"{0}" "log" encoding function is invalid, it must be one of {1}!', ) @@ -650,7 +650,7 @@ def log_decoding( function = validate_method( function, - LOG_DECODINGS, + tuple(LOG_DECODINGS), '"{0}" "log" decoding function is invalid, it must be one of {1}!', ) @@ -750,7 +750,9 @@ def oetf( """ function = validate_method( - function, OETFS, '"{0}" "OETF" is invalid, it must be one of {1}!' + function, + tuple(OETFS), + '"{0}" "OETF" is invalid, it must be one of {1}!', ) callable_ = OETFS[function] @@ -841,7 +843,7 @@ def oetf_inverse( function = validate_method( function, - OETF_INVERSES, + tuple(OETF_INVERSES), '"{0}" inverse "OETF" is invalid, it must be one of {1}!', ) @@ -925,7 +927,9 @@ def eotf( """ function = validate_method( - function, EOTFS, '"{0}" "EOTF" is invalid, it must be one of {1}!' + function, + tuple(EOTFS), + '"{0}" "EOTF" is invalid, it must be one of {1}!', ) callable_ = EOTFS[function] @@ -1008,7 +1012,7 @@ def eotf_inverse( function = validate_method( function, - EOTF_INVERSES, + tuple(EOTF_INVERSES), '"{0}" inverse "EOTF" is invalid, it must be one of {1}!', ) @@ -1165,7 +1169,7 @@ def cctf_encoding( function = validate_method( function, - CCTF_ENCODINGS, + tuple(CCTF_ENCODINGS), '"{0}" encoding "CCTF" is invalid, it must be one of {1}!', ) @@ -1322,7 +1326,7 @@ def cctf_decoding( function = validate_method( function, - CCTF_DECODINGS, + tuple(CCTF_DECODINGS), '"{0}" decoding "CCTF" is invalid, it must be one of {1}!', ) @@ -1398,7 +1402,9 @@ def ootf( """ function = validate_method( - function, OOTFS, '"{0}" "OOTF" is invalid, it must be one of {1}!' + function, + tuple(OOTFS), + '"{0}" "OOTF" is invalid, it must be one of {1}!', ) callable_ = OOTFS[function] @@ -1459,7 +1465,7 @@ def ootf_inverse( function = validate_method( function, - OOTF_INVERSES, + tuple(OOTF_INVERSES), '"{0}" inverse "OOTF" is invalid, it must be one of {1}!', ) diff --git a/colour/models/rgb/transfer_functions/arri.py b/colour/models/rgb/transfer_functions/arri.py index dc0d2b1c37..2538750473 100644 --- a/colour/models/rgb/transfer_functions/arri.py +++ b/colour/models/rgb/transfer_functions/arri.py @@ -604,9 +604,9 @@ def log_encoding_ARRILogC3( """ x = to_domain_1(x) - firmware = validate_method(firmware, ["SUP 3.x", "SUP 2.x"]) + firmware = validate_method(firmware, ("SUP 3.x", "SUP 2.x")) method = validate_method( - method, ["Linear Scene Exposure Factor", "Normalised Sensor Signal"] + method, ("Linear Scene Exposure Factor", "Normalised Sensor Signal") ) cut, a, b, c, d, e, f, _e_cut_f = DATA_ALEXA_LOG_C_CURVE_CONVERSION[ @@ -673,7 +673,7 @@ def log_decoding_ARRILogC3( t = to_domain_1(t) method = validate_method( - method, ["Linear Scene Exposure Factor", "Normalised Sensor Signal"] + method, ("Linear Scene Exposure Factor", "Normalised Sensor Signal") ) cut, a, b, c, d, e, f, _e_cut_f = DATA_ALEXA_LOG_C_CURVE_CONVERSION[ diff --git a/colour/models/rgb/transfer_functions/exponent.py b/colour/models/rgb/transfer_functions/exponent.py index 3188035582..7f77686926 100644 --- a/colour/models/rgb/transfer_functions/exponent.py +++ b/colour/models/rgb/transfer_functions/exponent.py @@ -144,14 +144,14 @@ def exponent_function_basic( exponent = as_float_array(exponent) style = validate_method( style, - [ + ( "basicFwd", "basicRev", "basicMirrorFwd", "basicMirrorRev", "basicPassThruFwd", "basicPassThruRev", - ], + ), '"{0}" style is invalid, it must be one of {1}!', ) @@ -269,12 +269,12 @@ def exponent_function_monitor_curve( offset = as_float_array(offset) style = validate_method( style, - [ + ( "monCurveFwd", "monCurveRev", "monCurveMirrorFwd", "monCurveMirrorRev", - ], + ), '"{0}" style is invalid, it must be one of {1}!', ) diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index cb727ee0ad..5f50e6a504 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -84,7 +84,7 @@ def gamma_function( exponent = as_float_array(exponent) negative_number_handling = validate_method( negative_number_handling, - ["Indeterminate", "Mirror", "Preserve", "Clamp"], + ("Indeterminate", "Mirror", "Preserve", "Clamp"), '"{0}" negative number handling is invalid, it must be one of {1}!', ) diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 8aed4cf943..e6a4e304a8 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -828,7 +828,7 @@ def eotf_BT2100_HLG( 7.3321975... """ - method = validate_method(method, BT2100_HLG_EOTF_METHODS) + method = validate_method(method, tuple(BT2100_HLG_EOTF_METHODS)) return BT2100_HLG_EOTF_METHODS[method](E_p, L_B, L_W, gamma, constants) @@ -1059,7 +1059,7 @@ def eotf_inverse_BT2100_HLG( 0.2121320... """ - method = validate_method(method, BT2100_HLG_EOTF_INVERSE_METHODS) + method = validate_method(method, tuple(BT2100_HLG_EOTF_INVERSE_METHODS)) return BT2100_HLG_EOTF_INVERSE_METHODS[method]( F_D, L_B, L_W, gamma, constants @@ -1324,7 +1324,7 @@ def ootf_BT2100_HLG( 63.1051034... """ - method = validate_method(method, BT2100_HLG_OOTF_METHODS) + method = validate_method(method, tuple(BT2100_HLG_OOTF_METHODS)) function = BT2100_HLG_OOTF_METHODS[method] @@ -1617,7 +1617,7 @@ def ootf_inverse_BT2100_HLG( 0.0999999... """ - method = validate_method(method, BT2100_HLG_OOTF_INVERSE_METHODS) + method = validate_method(method, tuple(BT2100_HLG_OOTF_INVERSE_METHODS)) function = BT2100_HLG_OOTF_INVERSE_METHODS[method] diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index 93838083a5..c33a124075 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -134,7 +134,7 @@ def logarithmic_function_basic( x = as_float_array(x) style = validate_method( style, - ["log10", "antiLog10", "log2", "antiLog2", "logB", "antiLogB"], + ("log10", "antiLog10", "log2", "antiLog2", "logB", "antiLogB"), '"{0}" style is invalid, it must be one of {1}!', ) @@ -208,7 +208,7 @@ def logarithmic_function_quasilog( x = as_float_array(x) style = validate_method( style, - ["lintolog", "logtolin"], + ("lintolog", "logtolin"), '"{0}" style is invalid, it must be one of {1}!', ) @@ -302,7 +302,7 @@ def logarithmic_function_camera( x = as_float_array(x) style = validate_method( style, - ["cameraLinToLog", "cameraLogToLin"], + ("cameraLinToLog", "cameraLogToLin"), '"{0}" style is invalid, it must be one of {1}!', ) diff --git a/colour/models/rgb/transfer_functions/red.py b/colour/models/rgb/transfer_functions/red.py index f49c765c9a..b01f5f111a 100644 --- a/colour/models/rgb/transfer_functions/red.py +++ b/colour/models/rgb/transfer_functions/red.py @@ -668,7 +668,7 @@ def log_encoding_Log3G10( 0.3333336... """ - method = validate_method(method, LOG3G10_ENCODING_METHODS) + method = validate_method(method, tuple(LOG3G10_ENCODING_METHODS)) return LOG3G10_ENCODING_METHODS[method](x) @@ -735,7 +735,7 @@ def log_decoding_Log3G10( 0.1799994... """ - method = validate_method(method, LOG3G10_DECODING_METHODS) + method = validate_method(method, tuple(LOG3G10_DECODING_METHODS)) return LOG3G10_DECODING_METHODS[method](y) diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 380e69f9c1..fc23f59bd5 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -822,7 +822,7 @@ def munsell_value( 4.0814348... """ - method = validate_method(method, MUNSELL_VALUE_METHODS) + method = validate_method(method, tuple(MUNSELL_VALUE_METHODS)) return MUNSELL_VALUE_METHODS[method](Y) diff --git a/colour/plotting/common.py b/colour/plotting/common.py index 6364ab3f81..89fbb9309b 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -728,7 +728,7 @@ def label_rectangles( rotation = validate_method( rotation, - ["horizontal", "vertical"], + ("horizontal", "vertical"), '"{0}" rotation is invalid, it must be one of {1}!', ) @@ -1224,14 +1224,14 @@ def plot_multi_colour_swatches( direction = validate_method( direction, - ["+y", "-y"], + ("+y", "-y"), '"{0}" direction is invalid, it must be one of {1}!', ) if compare_swatches is not None: compare_swatches = validate_method( compare_swatches, - ["Diagonal", "Stacked"], + ("Diagonal", "Stacked"), '"{0}" compare swatches method is invalid, it must be one of {1}!', ) diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index 10ba437641..dff303b315 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -152,7 +152,7 @@ def plot_spectral_locus( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) spectral_locus_colours = optional( @@ -430,7 +430,7 @@ def plot_chromaticity_diagram_colours( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) settings: Dict[str, Any] = {"uniform": True} @@ -565,7 +565,7 @@ def plot_chromaticity_diagram( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) settings: Dict[str, Any] = {"uniform": True} @@ -903,7 +903,7 @@ def plot_sds_in_chromaticity_diagram( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) sds_converted = sds_and_msds_to_sds(sds) diff --git a/colour/plotting/graph.py b/colour/plotting/graph.py index 2895c756c2..44372b864c 100644 --- a/colour/plotting/graph.py +++ b/colour/plotting/graph.py @@ -81,7 +81,7 @@ def plot_automatic_colour_conversion_graph( prog = validate_method( prog, - ["circo", "dot", "fdp", "neato", "nop", "twopi"], + ("circo", "dot", "fdp", "neato", "nop", "twopi"), '"{0}" program is invalid, it must be one of {1}!', ) diff --git a/colour/plotting/models.py b/colour/plotting/models.py index 2cd9b9a95b..1c1b57cb6b 100644 --- a/colour/plotting/models.py +++ b/colour/plotting/models.py @@ -254,13 +254,13 @@ def colourspace_model_axis_reorder( model = validate_method( model, - list(COLOURSPACE_MODELS_AXIS_ORDER.keys()), + tuple(COLOURSPACE_MODELS_AXIS_ORDER), '"{0}" model is invalid, it must be one of {1}!', ) direction = validate_method( direction, - ["Forward", "Inverse"], + ("Forward", "Inverse"), '"{0}" direction is invalid, it must be one of {1}!', ) @@ -316,7 +316,7 @@ def plot_pointer_gamut( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) pointer_gamut_colours = optional( @@ -507,7 +507,7 @@ def plot_RGB_colourspaces_in_chromaticity_diagram( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) colourspaces = cast( @@ -1008,7 +1008,7 @@ def plot_RGB_chromaticities_in_chromaticity_diagram( RGB = np.reshape(as_float_array(RGB), (-1, 3)) method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) settings: Dict[str, Any] = {"uniform": True} @@ -1342,7 +1342,7 @@ def ellipses_MacAdam1942( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) if method == "cie 1931": diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index 3bebdfed64..cbdc1e28e1 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -411,7 +411,7 @@ def plot_single_sd_colour_quality_scale_bars( :alt: plot_single_sd_colour_quality_scale_bars """ - method = validate_method(method, COLOUR_QUALITY_SCALE_METHODS) + method = validate_method(method, tuple(COLOUR_QUALITY_SCALE_METHODS)) return plot_multi_sds_colour_quality_scales_bars([sd], method, **kwargs) @@ -467,7 +467,7 @@ def plot_multi_sds_colour_quality_scales_bars( :alt: plot_multi_sds_colour_quality_scales_bars """ - method = validate_method(method, COLOUR_QUALITY_SCALE_METHODS) + method = validate_method(method, tuple(COLOUR_QUALITY_SCALE_METHODS)) sds_converted = sds_and_msds_to_sds(sds) diff --git a/colour/plotting/section.py b/colour/plotting/section.py index 2f3409d2cb..bb1b28b0eb 100644 --- a/colour/plotting/section.py +++ b/colour/plotting/section.py @@ -192,7 +192,7 @@ def plot_hull_section_colours( axis = validate_method( axis, - ["+z", "+x", "+y"], + ("+z", "+x", "+y"), '"{0}" axis is invalid, it must be one of {1}!', ) diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index b7446444d1..55c96b9749 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -131,7 +131,7 @@ def plot_daylight_locus( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) daylight_locus_colours = optional( @@ -272,7 +272,7 @@ def plot_planckian_locus( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) planckian_locus_colours = optional( @@ -491,7 +491,7 @@ def plot_planckian_locus_in_chromaticity_diagram( """ method = validate_method( - method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + method, ("CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS") ) cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] diff --git a/colour/plotting/tm3018/components.py b/colour/plotting/tm3018/components.py index 8327a0cbf9..6fcda3315d 100644 --- a/colour/plotting/tm3018/components.py +++ b/colour/plotting/tm3018/components.py @@ -520,7 +520,7 @@ def plot_16_bin_bars( values = as_float_array(values) label_orientation = validate_method( - label_orientation, ["Horizontal", "Vertical"] + label_orientation, ("Horizontal", "Vertical") ) _figure, axes = artist(**kwargs) diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index 07bbc7bfea..d41b4b3243 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -809,7 +809,7 @@ def plot_single_sd_colour_rendition_report( :alt: plot_single_sd_colour_rendition_report_simple """ - method = validate_method(method, ["Full", "Intermediate", "Simple"]) + method = validate_method(method, ("Full", "Intermediate", "Simple")) if method == "full": return plot_single_sd_colour_rendition_report_full(sd, **kwargs) diff --git a/colour/quality/__init__.py b/colour/quality/__init__.py index e5eee6770a..c7b5a1bff7 100644 --- a/colour/quality/__init__.py +++ b/colour/quality/__init__.py @@ -101,7 +101,7 @@ def colour_fidelity_index( 70.1208254... """ - method = validate_method(method, COLOUR_FIDELITY_INDEX_METHODS) + method = validate_method(method, tuple(COLOUR_FIDELITY_INDEX_METHODS)) function = COLOUR_FIDELITY_INDEX_METHODS[method] diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 36fb7433cd..3ccf3a9539 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -219,7 +219,7 @@ def colour_quality_scale( 64.1117031... """ - method = validate_method(method, COLOUR_QUALITY_SCALE_METHODS) + method = validate_method(method, tuple(COLOUR_QUALITY_SCALE_METHODS)) # pylint: disable=E1102 cmfs = reshape_msds( diff --git a/colour/recovery/__init__.py b/colour/recovery/__init__.py index 2afa953e35..6527468d89 100644 --- a/colour/recovery/__init__.py +++ b/colour/recovery/__init__.py @@ -511,7 +511,7 @@ def XYZ_to_sd( """ a = as_float_array(XYZ) - method = validate_method(method, XYZ_TO_SD_METHODS) + method = validate_method(method, tuple(XYZ_TO_SD_METHODS)) function = XYZ_TO_SD_METHODS[method] diff --git a/colour/temperature/__init__.py b/colour/temperature/__init__.py index 3fa9946857..55dc130ba6 100644 --- a/colour/temperature/__init__.py +++ b/colour/temperature/__init__.py @@ -184,7 +184,7 @@ def uv_to_CCT( array([ 6.507473...e+03, 3.223346...e-03]) """ - method = validate_method(method, UV_TO_CCT_METHODS) + method = validate_method(method, tuple(UV_TO_CCT_METHODS)) function = UV_TO_CCT_METHODS[method] @@ -262,7 +262,7 @@ def CCT_to_uv( array([ 0.1977999..., 0.3121999...]) """ - method = validate_method(method, CCT_TO_UV_METHODS) + method = validate_method(method, tuple(CCT_TO_UV_METHODS)) function = CCT_TO_UV_METHODS[method] @@ -353,7 +353,7 @@ def xy_to_CCT( 6500.7420431... """ - method = validate_method(method, XY_TO_CCT_METHODS) + method = validate_method(method, tuple(XY_TO_CCT_METHODS)) return XY_TO_CCT_METHODS[method](xy) @@ -432,7 +432,7 @@ def CCT_to_xy( array([ 0.313426 ..., 0.3235959...]) """ - method = validate_method(method, CCT_TO_XY_METHODS) + method = validate_method(method, tuple(CCT_TO_XY_METHODS)) return CCT_TO_XY_METHODS[method](CCT) diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 7c0d3bf668..c5d401e2fe 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -2231,7 +2231,7 @@ def orient( a = as_float_array(a) orientation = validate_method( - orientation, ["Ignore", "Flip", "Flop", "90 CW", "90 CCW", "180"] + orientation, ("Ignore", "Flip", "Flop", "90 CW", "90 CCW", "180") ) if orientation == "ignore": @@ -2324,7 +2324,7 @@ def fill_nan( """ a = np.array(a, copy=True) - method = validate_method(method, ["Interpolation", "Constant"]) + method = validate_method(method, ("Interpolation", "Constant")) mask = np.isnan(a) diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 7da7063119..1d25039c42 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -1299,9 +1299,10 @@ def copy_definition(definition: Callable, name: str | None = None) -> Callable: return copy +@functools.cache def validate_method( method: str, - valid_methods: Sequence | Mapping, + valid_methods: tuple, message: str = '"{0}" method is invalid, it must be one of {1}!', ) -> str: """ @@ -1329,7 +1330,7 @@ def validate_method( Examples -------- - >>> validate_method("Valid", ["Valid", "Yes", "Ok"]) + >>> validate_method("Valid", ("Valid", "Yes", "Ok")) 'valid' """ diff --git a/colour/utilities/tests/test_common.py b/colour/utilities/tests/test_common.py index c4fe050729..1f84ca0812 100644 --- a/colour/utilities/tests/test_common.py +++ b/colour/utilities/tests/test_common.py @@ -470,7 +470,7 @@ def test_validate_method(self): """Test :func:`colour.utilities.common.validate_method` definition.""" self.assertEqual( - validate_method("Valid", ["Valid", "Yes", "Ok"]), "valid" + validate_method("Valid", ("Valid", "Yes", "Ok")), "valid" ) def test_raise_exception_validate_method(self): @@ -480,7 +480,7 @@ def test_raise_exception_validate_method(self): """ self.assertRaises( - ValueError, validate_method, "Invalid", ["Valid", "Yes", "Ok"] + ValueError, validate_method, "Invalid", ("Valid", "Yes", "Ok") ) diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index abb13e3c5a..ccbecceae9 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -57,7 +57,7 @@ def _XYZ_optimal_colour_stimuli( illuminant = validate_method( illuminant, - list(OPTIMAL_COLOUR_STIMULI_ILLUMINANTS.keys()), + tuple(OPTIMAL_COLOUR_STIMULI_ILLUMINANTS), '"{0}" illuminant is invalid, it must be one of {1}!', ) diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py index 4a8104dc03..44edc63b70 100644 --- a/colour/volume/spectrum.py +++ b/colour/volume/spectrum.py @@ -208,7 +208,7 @@ def generate_pulse_waves( pulse_order = validate_method( pulse_order, - ["Bins", "Pulse Wave Width"], + ("Bins", "Pulse Wave Width"), '"{0}" pulse order is invalid, it must be one of {1}!', )