示例#1
0
def test_profile_getter_1_7_8():
    """Load a profile from version 1.7.8"""
    tdir = pathlib.Path(tempfile.mkdtemp(prefix="cli_profile_"))
    name = "cli-profile-1.7.8.cfg"
    cfgpath = tdir / name
    shutil.copy2(data_path / name, cfgpath)
    pf = profile.Profile(path=cfgpath)
    assert pf["segment"] == 0
    assert pf["segment"] == 0
示例#2
0
def test_fit_data():
    # use temporary file
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_cli_rate_")
    name = pathlib.Path(name)
    profile.Profile(path=name)

    # this will fit with the profile default parameters
    idnt = rating.fit_data(path=jpkfile, profile_path=name)
    assert idnt.path == jpkfile
    assert idnt.fit_properties["success"]
示例#3
0
def test_single_fitparam():
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_profile_")
    name = pathlib.Path(name)
    pf = profile.Profile(path=name)
    # sanity checks (run twice to trigger loading and saving)
    pf["fit param E value"] = 50
    pf["fit param R value"] = 16e-6
    params = pf.get_fit_params()
    assert params["E"].value == 50
    assert params["R"].value == 16e-6
示例#4
0
def test_profile_getter_2_1_0():
    """Load a profile from version 2.1.0"""
    tdir = pathlib.Path(tempfile.mkdtemp(prefix="cli_profile_"))
    name = "cli-profile-2.1.0.cfg"
    cfgpath = tdir / name
    shutil.copy2(data_path / name, cfgpath)
    pf = profile.Profile(path=cfgpath)
    assert pf["segment"] == 0
    assert pf["segment"] == 0
    assert pf["rating training set"] == "zef18"
示例#5
0
def test_profile_fitparams():
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_profile_")
    name = pathlib.Path(name)
    pf = profile.Profile(path=name)
    # sanity checks (run twice to trigger loading and saving)
    pf["model_key"] = "hertz_cone"
    params = pf.get_fit_params()
    params2 = pf.get_fit_params()
    assert params == params2
    assert len(params) == 5
    assert "E" in params.keys()
示例#6
0
def test_fit_data_with_user_training_set():
    tdir = setup_training_set()
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_cli_rate_")
    name = pathlib.Path(name)
    pf = profile.Profile(path=name)
    pf["rating training set"] = tdir
    pf["fit param R value"] = 37.28e-6 / 2
    pout = tempfile.mkdtemp(prefix="test_nanite_cli_rate_ts")
    pout = pathlib.Path(pout)
    rating.fit_perform(path=jpkfile2, path_results=pout, profile_path=name)
    stats = np.loadtxt(pout / "statistics.tsv", skiprows=1, usecols=(1, 2, 3))
    assert np.all(stats[:, 0] == [109, 129, 416])
    assert np.all((3.5 < stats[:, 2]) * (stats[:, 2] < 5))
示例#7
0
def test_fit_data_with_zef18():
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_cli_rate_")
    name = pathlib.Path(name)
    pf = profile.Profile(path=name)
    pf["rating training set"] = "zef18"
    pf["weight_cp"] = 2e-6
    pf["fit param R value"] = 137.28e-6 / 2
    pout = tempfile.mkdtemp(prefix="test_nanite_cli_rate_ts")
    pout = pathlib.Path(pout)
    rating.fit_perform(path=jpkfile2, path_results=pout, profile_path=name)
    stats = np.loadtxt(pout / "statistics.tsv", skiprows=1, usecols=(1, 2, 3))
    assert np.all(stats[:, 0] == [109, 129, 416])
    assert stats[0, 2] == 9.5
    assert stats[1, 2] == 2.4
    assert stats[2, 2] == 4.9
示例#8
0
def test_profile_getter():
    _, name = tempfile.mkstemp(suffix=".cfg", prefix="test_nanite_profile_")
    name = pathlib.Path(name)
    pf = profile.Profile(path=name)
    # sanity checks (run twice to trigger loading and saving)
    assert pf["segment"] == 0
    assert pf["segment"] == 0
    assert pf["preprocessing"] == [
        "compute_tip_position", "correct_force_offset", "correct_tip_offset"
    ]
    assert pf["preprocessing"] == [
        "compute_tip_position", "correct_force_offset", "correct_tip_offset"
    ]
    pf["preprocessing"] = ["compute_tip_position"]
    assert pf["preprocessing"] == ["compute_tip_position"]
    assert pf["range_x"] == [0, 0]
    assert pf["range_x"] == [0, 0]
    assert pf["weight_cp"] == 5e-7
    assert pf["weight_cp"] == 5e-7