<commit_before>import unittest
from .. import tfa
import pandas as pd
import numpy as np
import subprocess

units_in_the_last_place_tolerance = 16
class TestTFA(unittest.TestCase):

    def generate_random_matrix(self, n, m):
        return np.array([np.random.rand(m) for x in range(n)])

    # Test for 5 genes, one of which is a TF, 5 condidtions, and 4 TFs.
    # where tau is equal to 1, so exp_mat and exp_mat_tau are equivalent
    def setup_mouse_th17(self):
        tau = 1
        exp = pd.DataFrame(np.array([[12.28440, 12.55000, 11.86260, 11.86230, 11.88100], 
            [8.16000, 8.55360, 7.76500, 7.89030, 8.08710],
            [10.47820, 11.08340, 10.52270, 10.34180, 10.38780],
            [5.46000,5.48910, 4.90390, 4.69800, 5.07880],
            [7.96367, 7.86005, 7.82641, 7.94938, 7.67066]]))
        exp.columns = ['s1', 's2', 's3', 's4', 's5']
        exp.index = ['g1', 't2', 'g3', 'g4', 'g5']
        priors = pd.DataFrame(np.array([[1,0,0,1], 
            [0,0,0,0], 
            [0,0,-1,0], 
            [-1,0,0,-1], 
            [0,0,1,0]]))
        priors.columns = ['t1', 't2', 't3', 't4']
        priors.index = ['g1', 't2', 'g3', 'g4', 'g5']
        self.tfa_object = tfa.TFA(priors, exp, exp/1)

    def setup_three_columns(self):
        tau = 1
        exp = pd.DataFrame(np.array([[1, 3], [1, 2], [0, 3]]))
        exp.columns = ['s1', 's2']
        exp.index = ['g1', 'tf1', 'g3']
        priors = pd.DataFrame(np.array([[1, 1, 1], [1, 1, 0], [0, 0, 0]]))
        priors.columns = ['tf1', 'tf2', 'tf3']
        priors.index = exp.index
        self.tfa_object = tfa.TFA(priors, exp, exp/tau)
<commit_msg>renamed exp_mat to expression matrix<commit_after>import unittest
from .. import tfa
import pandas as pd
import numpy as np
import subprocess

units_in_the_last_place_tolerance = 16
class TestTFA(unittest.TestCase):

    def generate_random_matrix(self, n, m):
        return np.array([np.random.rand(m) for x in range(n)])

    # Test for 5 genes, one of which is a TF, 5 condidtions, and 4 TFs.
    # where tau is equal to 1, so expression_matrix and expression_matrix_halftau are equivalent
    def setup_mouse_th17(self):
        tau = 1
        exp = pd.DataFrame(np.array([[12.28440, 12.55000, 11.86260, 11.86230, 11.88100], 
            [8.16000, 8.55360, 7.76500, 7.89030, 8.08710],
            [10.47820, 11.08340, 10.52270, 10.34180, 10.38780],
            [5.46000,5.48910, 4.90390, 4.69800, 5.07880],
            [7.96367, 7.86005, 7.82641, 7.94938, 7.67066]]))
        exp.columns = ['s1', 's2', 's3', 's4', 's5']
        exp.index = ['g1', 't2', 'g3', 'g4', 'g5']
        priors = pd.DataFrame(np.array([[1,0,0,1], 
            [0,0,0,0], 
            [0,0,-1,0], 
            [-1,0,0,-1], 
            [0,0,1,0]]))
        priors.columns = ['t1', 't2', 't3', 't4']
        priors.index = ['g1', 't2', 'g3', 'g4', 'g5']
        self.tfa_object = tfa.TFA(priors, exp, exp/1)

    def setup_three_columns(self):
        tau = 1
        exp = pd.DataFrame(np.array([[1, 3], [1, 2], [0, 3]]))
        exp.columns = ['s1', 's2']
        exp.index = ['g1', 'tf1', 'g3']
        priors = pd.DataFrame(np.array([[1, 1, 1], [1, 1, 0], [0, 0, 0]]))
        priors.columns = ['tf1', 'tf2', 'tf3']
        priors.index = exp.index
        self.tfa_object = tfa.TFA(priors, exp, exp/tau)

{'fraction_non_alphanumeric': 0.18853197238066646, 'fraction_numerical': 0.13989792854998498, 'mean_word_length': 2.348743718592965, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1985792', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1361, 'n_words': 316}