fix linear with mismatched vectors
we had: $ vips linear sarto_ng.v x.v "1 2 3" "4" $ vipsheader x.v x.v: 1865x2556 float, 1 band, b-w $ vips linear sarto_ng.v x.v "1" "4 5 6" $ vipsheader x.v x.v: 1865x2556 float, 3 bands, b-w there was a typo in linear.c
This commit is contained in:
parent
12d623fa25
commit
133e2f94e9
@ -132,14 +132,16 @@ vips_linear_build( VipsObject *object )
|
|||||||
*/
|
*/
|
||||||
linear->n = 1;
|
linear->n = 1;
|
||||||
if( linear->a )
|
if( linear->a )
|
||||||
linear->n = VIPS_MAX( linear->n, linear->b->n );
|
linear->n = VIPS_MAX( linear->n, linear->a->n );
|
||||||
if( linear->b )
|
if( linear->b )
|
||||||
linear->n = VIPS_MAX( linear->n, linear->b->n );
|
linear->n = VIPS_MAX( linear->n, linear->b->n );
|
||||||
if( unary->in )
|
if( unary->in )
|
||||||
linear->n = VIPS_MAX( linear->n, bands );
|
linear->n = VIPS_MAX( linear->n, bands );
|
||||||
arithmetic->base_bands = linear->n;
|
arithmetic->base_bands = linear->n;
|
||||||
|
|
||||||
if( unary->in && linear->a && linear->b ) {
|
if( unary->in &&
|
||||||
|
linear->a &&
|
||||||
|
linear->b ) {
|
||||||
if( vips_check_vector( class->nickname,
|
if( vips_check_vector( class->nickname,
|
||||||
linear->a->n, unary->in ) ||
|
linear->a->n, unary->in ) ||
|
||||||
vips_check_vector( class->nickname,
|
vips_check_vector( class->nickname,
|
||||||
|
@ -315,5 +315,18 @@ class TestArithmetic(unittest.TestCase):
|
|||||||
self.assertAlmostEqualObjects(hist.getpoint(100,0), [5000])
|
self.assertAlmostEqualObjects(hist.getpoint(100,0), [5000])
|
||||||
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||||
|
|
||||||
|
test = test * [1, 2, 3]
|
||||||
|
|
||||||
|
for fmt in all_formats:
|
||||||
|
hist = test.cast(fmt).hist_find(band = 0)
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(0,0), [5000])
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(100,0), [5000])
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||||
|
|
||||||
|
hist = test.cast(fmt).hist_find(band = 1)
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(0,0), [5000])
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(200,0), [5000])
|
||||||
|
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user