<commit_before>require 'totem'
require 'image'

myTests = {}
local tester = totem.Tester()

local function test_transformation(f)
    local x_real = image.fabio():double():mul(255)
    local x_byte = x_real:clone():byte()

    assert(x_byte:size(1) > 256 and x_byte:size(2) > 256, 'Tricky case only occurs for images larger than 256 px, pick another example')

    local f_real, f_byte
    f_real = image[f](x_real)
    f_byte = image[f](x_byte)
    tester:assertTensorEq(f_real:byte():double(), f_byte:double(), 1e-16, f .. ':  result for double and byte images do not match')
end


function myTests.test_vflip()
    test_transformation('vflip')
end


function myTests.test_hflip()
    test_transformation('hflip')
end


tester:add(myTests)
return tester:run(myTests)
<commit_msg>Get ready to add more tests for vflip/hflip<commit_after>require 'totem'
require 'image'

myTests = {}
local tester = totem.Tester()


-- List of all possible tests
local all_tests = {}
function all_tests.test_transformation_largeByteImage(flip)
    local x_real = image.fabio():double():mul(255)
    local x_byte = x_real:clone():byte()

    assert(x_byte:size(1) > 256 and x_byte:size(2) > 256, 'Tricky case only occurs for images larger than 256 px, pick another example')

    local f_real, f_byte
    f_real = image[flip](x_real)
    f_byte = image[flip](x_byte)
    tester:assertTensorEq(f_real:byte():double(), f_byte:double(), 1e-16, flip .. ':  result for double and byte images do not match')
end


-- Apply all tests to both vflip and hflip
for _, flip in pairs{'vflip', 'hflip'} do
    for name, test in pairs(all_tests) do
        myTests[name .. '_' .. flip] = function() return test(flip) end
    end
end

tester:add(myTests)
return tester:run(myTests)

{'fraction_non_alphanumeric': 0.12407089765580331, 'fraction_numerical': 0.019439679817038306, 'mean_word_length': 4.451713395638629, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7421162', 'n_tokens_mistral': 648, 'n_tokens_neox': 596, 'n_words': 167}