Skip to content

Commit

Permalink
Static analysis session from "landscape.io" results.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Aug 26, 2014
1 parent 7da16d8 commit 4273495
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 71 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
Colour Science for Python
=========================

.. image:: https://raw.githubusercontent.com/colour-science/colour-branding/master/images/Colour_Logo_Medium_001.png

.. image:: https://travis-ci.org/colour-science/colour.svg?branch=master
:target: https://travis-ci.org/colour-science/colour
.. image:: https://coveralls.io/repos/colour-science/colour/badge.png?branch=master
Expand All @@ -15,6 +10,11 @@ Colour Science for Python
:target: https://waffle.io/colour-science/colour
:alt: 'Stories in Ready'

Colour Science for Python
=========================

.. image:: https://raw.githubusercontent.com/colour-science/colour-branding/master/images/Colour_Logo_Medium_001.png

`Colour <https://github.com/colour-science/colour>`_ is a `Python <https://www.python.org/>`_ colour science package implementing a comprehensive number of colour theory transformations and algorithms.

It is open source and freely available and under the `New BSD License <http://opensource.org/licenses/BSD-3-Clause>`_ terms.
Expand Down Expand Up @@ -58,4 +58,4 @@ About
| **Colour** by Colour Developers - 2013 - 2014
| Copyright © 2013 - 2014 – Colour Developers – `[email protected] <[email protected]>`_
| This software is released under terms of New BSD License: http://opensource.org/licenses/BSD-3-Clause
| `http://github.com/colour-science/colour <http://github.com/colour-science/colour>`_
| `http://github.com/colour-science/colour <http://github.com/colour-science/colour>`_
6 changes: 2 additions & 4 deletions colour/algebra/extrapolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,9 @@ def interpolator(self, value):

if value is not None:
assert hasattr(value, 'x'), (
'"{0}" attribute has no "x" attribute!'.format(
'interpolator', value))
'"{0}" interpolator has no "x" attribute!'.format(value))
assert hasattr(value, 'y'), (
'"{0}" attribute has no "y" attribute!'.format(
'interpolator', value))
'"{0}" interpolator has no "y" attribute!'.format(value))

self.__interpolator = value

Expand Down
3 changes: 1 addition & 2 deletions colour/appearance/ciecam02.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import numpy as np
from collections import namedtuple

import colour
from colour.adaptation.cat import CAT02_CAT, CAT02_INVERSE_CAT
from colour.appearance.hunt import (HPE_MATRIX,
HPE_MATRIX_INVERSE,
Expand Down Expand Up @@ -305,7 +304,7 @@ def CIECAM02_to_XYZ(J, C, h,
>>> XYZ_w = np.array([96.4219075, 100.00, 82.520490])
>>> L_A = 100
>>> Y_b = 20.0
>>> colour.CIECAM02_to_XYZ(J, C, h, XYZ_w, L_A, Y_b) # doctest: +ELLIPSIS
>>> CIECAM02_to_XYZ(J, C, h, XYZ_w, L_A, Y_b) # doctest: +ELLIPSIS
array([ 28.8452082..., 18.4037556..., 2.6743017...])
"""

Expand Down
1 change: 0 additions & 1 deletion colour/appearance/hunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import numpy as np
from collections import namedtuple

import colour
from colour.utilities import CaseInsensitiveMapping, warning

__author__ = 'Colour Developers'
Expand Down
1 change: 0 additions & 1 deletion colour/appearance/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def check_model_consistency(self, data, output_attributes):
specification_attr,
data[data_attr])


def fixtures(self):
"""
Returns the fixtures case for tested colour appearance model and
Expand Down
1 change: 0 additions & 1 deletion colour/examples/plotting/examples_phenomenon_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Showcases optical phenomenons plotting examples.
"""

import colour
from colour.phenomenons import rayleigh_scattering_spd
from colour.plotting import *

Expand Down
25 changes: 16 additions & 9 deletions colour/plotting/colorimetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,13 @@ def single_cmfs_plot(cmfs='CIE 1931 2 Degree Standard Observer', **kwargs):
return multi_cmfs_plot([cmfs], **settings)


def multi_cmfs_plot(cmfss=['CIE 1931 2 Degree Standard Observer',
'CIE 1964 10 Degree Standard Observer'], **kwargs):
def multi_cmfs_plot(cmfss=None, **kwargs):
"""
Plots given colour matching functions.
Parameters
----------
cmfss : list, optional
cmfss : array_like, optional
Colour matching functions to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -308,6 +307,10 @@ def multi_cmfs_plot(cmfss=['CIE 1931 2 Degree Standard Observer',
True
"""

if cmfss is None:
cmfss = ('CIE 1931 2 Degree Standard Observer',
'CIE 1964 10 Degree Standard Observer')

x_limit_min, x_limit_max, y_limit_min, y_limit_max = [], [], [], []
for axis, rgb in (('x', [1, 0, 0]),
('y', [0, 1, 0]),
Expand Down Expand Up @@ -392,13 +395,13 @@ def single_illuminant_relative_spd_plot(
return single_spd_plot(illuminant, **settings)


def multi_illuminants_relative_spd_plot(illuminants=['A', 'B', 'C'], **kwargs):
def multi_illuminants_relative_spd_plot(illuminants=None, **kwargs):
"""
Plots given illuminants relative spectral power distributions.
Parameters
----------
illuminants : tuple or list, optional
illuminants : array_like, optional
Factory illuminants to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -414,6 +417,9 @@ def multi_illuminants_relative_spd_plot(illuminants=['A', 'B', 'C'], **kwargs):
True
"""

if illuminants is None:
illuminants = ('A', 'B', 'C')

spds = []
for illuminant in illuminants:
spds.append(get_illuminant(illuminant))
Expand Down Expand Up @@ -504,15 +510,13 @@ def single_lightness_function_plot(function='Lightness 1976', **kwargs):


@figure_size((8, 8))
def multi_lightness_function_plot(
functions=['Lightness 1976', 'Lightness Wyszecki 1964'],
**kwargs):
def multi_lightness_function_plot(functions=None, **kwargs):
"""
Plots given *Lightness* functions.
Parameters
----------
functions : list, optional
functions : array_like, optional
*Lightness* functions to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -529,6 +533,9 @@ def multi_lightness_function_plot(
True
"""

if functions is None:
functions = ('Lightness 1976', 'Lightness Wyszecki 1964')

samples = np.linspace(0, 100, 1000)
for i, function in enumerate(functions):
function, name = LIGHTNESS_FUNCTIONS.get(function), function
Expand Down
67 changes: 40 additions & 27 deletions colour/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ def figure_size_wrapper(*args, **kwargs):
Object.
"""

pylab.rcParams['figure.figsize'] = kwargs.get(
'figure_size') if kwargs.get(
'figure_size') is not None else size
pylab.rcParams['figure.figsize'] = (
kwargs.get('figure_size')
if kwargs.get('figure_size') is not None else
size)

try:
return object(*args, **kwargs)
Expand Down Expand Up @@ -208,25 +209,35 @@ def aspect(**kwargs):
'aspect': None})
settings.update(kwargs)

settings.title and pylab.title(settings.title)
settings.x_label and pylab.xlabel(settings.x_label)
settings.y_label and pylab.ylabel(settings.y_label)
settings.legend and pylab.legend(loc=settings.legend_location)
settings.x_ticker and matplotlib.pyplot.gca().xaxis.set_minor_locator(
settings.x_ticker_locator)
settings.y_ticker and matplotlib.pyplot.gca().yaxis.set_minor_locator(
settings.y_ticker_locator)
if settings.title:
pylab.title(settings.title)
if settings.x_label:
pylab.xlabel(settings.x_label)
if settings.y_label:
pylab.ylabel(settings.y_label)
if settings.legend:
pylab.legend(loc=settings.legend_location)
if settings.x_ticker:
matplotlib.pyplot.gca().xaxis.set_minor_locator(
settings.x_ticker_locator)
if settings.y_ticker:
matplotlib.pyplot.gca().yaxis.set_minor_locator(
settings.y_ticker_locator)
if settings.no_ticks:
matplotlib.pyplot.gca().set_xticks([])
matplotlib.pyplot.gca().set_yticks([])
if settings.no_x_ticks:
matplotlib.pyplot.gca().set_xticks([])
if settings.no_y_ticks:
matplotlib.pyplot.gca().set_yticks([])
settings.grid and pylab.grid(which=settings.axis_grid)
settings.x_axis_line and pylab.axvline(0, color='black', linestyle='--')
settings.y_axis_line and pylab.axhline(0, color='black', linestyle='--')
settings.aspect and matplotlib.pyplot.axes().set_aspect(settings.aspect)
if settings.grid:
pylab.grid(which=settings.axis_grid)
if settings.x_axis_line:
pylab.axvline(0, color='black', linestyle='--')
if settings.y_axis_line:
pylab.axhline(0, color='black', linestyle='--')
if settings.aspect:
matplotlib.pyplot.axes().set_aspect(settings.aspect)

return True

Expand Down Expand Up @@ -257,10 +268,10 @@ def bounding_box(**kwargs):
if settings.bounding_box is None:
x_limit_min, x_limit_max, y_limit_min, y_limit_max = settings.limits
x_margin_min, x_margin_max, y_margin_min, y_margin_max = settings.margins
settings.x_tighten and pylab.xlim(x_limit_min + x_margin_min,
x_limit_max + x_margin_max)
settings.y_tighten and pylab.ylim(y_limit_min + y_margin_min,
y_limit_max + y_margin_max)
if settings.x_tighten:
pylab.xlim(x_limit_min + x_margin_min, x_limit_max + x_margin_max)
if settings.y_tighten:
pylab.ylim(y_limit_min + y_margin_min, y_limit_max + y_margin_max)
else:
pylab.xlim(settings.bounding_box[0], settings.bounding_box[1])
pylab.ylim(settings.bounding_box[2], settings.bounding_box[3])
Expand Down Expand Up @@ -383,16 +394,18 @@ def colour_parameters_plot(colour_parameters,
edgecolor=colour_parameters[i].RGB)

if all([x.y0 is not None for x in colour_parameters]):
y0_plot and pylab.plot([x.x for x in colour_parameters],
[x.y0 for x in colour_parameters],
color='black',
linewidth=2)
if y0_plot:
pylab.plot([x.x for x in colour_parameters],
[x.y0 for x in colour_parameters],
color='black',
linewidth=2)

if all([x.y1 is not None for x in colour_parameters]):
y1_plot and pylab.plot([x.x for x in colour_parameters],
[x.y1 for x in colour_parameters],
color='black',
linewidth=2)
if y1_plot:
pylab.plot([x.x for x in colour_parameters],
[x.y1 for x in colour_parameters],
color='black',
linewidth=2)

y_limit_min0 = min(
[0 if x.y0 is None else x.y0 for x in colour_parameters])
Expand Down
10 changes: 8 additions & 2 deletions colour/plotting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_RGB_colourspace(colourspace):

@figure_size((8, 8))
def colourspaces_CIE_1931_chromaticity_diagram_plot(
colourspaces=['sRGB', 'ACES RGB', 'Pointer Gamut'],
colourspaces=None,
cmfs='CIE 1931 2 Degree Standard Observer',
**kwargs):
"""
Expand All @@ -93,6 +93,9 @@ def colourspaces_CIE_1931_chromaticity_diagram_plot(
True
"""

if colourspaces is None:
colourspaces = ('sRGB', 'ACES RGB', 'Pointer Gamut')

cmfs, name = get_cmfs(cmfs), cmfs

settings = {'title': '{0} - {1}'.format(', '.join(colourspaces), name),
Expand Down Expand Up @@ -203,7 +206,7 @@ def single_transfer_function_plot(colourspace='sRGB', **kwargs):


@figure_size((8, 8))
def multi_transfer_function_plot(colourspaces=['sRGB', 'Rec. 709'],
def multi_transfer_function_plot(colourspaces=None,
inverse=False, **kwargs):
"""
Plots given colourspaces transfer functions.
Expand All @@ -228,6 +231,9 @@ def multi_transfer_function_plot(colourspaces=['sRGB', 'Rec. 709'],
True
"""

if colourspaces is None:
colourspaces = ['sRGB', 'Rec. 709']

samples = np.linspace(0, 1, 1000)
for i, colourspace in enumerate(colourspaces):
colourspace, name = get_RGB_colourspace(colourspace), colourspace
Expand Down
9 changes: 6 additions & 3 deletions colour/plotting/notation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ def single_munsell_value_function_plot(function='Munsell Value ASTM D1535-08',

@figure_size((8, 8))
def multi_munsell_value_function_plot(
functions=['Munsell Value ASTM D1535-08',
'Munsell Value McCamy 1987'],
functions=None,
**kwargs):
"""
Plots given *Munsell* value functions.
Parameters
----------
functions : list, optional
functions : array_like, optional
*Munsell* value functions to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -91,6 +90,10 @@ def multi_munsell_value_function_plot(
True
"""

if functions is None:
functions = ('Munsell Value ASTM D1535-08',
'Munsell Value McCamy 1987')

samples = np.linspace(0, 100, 1000)
for i, function in enumerate(functions):
function, name = MUNSELL_VALUE_FUNCTIONS.get(function), function
Expand Down
15 changes: 11 additions & 4 deletions colour/plotting/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@

@figure_size((8, 8))
def planckian_locus_CIE_1931_chromaticity_diagram_plot(
illuminants=['A', 'B', 'C'],
illuminants=None,
**kwargs):
"""
Plots the planckian locus and given illuminants in
*CIE 1931 Chromaticity Diagram*.
Parameters
----------
illuminants : tuple or list, optional
illuminants : array_like, optional
Factory illuminants to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -70,6 +70,9 @@ def planckian_locus_CIE_1931_chromaticity_diagram_plot(
True
"""

if illuminants is None:
illuminants = ('A', 'B', 'C')

cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')

settings = {
Expand Down Expand Up @@ -125,14 +128,15 @@ def planckian_locus_CIE_1931_chromaticity_diagram_plot(

@figure_size((8, 8))
def planckian_locus_CIE_1960_UCS_chromaticity_diagram_plot(
illuminants=['A', 'C', 'E'], **kwargs):
illuminants=None,
**kwargs):
"""
Plots the planckian locus and given illuminants in
*CIE 1960 UCS Chromaticity Diagram*.
Parameters
----------
illuminants : tuple or list, optional
illuminants : array_like, optional
Factory illuminants to plot.
\*\*kwargs : \*\*
Keywords arguments.
Expand All @@ -149,6 +153,9 @@ def planckian_locus_CIE_1960_UCS_chromaticity_diagram_plot(
True
"""

if illuminants is None:
illuminants = ('A', 'C', 'E')

cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')

settings = {
Expand Down
Loading

0 comments on commit 4273495

Please sign in to comment.