Пример #1
0
def test_cpu_info_errors():

    with pytest.raises(KeyError) as exc:
        cpu_info.get("E7-8867 V4")

    assert "not determine vendor" in exc.value.args[0], exc.value.args[0]

    with pytest.raises(KeyError) as exc:
        cpu_info.get("Intel E0-9999 V4")

    assert "intel: e0-9999" in exc.value.args[0], exc.value.args[0]
Пример #2
0
    def transform(self, X: pd.DataFrame) -> pd.DataFrame:

        # not features to extract
        if 'cpu' not in X:
            return X

        clock = []
        launch = []
        vendor = []
        instructions = []
        for cpu in X["cpu"]:
            info = cpu_info.get(cpu)
            clock.append(info.base_clock / 1_000_000)
            if not info.launch_date:
                launch.append(2018)  # TODO imputation
            else:
                launch.append(info.launch_date)
            vendor.append(info.vendor)
            instructions.append(info.instructions)

        ret_df = X.copy()
        ret_df["cpu_clock_speed"] = clock
        ret_df["cpu_launch_year"] = launch
        ret_df["cpu_vendor"] = vendor
        ret_df["cpu_instructions"] = instructions

        return ret_df
Пример #3
0
def test_cpu_info_matches():
    assert cpu_info.get("E7-8867 V4", vendor="intel").model == "E7-8867V4"
Пример #4
0
def test_cpu_info_search(name, model):

    cpu = cpu_info.get(name)
    assert cpu is not None, name
    assert cpu.model == model, name
Пример #5
0
def test_cpu_fixes(name, fixes):
    info = cpu_info.get(name)
    print(info)
    for k, v in fixes.items():
        assert getattr(info, k) == v