def test_woehler_elementary_only_one_load_level():
    data = pd.DataFrame(np.array([[350.0, 1e7], [350.0, 1e6]]),
                        columns=['load', 'cycles'])
    fd = woehler.determine_fractures(data, 1e7).fatigue_data
    with pytest.raises(
            ValueError,
            match=r"Need at least two load levels to do a Wöhler analysis."):
        woehler.Elementary(fd).analyze().sort_index()
def test_woehler_probit_one_runout_load_level():
    fd = woehler.determine_fractures(data_one_runout_load_level,
                                     1e7).fatigue_data
    expected = woehler.Elementary(fd).analyze()
    with pytest.warns(
            UserWarning,
            match=
            r"Probit needs at least two runout load levels. Falling back to Elementary."
    ):
        wc = woehler.Probit(fd).analyze()
    pd.testing.assert_series_equal(wc, expected)
def test_woehler_elementary_initialize_with_pandas_dataframe():
    expected = pd.Series({
        'SD_50': 362.5,
        'k_1': 7.0,
        'ND_50': 3e5,
        '1/TN': 5.3,
        '1/TS': 1.27
    }).sort_index()

    wc = woehler.Elementary(data).analyze().sort_index()
    pd.testing.assert_index_equal(wc.index, expected.index)
    np.testing.assert_allclose(wc.to_numpy(), expected.to_numpy(), rtol=1e-1)
def test_woehler_elementary_no_runouts():
    expected = pd.Series({
        'SD_50': 0.0,
        'k_1': 7.0,
        '1/TN': 5.3,
        '1/TS': 1.27
    }).sort_index()

    fd = woehler.determine_fractures(data_no_runouts, 1e7).fatigue_data
    wc = woehler.Elementary(fd).analyze().sort_index().drop('ND_50')
    pd.testing.assert_index_equal(wc.index, expected.index)
    np.testing.assert_allclose(wc.to_numpy(), expected.to_numpy(), rtol=1e-1)
def test_woehler_elementary_initialize_with_determined_fractures():
    expected = pd.Series({
        'SD_50': 362.5,
        'k_1': 7.0,
        'ND_50': 3e5,
        '1/TN': 5.3,
        '1/TS': 1.27
    }).sort_index()

    fd = woehler.determine_fractures(data, 1e7)
    wc = woehler.Elementary(fd).analyze().sort_index()
    pd.testing.assert_index_equal(wc.index, expected.index)
    np.testing.assert_allclose(wc.to_numpy(), expected.to_numpy(), rtol=1e-1)