<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import unittest

from hwt.hdlObjects.constants import Time
from hwt.interfaces.std import Handshaked
from hwt.simulator.shortcuts import simPrepare
from hwt.simulator.simTestCase import SimTestCase
from hwtLib.handshaked.joinFair import HsJoinFairShare
from hwt.simulator.agentConnector import valuesToInts


def dataFn(d):
    return d._ag.data


class HsJoinFair_2inputs_TC(SimTestCase):
    def setUp(self):
        u = self.u = HsJoinFairShare(Handshaked)
        self.INPUTS = 2
        u.INPUTS.set(self.INPUTS)
        u.DATA_WIDTH.set(8)
        u.EXPORT_SELECTED.set(True)
        _, self.model, self.procs = simPrepare(self.u)

    def addToAllInputs(self, n):
        u = self.u
        for i, d in enumerate(u.dataIn):
            d._ag.data = [_i + (n * i) for _i in range(n)]

        expected = []
        for d in zip(*map(dataFn, u.dataIn)):
            expected.extend(d)

        return expected<commit_msg>update prepareUnit usage<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import unittest

from hwt.hdlObjects.constants import Time
from hwt.interfaces.std import Handshaked
from hwt.simulator.shortcuts import simPrepare
from hwt.simulator.simTestCase import SimTestCase
from hwtLib.handshaked.joinFair import HsJoinFairShare
from hwt.simulator.agentConnector import valuesToInts


def dataFn(d):
    return d._ag.data


class HsJoinFair_2inputs_TC(SimTestCase):
    def setUp(self):
        u = self.u = HsJoinFairShare(Handshaked)
        self.INPUTS = 2
        u.INPUTS.set(self.INPUTS)
        u.DATA_WIDTH.set(8)
        u.EXPORT_SELECTED.set(True)
        self.prepareUnit(u)

    def addToAllInputs(self, n):
        u = self.u
        for i, d in enumerate(u.dataIn):
            d._ag.data = [_i + (n * i) for _i in range(n)]

        expected = []
        for d in zip(*map(dataFn, u.dataIn)):
            expected.extend(d)

        return expected
{'fraction_non_alphanumeric': 0.1034658511722732, 'fraction_numerical': 0.0050968399592252805, 'mean_word_length': 2.767754318618042, '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': '3932914', 'n_tokens_mistral': 689, 'n_tokens_neox': 664, 'n_words': 151}