Skip to content

Commit

Permalink
Peanuts: lint session
Browse files Browse the repository at this point in the history
  • Loading branch information
mfe committed Jun 26, 2014
1 parent 86ab9a1 commit 7d8c2d2
Show file tree
Hide file tree
Showing 26 changed files with 237 additions and 242 deletions.
10 changes: 5 additions & 5 deletions lutLab/curve_to_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def curve_to_lut(colorspace, gamma, outlutfile, out_type=None, out_format=None,
# colorspace mode
try:
colorspace_obj = dict(COLORSPACES.items() +
PRIVATE_COLORSPACES.items())[colorspace]
PRIVATE_COLORSPACES.items())[colorspace]
except KeyError:
raise CurveToLUTException(("Unsupported {0} "
"Colorspace!").format(colorspace))
Expand Down Expand Up @@ -141,7 +141,7 @@ def curve_to_lut(colorspace, gamma, outlutfile, out_type=None, out_format=None,
# process file output
if os.path.isdir(outlutfile):
filename = "{0}{1}".format(title,
preset[presets.EXT])
preset[presets.EXT])
outlutfile = os.path.join(outlutfile, filename)
else:
try:
Expand Down Expand Up @@ -215,11 +215,11 @@ def __get_options():
if __name__ == '__main__':
ARGS = __get_options()
try:
if not ARGS.input_range is None:
if ARGS.input_range is not None:
ARGS.input_range = presets.convert_string_range(ARGS.input_range)
if not ARGS.output_range is None:
if ARGS.output_range is not None:
ARGS.output_range = presets.convert_string_range(ARGS.output_range)
if not ARGS.preset is None:
if ARGS.preset is not None:
ARGS.preset = presets.get_presets_from_env()[ARGS.preset]
curve_to_lut(ARGS.colorspace,
ARGS.gamma,
Expand Down
6 changes: 3 additions & 3 deletions lutLab/lut_to_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ def __get_options():

if __name__ == '__main__':
ARGS = __get_options()
if not ARGS.input_range is None:
if ARGS.input_range is not None:
ARGS.input_range = presets.convert_string_range(ARGS.input_range)
if not ARGS.output_range is None:
if ARGS.output_range is not None:
ARGS.output_range = presets.convert_string_range(ARGS.output_range)
if not ARGS.preset is None:
if ARGS.preset is not None:
ARGS.preset = presets.get_presets_from_env()[ARGS.preset]
try:
lut_to_lut(ARGS.inlutfiles,
Expand Down
2 changes: 1 addition & 1 deletion lutLab/plot_that_chroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __get_options():
help=("RGB Colorspace."),
type=str, action='append', dest='colorspaces',
choices=sorted(COLORSPACES.keys() +
PRIVATE_COLORSPACES.keys()))
PRIVATE_COLORSPACES.keys()))
# Points
parser.add_argument("-p", "--point", type=float, nargs=2,
metavar=('x', 'y'), action='append',
Expand Down
2 changes: 1 addition & 1 deletion lutLab/rgb_to_xyz_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __get_options():
help=("Input RGB Colorspace."),
type=str,
choices=sorted(COLORSPACES.keys() +
PRIVATE_COLORSPACES.keys()),
PRIVATE_COLORSPACES.keys()),
default='Rec709')
# Output format
parser.add_argument("-f", "--format",
Expand Down
2 changes: 1 addition & 1 deletion plotThatLut/plot_that_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def plot_cube(lutfile, cube_size, processor):
title(filename)
# plot 3D values
axis.scatter(red_values, green_values, blue_values, c=input_colors,
marker="o")
marker="o")
return show_plot(fig, filename)


Expand Down
4 changes: 2 additions & 2 deletions plotThatLut/ptlut.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __get_options():
# type
parser.add_argument("-t", "--plot-type",
help=("Plot type. By default, a curve for a 1D/2D LUT "
"and a cube for a 3D LUT."),
"and a cube for a 3D LUT."),
type=str,
choices=['auto', 'curve', 'red_curve', 'blue_curve',
'green_curve', 'cube'],
Expand All @@ -53,7 +53,7 @@ def __get_options():
parser.add_argument("-s", "--samples-count", help=(
"Samples count. Ex : {0} for a curve or {1} for a cube."
).format(plot_that_lut.DEFAULT_SAMPLE, plot_that_lut.DEFAULT_CUBE_SIZE),
default=None, type=int)
default=None, type=int)
# version
parser.add_argument('-v', "--version", action='version',
version='{0} - version {1}'.format(description,
Expand Down
64 changes: 32 additions & 32 deletions test/abstract_lut_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ def setUp(self):
lut1d = os.path.join(test_dir, 'CineonToLin_1D.csp')
lut3d = os.path.join(test_dir, 'saturation.3dl')
self.processor_1d = create_ocio_processor(lut1d,
interpolation=INTERP_LINEAR)
interpolation=INTERP_LINEAR)
self.processor_3d = create_ocio_processor(lut3d,
interpolation=INTERP_TETRAHEDRAL)
interpolation=INTERP_TETRAHEDRAL)
self.helpers_1d_to_test = [
(CUBE_HELPER, '.cube'),
[SPI_HELPER, '.spi1d'],
(CSP_HELPER, '.csp'),
]
(CUBE_HELPER, '.cube'),
[SPI_HELPER, '.spi1d'],
(CSP_HELPER, '.csp'),
]
self.helpers_3d_to_test = [
(CUBE_HELPER, '.cube', True),
[SPI_HELPER, '.spi3d', True],
(CSP_HELPER, '.csp', True),
(THREEDL_HELPER, '.3dl', True),
(CLCC_HELPER, '.cc', False),
(JSON_HELPER, '.json', False)
]
(CUBE_HELPER, '.cube', True),
[SPI_HELPER, '.spi3d', True],
(CSP_HELPER, '.csp', True),
(THREEDL_HELPER, '.3dl', True),
(CLCC_HELPER, '.cc', False),
(JSON_HELPER, '.json', False)
]

def test_default_1d_lut(self):
""" Test a default 1d LUT export
Expand Down Expand Up @@ -129,11 +129,11 @@ def test_check_attributes(self):
CUBE_HELPER.check_preset(cust_preset)
# try to write a 1D LUT with a 3D preset
self.failUnlessRaises(alh.AbstractLUTException,
CUBE_HELPER.write_1d_lut,
self.processor_1d,
outlutfile,
cust_preset)
## test value type
CUBE_HELPER.write_1d_lut,
self.processor_1d,
outlutfile,
cust_preset)
# # test value type
# cube size
cust_preset[presets.CUBE_SIZE] = presets.CUBE_SIZE_MAX_VALUE + 1
self.failUnlessRaises(presets.PresetException,
Expand Down Expand Up @@ -177,15 +177,15 @@ def test_float_luts(self):
10)
# write encode LUT
helper.write_2d_lut(colorspace.encode_gradation,
encode_filepath,
args_1d)
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)
decode_filepath,
args_1d)
# test transparency
proc = create_ocio_processor(encode_filepath,
postlutfile=decode_filepath,
Expand All @@ -201,8 +201,8 @@ def test_float_luts(self):
self.assert_(abs_value < delta,
"{0} transparency test failed : {1:8f} >"
" acceptable delta ({2:8f})".format(name,
abs_value,
delta)
abs_value,
delta)
)

def test_3dl_preset(self):
Expand Down Expand Up @@ -247,14 +247,14 @@ def test_ascii_lut(self):
outlutfile = os.path.join(self.tmp_dir, "default_2D.lut")
preset = ASCII_HELPER.get_default_preset()
ASCII_HELPER.write_2d_lut(colorspace.decode_gradation,
outlutfile,
preset)
outlutfile,
preset)
# 1D LUT
outlutfile = os.path.join(self.tmp_dir, "default_1D.lut")
preset = ASCII_HELPER.get_default_preset()
ASCII_HELPER.write_1d_lut(colorspace.decode_gradation,
outlutfile,
preset)
outlutfile,
preset)
# test out bit depth inadequate with output range
preset[OUT_BITDEPTH] = 12
self.failUnlessRaises(AsciiHelperException, ASCII_HELPER.write_1d_lut,
Expand All @@ -278,17 +278,17 @@ def test_complete_attributes(self):
# try to write a float ascii lut without forcing float mode
cust_preset[presets.IN_RANGE] = [0, 1.0]
self.failUnlessRaises(PresetException, ASCII_HELPER.write_1d_lut,
colorspace.decode_gradation,
outlutfile,
cust_preset)
colorspace.decode_gradation,
outlutfile,
cust_preset)
# force float mode
cust_preset[presets.IS_FLOAT] = True
ASCII_HELPER.write_1d_lut(colorspace.decode_gradation,
outlutfile,
cust_preset)

def tearDown(self):
#Remove test directory
# Remove test directory
shutil.rmtree(self.tmp_dir)


Expand Down
2 changes: 1 addition & 1 deletion test/chroma_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_chroma_plot(self):
mplh.plot_colorspace_gamut(colorspaces.ACES, lines_color="c",
upvp_conversion=True)
mplh.plot_colorspace_gamut(colorspaces.REC709, lines_color="m",
upvp_conversion=True)
upvp_conversion=True)
plt.legend(loc=4)
if DISPLAY:
plt.show()
Expand Down
22 changes: 11 additions & 11 deletions test/colorspaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def test_gradation(self):
"""
colorspace_to_test = [REC709,
ALEXALOGCV3,
WIDEGAMUT,
REC2020_12B,
ACESLOG_32f,
sRGB,
SGAMUTSLOG,
SGAMUTSLOG2,
SGAMUTSLOG3,
]
ALEXALOGCV3,
WIDEGAMUT,
REC2020_12B,
ACESLOG_32f,
sRGB,
SGAMUTSLOG,
SGAMUTSLOG2,
SGAMUTSLOG3,
]
delta = 0.000000000000001
for space in colorspace_to_test:
name = space.__class__.__name__
Expand All @@ -34,8 +34,8 @@ def test_gradation(self):
diff = abs(res - value)
message = ("{0} gradations not transparent ! "
"in: {1:8f} out: {2:8f}").format(name,
value,
res)
value,
res)
self.assert_(diff < delta, message)


Expand Down
2 changes: 1 addition & 1 deletion test/curve_to_lut_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_curve(self):
process_input_range=True)

def tearDown(self):
#Remove test directory
# Remove test directory
shutil.rmtree(self.tmp_dir)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion test/general_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_rgb_to_matrix(self):
# TODO test values

def tearDown(self):
#Remove test directory
# Remove test directory
shutil.rmtree(self.tmp_dir)


Expand Down
5 changes: 3 additions & 2 deletions test/lut_to_lut_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_export_cc_json(self):
"""
for form, ext, excep in [('json', '.json', JsonHelperException),
('clcc', '.cc', CLCCHelperException)]:
('clcc', '.cc', CLCCHelperException)]:
outlutfile = os.path.join(self.tmp_dir, "CineonToLin_export" + ext)
lut_to_lut(self.lut1d, "3D", form, outlutfile)
# test wrong type
Expand Down Expand Up @@ -119,8 +119,9 @@ def test_concatenate_luts(self):
lut_to_lut([self.lut3d, self.lut3d, self.lut1d],
"3D", "csp", outlutfile)
lut_to_lut(outlutfile, "2D", "lut", self.tmp_dir)

def tearDown(self):
#Remove test directory
# Remove test directory
shutil.rmtree(self.tmp_dir)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion test/preset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_env_presets(self):
curve_to_lut('sRGB', None, outlutfile=self.tmp_dir, preset=preset)

def tearDown(self):
#Remove test directory
# Remove test directory
shutil.rmtree(self.tmp_dir)

if __name__ == '__main__':
Expand Down
28 changes: 13 additions & 15 deletions utils/abstract_lut_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ def _get_rgb_value_line(self, preset, rgb, in_rgb=None, separator=" "):
"""
line = self._get_pattern(preset, separator).format(rgb.r, rgb.g, rgb.b)
if not in_rgb is None:
if in_rgb is not None:
return "{0}{4}{1}{4}{2}{4}{3}".format(in_rgb.r,
in_rgb.g,
in_rgb.b,
line,
separator)
in_rgb.g,
in_rgb.b,
line,
separator)
return line

def _get_1d_data(self, process_function, preset):
Expand Down Expand Up @@ -240,8 +240,8 @@ def _get_3d_data(self, process_function, preset,
input_range = preset[presets.IN_RANGE]
output_range = preset[presets.OUT_RANGE]
is_int = False
if (isinstance(output_range[0], int)
and isinstance(output_range[1], int)):
if (isinstance(output_range[0], int) and
isinstance(output_range[1], int)):
is_int = True
compute_range = linspace(input_range[0],
input_range[1],
Expand Down Expand Up @@ -315,7 +315,7 @@ def write_2d_lut(self, process_function, file_path, preset):
"""
return self._write_1d_2d_lut(process_function, file_path, preset,
self._get_rgb_value_line)
self._get_rgb_value_line)

def write_1d_lut(self, process_function, file_path, preset):
""" Write 2d LUT in output file
Expand All @@ -333,7 +333,7 @@ def write_1d_lut(self, process_function, file_path, preset):
"""
return self._write_1d_2d_lut(process_function, file_path, preset,
self._get_r_value_line)
self._get_r_value_line)

@abstractmethod
def write_3d_lut(self, process_function, file_path, preset):
Expand Down Expand Up @@ -369,9 +369,8 @@ def get_export_message(file_path):
.str
"""
return "a new LUT was written in {1}".format(
get_file_shortname(file_path),
file_path)
return ("a new LUT was written in {1}"
).format(get_file_shortname(file_path), file_path)

def _validate_preset(self, preset, mode=RAISE_MODE, default_preset=None):
""" Check preset. When an irregularity is found, if mode is 'raise'
Expand All @@ -398,7 +397,7 @@ def _validate_preset(self, preset, mode=RAISE_MODE, default_preset=None):
raise PresetException(("{0} is not a valid type: "
"{1}").format(preset[TYPE], TYPE_CHOICE))
preset[TYPE] = default_preset[TYPE]
## check if type specific attr are set
# # check if type specific attr are set
# default type
if preset[TYPE] == 'default' and (OUT_BITDEPTH not in preset
or CUBE_SIZE not in preset):
Expand Down Expand Up @@ -480,8 +479,7 @@ def complete_preset(self, preset, default_preset=None):
preset (dict): preset to validate
"""
return self._validate_preset(preset, FILL_MODE,
default_preset)
return self._validate_preset(preset, FILL_MODE, default_preset)

@staticmethod
def get_generated_title(file_path, preset):
Expand Down
Loading

0 comments on commit 7d8c2d2

Please sign in to comment.