Esempio n. 1
0
def test_log_format():
    formatter = log_format()

    assert formatter([0.001, 0.1, 100]) == ['0.001', '0.1', '100']
    assert formatter([0.001, 0.1, 1000]) == ['1e-3', '1e-1', '1e3']
    assert formatter([35, 60]) == ['35', '60']
    assert formatter([34.99999999999, 60.0000000001]) == ['35', '60']
    assert formatter([3000.0000000000014, 4999.999999999999]) == \
        ['3000', '5000']
    assert formatter([1, 35, 60, 1000]) == ['1', '35', '60', '1000']
    assert formatter([1, 35, 60, 10000]) == ['1', '35', '60', '10000']

    formatter = log_format(base=2)
    assert formatter([1, 10, 11, 1011]) == ['1', '10', '11', '1011']
Esempio n. 2
0
def test_log_format():
    formatter = log_format()

    assert formatter([0.001, 0.1, 100]) == ['0.001', '0.1', '100']
    assert formatter([0.001, 0.1, 10000]) == ['1e-3', '1e-1', '1e4']
    assert formatter([35, 60]) == ['35', '60']
    assert formatter([34.99999999999, 60.0000000001]) == ['35', '60']
    assert formatter([3000.0000000000014, 4999.999999999999]) == \
        ['3000', '5000']
    assert formatter([1, 35, 60, 1000]) == ['1', '35', '60', '1000']
    assert formatter([1, 35, 60, 10000]) == ['1', '35', '60', '10000']
    assert formatter([3.000000000000001e-05]) == ['3e-5']

    formatter = log_format(base=2)
    assert formatter([1, 10, 11, 1011]) == ['1', '10', '11', '1011']
Esempio n. 3
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) == []
Esempio n. 4
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) == []
         x="Eucledian Distance of Preprints First and Final Versions",
         y="Time Elapsed Until Preprint is Published",
     ) + p9.theme_seaborn(
         context="paper",
         style="ticks", font="Arial", font_scale=1.3))
print(g)

g = (p9.ggplot(published_date_distances,
               p9.aes(x="doc_distances", y="time_to_published")) +
     p9.geom_bin2d(bins=100) + p9.scale_fill_distiller(
         trans="log",
         direction=-1,
         type="seq",
         palette="YlGnBu",
         name="log(count)",
         labels=log_format(base=10),
     ) + p9.geom_line(stat="smooth",
                      method="lm",
                      linetype="dashed",
                      se=False,
                      alpha=1,
                      size=0.7) +
     p9.scale_y_timedelta(labels=timedelta_format("d")) + p9.annotate(
         "text",
         x=10,
         y=timedelta(days=1490),
         label=f"Y={results_2.slope:.2f}*X+{results_2.intercept:.2f}",
     ) + p9.labs(
         x="Eucledian Distance of Preprint-Published Versions",
         y="Time Elapsed Until Preprint is Published",
         legend="log(count)",