mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 05:01:42 +08:00
Fix validation bug and add test
This commit is contained in:
@@ -95,12 +95,7 @@ class Pixel(object):
|
||||
|
||||
@rgb.setter
|
||||
def rgb(self, value):
|
||||
for v in value:
|
||||
self._validate(v)
|
||||
|
||||
self._red = value[0]
|
||||
self._green = value[1]
|
||||
self._blue = value[2]
|
||||
self._red, self._green, self._blue = (self._validate(v) for v in value)
|
||||
self._setpixel()
|
||||
|
||||
def _validate(self, value):
|
||||
|
||||
@@ -70,6 +70,12 @@ def test_pixel_rgb():
|
||||
assert_equal(channel, i + 3)
|
||||
|
||||
|
||||
def test_pixel_rgb_float():
|
||||
pixel = novice.Picture(size=(1, 1))[0, 0]
|
||||
pixel.rgb = (1.1, 1.1, 1.1)
|
||||
assert_equal(pixel.rgb, (1, 1, 1))
|
||||
|
||||
|
||||
@raises(ValueError)
|
||||
def test_pixel_rgb_raises():
|
||||
pixel = novice.Picture(size=(1, 1))[0, 0]
|
||||
|
||||
Reference in New Issue
Block a user