def test_float_luts(self): """ Test float LUT transparency """ helpers_float_to_test = [(CSP_HELPER, '.csp'), (SPI_HELPER, '.spi1d')] colorspace_to_test = [REC709, SGAMUTSLOG, ALEXALOGCV3] delta = 0.00001 for helper, ext in helpers_float_to_test: for colorspace in colorspace_to_test: # define file name name = colorspace.__class__.__name__ encode_filename = "linTo{0}_1D{1}".format(name, ext) decode_filename = "{0}ToLin_1D{1}".format(name, ext) encode_filepath = os.path.join(self.tmp_dir, encode_filename) decode_filepath = os.path.join(self.tmp_dir, decode_filename) # set preset args_1d = CSP_HELPER.get_default_preset() args_1d[presets.OUT_BITDEPTH] = 16 decode_min = colorspace.decode_gradation(0) decode_max = colorspace.decode_gradation(1) args_1d[presets.IN_RANGE] = get_input_range(colorspace, "encode", 10) # write encode LUT helper.write_2d_lut(colorspace.encode_gradation, encode_filepath, args_1d) # write decode LUT args_1d[presets.IN_RANGE] = get_input_range(colorspace, "decode", 10) helper.write_2d_lut(colorspace.decode_gradation, decode_filepath, args_1d) # test transparency proc = create_ocio_processor(encode_filepath, postlutfile=decode_filepath, interpolation=INTERP_LINEAR) test_values = [[decode_min] * 3, [decode_max] * 3, [0] * 3, [0.5] * 3, [1] * 3] for rgb in test_values: res = proc.applyRGB(rgb) abs_value = abs(rgb[0] - res[0]) self.assert_(abs_value < delta, "{0} transparency test failed : {1:8f} >" " acceptable delta ({2:8f})".format(name, abs_value, delta) )
def test_write_and_readback(self): """Write and read back a preset """ preset = {presets.TYPE: '1D'} preset = CSP_HELPER.complete_preset(preset) presets.write_preset(self.preset_path, preset) back_preset = presets.read_preset(self.preset_path) expression = set(back_preset).issubset(set(preset)) self.assert_(expression, ("Something went wrong in preset write and read :\n" "Write preset:\n{0}\nRead one:\n{1}" ).format(preset, back_preset))