Skip to content

Commit

Permalink
Merge pull request #168 from facelessuser/bugfix/cat
Browse files Browse the repository at this point in the history
Fix cat16 not applying the matrix
  • Loading branch information
facelessuser authored May 10, 2022
2 parents 38a56ff + 2ca9e01 commit 8088784
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coloraide/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class CAT16(VonKries):

NAME = "cat16"

M = [
MATRIX = [
[-0.401288, -0.250268, -0.002079],
[0.650173, 1.204414, 0.048952],
[-0.051461, -0.045854, -0.953127]
Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **NEW**: Allow dictionary input to use aliases in the dictionary.
- **FIX**: If too many channels are given to a color space via raw data, ensure the operation fails.
- **FIX**: Sync up achromatic logic of the Okhsl and Okhsv `normalize` function with the actual conversion algorithm.
- **FIX**: Regression that caused `cat16` not to work due to a misnamed variable.

## 0.17.0

Expand Down
33 changes: 33 additions & 0 deletions tests/test_cat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Test chromatic adaptation."""
from coloraide import Color
from coloraide import cat
from coloraide import util as cutil
from . import util
import pytest


class TestCAT(util.ColorAssertsPyTest):
"""Test CAT."""

@pytest.mark.parametrize(
'method,cat1,cat2',
[
('bradford', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('von-kries', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('xyz-scaling', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('cat02', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('cmccat97', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('sharp', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('cmccat2000', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50']),
('cat16', cat.WHITES['2deg']['D65'], cat.WHITES['2deg']['D50'])
]
)
def test_cat(self, method, cat1, cat2):
"""Test CAT methods."""

c1 = Color('white').convert('xyz-d65')
c2 = Color('xyz-d50', c1.chromatic_adaptation(cat1, cat2, c1[:-1], method=method))
c3 = Color('xyz-d65', c2.chromatic_adaptation(cat2, cat1, c2[:-1], method=method))
self.assertColorEqual(c1, c3)
self.assertColorEqual(c2, Color('xyz-d50', cutil.xy_to_xyz(cat2)))

0 comments on commit 8088784

Please sign in to comment.