<commit_before>local lapp = require 'pl.lapp'
require 'sys'
local c = sys.COLORS

local NCOLS = 80


local isTensor = totem._isTensor


local Tester = torch.class('totem.Tester')

function Tester:__init()
    self.errors = {}
    self.tests = {}
    self.curtestname = ''
end


-- Add a success to the test
function Tester:_success (message)
    self.countasserts = self.countasserts + 1
    local name = self.curtestname
    self.assertionPass[name] = self.assertionPass[name] + 1
end

-- Add a failure to the test
function Tester:_failure (message)
    self.countasserts = self.countasserts + 1
    local name = self.curtestname
    self.assertionFail[name] = self.assertionFail[name] + 1
    local ss = debug.traceback('tester',2)
    ss = ss:match('[^\n]+\n[^\n]+\n([^\n]+\n[^\n]+)\n')
    if type(message) == 'function' then
        message = message()
    end
    self.errors[#self.errors+1] = self.curtestname .. '\n' .. message .. '\n' .. ss .. '\n'
end

--[[

Parameters:

- `condition` (boolean)
- `message` (string or function : nil → string)

]]
function Tester:_assert_sub (condition, message)
    if condition then
        self:_success(message)
    else
        self:_failure(message)
    end
end

<commit_msg>Changed part of stack displayed on assertion failure<commit_after>local lapp = require 'pl.lapp'
require 'sys'
local c = sys.COLORS

local NCOLS = 80


local isTensor = totem._isTensor


local Tester = torch.class('totem.Tester')

function Tester:__init()
    self.errors = {}
    self.tests = {}
    self.curtestname = ''
end


-- Add a success to the test
function Tester:_success (message)
    self.countasserts = self.countasserts + 1
    local name = self.curtestname
    self.assertionPass[name] = self.assertionPass[name] + 1
end

-- Add a failure to the test
function Tester:_failure (message)
    self.countasserts = self.countasserts + 1
    local name = self.curtestname
    self.assertionFail[name] = self.assertionFail[name] + 1
    local ss = debug.traceback('tester',3)
    ss = ss:match('[^\n]+\n[^\n]+\n([^\n]+\n[^\n]+)\n')
    if type(message) == 'function' then
        message = message()
    end
    self.errors[#self.errors+1] = self.curtestname .. '\n' .. message .. '\n' .. ss .. '\n'
end

--[[

Parameters:

- `condition` (boolean)
- `message` (string or function : nil → string)

]]
function Tester:_assert_sub (condition, message)
    if condition then
        self:_success(message)
    else
        self:_failure(message)
    end
end


{'fraction_non_alphanumeric': 0.14302932904781038, 'fraction_numerical': 0.0064282844515869825, 'mean_word_length': 3.122516556291391, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1624093', 'n_tokens_mistral': 857, 'n_tokens_neox': 836, 'n_words': 213}