def test_build_API_changes(self): """ Test :func:`colour.utilities.deprecation.build_API_changes` definition. """ changes = build_API_changes( { "ObjectRenamed": [ [ "module.object_1_name", "module.object_1_new_name", ] ], "ObjectFutureRename": [ [ "module.object_2_name", "module.object_2_new_name", ] ], "ObjectFutureAccessChange": [ [ "module.object_3_access", "module.sub_module.object_3_new_access", ] ], "ObjectRemoved": ["module.object_4_name"], "ObjectFutureRemove": ["module.object_5_name"], "ObjectFutureAccessRemove": ["module.object_6_access"], "ArgumentRenamed": [ [ "argument_1_name", "argument_1_new_name", ] ], "ArgumentFutureRename": [ [ "argument_2_name", "argument_2_new_name", ] ], "ArgumentRemoved": ["argument_3_name"], "ArgumentFutureRemove": ["argument_4_name"], } ) for name, change_type in ( ("object_1_name", ObjectRenamed), ("object_2_name", ObjectFutureRename), ("object_3_access", ObjectFutureAccessChange), ("object_4_name", ObjectRemoved), ("object_5_name", ObjectFutureRemove), ("object_6_access", ObjectFutureAccessRemove), ("argument_1_name", ArgumentRenamed), ("argument_2_name", ArgumentFutureRename), ("argument_3_name", ArgumentRemoved), ("argument_4_name", ArgumentFutureRemove), ): self.assertIsInstance(changes[name], change_type)
def test_build_API_changes(self): """ Tests :func:`colour.utilities.deprecation.build_API_changes` definition. """ changes = build_API_changes({ 'ObjectRenamed': [[ 'module.object_1_name', 'module.object_1_new_name', ]], 'ObjectFutureRename': [[ 'module.object_2_name', 'module.object_2_new_name', ]], 'ObjectFutureAccessChange': [[ 'module.object_3_access', 'module.sub_module.object_3_new_access', ]], 'ObjectRemoved': ['module.object_4_name'], 'ObjectFutureRemove': ['module.object_5_name'], 'ObjectFutureAccessRemove': ['module.object_6_access'], 'ArgumentRenamed': [[ 'argument_1_name', 'argument_1_new_name', ]], 'ArgumentFutureRename': [[ 'argument_2_name', 'argument_2_new_name', ]], 'ArgumentRemoved': ['argument_3_name'], 'ArgumentFutureRemove': ['argument_4_name'], }) for name, change_type in ( ('object_1_name', ObjectRenamed), ('object_2_name', ObjectFutureRename), ('object_3_access', ObjectFutureAccessChange), ('object_4_name', ObjectRemoved), ('object_5_name', ObjectFutureRemove), ('object_6_access', ObjectFutureAccessRemove), ('argument_1_name', ArgumentRenamed), ('argument_2_name', ArgumentFutureRename), ('argument_3_name', ArgumentRemoved), ('argument_4_name', ArgumentFutureRemove), ): self.assertIsInstance(changes[name], change_type)
'colour.models.oetf_BT2020', 'colour.models.eotf_inverse_BT2020', ], [ 'colour.models.POINTER_GAMUT_BOUNDARIES', 'colour.models.CCS_POINTER_GAMUT_BOUNDARY', ], [ 'colour.models.POINTER_GAMUT_DATA', 'colour.models.DATA_POINTER_GAMUT_VOLUME', ], [ 'colour.models.POINTER_GAMUT_ILLUMINANT', 'colour.models.CCS_ILLUMINANT_POINTER_GAMUT', ], [ 'colour.models.YCBCR_WEIGHTS', 'colour.models.WEIGHTS_YCBCR', ], [ 'colour.models.RGB_to_RGB_matrix', 'colour.models.matrix_RGB_to_RGB', ], ] if not is_documentation_building(): sys.modules['colour.models'] = models(sys.modules['colour.models'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
] # ----------------------------------------------------------------------------# # --- API Changes and Deprecation Management ---# # ----------------------------------------------------------------------------# class recovery(ModuleAPI): """Define a class acting like the *recovery* module.""" def __getattr__(self, attribute) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) # v0.4.0 API_CHANGES = { "ObjectRenamed": [ [ "colour.recovery.NodeTree_Otsu2018", "colour.recovery.Tree_Otsu2018", ], ] } """Defines the *colour.recovery* sub-package API changes.""" if not is_documentation_building(): sys.modules["colour.recovery"] = recovery( # type: ignore[assignment] sys.modules["colour.recovery"], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
# ----------------------------------------------------------------------------# class utilities(ModuleAPI): def __getattr__(self, attribute): return super(utilities, self).__getattr__(attribute) # v0.3.16 API_CHANGES = { 'ObjectRenamed': [ [ 'colour.utilities.dot_vector', 'colour.utilities.vector_dot', ], [ 'colour.utilities.dot_matrix', 'colour.utilities.matrix_dot', ], ] } """ Defines *colour.utilities* sub-package API changes. API_CHANGES : dict """ if not is_documentation_building(): sys.modules['colour.utilities'] = utilities( sys.modules['colour.utilities'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
# ----------------------------------------------------------------------------# # --- API Changes and Deprecation Management ---# # ----------------------------------------------------------------------------# class continuous(ModuleAPI): def __getattr__(self, attribute): return super(continuous, self).__getattr__(attribute) # v0.3.14 API_CHANGES = { 'ObjectRenamed': [ [ 'colour.continuous.MultiSignal', 'colour.continuous.MultiSignals', ], ] } """ Defines *colour.continuous* sub-package API changes. API_CHANGES : dict """ if not is_documentation_building(): sys.modules['colour.continuous'] = continuous( sys.modules['colour.continuous'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
'colour.colorimetry.PHOTOPIC_LEFS', 'colour.colorimetry.SDS_LEFS_PHOTOPIC', ], [ 'colour.colorimetry.RGB_CMFS', 'colour.colorimetry.MSDS_CMFS_RGB', ], [ 'colour.colorimetry.SCOTOPIC_LEFS', 'colour.colorimetry.SDS_LEFS_SCOTOPIC', ], [ 'colour.colorimetry.STANDARD_OBSERVERS_CMFS', 'colour.colorimetry.MSDS_CMFS_STANDARD_OBSERVER', ], [ 'colour.colorimetry.sds_and_multi_sds_to_sds', 'colour.colorimetry.sds_and_msds_to_sds', ], [ 'colour.colorimetry.sds_and_multi_sds_to_multi_sds', 'colour.colorimetry.sds_and_msds_to_msds', ], ] if not is_documentation_building(): sys.modules['colour.colorimetry'] = colorimetry( sys.modules['colour.colorimetry'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
# v0.3.16 API_CHANGES = { 'ObjectRenamed': [ [ 'colour.blindness.anomalous_trichromacy_cmfs_Machado2009', 'colour.blindness.msds_cmfs_anomalous_trichromacy_Machado2009', ], [ 'colour.blindness.anomalous_trichromacy_matrix_Machado2009', 'colour.blindness.matrix_anomalous_trichromacy_Machado2009', ], [ 'colour.blindness.cvd_matrix_Machado2009', 'colour.blindness.matrix_cvd_Machado2009', ], ] } """ Defines *colour.blindness* sub-package API changes. API_CHANGES : dict """ if not is_documentation_building(): sys.modules['colour.blindness'] = blindness( sys.modules['colour.blindness'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
], [ "colour.models.ICTCP_to_RGB", "colour.models.ICtCp_to_RGB", ], [ "colour.models.RGB_to_IGPGTG", "colour.models.RGB_to_IgPgTg", ], [ "colour.models.IGPGTG_to_RGB", "colour.models.IgPgTg_to_RGB", ], [ "colour.models.XYZ_to_JzAzBz", "colour.models.XYZ_to_Jzazbz", ], [ "colour.models.JzAzBz_to_XYZ", "colour.models.Jzazbz_to_XYZ", ], ] } """Defines the *colour.models* sub-package API changes.""" if not is_documentation_building(): sys.modules["colour.models"] = models( # type: ignore[assignment] sys.modules["colour.models"], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
'colour.adaptation.CMCCAT2000_VIEWING_CONDITIONS', 'colour.adaptation.VIEWING_CONDITIONS_CMCCAT2000', ], [ 'colour.adaptation.FAIRCHILD_CAT', 'colour.adaptation.CAT_FAIRCHILD', ], [ 'colour.adaptation.SHARP_CAT', 'colour.adaptation.CAT_SHARP', ], [ 'colour.adaptation.VON_KRIES_CAT', 'colour.adaptation.CAT_VON_KRIES', ], [ 'colour.adaptation.XYZ_SCALING_CAT', 'colour.adaptation.CAT_XYZ_SCALING', ], [ 'colour.adaptation.chromatic_adaptation_matrix_VonKries', 'colour.adaptation.matrix_chromatic_adaptation_VonKries)', ], ] if not is_documentation_building(): sys.modules['colour.adaptation'] = adaptation( sys.modules['colour.adaptation'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
], [ 'colour.appearance.Nayatani95_Specification', 'colour.appearance.CAM_Specification_Nayatani95', ], [ 'colour.appearance.RLAB_VIEWING_CONDITIONS', 'colour.appearance.VIEWING_CONDITIONS_RLAB', ], [ 'colour.appearance.RLAB_D_FACTOR', 'colour.appearance.D_FACTOR_RLAB', ], [ 'colour.appearance.RLAB_Specification', 'colour.appearance.CAM_Specification_RLAB', ], ] } """ Defines *colour.appearance* sub-package API changes. API_CHANGES : dict """ if not is_documentation_building(): sys.modules['colour.appearance'] = appearance( sys.modules['colour.appearance'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
# ----------------------------------------------------------------------------# class biochemistry(ModuleAPI): """Define a class acting like the *biochemistry* module.""" def __getattr__(self, attribute) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) # v0.4.0 API_CHANGES = { "ObjectRenamed": [ [ "colour.biochemistry.reaction_rate_MichealisMenten", "colour.biochemistry.reaction_rate_MichaelisMenten", ], [ "colour.biochemistry.substrate_concentration_MichealisMenten", "colour.biochemistry.substrate_concentration_MichaelisMenten", ], ] } """Defines the *colour.biochemistry* sub-package API changes.""" if not is_documentation_building(): sys.modules[ "colour.biochemistry"] = biochemistry( # type:ignore[assignment] sys.modules["colour.biochemistry"], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys
[ 'colour.characterisation.colour_correction_matrix_Cheung2004', 'colour.characterisation.matrix_colour_correction_Cheung2004', ], [ 'colour.characterisation.colour_correction_matrix_Finlayson2015', 'colour.characterisation.matrix_colour_correction_Finlayson2015', ], [ 'colour.characterisation.colour_correction_matrix_Vandermonde', 'colour.characterisation.matrix_colour_correction_Vandermonde', ], # Not strictly needed but in use by A.M.P.A.S. [ 'colour.characterisation.idt_matrix', 'colour.characterisation.matrix_idt', ], ] } """ Defines *colour.characterisation* sub-package API changes. API_CHANGES : dict """ if not is_documentation_building(): sys.modules['colour.characterisation'] = characterisation( sys.modules['colour.characterisation'], build_API_changes(API_CHANGES)) del ModuleAPI, is_documentation_building, build_API_changes, sys