<commit_before># -*- coding: utf-8 -*-

import os
import subprocess

import pandas as pd
from pandas.util.testing import assert_series_equal

import pytest

import pyhector
from pyhector import (
    Hector, rcp26, rcp45, rcp60, rcp85, read_hector_input, read_hector_output
)


path = os.path.dirname(__file__)
rcps = {
    'rcp26': rcp26,
    'rcp45': rcp45,
    'rcp60': rcp60,
    'rcp85': rcp85
}

path = os.path.dirname(os.path.realpath(__file__))
hector_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "hector")
output_path = os.path.join(hector_path, "output")


@pytest.fixture
def compile_hector():
    if not os.path.exists(hector_path):
        p = subprocess.Popen(
            ["git", "clone", "https://github.com/JGCRI/hector.git",
             "--depth", "1"], cwd=path)
        p.wait()

    ver=["awk", "/define.*BOOST_LIB_VERSION/ {print $3}",
         "/usr/include/boost/version.hpp"]
    p = subprocess.run(ver, stdout=subprocess.PIPE)
    version = p.stdout.decode()
    p = subprocess.Popen(["git", "pull"], cwd=hector_path)
    p.wait()
    env = {
        **os.environ,
        "BOOSTLIB": "/usr/local/lib",
        "BOOSTVERSION": version,
        "BOOSTROOT": "/usr/include/boost"
    }
    p = subprocess.Popen(["make", "hector"], cwd=hector_path, env=env)
    p.wait()


@pytest.fixture
def run_rcps(compile_hector):
    for rcp in rcps.keys():
        output_stream = os.path.join(hector_path,
                          "output/outputstream_{}.csv".format(rcp))
        if os.path.exists(output_stream):
            os.remove(output_stream)
        ret = subprocess.call([
            "source/hector",
            "input/hector_{}.ini".format(rcp)
        ], cwd=hector_path)
        assert ret == 0
        assert os.path.exists(output_stream)

<commit_msg>fixed env for python2.7<commit_after># -*- coding: utf-8 -*-

import os
import subprocess

import pandas as pd
from pandas.util.testing import assert_series_equal

import pytest

import pyhector
from pyhector import (
    Hector, rcp26, rcp45, rcp60, rcp85, read_hector_input, read_hector_output
)


path = os.path.dirname(__file__)
rcps = {
    'rcp26': rcp26,
    'rcp45': rcp45,
    'rcp60': rcp60,
    'rcp85': rcp85
}

path = os.path.dirname(os.path.realpath(__file__))
hector_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "hector")
output_path = os.path.join(hector_path, "output")


@pytest.fixture
def compile_hector():
    if not os.path.exists(hector_path):
        p = subprocess.Popen(
            ["git", "clone", "https://github.com/JGCRI/hector.git",
             "--depth", "1"], cwd=path)
        p.wait()

    ver=["awk", "/define.*BOOST_LIB_VERSION/ {print $3}",
         "/usr/include/boost/version.hpp"]
    p = subprocess.run(ver, stdout=subprocess.PIPE)
    version = p.stdout.decode()
    p = subprocess.Popen(["git", "pull"], cwd=hector_path)
    p.wait()
    env = dict(**os.environ)
    env.update({
        "BOOSTLIB": "/usr/local/lib",
        "BOOSTVERSION": version,
        "BOOSTROOT": "/usr/include/boost"
    })
    p = subprocess.Popen(["make", "hector"], cwd=hector_path, env=env)
    p.wait()


@pytest.fixture
def run_rcps(compile_hector):
    for rcp in rcps.keys():
        output_stream = os.path.join(hector_path,
                          "output/outputstream_{}.csv".format(rcp))
        if os.path.exists(output_stream):
            os.remove(output_stream)
        ret = subprocess.call([
            "source/hector",
            "input/hector_{}.ini".format(rcp)
        ], cwd=hector_path)
        assert ret == 0
        assert os.path.exists(output_stream)


{'fraction_non_alphanumeric': 0.15441783649876134, 'fraction_numerical': 0.015964767409854114, 'mean_word_length': 2.7697095435684647, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '949078', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1307, 'n_words': 234}