def test_pvalue_format(): x = [.90, .15, .015, .009, 0.0005] labels = pvalue_format()(x) assert labels == ['0.9', '0.15', '0.015', '0.009', '<0.001'] labels = pvalue_format(add_p=True)(x) assert labels == ['p=0.9', 'p=0.15', 'p=0.015', 'p=0.009', 'p<0.001'] with pytest.warns(None) as record: x = [.90, .15, np.nan, .015, .009, 0.0005] labels = pvalue_format()(x) assert labels == ['0.9', '0.15', 'nan', '0.015', '0.009', '<0.001'] # NaN is handled without any warning assert len(record) == 0
def test_pvalue_format(): x = [.90, .15, .015, .009, 0.0005] labels = pvalue_format()(x) assert labels == ['0.9', '0.15', '0.015', '0.009', '<0.001'] labels = pvalue_format(add_p=True)(x) assert labels == ['p=0.9', 'p=0.15', 'p=0.015', 'p=0.009', 'p<0.001'] with warnings.catch_warnings(record=True) as record: x = [.90, .15, np.nan, .015, .009, 0.0005] labels = pvalue_format()(x) assert labels == ['0.9', '0.15', 'nan', '0.015', '0.009', '<0.001'] assert not record, "Issued an unexpected warning" # NaN is handled without any warning assert len(record) == 0
def test_empty_breaks(): x = [] assert custom_format()(x) == [] assert comma_format()(x) == [] assert currency_format()(x) == [] assert percent_format()(x) == [] assert scientific_format()(x) == [] assert date_format()(x) == [] assert mpl_format()(x) == [] assert log_format()(x) == [] assert timedelta_format()(x) == [] assert pvalue_format()(x) == [] assert ordinal_format()(x) == [] assert number_bytes_format()(x) == []