Esempio n. 1
0
def cumulative_df(df, full_cum=False):
    """Index by band, """
    bands = df.index
    assert all(bands == ["Z", "Y", "J", "H", "K"]), bands
    if full_cum:
        cum_bands = [
            "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK", "YJHK", "JHK", "HK", "K"
        ]

        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative_full(df["Cond. 1"]),
            "Cond. 2": rv_cumulative_full(df["Cond. 2"]),
            "Cond. 3": rv_cumulative_full(df["Cond. 3"]),
        }
    else:
        cum_bands = ["Z", "ZY", "ZYJ", "ZYJH", "ZYJHK"]
        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative(df["Cond. 1"], single=True),
            "Cond. 2": rv_cumulative(df["Cond. 2"], single=True),
            "Cond. 3": rv_cumulative(df["Cond. 3"], single=True),
        }
    cum_df = pd.DataFrame(cum_dict)
    cum_df = cum_df.set_index("Band")
    cum_df = cum_df.reindex(cum_bands)
    return cum_df
Esempio n. 2
0
def test_rv_cumulative_full(input_):
    result = rv_cumulative_full(input_)
    assert len(result) == 9
    assert result[4] == weighted_error(input_)
    assert result[0] == input_[0]
    assert result[-1] == input_[-1]
    assert isinstance(result, np.ndarray)
Esempio n. 3
0
def cumulative_df(df, full_cum=False):
    """Calculated cumulative RV precision across bands.
    The precision of "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK" bands.

    Parameters
    ----------
    df: pandas.DataFrame
       DataFrame.
    full_cum: bool
       Include "YJHK", "JHK", "HK", "K" grouping also. Default is False.

    """
    bands = df.index
    assert all(bands == ["Z", "Y", "J", "H", "K"]), bands
    if full_cum:
        cum_bands = [
            "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK", "YJHK", "JHK", "HK", "K"
        ]

        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative_full(df["Cond. 1"]),
            "Cond. 2": rv_cumulative_full(df["Cond. 2"]),
            "Cond. 3": rv_cumulative_full(df["Cond. 3"]),
        }
    else:
        cum_bands = ["Z", "ZY", "ZYJ", "ZYJH", "ZYJHK"]
        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative(df["Cond. 1"], single=True),
            "Cond. 2": rv_cumulative(df["Cond. 2"], single=True),
            "Cond. 3": rv_cumulative(df["Cond. 3"], single=True),
        }
    cum_df = pd.DataFrame(cum_dict)
    cum_df = cum_df.set_index("Band")
    cum_df = cum_df.reindex(cum_bands)
    return cum_df
Esempio n. 4
0
def test_rv_cumulative_full_errors_on_size(input_):
    """Test it errors when not given 5 values."""
    with pytest.raises(AssertionError):
        rv_cumulative_full(input_)