def test_split_filter_invalid_blocksize(): ''' test blocksize argument handling ''' h = HaarFeature([((0, 0, 5, 5), -1)], False, 0.01, 0.2, 0.8) try: res = gen_code.split_filter(h, (1,1), (4,5)) # blocksizes for w and h should be equal except InvalidBlocksizeException: assert True # this exception should be raised return assert False # should never get here
def test_split_filter_correctness(): ''' test correctness of split_filter ''' block_size = 4 pos = (1,1) h = HaarFeature([((0, 0, 5, 5), -1)], False, 0.01, 0.2, 0.8) res = gen_code.split_filter(h, pos, block_size) # this result may seem strange, but the pos offset needs to be added to get the correct result ref = [((0, 0, 3, 3), -1), ((0, 3, 3, 2), -1), ((3, 0, 2, 3), -1), ((3, 3, 2, 2), -1)] assert ref == res.shapes