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

RuntimeWarning: divide by zero #2

Open
SteveKing opened this issue May 17, 2017 · 2 comments
Open

RuntimeWarning: divide by zero #2

SteveKing opened this issue May 17, 2017 · 2 comments

Comments

@SteveKing
Copy link

The script appears to work (it generates an output file with the expected color differences) but I get a divide by zero warning and, with the --invert flag, an "invalid value encountered in power" warning.

Good work on this, BTW! I think perceptual color space is fascinating.

colorprofiles.zip

macabre:~/tmp/iterm_schemer$ python3 -m iterm_schemer irblack.itermcolors OutputLight.itermcolors --src-bg dark --dst-bg light --invert
/usr/local/lib/python3.6/site-packages/colour/appearance/ciecam02.py:1358: RuntimeWarning: divide by zero encountered in double_scalars
  P_1 = ((50000 / 13) * N_c * N_cb * e_t) / t
Ansi 0 Color       [  0   0   0] → [  0   0   0]
Ansi 1 Color       [252 111  92] → [255 118  91]
Ansi 2 Color       [174 250  58] → [169 255   0]
Ansi 3 Color       [255 253 173] → [255 255 146]
Ansi 4 Color       [150 201 255] → [153 209 255]
Ansi 5 Color       [250 115 255] → [255 123 255]
Ansi 6 Color       [197 196 255] → [202 201 255]
Ansi 7 Color       [237 237 237] → [244 244 244]
Ansi 8 Color       [123 123 123] → [160 160 160]
Ansi 9 Color       [253 182 175] → [255 187 178]
Ansi 10 Color      [209 252 162] → [203 255 132]
Ansi 11 Color      [255 253 197] → [255 255 178]
Ansi 12 Color      [181 218 255] → [179 222 255]
Ansi 13 Color      [251 156 255] → [255 157 255]
Ansi 14 Color      [222 222 255] → [222 222 255]
Ansi 15 Color      [254 255 254] → [254 255 254]
Foreground Color   [237 237 237] → [ 24  24  24]
Background Color   [  0   0   0] → [255 255 255]
Bold Color         [255 255 255] → [  0   0   0]
/usr/local/lib/python3.6/site-packages/colour/appearance/ciecam02.py:714: RuntimeWarning: invalid value encountered in power
  RGB_c = ((((400 * (F_L[..., np.newaxis] * RGB / 100) ** 0.42) /
/usr/local/lib/python3.6/site-packages/colour/appearance/ciecam02.py:715: RuntimeWarning: invalid value encountered in power
  (27.13 + (F_L[..., np.newaxis] * RGB / 100) ** 0.42))) + 0.1)
Cursor Color       [255 180 115] → [ 94  25   0]
Cursor Text Color  [237 237 237] → [ 24  24  24]
macabre:~/tmp/iterm_schemer$
@crowsonkb
Copy link
Owner

It looks like the 'invalid value encountered in power' warnings are due to colour-science not checking or and handling negative values in one place. I'm working on a pull request for it: colour-science/colour#326. The divide by zero warnings are due to colour-science not testing for divide by zero, and I am still working on it.

@crowsonkb
Copy link
Owner

Pull request colour-science/colour#327, fixing the divide by zero issue, submitted upstream. I also created a special branch in my colour-science fork for iterm_schemer, and if you reinstall it with this URL git+https://github.com/crowsonkb/colour@iterm_schemer it has these two pull requests merged already.

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