<commit_before>import unittest

from scribblers.jec import ApplyJEC
from scribblers.obj import Object

##__________________________________________________________________||
class MockScaleFunc(object):
    def __init__(self):
        self.ret = 1.0
        self.args = None

    def __call__(self, pt, eta):
        self.args = (pt, eta)
        return self.ret

##__________________________________________________________________||
class Test_ApplyJEC(unittest.TestCase):

    def setUp(self):
        self.scale_func = MockScaleFunc()
        self.obj = ApplyJEC(
            scale_func_pt_eta = self.scale_func
        )

    def tearDown(self):
        pass

    def test_repr(self):
        repr(self.obj)

    def test_call(self):
        self.scale_func.ret = 48.0

        jet = Object([('pt', 40.0), ('eta', 1.1), ('phi', 0.1)])
        jet_corr = self.obj(jet)

        self.assertEqual((40.0, 1.1),  self.scale_func.args)
        self.assertEqual(
            Object([('pt', 48.0), ('eta', 1.1), ('phi', 0.1)]),
            jet_corr
        )

##__________________________________________________________________||<commit_msg>reimplement test for ApplyJEC with pytest<commit_after># <NAME> <<EMAIL>>

import pytest

from scribblers.jec import ApplyJEC
from scribblers.obj import Object

##__________________________________________________________________||
class MockScaleFunc(object):
    def __init__(self):
        self.ret = 1.0
        self.args = None

    def __call__(self, pt, eta):
        self.args = (pt, eta)
        return self.ret

##__________________________________________________________________||
@pytest.fixture()
def scale_func():
    return MockScaleFunc()

@pytest.fixture()
def obj(scale_func):
    return ApplyJEC(
        scale_func_pt_eta = scale_func
    )

##__________________________________________________________________||
def test_repr(obj, scale_func):
    repr(obj)

def test_call(obj, scale_func):
    scale_func.ret = 48.0

    jet = Object([('pt', 40.0), ('eta', 1.1), ('phi', 0.1)])
    jet_corr = obj(jet)

    assert scale_func.args == (40.0, 1.1)
    assert jet_corr == Object([('pt', 48.0), ('eta', 1.1), ('phi', 0.1)])

##__________________________________________________________________||
{'fraction_non_alphanumeric': 0.1261101243339254, 'fraction_numerical': 0.021314387211367674, 'mean_word_length': 3.452569169960474, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5660670', 'n_tokens_mistral': 699, 'n_tokens_neox': 659, 'n_words': 144}