Exemplo n.º 1
0
def test_calculate_bins():
    target = np.array(['2018-01-01 00:00', '2018-01-01 01:00', '2018-01-01 02:00',
       '2018-01-01 03:00', '2018-01-01 04:00', '2018-01-01 05:00',
       '2018-01-01 06:00', '2018-01-01 07:00', '2018-01-01 08:00'])
    df = setup_dataframe.create_dataframe()
    bins = EDA_countplot.calculate_bins(df,'H').values
    assert (bins == target).all()
Exemplo n.º 2
0
def test_punchcard_two_users():
    df = setup_dataframe.create_dataframe()
    user_list = ['user_1', 'user_2']
    columns = ['col_1']
    title = 'test_title'
    resample = "D"

    fig = EDA_punchcard.punchcard_plot(df, user_list, columns, title, resample)
    assert (type(fig) == plotly.graph_objs._figure.Figure)
Exemplo n.º 3
0
def test_punchcard_one_user():
    df = setup_dataframe.create_dataframe()
    user_list = ['user_1']
    columns = ['col_1']
    title = 'test_title'
    resample = "D"

    fig = EDA_punchcard.punchcard_plot(df, user_list, columns, title, resample)
    assert (type(fig) == plotly.graph_objs._figure.Figure)
    assert (type(fig) == plotly.graph_objs._figure.Figure)
    assert (fig.layout.xaxis.nticks == 31)
    assert (fig.layout.title.text == 'test_title')
Exemplo n.º 4
0
def test_EDA_countplot_subject():
    df = setup_dataframe.create_dataframe()
    fig = EDA_countplot.EDA_countplot(df, 
                                      fig_title = 'Test_title', 
                                      plot_type = 'count', 
                                      points = 'all',
                                      aggregation = 'user', 
                                      user = None, 
                                      column = None,
                                      binning=False)
    
    assert (type(fig) == plotly.graph_objs._figure.Figure)
Exemplo n.º 5
0
def test_EDA_countplot_value():
    df = setup_dataframe.create_dataframe()
    fig = EDA_countplot.EDA_countplot(df, 
                                fig_title = 'Test_title', 
                                plot_type = 'value', 
                                points = 'all',
                                aggregation = 'group', 
                                user = None, 
                                column='col_1',
                                binning='H')
    
    assert (type(fig) == plotly.graph_objs._figure.Figure)
Exemplo n.º 6
0
def test_punchcard_one_user_two_columns():
    df = setup_dataframe.create_dataframe()
    user_list = ['user_1']
    columns = ['col_1', 'col_2']
    title = 'test_title'
    resample = "D"
    normalize = True

    fig = EDA_punchcard.punchcard_plot(df, user_list, columns, title, resample,
                                       normalize)
    assert (type(fig) == plotly.graph_objs._figure.Figure)
    assert (fig.layout.legend.x == None)
    assert (fig.layout.legend.y == None)
Exemplo n.º 7
0
def test_punchcard_two_users_timerange():
    df = setup_dataframe.create_dataframe()
    user_list = ['user_1', 'user_2']
    columns = ['col_1']
    title = 'test_title'
    resample = "D"
    normalize = False
    agg_function = np.mean
    timerange = ('20171231', '20180101')

    fig = EDA_punchcard.punchcard_plot(df, user_list, columns, title, resample,
                                       normalize, agg_function, timerange)
    assert (type(fig) == plotly.graph_objs._figure.Figure)
    assert (fig.data[0].x == datetime.datetime(2018, 1, 1, 0, 0))
Exemplo n.º 8
0
def test_timeplot_two_users_and_columns():
    df = setup_dataframe.create_dataframe()
    
    fig = EDA_lineplot.timeplot(df,
                                users=['user_1','user_2'],
                                columns=['col_1','col_2'],
                                title='Test title',
                                xlabel='Xlabel',
                                ylabel='Ylabel',
                                resample='H',
                                interpolate=True,
                                window=1,
                                reset_index=False,
                                by='hour'
    )
    
    assert (type(fig) == plotly.graph_objs._figure.Figure)
Exemplo n.º 9
0
def test_group_averages():
    df = setup_dataframe.create_dataframe()
    #df = df.rename_axis('timestamp')
    
    fig = EDA_lineplot.timeplot(df,
                                users='Group',
                                columns=['col_1'],
                                title='Test title',
                                xlabel='Xlabel',
                                ylabel='Ylabel',
                                resample='D',
                                interpolate=True,
                                window=1,
                                reset_index=False,
                                by='weekday'
    )
    
    assert (type(fig) == plotly.graph_objs._figure.Figure)
Exemplo n.º 10
0
def test_get_counts():
    df = setup_dataframe.create_dataframe()
    group_counts = EDA_countplot.get_counts(df,'group')
    user_counts = EDA_countplot.get_counts(df,'user')
    assert (group_counts['values'].values == np.array([3,3,3])).all()
    assert (user_counts['values'].values == np.ones(9)).all()