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

Python 3 support #18

Open
s-celles opened this issue Oct 12, 2015 · 5 comments · May be fixed by #21
Open

Python 3 support #18

s-celles opened this issue Oct 12, 2015 · 5 comments · May be fixed by #21

Comments

@s-celles
Copy link

Hello,

Chroma doesn't seems to support Python 3.

In [1]: import chroma
  File "//anaconda/lib/python3.4/site-packages/chroma/core.py", line 273
    except Exception, e:

Kind regards

@s-celles
Copy link
Author

    except Exception, e:
        raise ValueError('Invalid Hex Input: %s' % (color_value))

should be changed to

    except Exception as e:
        raise ValueError('Invalid Hex Input: %s' % (color_value))

but some unit tests are still failling

$ nosetests -s -v
Test alpha support / no-support with various color systems ... ok
Test input that goes beyond color system bounds ... ERROR
Test additive and subtractive mixing ... ok
Test construction of color object ... ERROR
Test equality and inequality ... ok
Test conversion between systems ... ERROR

======================================================================
ERROR: Test input that goes beyond color system bounds
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/Chroma/tests/test_chroma.py", line 82, in test_bad_input
    self.assertEqual(chroma.Color((300, -3, 50), 'RGB256').rgb256, chroma.Color((255, 0, 50), 'RGB256').rgb256)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 35, in __init__
    self.rgb256 = color_value
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 103, in rgb256
    self.rgb = map(lambda x: x / 255.0, color_tuple)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 95, in rgb
    self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))
TypeError: 'map' object is not subscriptable

======================================================================
ERROR: Test construction of color object
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/Chroma/tests/test_chroma.py", line 38, in test_color_initialization
    self.assertEqual(chroma.Color((255, 255, 255), 'RGB256').hex, white)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 35, in __init__
    self.rgb256 = color_value
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 103, in rgb256
    self.rgb = map(lambda x: x / 255.0, color_tuple)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 95, in rgb
    self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))
TypeError: 'map' object is not subscriptable

======================================================================
ERROR: Test conversion between systems
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/Chroma/tests/test_chroma.py", line 64, in test_system_conversion
    self.assertTupleAlmostEqual(chroma.Color((51, 85, 119), 'RGB256').rgb, self.c1.rgb)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 35, in __init__
    self.rgb256 = color_value
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 103, in rgb256
    self.rgb = map(lambda x: x / 255.0, color_tuple)
  File "/Users/scls/github/scls19fr/Chroma/chroma/core.py", line 95, in rgb
    self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))
TypeError: 'map' object is not subscriptable

----------------------------------------------------------------------
Ran 6 tests in 0.015s

FAILED (errors=3)

@s-celles
Copy link
Author

Pinging @aerickson

@s-celles
Copy link
Author

@rgb256.setter
def rgb256(self, color_tuple):
    self.rgb = map(lambda x: x / 255.0, color_tuple)

should be

@rgb256.setter
def rgb256(self, color_tuple):
    self.rgb = tuple(map(lambda x: x / 255.0, color_tuple))

@s-celles s-celles linked a pull request Oct 12, 2015 that will close this issue
@lyneca
Copy link

lyneca commented Jan 31, 2018

Bump :(

@aerickson
Copy link

@lyneca Until it's merged you can install a pip from a git source. Just use a fork with the code you want.

https://stackoverflow.com/questions/16584552/how-to-state-in-requirements-txt-a-direct-github-source

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

Successfully merging a pull request may close this issue.

3 participants