コード例 #1
0
def test_wrong_range():
    small_list = np.random.normal(5, 2, 3)
    large_list = np.random.normal(5, 2, 6000)
    with pytest.raises(ValueError):
        shapiro_wilk(small_list)
    with pytest.raises(ValueError):
        shapiro_wilk(large_list)
コード例 #2
0
def test_meaningless_input():
    """check that meaningless input isn't prcoessed"""
    with pytest.raises(ValueError):
        shapiro_wilk(data_meaningless1)
    with pytest.raises(ValueError):
        shapiro_wilk(data_meaningless2)
    with pytest.raises(TypeError):
        shapiro_wilk(data_meaningless3)
    with pytest.raises(ValueError):
        shapiro_wilk(data_meaningless4)
    with pytest.raises(ValueError):
        shapiro_wilk(data_meaningless5)
コード例 #3
0
def test_output_and_input_type():
    """Check that output is a tuple for all possible inputs"""
    assert type(shapiro_wilk(data_df)) == tuple
    assert type(shapiro_wilk(data_list1)) == tuple
    assert type(shapiro_wilk(data_list2)) == tuple
    assert type(shapiro_wilk(data_list3)) == tuple
    assert type(shapiro_wilk(data_ndarray)) == tuple
    assert type(shapiro_wilk(data_ndarray[:,0])) == tuple
    assert type(shapiro_wilk(data_series1)) == tuple
    assert type(shapiro_wilk(data_series2)) == tuple
コード例 #4
0
def calculation_test():
    """check that the shapiro-wilk test statistic is correctly calculated because p-value should be > 0.05"""
    norm_values = np.random.normal(5, 2, 100)
    assert shapiro_wilk(norm_values)[1] > 0.05
コード例 #5
0
def test_input_type():
    """check that the function returns TypeError if the dataframe has no continuous variables"""
    with pytest.raises(TypeError):
        shapiro_wilk(data_df2)
コード例 #6
0
def test_output_lists_equal():
    """check that the length of the first list is equal to the output of the second list"""
    stats = shapiro_wilk(data)
    assert len(stats[0]) == len(stats[1])
コード例 #7
0
def test_output_list_length():
    """check that the length of the first list is as <= amount of columns in pd.dataframe"""
    stats_1 = shapiro_wilk(data_df)[0]
    assert len(stats_1) <= data_df.shape[1]
コード例 #8
0
def test_output_tuple_length():
    """check that length of output is two since the tuple always has 2 lists in it"""
    stats = shapiro_wilk(data_df)
    assert len(stats) == 2
コード例 #9
0
def test_output_type():
    """Check that output is a tuple"""
    stats = shapiro_wilk(data_df)
    assert type(stats) == tuple