Skip to content

Commit

Permalink
Fix various broken unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 1, 2024
1 parent 77e1833 commit 1aff87f
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 166 deletions.
2 changes: 1 addition & 1 deletion colour/io/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_read_image_OpenImageIO(self): # pragma: no cover
)
assert image.shape == (1267, 1274, 3)
assert attributes[0].name == "oiio:ColorSpace"
assert attributes[0].value == "Linear"
assert attributes[0].value in ("Linear", "lin_rec709")

image = read_image_OpenImageIO(
os.path.join(ROOT_RESOURCES, "Single_Channel.exr")
Expand Down
200 changes: 99 additions & 101 deletions colour/recovery/tests/test_jiang2013.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,124 +63,122 @@ def test_PCA_Jiang2013(self):
}
w, v = PCA_Jiang2013(camera_sensitivities, 3, True)

# TODO: Last eigen value seems to be very sensitive and produce
# differences on ARM.
np.testing.assert_allclose(
np.array(w)[..., 0:2],
np.abs(np.array(w)),
np.array(
[
[
[-0.00137594, 0.00399416],
[-0.00214835, 0.00184422],
[-0.02757181, 0.00553587],
[-0.02510621, -0.04216468],
[-0.02011623, -0.03371162],
[-0.01392282, -0.03297985],
[-0.00944513, -0.03300938],
[-0.02019958, -0.01289400],
[-0.02394423, -0.00980934],
[-0.04196326, 0.04987050],
[-0.04988732, 0.06936603],
[-0.06527141, 0.09378614],
[-0.09412575, 0.12244081],
[-0.10915913, 0.13119983],
[-0.12314840, 0.24280936],
[-0.11673941, 0.27700737],
[-0.12534133, 0.29994127],
[-0.14599255, 0.25586532],
[-0.25249090, -0.11499750],
[-0.35163407, -0.45286818],
[-0.35805737, -0.40724252],
[-0.36927899, -0.18120838],
[-0.35374885, -0.03010008],
[-0.35340909, 0.16847527],
[-0.32696116, 0.29068981],
[-0.29067354, 0.32862702],
[-0.08964758, -0.09682656],
[-0.01891664, -0.08221113],
[-0.00521149, -0.01578907],
[-0.00232366, -0.00137751],
[-0.00153787, 0.00254398],
[0.00137594, 0.00399416, 0.00074515],
[0.00214835, 0.00184422, 0.85753040],
[0.02757181, 0.00553587, 0.02033235],
[0.02510621, 0.04216468, 0.01860012],
[0.02011623, 0.03371162, 0.01474896],
[0.01392282, 0.03297985, 0.00645105],
[0.00944513, 0.03300938, 0.00649418],
[0.02019958, 0.01289400, 0.01138365],
[0.02394423, 0.00980934, 0.00348705],
[0.04196326, 0.04987050, 0.00462977],
[0.04988732, 0.06936603, 0.01299320],
[0.06527141, 0.09378614, 0.00320186],
[0.09412575, 0.12244081, 0.02936062],
[0.10915913, 0.13119983, 0.02403866],
[0.12314840, 0.24280936, 0.03433110],
[0.11673941, 0.27700737, 0.11678028],
[0.12534133, 0.29994127, 0.11683063],
[0.14599255, 0.25586532, 0.04332511],
[0.25249090, 0.11499750, 0.04112949],
[0.35163407, 0.45286818, 0.04259130],
[0.35805737, 0.40724252, 0.24276366],
[0.36927899, 0.18120838, 0.28042101],
[0.35374885, 0.03010008, 0.05772918],
[0.35340909, 0.16847527, 0.23388908],
[0.32696116, 0.29068981, 0.09224334],
[0.29067354, 0.32862702, 0.14708450],
[0.08964758, 0.09682656, 0.04541265],
[0.01891664, 0.08221113, 0.01157780],
[0.00521149, 0.01578907, 0.00133064],
[0.00232366, 0.00137751, 0.00139661],
[0.00153787, 0.00254398, 0.00042512],
],
[
[-0.00119598, 0.00267792],
[-0.00200327, 0.00322983],
[-0.01247816, -0.03313976],
[-0.03207685, -0.05703294],
[-0.04715050, -0.05296451],
[-0.05794010, -0.05455737],
[-0.10745571, 0.00158911],
[-0.14178525, -0.03362764],
[-0.16811402, -0.05569833],
[-0.18463716, -0.04615404],
[-0.21531623, -0.09745078],
[-0.25442570, -0.18330481],
[-0.28168018, -0.25193267],
[-0.29237178, -0.28545428],
[-0.29693117, -0.23909467],
[-0.28631319, -0.19476441],
[-0.27195968, -0.12087420],
[-0.25988140, -0.01581316],
[-0.24222660, 0.07912972],
[-0.23069698, 0.18583667],
[-0.20831983, 0.26745561],
[-0.19437168, 0.32425009],
[-0.18470894, 0.34768079],
[-0.18056180, 0.35983221],
[-0.17141337, 0.35067306],
[-0.14712541, 0.30423172],
[-0.02897026, 0.04573993],
[-0.00190228, -0.00461591],
[-0.00069122, -0.00118817],
[-0.00045559, 0.00015286],
[-0.00039509, 0.00049719],
[0.00119598, 0.00267792, 0.00026101],
[0.00200327, 0.00322983, 0.62788798],
[0.01247816, 0.03313976, 0.01072884],
[0.03207685, 0.05703294, 0.03730884],
[0.04715050, 0.05296451, 0.02043038],
[0.05794010, 0.05455737, 0.01279190],
[0.10745571, 0.00158911, 0.03200481],
[0.14178525, 0.03362764, 0.15020663],
[0.16811402, 0.05569833, 0.00844788],
[0.18463716, 0.04615404, 0.03103250],
[0.21531623, 0.09745078, 0.39693604],
[0.25442570, 0.18330481, 0.14940077],
[0.28168018, 0.25193267, 0.00347081],
[0.29237178, 0.28545428, 0.03254141],
[0.29693117, 0.23909467, 0.00779634],
[0.28631319, 0.19476441, 0.31698680],
[0.27195968, 0.12087420, 0.28305850],
[0.25988140, 0.01581316, 0.04130875],
[0.24222660, 0.07912972, 0.18481425],
[0.23069698, 0.18583667, 0.18113417],
[0.20831983, 0.26745561, 0.13793240],
[0.19437168, 0.32425009, 0.20908259],
[0.18470894, 0.34768079, 0.15013614],
[0.18056180, 0.35983221, 0.24060984],
[0.17141337, 0.35067306, 0.04478566],
[0.14712541, 0.30423172, 0.05583266],
[0.02897026, 0.04573993, 0.02137366],
[0.00190228, 0.00461591, 0.00240276],
[0.00069122, 0.00118817, 0.00011696],
[0.00045559, 0.00015286, 0.00075939],
[0.00039509, 0.00049719, 0.00104581],
],
[
[-0.03283371, 0.04707162],
[-0.05932690, 0.07529740],
[-0.11947381, -0.07977219],
[-0.18492233, -0.26127374],
[-0.22091564, -0.29279976],
[-0.25377875, -0.30677709],
[-0.29969822, -0.26541777],
[-0.30232755, -0.25378622],
[-0.30031732, -0.19751184],
[-0.28072276, -0.11804285],
[-0.26005747, -0.01836333],
[-0.23839367, 0.07182421],
[-0.21721831, 0.14245410],
[-0.19828405, 0.17684950],
[-0.19018451, 0.20137781],
[-0.18196762, 0.22086321],
[-0.17168644, 0.22771873],
[-0.16977073, 0.23504018],
[-0.16277670, 0.22897797],
[-0.15880423, 0.22583675],
[-0.14966812, 0.21494312],
[-0.13480155, 0.19511162],
[-0.12541764, 0.18113238],
[-0.12355731, 0.17835150],
[-0.11175064, 0.15997651],
[-0.09440304, 0.13423453],
[-0.01670581, 0.02019670],
[-0.00045002, -0.00147362],
[-0.00102919, 0.00095904],
[-0.00097397, 0.00123434],
[-0.00097116, 0.00124835],
[0.03283371, 0.04707162, 0.99591944],
[0.05932690, 0.07529740, 0.06152683],
[0.11947381, 0.07977219, 0.00156116],
[0.18492233, 0.26127374, 0.00717981],
[0.22091564, 0.29279976, 0.00487132],
[0.25377875, 0.30677709, 0.00614140],
[0.29969822, 0.26541777, 0.00429149],
[0.30232755, 0.25378622, 0.00354243],
[0.30031732, 0.19751184, 0.00199307],
[0.28072276, 0.11804285, 0.00591452],
[0.26005747, 0.01836333, 0.00698676],
[0.23839367, 0.07182421, 0.01904751],
[0.21721831, 0.14245410, 0.00452400],
[0.19828405, 0.17684950, 0.01371456],
[0.19018451, 0.20137781, 0.01184653],
[0.18196762, 0.22086321, 0.01434790],
[0.17168644, 0.22771873, 0.02205056],
[0.16977073, 0.23504018, 0.01730589],
[0.16277670, 0.22897797, 0.02229014],
[0.15880423, 0.22583675, 0.02123217],
[0.14966812, 0.21494312, 0.01417066],
[0.13480155, 0.19511162, 0.01901915],
[0.12541764, 0.18113238, 0.01413883],
[0.12355731, 0.17835150, 0.01809536],
[0.11175064, 0.15997651, 0.01436804],
[0.09440304, 0.13423453, 0.01316519],
[0.01670581, 0.02019670, 0.00202853],
[0.00045002, 0.00147362, 0.00007713],
[0.00102919, 0.00095904, 0.00008866],
[0.00097397, 0.00123434, 0.00011166],
[0.00097116, 0.00124835, 0.00014463],
],
]
),
atol=TOLERANCE_ABSOLUTE_TESTS,
)
np.testing.assert_allclose(
np.array(v)[..., 0:2],
np.array(v),
np.array(
[
[1.05516066e01, 7.28373797e-01, 3.84530151e-16],
[2.00917798e01, 1.57662524e00, 1.65371431e-15],
[1.90414282e01, 2.60426480e00, 5.11235833e-15],
[10.55160659, 0.72837380, 0.00000000],
[20.09177982, 1.57662524, 0.00000000],
[19.04142816, 2.60426480, 0.00000000],
]
)[..., 0:2],
),
atol=TOLERANCE_ABSOLUTE_TESTS,
)

Expand Down
128 changes: 64 additions & 64 deletions colour/recovery/tests/test_otsu2018.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def test_PCA(self):
data.PCA()

np.testing.assert_allclose(
data.basis_functions,
np.abs(data.basis_functions),
np.array(
[
[
Expand All @@ -451,19 +451,19 @@ def test_PCA(self):
0.16868383,
0.12020268,
0.05958463,
-0.01015508,
-0.08775193,
-0.16957532,
-0.23186776,
-0.26516404,
-0.27409402,
-0.27856619,
-0.27685075,
-0.25597708,
-0.21331000,
-0.15372029,
-0.08746878,
-0.02744494,
0.01015508,
0.08775193,
0.16957532,
0.23186776,
0.26516404,
0.27409402,
0.27856619,
0.27685075,
0.25597708,
0.21331000,
0.15372029,
0.08746878,
0.02744494,
0.01725581,
0.04756055,
0.07184639,
Expand Down Expand Up @@ -499,58 +499,58 @@ def test_PCA(self):
0.09178015,
0.06539517,
0.03173809,
-0.00658524,
-0.04710763,
-0.08379987,
-0.11074555,
-0.12606191,
-0.13630094,
-0.13988107,
-0.14193361,
-0.14671866,
-0.15164795,
-0.15772737,
-0.16328073,
-0.16588768,
-0.16947164,
0.00658524,
0.04710763,
0.08379987,
0.11074555,
0.12606191,
0.13630094,
0.13988107,
0.14193361,
0.14671866,
0.15164795,
0.15772737,
0.16328073,
0.16588768,
0.16947164,
],
[
-0.01360289,
-0.02375832,
-0.04262545,
-0.07345243,
-0.09081235,
-0.09227928,
-0.08922710,
-0.08626299,
-0.08584571,
-0.08843734,
-0.09475094,
-0.10376740,
-0.11331399,
-0.12109706,
-0.12678070,
-0.13401030,
-0.14417036,
-0.15408359,
-0.16265529,
-0.17079814,
-0.17972656,
-0.19005983,
-0.20053986,
-0.21017531,
-0.21808806,
-0.22347400,
-0.22650876,
-0.22895376,
-0.22982598,
-0.23001787,
-0.23036398,
-0.22917409,
-0.22684271,
-0.22387883,
-0.22065773,
-0.21821049,
0.01360289,
0.02375832,
0.04262545,
0.07345243,
0.09081235,
0.09227928,
0.08922710,
0.08626299,
0.08584571,
0.08843734,
0.09475094,
0.10376740,
0.11331399,
0.12109706,
0.12678070,
0.13401030,
0.14417036,
0.15408359,
0.16265529,
0.17079814,
0.17972656,
0.19005983,
0.20053986,
0.21017531,
0.21808806,
0.22347400,
0.22650876,
0.22895376,
0.22982598,
0.23001787,
0.23036398,
0.22917409,
0.22684271,
0.22387883,
0.22065773,
0.21821049,
],
]
),
Expand Down

0 comments on commit 1aff87f

Please sign in to comment.