Skip to content

Commit

Permalink
Merge pull request #332 from colour-science/feature/yapf
Browse files Browse the repository at this point in the history
PR: Format codebase with "Yapf".
  • Loading branch information
MichaelMauderer authored Jul 8, 2017
2 parents a99ec40 + f6e1b97 commit e789c8a
Show file tree
Hide file tree
Showing 364 changed files with 11,898 additions and 15,928 deletions.
180 changes: 180 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
[style]
# Align closing bracket with visual indentation.
align_closing_bracket_with_visual_indent=True

# Allow dictionary keys to exist on multiple lines. For example:
#
# x = {
# ('this is the first element of a tuple',
# 'this is the second element of a tuple'):
# value,
# }
allow_multiline_dictionary_keys=False

# Allow lambdas to be formatted on more than one line.
allow_multiline_lambdas=False

# Insert a blank line before a class-level docstring.
blank_line_before_class_docstring=False

# Insert a blank line before a 'def' or 'class' immediately nested
# within another 'def' or 'class'. For example:
#
# class Foo:
# # <------ this blank line
# def method():
# ...
blank_line_before_nested_class_or_def=False

# Do not split consecutive brackets. Only relevant when
# dedent_closing_brackets is set. For example:
#
# call_func_that_takes_a_dict(
# {
# 'key1': 'value1',
# 'key2': 'value2',
# }
# )
#
# would reformat to:
#
# call_func_that_takes_a_dict({
# 'key1': 'value1',
# 'key2': 'value2',
# })
coalesce_brackets=False

# The column limit.
column_limit=79

# Indent width used for line continuations.
continuation_indent_width=4

# Put closing brackets on a separate line, dedented, if the bracketed
# expression can't fit in a single line. Applies to all kinds of brackets,
# including function definitions and calls. For example:
#
# config = {
# 'key1': 'value1',
# 'key2': 'value2',
# } # <--- this bracket is dedented and on a separate line
#
# time_series = self.remote_client.query_entity_counters(
# entity='dev3246.region1',
# key='dns.query_latency_tcp',
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)),
# start_ts=now()-timedelta(days=3),
# end_ts=now(),
# ) # <--- this bracket is dedented and on a separate line
dedent_closing_brackets=False

# Place each dictionary entry onto its own line.
each_dict_entry_on_separate_line=True

# The regex for an i18n comment. The presence of this comment stops
# reformatting of that line, because the comments are required to be
# next to the string they translate.
i18n_comment=

# The i18n function call names. The presence of this function stops
# reformattting on that line, because the string it has cannot be moved
# away from the i18n comment.
i18n_function_call=

# Indent the dictionary value if it cannot fit on the same line as the
# dictionary key. For example:
#
# config = {
# 'key1':
# 'value1',
# 'key2': value1 +
# value2,
# }
indent_dictionary_value=True

# The number of columns to use for indentation.
indent_width=4

# Join short lines into one line. E.g., single line 'if' statements.
join_multiple_lines=True

# Use spaces around default or named assigns.
spaces_around_default_or_named_assign=False

# Use spaces around the power operator.
spaces_around_power_operator=True

# The number of spaces required before a trailing comment.
spaces_before_comment=2

# Insert a space between the ending comma and closing bracket of a list,
# etc.
space_between_ending_comma_and_closing_bracket=True

# Split before arguments if the argument list is terminated by a
# comma.
split_arguments_when_comma_terminated=False

# Set to True to prefer splitting before '&', '|' or '^' rather than
# after.
split_before_bitwise_operator=False

# Split before a dictionary or set generator (comp_for). For example, note
# the split before the 'for':
#
# foo = {
# variable: 'Hello world, have a nice day!'
# for variable in bar if variable != 42
# }
split_before_dict_set_generator=True

# If an argument / parameter list is going to be split, then split before
# the first argument.
split_before_first_argument=False

# Set to True to prefer splitting before 'and' or 'or' rather than
# after.
split_before_logical_operator=False

# Split named assignments onto individual lines.
split_before_named_assigns=True

# The penalty for splitting right after the opening bracket.
split_penalty_after_opening_bracket=30

# The penalty for splitting the line after a unary operator.
split_penalty_after_unary_operator=10000

# The penalty for splitting right before an if expression.
split_penalty_before_if_expr=0

# The penalty of splitting the line around the '&', '|', and '^'
# operators.
split_penalty_bitwise_operator=300

# The penalty for characters over the column limit.
split_penalty_excess_character=4500

# The penalty incurred by adding a line split to the unwrapped line. The
# more line splits added the higher the penalty.
split_penalty_for_added_line_split=30

# The penalty of splitting a list of "import as" names. For example:
#
# from a_very_long_or_indented_module_name_yada_yad import (long_argument_1,
# long_argument_2,
# long_argument_3)
#
# would reformat to something like:
#
# from a_very_long_or_indented_module_name_yada_yad import (
# long_argument_1, long_argument_2, long_argument_3)
split_penalty_import_names=0

# The penalty of splitting the line around the 'and' and 'or'
# operators.
split_penalty_logical_operator=300

# Use the Tab character for indentation.
use_tabs=False

8 changes: 4 additions & 4 deletions colour/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Colour
======
Expand Down Expand Up @@ -104,6 +103,7 @@
__major_version__ = '0'
__minor_version__ = '3'
__change_version__ = '9'
__version__ = '.'.join((__major_version__,
__minor_version__,
__change_version__))
__version__ = '.'.join(
(__major_version__,
__minor_version__,
__change_version__)) # yapf: disable
27 changes: 13 additions & 14 deletions colour/adaptation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@

from .dataset import * # noqa
from . import dataset
from .vonkries import (
chromatic_adaptation_matrix_VonKries,
chromatic_adaptation_VonKries)
from .vonkries import (chromatic_adaptation_matrix_VonKries,
chromatic_adaptation_VonKries)
from .fairchild1990 import chromatic_adaptation_Fairchild1990
from .cmccat2000 import (
CMCCAT2000_InductionFactors,
CMCCAT2000_VIEWING_CONDITIONS,
CMCCAT2000_InductionFactors, CMCCAT2000_VIEWING_CONDITIONS,
chromatic_adaptation_forward_CMCCAT2000,
chromatic_adaptation_reverse_CMCCAT2000,
chromatic_adaptation_CMCCAT2000)
chromatic_adaptation_reverse_CMCCAT2000, chromatic_adaptation_CMCCAT2000)
from .cie1994 import chromatic_adaptation_CIE1994

__all__ = []
__all__ += dataset.__all__
__all__ += ['chromatic_adaptation_matrix_VonKries',
'chromatic_adaptation_VonKries']
__all__ += [
'chromatic_adaptation_matrix_VonKries', 'chromatic_adaptation_VonKries'
]
__all__ += ['chromatic_adaptation_Fairchild1990']
__all__ += ['CMCCAT2000_InductionFactors',
'CMCCAT2000_VIEWING_CONDITIONS',
'chromatic_adaptation_forward_CMCCAT2000',
'chromatic_adaptation_reverse_CMCCAT2000',
'chromatic_adaptation_CMCCAT2000']
__all__ += [
'CMCCAT2000_InductionFactors', 'CMCCAT2000_VIEWING_CONDITIONS',
'chromatic_adaptation_forward_CMCCAT2000',
'chromatic_adaptation_reverse_CMCCAT2000',
'chromatic_adaptation_CMCCAT2000'
]
__all__ += ['chromatic_adaptation_CIE1994']
31 changes: 9 additions & 22 deletions colour/adaptation/cie1994.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
CIE 1994 Chromatic Adaptation Model
===================================
Expand Down Expand Up @@ -36,18 +35,12 @@
__email__ = '[email protected]'
__status__ = 'Production'

__all__ = ['CIE1994_XYZ_TO_RGB_MATRIX',
'CIE1994_RGB_TO_XYZ_MATRIX',
'chromatic_adaptation_CIE1994',
'XYZ_to_RGB_CIE1994',
'RGB_to_XYZ_CIE1994',
'intermediate_values',
'effective_adapting_responses',
'beta_1',
'beta_2',
'exponential_factors',
'K_coefficient',
'corresponding_colour']
__all__ = [
'CIE1994_XYZ_TO_RGB_MATRIX', 'CIE1994_RGB_TO_XYZ_MATRIX',
'chromatic_adaptation_CIE1994', 'XYZ_to_RGB_CIE1994', 'RGB_to_XYZ_CIE1994',
'intermediate_values', 'effective_adapting_responses', 'beta_1', 'beta_2',
'exponential_factors', 'K_coefficient', 'corresponding_colour'
]

CIE1994_XYZ_TO_RGB_MATRIX = VON_KRIES_CAT
"""
Expand All @@ -66,13 +59,7 @@
"""


def chromatic_adaptation_CIE1994(XYZ_1,
xy_o1,
xy_o2,
Y_o,
E_o1,
E_o2,
n=1):
def chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2, n=1):
"""
Adapts given stimulus *CIE XYZ_1* tristimulus values from test viewing
conditions to reference viewing conditions using *CIE 1994* chromatic
Expand Down Expand Up @@ -147,8 +134,8 @@ def chromatic_adaptation_CIE1994(XYZ_1,

K = K_coefficient(xez_1, xez_2, bRGB_o1, bRGB_o2, Y_o, n)

RGB_2 = corresponding_colour(
RGB_1, xez_1, xez_2, bRGB_o1, bRGB_o2, Y_o, K, n)
RGB_2 = corresponding_colour(RGB_1, xez_1, xez_2, bRGB_o1, bRGB_o2, Y_o, K,
n)
XYZ_2 = RGB_to_XYZ_CIE1994(RGB_2)

return XYZ_2
Expand Down
Loading

0 comments on commit e789c8a

Please sign in to comment.