Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 6cb12bf

Browse files
authored
Merge pull request #101 from gtaylor/feature/formatting
PR: Code formatting using Black and Flake8.
2 parents cedfdc4 + ff383b2 commit 6cb12bf

26 files changed

+3206
-2494
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://gitlab.com/pycqa/flake8
3+
rev: 3.7.8
4+
hooks:
5+
- id: flake8
6+
args: ['--max-line-length=90']
7+
- repo: https://github.com/ambv/black
8+
rev: stable
9+
hooks:
10+
- id: black

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ Installation
2828

2929
The easiest way to install colormath is via pip/easy_install::
3030

31-
pip install colormath
31+
$ pip install colormath
32+
33+
The development dependencies are installed as follows:
34+
35+
$ pip install 'colormath[development]'
3236

3337
Documentation
3438
-------------

colormath/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
VERSION = '3.0.0'
2+
VERSION = "3.0.0"

colormath/chromatic_adaptation.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def _get_adaptation_matrix(wp_src, wp_dst, observer, adaptation):
2929
if isinstance(wp_src, str):
3030
orig_illum = wp_src.lower()
3131
wp_src = color_constants.ILLUMINANTS[observer][orig_illum]
32-
elif hasattr(wp_src, '__iter__'):
32+
elif hasattr(wp_src, "__iter__"):
3333
wp_src = wp_src
3434

3535
if isinstance(wp_dst, str):
3636
targ_illum = wp_dst.lower()
3737
wp_dst = color_constants.ILLUMINANTS[observer][targ_illum]
38-
elif hasattr(wp_dst, '__iter__'):
38+
elif hasattr(wp_dst, "__iter__"):
3939
wp_dst = wp_dst
4040

4141
# Sharpened cone responses ~ rho gamma beta ~ sharpened r g b
@@ -52,8 +52,9 @@ def _get_adaptation_matrix(wp_src, wp_dst, observer, adaptation):
5252

5353

5454
# noinspection PyPep8Naming
55-
def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum,
56-
observer='2', adaptation='bradford'):
55+
def apply_chromatic_adaptation(
56+
val_x, val_y, val_z, orig_illum, targ_illum, observer="2", adaptation="bradford"
57+
):
5758
"""
5859
Applies a chromatic adaptation matrix to convert XYZ values between
5960
illuminants. It is important to recognize that color transformation results
@@ -74,19 +75,18 @@ def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum,
7475
if isinstance(orig_illum, str):
7576
orig_illum = orig_illum.lower()
7677
wp_src = color_constants.ILLUMINANTS[observer][orig_illum]
77-
elif hasattr(orig_illum, '__iter__'):
78+
elif hasattr(orig_illum, "__iter__"):
7879
wp_src = orig_illum
7980

8081
if isinstance(targ_illum, str):
8182
targ_illum = targ_illum.lower()
8283
wp_dst = color_constants.ILLUMINANTS[observer][targ_illum]
83-
elif hasattr(targ_illum, '__iter__'):
84+
elif hasattr(targ_illum, "__iter__"):
8485
wp_dst = targ_illum
8586

8687
logger.debug(" \\* Applying adaptation matrix: %s", adaptation)
8788
# Retrieve the appropriate transformation matrix from the constants.
88-
transform_matrix = _get_adaptation_matrix(wp_src, wp_dst,
89-
observer, adaptation)
89+
transform_matrix = _get_adaptation_matrix(wp_src, wp_dst, observer, adaptation)
9090

9191
# Stuff the XYZ values into a NumPy matrix for conversion.
9292
XYZ_matrix = numpy.array((val_x, val_y, val_z))
@@ -98,7 +98,7 @@ def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum,
9898

9999

100100
# noinspection PyPep8Naming
101-
def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation='bradford'):
101+
def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation="bradford"):
102102
"""
103103
Convenience function to apply an adaptation directly to a Color object.
104104
"""
@@ -112,8 +112,14 @@ def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation='bradford'
112112

113113
# Return individual X, Y, and Z coordinates.
114114
color.xyz_x, color.xyz_y, color.xyz_z = apply_chromatic_adaptation(
115-
xyz_x, xyz_y, xyz_z, orig_illum, targ_illum,
116-
observer=observer, adaptation=adaptation)
115+
xyz_x,
116+
xyz_y,
117+
xyz_z,
118+
orig_illum,
119+
targ_illum,
120+
observer=observer,
121+
adaptation=adaptation,
122+
)
117123
color.set_illuminant(targ_illum)
118124

119125
return color

0 commit comments

Comments
 (0)