Skip to content

Commit

Permalink
Static analysis session from "PyCharm" results.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Aug 26, 2014
1 parent 4273495 commit cf82f74
Show file tree
Hide file tree
Showing 110 changed files with 1,041 additions and 671 deletions.
3 changes: 3 additions & 0 deletions .landscape.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore-paths:
- docs
- utilities
10 changes: 8 additions & 2 deletions colour/adaptation/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ def chromatic_adaptation_matrix(XYZ1, XYZ2, method='CAT02'):
ndarray, (3, 3)
Chromatic adaptation matrix.
Raises
------
KeyError
If chromatic adaptation method is not defined.
References
----------
.. [4] http://brucelindbloom.com/Eqn_ChromAdapt.html
Expand All @@ -141,15 +146,16 @@ def chromatic_adaptation_matrix(XYZ1, XYZ2, method='CAT02'):
--------
>>> XYZ1 = np.array([1.09923822, 1.000, 0.35445412])
>>> XYZ2 = np.array([0.96907232, 1.000, 1.121792157])
>>> chromatic_adaptation_matrix(XYZ1, XYZ2) # doctest: +ELLIPSIS
>>> chromatic_adaptation_matrix(XYZ1, XYZ2) # doctest: +ELLIPSIS
array([[ 0.8714561..., -0.1320467..., 0.4039483...],
[-0.0963880..., 1.0490978..., 0.160403... ],
[ 0.0080207..., 0.0282636..., 3.0602319...]])
Using *Bradford* method:
>>> XYZ1 = np.array([1.09923822, 1.000, 0.35445412])
>>> XYZ2 = np.array([0.96907232, 1.000, 1.121792157])
>>> chromatic_adaptation_matrix(XYZ1, XYZ2, 'Bradford') # doctest: +ELLIPSIS
>>> method = 'Bradford'
>>> chromatic_adaptation_matrix(XYZ1, XYZ2, method) # doctest: +ELLIPSIS
array([[ 0.8518131..., -0.1134786..., 0.4124804...],
[-0.1277659..., 1.0928930..., 0.1341559...],
[ 0.0845323..., -0.1434969..., 3.3075309...]])
Expand Down
3 changes: 3 additions & 0 deletions colour/adaptation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

11 changes: 6 additions & 5 deletions colour/algebra/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def closest(y, x):
Examples
--------
>>> y = np.array([24.31357115, 63.62396289, 55.71528816, 62.70988028, 46.84480573, 25.40026416])
>>> y = np.array([24.31357115, 63.62396289, 55.71528816, 62.70988028, 46.84480573, 25.40026416]) # noqa
>>> closest(y, 63)
62.70988028
"""
Expand Down Expand Up @@ -220,7 +220,7 @@ def is_numeric(x):

def is_integer(x):
"""
Returns if given :math:`x` variable is an integer through thresholding.
Returns if given :math:`x` variable is an integer under given threshold.
Parameters
----------
Expand All @@ -234,8 +234,8 @@ def is_integer(x):
Notes
-----
The determination threshold is defined by the
:attr:`colour.algebra.common.INTEGER_THRESHOLD` attribute.
- The determination threshold is defined by the
:attr:`colour.algebra.common.INTEGER_THRESHOLD` attribute.
See Also
--------
Expand Down Expand Up @@ -273,7 +273,8 @@ def normalise(x, factor=1, clip=True):
Examples
--------
>>> normalise(np.array([0.48224885, 0.31651974, 0.22070513])) # doctest: +ELLIPSIS
>>> x = np.array([0.48224885, 0.31651974, 0.22070513])
>>> normalise(x) # doctest: +ELLIPSIS
array([ 1. , 0.6563411..., 0.4576581...])
"""

Expand Down
12 changes: 8 additions & 4 deletions colour/algebra/coordinates/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def cartesian_to_spherical(vector):
Examples
--------
>>> cartesian_to_spherical(np.array([3, 1, 6])) # doctest: +ELLIPSIS
>>> vector = np.array([3, 1, 6])
>>> cartesian_to_spherical(vector) # doctest: +ELLIPSIS
array([ 6.7823299..., 1.0857465..., 0.3217505...])
"""

Expand Down Expand Up @@ -90,7 +91,8 @@ def spherical_to_cartesian(vector):
Examples
--------
>>> spherical_to_cartesian(np.array([6.78232998, 1.08574654, 0.32175055])) # doctest: +ELLIPSIS
>>> vector = np.array([6.78232998, 1.08574654, 0.32175055])
>>> spherical_to_cartesian(vector) # doctest: +ELLIPSIS
array([ 3. , 0.9999999..., 6. ])
"""

Expand Down Expand Up @@ -123,7 +125,8 @@ def cartesian_to_cylindrical(vector):
Examples
--------
>>> cartesian_to_cylindrical(np.array([3, 1, 6])) # doctest: +ELLIPSIS
>>> vector = np.array([3, 1, 6])
>>> cartesian_to_cylindrical(vector) # doctest: +ELLIPSIS
array([ 6. , 0.3217505..., 3.1622776...])
"""

Expand Down Expand Up @@ -155,7 +158,8 @@ def cylindrical_to_cartesian(vector):
Examples
--------
>>> cylindrical_to_cartesian(np.array([6, 0.32175055, 3.16227766])) # doctest: +ELLIPSIS
>>> vector = np.array([6, 0.32175055, 3.16227766])
>>> cylindrical_to_cartesian(vector) # doctest: +ELLIPSIS
array([ 3. , 0.9999999..., 6. ])
"""

Expand Down
4 changes: 2 additions & 2 deletions colour/algebra/extrapolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def method(self, value):

if value is not None:
assert type(value) in (str, unicode), (
'"{0}" attribute: "{1}" type is not "str" or "unicode"!'.format(
'method', value))
('"{0}" attribute: "{1}" type is not '
'"str" or "unicode"!').format('method', value))

value = value.lower()

Expand Down
12 changes: 6 additions & 6 deletions colour/algebra/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class LinearInterpolator1d(object):
--------
Interpolating a single numeric variable:
>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500])
>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500]) # noqa
>>> x = np.arange(len(y))
>>> f = LinearInterpolator1d(x, y)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> f(0.5) # doctest: +ELLIPSIS
>>> f(0.5) # doctest: +ELLIPSIS
7.64...
Interpolating an *array_like* variable:
Expand Down Expand Up @@ -290,15 +290,15 @@ class SpragueInterpolator(object):
--------
Interpolating a single numeric variable:
>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500])
>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500]) # noqa
>>> x = np.arange(len(y))
>>> f = SpragueInterpolator(x, y)
>>> f(0.5) # doctest: +ELLIPSIS
>>> f(0.5) # doctest: +ELLIPSIS
7.2185025...
Interpolating an *array_like* variable:
>>> f([0.25, 0.75]) # doctest: +ELLIPSIS
>>> f([0.25, 0.75]) # doctest: +ELLIPSIS
array([ 6.7295161..., 7.8140625...])
"""

Expand All @@ -315,7 +315,7 @@ class SpragueInterpolator(object):
References
----------
.. [3] `CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: Table V <http://div1.cie.co.at/?i_ca_id=551&pubid=47>`_
.. [3] `CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: Table V <http://div1.cie.co.at/?i_ca_id=551&pubid=47>`_ # noqa
"""

def __init__(self, x=None, y=None):
Expand Down
15 changes: 10 additions & 5 deletions colour/algebra/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def linear_regression(y, x=None, additional_statistics=False):
ndarray, ({{mn, mn-1, ..., b}, {sum_of_squares_residual}})
Regression statistics.
Raises
------
ValueError
If :math:`y` and :math:`x` variables have incompatible dimensions.
References
----------
.. [2] http://en.wikipedia.org/wiki/Simple_linear_regression
Expand All @@ -65,27 +70,27 @@ def linear_regression(y, x=None, additional_statistics=False):
--------
Linear regression with the dependent and already known :math:`y` variable:
>>> y = np.array([1,2,1,3,2,3,3,4,4,3])
>>> linear_regression(y) # doctest: +ELLIPSIS
>>> y = np.array([1, 2, 1, 3, 2, 3, 3, 4, 4, 3])
>>> linear_regression(y) # doctest: +ELLIPSIS
array([ 0.2909090..., 1. ])
Linear regression with the dependent :math:`y` variable and independent
:math:`x` variable:
>>> x1 = np.array([40, 45, 38, 50, 48, 55, 53, 55, 58, 40])
>>> linear_regression(y, x1) # doctest: +ELLIPSIS
>>> linear_regression(y, x1) # doctest: +ELLIPSIS
array([ 0.1225194..., -3.3054357...])
Multiple linear regression with the dependent :math:`y` variable and
multiple independent :math:`x_i` variables:
>>> x2 = np.array([25, 20, 30, 30, 28, 30, 34, 36, 32, 34])
>>> linear_regression(y, tuple(zip(x1, x2))) # doctest: +ELLIPSIS
>>> linear_regression(y, tuple(zip(x1, x2))) # doctest: +ELLIPSIS
array([ 0.0998002..., 0.0876257..., -4.8303807...])
Multiple linear regression with additional statistics:
>>> linear_regression(y, tuple(zip(x1, x2)), additional_statistics=True) # doctest: +ELLIPSIS
>>> linear_regression(y, tuple(zip(x1, x2)), True) # doctest: +ELLIPSIS
(array([ 0.0998002..., 0.0876257..., -4.8303807...]), array([ 2.1376249...]))
"""

Expand Down
2 changes: 2 additions & 0 deletions colour/algebra/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2 changes: 2 additions & 0 deletions colour/algebra/tests/tests_coordinates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
24 changes: 16 additions & 8 deletions colour/algebra/tests/tests_coordinates/tests_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@

class TestCartesianToSpherical(unittest.TestCase):
"""
Defines :func:`colour.algebra.coordinates.transformations.cartesian_to_spherical`
Defines
:func:`colour.algebra.coordinates.transformations.cartesian_to_spherical`
definition unit tests methods.
"""

def test_cartesian_to_spherical(self):
"""
Tests :func:`colour.algebra.coordinates.transformations.cartesian_to_spherical`
Tests
:func:`colour.algebra.coordinates.transformations.cartesian_to_spherical` # noqa
definition.
"""

Expand All @@ -60,13 +62,15 @@ def test_cartesian_to_spherical(self):

class TestSphericalToCartesian(unittest.TestCase):
"""
Defines :func:`colour.algebra.coordinates.transformations.spherical_to_cartesian`
Defines
:func:`colour.algebra.coordinates.transformations.spherical_to_cartesian`
definition unit tests methods.
"""

def test_spherical_to_cartesian(self):
"""
Tests :func:`colour.algebra.coordinates.transformations.spherical_to_cartesian`
Tests
:func:`colour.algebra.coordinates.transformations.spherical_to_cartesian` # noqa
definition.
"""

Expand All @@ -86,13 +90,15 @@ def test_spherical_to_cartesian(self):

class TestCartesianToCylindrical(unittest.TestCase):
"""
Defines :func:`colour.algebra.coordinates.transformations.cartesian_to_cylindrical`
Defines
:func:`colour.algebra.coordinates.transformations.cartesian_to_cylindrical`
definition unit tests methods.
"""

def test_cartesian_to_cylindrical(self):
"""
Tests :func:`colour.algebra.coordinates.transformations.cartesian_to_cylindrical`
Tests
:func:`colour.algebra.coordinates.transformations.cartesian_to_cylindrical` # noqa
definition.
"""

Expand All @@ -112,13 +118,15 @@ def test_cartesian_to_cylindrical(self):

class TestCylindricalToCartesian(unittest.TestCase):
"""
Defines :func:`colour.algebra.coordinates.transformations.cylindrical_to_cartesian`
Defines
:func:`colour.algebra.coordinates.transformations.cylindrical_to_cartesian` # noqa
definition unit tests methods.
"""

def test_cylindrical_to_cartesian(self):
"""
Tests :func:`colour.algebra.coordinates.transformations.cylindrical_to_cartesian`
Tests
:func:`colour.algebra.coordinates.transformations.cylindrical_to_cartesian` # noqa
definition.
"""

Expand Down
6 changes: 4 additions & 2 deletions colour/algebra/tests/tests_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@

class TestLinearInterpolator1d(unittest.TestCase):
"""
Defines :func:`colour.algebra.interpolation.LinearInterpolator1d` class units
Defines
:func:`colour.algebra.interpolation.LinearInterpolator1d` class units
tests methods.
"""

Expand All @@ -385,7 +386,8 @@ def test_required_methods(self):

def test___call__(self):
"""
Tests :func:`colour.algebra.interpolation.LinearInterpolator1d.__call__`
Tests
:func:`colour.algebra.interpolation.LinearInterpolator1d.__call__`
method.
"""

Expand Down
22 changes: 14 additions & 8 deletions colour/appearance/atd95.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def XYZ_to_ATD95(XYZ, XYZ_0, Y_0, k_1, k_2, sigma=300):
>>> Y_0 = 318.31
>>> k_1 = 0.0
>>> k_2 = 50.0
>>> XYZ_to_ATD95(XYZ, XYZ_0, Y_0, k_1, k_2) # doctest: +ELLIPSIS
>>> XYZ_to_ATD95(XYZ, XYZ_0, Y_0, k_1, k_2) # doctest: +ELLIPSIS
ATD95_Specification(H=1.9089869..., Br=0.1814003..., C=1.2064060..., A_1=0.1787931... T_1=0.0286942..., D_1=0.0107584..., A_2=0.0192182..., T_2=0.0205377..., D_2=0.0107584...)
"""

Expand Down Expand Up @@ -188,9 +188,9 @@ def luminance_to_retinal_illuminance(XYZ, absolute_adapting_field_luminance):
Examples
--------
>>> XYZ = np.array([ 19.01, 20. , 21.78])
>>> XYZ = np.array([19.01, 20., 21.78])
>>> Y_0 = 318.31
>>> luminance_to_retinal_illuminance(XYZ, Y_0) # doctest: +ELLIPSIS
>>> luminance_to_retinal_illuminance(XYZ, Y_0) # doctest: +ELLIPSIS
array([ 479.4445924..., 499.3174313..., 534.5631673...])
"""

Expand All @@ -213,9 +213,9 @@ def XYZ_to_LMS_ATD95(XYZ):
Examples
--------
>>> XYZ = np.array([ 19.01, 20. , 21.78])
>>> XYZ = np.array([19.01, 20., 21.78])
>>> Y_0 = 318.31
>>> luminance_to_retinal_illuminance(XYZ, Y_0) # doctest: +ELLIPSIS
>>> luminance_to_retinal_illuminance(XYZ, Y_0) # doctest: +ELLIPSIS
array([ 479.4445924..., 499.3174313..., 534.5631673...])
"""

Expand Down Expand Up @@ -245,9 +245,15 @@ def opponent_colour_dimensions(LMS_g):
Examples
--------
>>> from pprint import pprint
>>> LMS_g = np.array([6.95457922, 7.08945043, 6.44069316])
>>> opponent_colour_dimensions(LMS_g) # doctest: +ELLIPSIS
(0.1787931..., 0.0286942..., 0.0107584..., 0.0192182..., 0.0205377..., 0.0107584...)
>>> pprint(opponent_colour_dimensions(LMS_g)) # doctest: +ELLIPSIS
(0.1787931...,
0.0286942...,
0.0107584...,
0.0192182...,
0.0205377...,
0.0107584...)
"""

L_g, M_g, S_g = LMS_g
Expand Down Expand Up @@ -285,7 +291,7 @@ def final_response(value):
Examples
--------
>>> final_response(43.54399695501678) # doctest: +ELLIPSIS
>>> final_response(43.54399695501678) # doctest: +ELLIPSIS
0.1787931...
"""

Expand Down
Loading

0 comments on commit cf82f74

Please sign in to comment.