libvips/python/test_arithmetic.py

42 lines
1.1 KiB
Python
Raw Normal View History

2014-09-11 22:54:52 +02:00
#!/usr/bin/python
import unittest
#import logging
#logging.basicConfig(level = logging.DEBUG)
from gi.repository import Vips
from vips8 import vips
formats = [Vips.BandFormat.UCHAR,
Vips.BandFormat.CHAR,
Vips.BandFormat.USHORT,
Vips.BandFormat.SHORT,
Vips.BandFormat.UINT,
Vips.BandFormat.INT,
Vips.BandFormat.FLOAT,
Vips.BandFormat.DOUBLE,
Vips.BandFormat.COMPLEX,
Vips.BandFormat.DPCOMPLEX]
class TestArithmetic(unittest.TestCase):
def setUp(self):
black = Vips.Image.black(100, 100)
mono = black.draw_circle(128, 50, 50, 50)
colour = Vips.Image.bandjoin([black, mono, black])
images = [black, mono, colour]
self.test_set = [x.cast(y) for x in images for y in formats]
self.avgs = [x.avg() for x in self.test_set]
def test_addconst(self):
def add12(x):
return x + 12
self.assertEqual([add12(x).avg() for x in self.test_set],
2014-09-11 22:54:52 +02:00
[add12(x) for x in self.avgs])
if __name__ == '__main__':
unittest.main()