Example #1
0
def test_sunspotter_timesfits_columns():

    with pytest.raises(SunpyUserWarning):
        Sunspotter(timesfits=path / "lookup_timesfits.csv",
                   properties=path / "lookup_properties.csv",
                   timesfits_columns=["This shouldn't be present"],
                   delimiter=';')
Example #2
0
def sunspotter(properties_columns, timesfits_columns, classifications_columns):
    return Sunspotter(timesfits=path / "lookup_timesfits.csv",
                      properties=path / "lookup_properties.csv",
                      classifications=path / "classifications.csv",
                      delimiter=';',
                      timesfits_columns=timesfits_columns,
                      properties_columns=properties_columns,
                      classifications_columns=classifications_columns)
Example #3
0
def test_sunspotter_base_object(properties_columns, timesfits_columns):

    sunspotter = Sunspotter(timesfits=path / "lookup_timesfits.csv",
                            properties=path / "lookup_properties.csv",
                            timesfits_columns=timesfits_columns,
                            properties_columns=properties_columns)

    assert set(sunspotter.properties_columns) == set(properties_columns)
    assert set(sunspotter.timesfits_columns) == set(timesfits_columns)
Example #4
0
def test_sunspotter_with_classifications(classifications_columns):

    sunspotter = Sunspotter(timesfits=path / "lookup_timesfits.csv",
                            properties=path / "lookup_properties.csv")

    assert sunspotter.classifications_columns is None
    assert sunspotter.classifications is None

    with pytest.raises(SunpyUserWarning):
        # Because Classifications Columns aren't specified.
        Sunspotter(timesfits=path / "lookup_timesfits.csv",
                   properties=path / "lookup_properties.csv",
                   classifications=path / "classifications.csv")

    assert sunspotter.classifications_columns is None
    assert sunspotter.classifications is None

    sunspotter = Sunspotter(timesfits=path / "lookup_timesfits.csv",
                            properties=path / "lookup_properties.csv",
                            classifications=path / "classifications.csv",
                            classifications_columns=classifications_columns)

    assert set(
        sunspotter.classifications_columns) == set(classifications_columns)
Example #5
0
def test_sunspotter_no_parameters():
    timesfits = pd.read_csv(path / "lookup_timesfits.csv", delimiter=';')
    properties = pd.read_csv(path / "lookup_properties.csv", delimiter=';')

    # get all columns is by default True for both Timesfits and Properties.
    sunspotter = Sunspotter()

    # To get obs_date back a column of dtype `str`
    sunspotter.timesfits.reset_index(inplace=True)
    sunspotter.timesfits.obs_date = sunspotter.timesfits.obs_date.dt.strftime(
        '%Y-%m-%d %H:%M:%S')

    # To get #id back a column of dtype int
    sunspotter.properties.reset_index(inplace=True)

    # Sorting columns as the order of Columns shouldn't matter
    assert sunspotter.timesfits.sort_index(axis=1).equals(
        timesfits.sort_index(axis=1))
    assert sunspotter.properties.sort_index(axis=1).equals(
        properties.sort_index(axis=1))
Example #6
0
def test_sunspotter_incorrect_delimiter():

    with pytest.raises(SunpyUserWarning):
        Sunspotter(timesfits=path / "lookup_timesfits.csv",
                   properties=path / "lookup_properties.csv",
                   delimiter=',')