Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cspace_convert raises IndexError on xyY = [0, 0, 0.5] #19

Open
maxnoe opened this issue Aug 14, 2019 · 3 comments
Open

cspace_convert raises IndexError on xyY = [0, 0, 0.5] #19

maxnoe opened this issue Aug 14, 2019 · 3 comments

Comments

@maxnoe
Copy link
Contributor

maxnoe commented Aug 14, 2019

I wanted to plot the xy gamut so I created a meshgrid from 0 to 1,
but colorspacious raises an IndexError for [0, 0, 0.5]:

In [5]: colorspacious.cspace_convert([0.0, 0.0, 0.5], 'xyY1', 'JCh')

IndexError                                Traceback (most recent call last)
<ipython-input-16-75b580b587d2> in <module>
----> 1 colorspacious.cspace_convert([0.0, 0.0, 0.5], 'xyY1', 'JCh')

~/.local/anaconda3/lib/python3.7/site-packages/colorspacious/conversion.py in cspace_convert(arr, start, end)
    230     """
    231     converter = cspace_converter(start, end)
--> 232     return converter(arr)
    233
    234 def check_cspace_convert(source_cspace, target_cspace, gold, **kwargs):

~/.local/anaconda3/lib/python3.7/site-packages/colorspacious/transform_graph.py in __call__(self, x)
    579     def __call__(self, x):
    580         for transform, kwargs in zip(self._transforms, self._kwargses):
--> 581             x = transform(x, **kwargs)
    582         return x
    583

~/.local/anaconda3/lib/python3.7/site-packages/colorspacious/conversion.py in _XYZ100_to_CIECAM02(XYZ100, ciecam02_space)
     84
     85 def _XYZ100_to_CIECAM02(XYZ100, ciecam02_space):
---> 86     return ciecam02_space.XYZ100_to_CIECAM02(XYZ100)
     87
     88 def _CIECAM02_to_XYZ100(CIECAM02, ciecam02_space):

~/.local/anaconda3/lib/python3.7/site-packages/colorspacious/ciecam02.py in XYZ100_to_CIECAM02(self, XYZ100, on_negative_A)
    213         tmp = (hprime - h_i[i]) / e_i[i]
    214         H = H_i[i] + ((100 * tmp)
--> 215                       / (tmp + (h_i[i + 1] - hprime) / e_i[i + 1]))
    216
    217         #### Step 7

IndexError: index 5 is out of bounds for axis 0 with size 5

For rather small values, it raises a different, more telling error:

In [6]: colorspacious.cspace_convert([0.0, 0.00001, 0.5], 'xyY1', 'JCh')
NegativeAError: attempted to convert a tristimulus value whose achromatic signal was negative, and on_negative_A="raise"
@maxnoe
Copy link
Contributor Author

maxnoe commented Aug 14, 2019

I can see that XYZ100_to_CIECAM02 has a kwarg on_negative_A, but cspace_convert seems not to expose this.

@njsmith
Copy link
Owner

njsmith commented Aug 14, 2019 via email

@maxnoe
Copy link
Contributor Author

maxnoe commented Aug 26, 2019

The problem is that RGB in l 183 is [nan nan nan]. Is that expected, so [nan nan nan] should also be returned here, or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants