Skip to content

Commit

Permalink
Improve tuple / list usage consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Apr 17, 2015
1 parent b9b508c commit 517b24c
Show file tree
Hide file tree
Showing 32 changed files with 881 additions and 884 deletions.
14 changes: 7 additions & 7 deletions colour/algebra/tests/tests_extrapolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ def test___call__(self):
LinearInterpolator1d(
np.array([5, 6, 7]),
np.array([5, 6, 7])))
np.testing.assert_almost_equal(extrapolator([4, 8]), [4., 8.])
np.testing.assert_almost_equal(extrapolator((4, 8)), (4., 8.))
self.assertEqual(extrapolator(4), 4.)

extrapolator = Extrapolator1d(
LinearInterpolator1d(
np.array([3, 4, 5]),
np.array([1, 2, 3])),
method='Constant')
np.testing.assert_almost_equal(extrapolator([0.1, 0.2, 8, 9]),
[1., 1., 3., 3.])
np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
(1., 1., 3., 3.))
self.assertEqual(extrapolator(0.1), 1.)

extrapolator = Extrapolator1d(
Expand All @@ -82,8 +82,8 @@ def test___call__(self):
np.array([1, 2, 3])),
method='Constant',
left=0)
np.testing.assert_almost_equal(extrapolator([0.1, 0.2, 8, 9]),
[0., 0., 3., 3.])
np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
(0., 0., 3., 3.))
self.assertEqual(extrapolator(0.1), 0.)

extrapolator = Extrapolator1d(
Expand All @@ -92,8 +92,8 @@ def test___call__(self):
np.array([1, 2, 3])),
method='Constant',
right=0)
np.testing.assert_almost_equal(extrapolator([0.1, 0.2, 8, 9]),
[1., 1., 0., 0.])
np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
(1., 1., 0., 0.))
self.assertEqual(extrapolator(9), 0.)


Expand Down
4 changes: 2 additions & 2 deletions colour/colorimetry/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2447,8 +2447,8 @@ def __setitem__(self, wavelength, value):
>>> tri_spd[510] = np.array([49.67, 49.67, 49.67])
>>> tri_spd.values
array([[ 49.67, 49.67, 49.67]])
>>> tri_spd[np.array([520, 530])] = np.array([(69.59, 69.59, 69.59),
... (81.73, 81.73, 81.73)])
>>> tri_spd[np.array([520, 530])] = np.array([[69.59, 69.59, 69.59],
... [81.73, 81.73, 81.73]])
>>> tri_spd.values
array([[ 49.67, 49.67, 49.67],
[ 69.59, 69.59, 69.59],
Expand Down
12 changes: 6 additions & 6 deletions colour/colorimetry/tests/tests_lightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_n_dimensional_lightness_Glasser1958(self):
L,
decimal=7)

Y = [Y] * 6
L = [L] * 6
Y = np.tile(Y, 6)
L = np.tile(L, 6)
np.testing.assert_almost_equal(
lightness_Glasser1958(Y),
L,
Expand Down Expand Up @@ -134,8 +134,8 @@ def test_n_dimensional_lightness_Wyszecki1963(self):
W,
decimal=7)

Y = [Y] * 6
W = [W] * 6
Y = np.tile(Y, 6)
W = np.tile(W, 6)
np.testing.assert_almost_equal(
lightness_Wyszecki1963(Y),
W,
Expand Down Expand Up @@ -210,8 +210,8 @@ def test_n_dimensional_lightness_1976(self):
Lstar,
decimal=7)

Y = [Y] * 6
Lstar = [Lstar] * 6
Y = np.tile(Y, 6)
Lstar = np.tile(Lstar, 6)
np.testing.assert_almost_equal(
lightness_1976(Y),
Lstar,
Expand Down
12 changes: 6 additions & 6 deletions colour/colorimetry/tests/tests_luminance.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_n_dimensional_luminance_Newhall1943(self):
Y,
decimal=7)

V = [V] * 6
Y = [Y] * 6
V = np.tile(V, 6)
Y = np.tile(Y, 6)
np.testing.assert_almost_equal(
luminance_Newhall1943(V),
Y,
Expand Down Expand Up @@ -134,8 +134,8 @@ def test_n_dimensional_luminance_ASTMD153508(self):
Y,
decimal=7)

V = [V] * 6
Y = [Y] * 6
V = np.tile(V, 6)
Y = np.tile(Y, 6)
np.testing.assert_almost_equal(
luminance_ASTMD153508(V),
Y,
Expand Down Expand Up @@ -210,8 +210,8 @@ def test_n_dimensional_luminance_1976(self):
Y,
decimal=7)

Lstar = [Lstar] * 6
Y = [Y] * 6
Lstar = np.tile(Lstar, 6)
Y = np.tile(Y, 6)
np.testing.assert_almost_equal(
luminance_1976(Lstar),
Y,
Expand Down
4 changes: 2 additions & 2 deletions colour/colorimetry/tests/tests_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2602,8 +2602,8 @@ def test__setitem__(self):
tri_spd.values,
np.array([[49.67, 49.67, 49.67]]))

tri_spd[np.array([520, 530])] = np.array([(69.59, 69.59, 69.59),
(81.73, 81.73, 81.73)])
tri_spd[np.array([520, 530])] = np.array([[69.59, 69.59, 69.59],
[81.73, 81.73, 81.73]])
np.testing.assert_almost_equal(
tri_spd.values,
np.array([[49.67, 49.67, 49.67],
Expand Down
2 changes: 1 addition & 1 deletion colour/examples/adaptation/examples_vonkries.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

print('\n')

XYZ = [1.14176346, 1., 0.49815206]
XYZ = (1.14176346, 1., 0.49815206)
message_box(('Adapting given "CIE XYZ" tristimulus values from '
'"CIE Standard Illuminant A" to '
'"CIE Standard Illuminant D Series D65" using "Sharp" CAT.\n'
Expand Down
4 changes: 2 additions & 2 deletions colour/examples/algebra/examples_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
'legend_location': 'upper left',
'x_ticker': True,
'y_ticker': True,
'limits': [min(x_limit_min), max(x_limit_max), min(y_limit_min),
max(y_limit_max)]}
'limits': (min(x_limit_min), max(x_limit_max),
min(y_limit_min), max(y_limit_max))}

boundaries(**settings)
decorate(**settings)
Expand Down
100 changes: 50 additions & 50 deletions colour/examples/characterisation/examples_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,56 @@
'uses "first order" colour fitting based on "multiple linear '
'regressions".'))

reference = np.array(
[[0.172906, 0.08205715, 0.05711951],
[0.5680735, 0.29250361, 0.21942],
[0.10437166, 0.19656122, 0.32946697],
[0.10089156, 0.14839029, 0.05324779],
[0.22306044, 0.21697008, 0.43151034],
[0.10718115, 0.51351274, 0.41399101],
[0.7464409, 0.20020391, 0.03077999],
[0.05948985, 0.10659048, 0.39884205],
[0.56735781, 0.08485298, 0.11940265],
[0.11178198, 0.04285385, 0.14161263],
[0.34254479, 0.50627811, 0.0557158],
[0.79268226, 0.35803827, 0.02544159],
[0.01865226, 0.05139666, 0.28876921],
[0.05440562, 0.29876767, 0.07183236],
[0.45631278, 0.03075616, 0.0408993],
[0.85385852, 0.56503529, 0.01470045],
[0.53537579, 0.09006281, 0.30467248],
[-0.03661893, 0.24753827, 0.39810356],
[0.91186287, 0.91497635, 0.8939137],
[0.5797986, 0.592032, 0.59346914],
[0.3549918, 0.36538033, 0.36757315],
[0.19011528, 0.19180135, 0.19309001],
[0.08525591, 0.08890588, 0.09252104],
[0.03039192, 0.03118624, 0.03278316]])
reference = (
((0.172906, 0.08205715, 0.05711951),
(0.5680735, 0.29250361, 0.21942),
(0.10437166, 0.19656122, 0.32946697),
(0.10089156, 0.14839029, 0.05324779),
(0.22306044, 0.21697008, 0.43151034),
(0.10718115, 0.51351274, 0.41399101),
(0.7464409, 0.20020391, 0.03077999),
(0.05948985, 0.10659048, 0.39884205),
(0.56735781, 0.08485298, 0.11940265),
(0.11178198, 0.04285385, 0.14161263),
(0.34254479, 0.50627811, 0.0557158),
(0.79268226, 0.35803827, 0.02544159),
(0.01865226, 0.05139666, 0.28876921),
(0.05440562, 0.29876767, 0.07183236),
(0.45631278, 0.03075616, 0.0408993),
(0.85385852, 0.56503529, 0.01470045),
(0.53537579, 0.09006281, 0.30467248),
(-0.03661893, 0.24753827, 0.39810356),
(0.91186287, 0.91497635, 0.8939137),
(0.5797986, 0.592032, 0.59346914),
(0.3549918, 0.36538033, 0.36757315),
(0.19011528, 0.19180135, 0.19309001),
(0.08525591, 0.08890588, 0.09252104),
(0.03039192, 0.03118624, 0.03278316)))

measured = np.array(
[[0.1557955891, 0.09715754539, 0.07514556497],
[0.3911314011, 0.2594341934, 0.2126670778],
[0.1282482147, 0.1846356988, 0.3150802255],
[0.1202897355, 0.1345565915, 0.0740839988],
[0.1936898828, 0.2115894556, 0.3795596361],
[0.199574247, 0.3608543873, 0.4067812264],
[0.4889660478, 0.2069168836, 0.05816533044],
[0.09775521606, 0.1671069264, 0.4714772403],
[0.3935864866, 0.1223340034, 0.1052642539],
[0.1078033224, 0.07258529216, 0.1615147293],
[0.2750267088, 0.3470545411, 0.09728099406],
[0.439804405, 0.2688055933, 0.05430532619],
[0.05887211859, 0.1112627164, 0.3855246902],
[0.1270582527, 0.2578786016, 0.1356646419],
[0.3561292887, 0.0793325752, 0.05118732154],
[0.4813197553, 0.4208284318, 0.07120611519],
[0.3466558456, 0.1517071426, 0.2496980429],
[0.08261115849, 0.2458871603, 0.4870773256],
[0.6605490446, 0.6594113708, 0.6637641191],
[0.4805150926, 0.4787029624, 0.482300818],
[0.3304535449, 0.3290418386, 0.3322888613],
[0.1800130457, 0.1797856688, 0.1800441593],
[0.102839753, 0.1042467952, 0.1038497463],
[0.04742204025, 0.04772202671, 0.04914225638]])
measured = (
((0.1557955891, 0.09715754539, 0.07514556497),
(0.3911314011, 0.2594341934, 0.2126670778),
(0.1282482147, 0.1846356988, 0.3150802255),
(0.1202897355, 0.1345565915, 0.0740839988),
(0.1936898828, 0.2115894556, 0.3795596361),
(0.199574247, 0.3608543873, 0.4067812264),
(0.4889660478, 0.2069168836, 0.05816533044),
(0.09775521606, 0.1671069264, 0.4714772403),
(0.3935864866, 0.1223340034, 0.1052642539),
(0.1078033224, 0.07258529216, 0.1615147293),
(0.2750267088, 0.3470545411, 0.09728099406),
(0.439804405, 0.2688055933, 0.05430532619),
(0.05887211859, 0.1112627164, 0.3855246902),
(0.1270582527, 0.2578786016, 0.1356646419),
(0.3561292887, 0.0793325752, 0.05118732154),
(0.4813197553, 0.4208284318, 0.07120611519),
(0.3466558456, 0.1517071426, 0.2496980429),
(0.08261115849, 0.2458871603, 0.4870773256),
(0.6605490446, 0.6594113708, 0.6637641191),
(0.4805150926, 0.4787029624, 0.482300818),
(0.3304535449, 0.3290418386, 0.3322888613),
(0.1800130457, 0.1797856688, 0.1800441593),
(0.102839753, 0.1042467952, 0.1038497463),
(0.04742204025, 0.04772202671, 0.04914225638)))

print(colour.first_order_colour_fit(reference, measured))
2 changes: 1 addition & 1 deletion colour/examples/colorimetry/examples_lightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

message_box('"Lightness" Computations')

xyY = [0.4316, 0.3777, 0.1008]
xyY = (0.4316, 0.3777, 0.1008)
message_box(('Computing "Lightness" "CIE Lab" reference value for given '
'"CIE xyY" colourspace values:\n'
'\n\t{0}'.format(xyY)))
Expand Down
4 changes: 2 additions & 2 deletions colour/examples/difference/examples_delta_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

message_box('"Delta E" Computations')

Lab1 = [100, 21.57210357, 272.2281935]
Lab2 = [100, 426.67945353, 72.39590835]
Lab1 = (100, 21.57210357, 272.2281935)
Lab2 = (100, 426.67945353, 72.39590835)
message_box(('Computing "Delta E" with CIE 1976 method from given *CIE Lab* '
'colourspace matrices:\n'
'\n\t{0}\n\t{1}'.format(Lab1, Lab2)))
Expand Down
10 changes: 5 additions & 5 deletions colour/examples/models/examples_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
message_box(('Deprecated Colour Models Computations\n'
'\nDon\'t use that! Seriously...'))

RGB = [0.49019607843137253, 0.9803921568627451, 0.25098039215686274]
RGB = (0.49019607843137253, 0.9803921568627451, 0.25098039215686274)
message_box(('Converting to "HSV" colourspace from given "RGB" colourspace '
'values:\n'
'\n\t{0}'.format(RGB)))
print(colour.models.deprecated.RGB_to_HSV(RGB))

print('\n')

HSV = [0.27867384, 0.744, 0.98039216]
HSV = (0.27867384, 0.744, 0.98039216)
message_box(('Converting to "RGB" colourspace from given "HSV" colourspace '
'values:\n'
'\n\t{0}'.format(HSV)))
Expand All @@ -34,7 +34,7 @@

print('\n')

HSL = [0.27867384, 0.94897959, 0.61568627]
HSL = (0.27867384, 0.94897959, 0.61568627)
message_box(('Converting to "RGB" colourspace from given "HSL" colourspace '
'values:\n'
'\n\t{0}'.format(HSL)))
Expand All @@ -49,7 +49,7 @@

print('\n')

CMY = [0.50980392, 0.01960784, 0.74901961]
CMY = (0.50980392, 0.01960784, 0.74901961)
message_box(('Converting to "RGB" colourspace from given "CMY" colourspace '
'values:\n'
'\n\t{0}'.format(CMY)))
Expand All @@ -64,7 +64,7 @@

print('\n')

CMYK = [0.5, 0, 0.744, 0.01960784]
CMYK = (0.5, 0, 0.744, 0.01960784)
message_box(('Converting to "CMY" colourspace from given "CMYK" colourspace '
'values:\n'
'\n\t{0}'.format(CMYK)))
Expand Down
2 changes: 1 addition & 1 deletion colour/examples/models/examples_derivation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

print('\n')

RGB = [56, 16, 100]
RGB = (56, 16, 100)
message_box(('Computing the normalised primary matrix for "RGB" luminance of '
'given "RGB" values:\n'
'\n\t{0}'.format(RGB)))
Expand Down
Loading

0 comments on commit 517b24c

Please sign in to comment.