How to use the corner.quantile function in corner

To help you get started, we’ve selected a few corner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfm / corner.py / tests / test_quantile.py View on Github external
def test_weighted_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)
    a = corner.quantile(x, q, weights=np.ones_like(x))
    b = np.percentile(x, 100 * np.array(q))
    assert np.allclose(a, b)

    q = [0.0, 1.0]
    a = corner.quantile(x, q, weights=np.random.rand(len(x)))
    assert np.allclose(a, (np.min(x), np.max(x)))
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_1(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), [-0.1, 5])
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_2(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), 5)
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_dimension_mismatch(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(
            np.random.rand(100), [0.1, 0.5], weights=np.random.rand(3)
        )
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_valid_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)

    a = corner.quantile(x, q)
    b = np.percentile(x, 100 * q)
    assert np.allclose(a, b)
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_3(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), [0.5, 1.0, 8.1])
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_weighted_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)
    a = corner.quantile(x, q, weights=np.ones_like(x))
    b = np.percentile(x, 100 * np.array(q))
    assert np.allclose(a, b)

    q = [0.0, 1.0]
    a = corner.quantile(x, q, weights=np.random.rand(len(x)))
    assert np.allclose(a, (np.min(x), np.max(x)))
github rodluger / starry / tex / figures / hd189733b.py View on Github external
# Maximum likelihood values. Obtained from the gradient
        # descent optimization step.
        mapvals = np.array([0.11145594, 0.54403427, 0.15739444, 0.00205864])

        fig = corner.corner(self.samples2, labels=self.labels2,
                            bins=45, show_titles=True, title_fmt='.3f')
        for ax in fig.axes:
            ax.xaxis.label.set_fontsize(20)
            ax.yaxis.label.set_fontsize(20)
            ax.title.set_fontsize(18)

        # DEBUG: The luminosity standard deviaton is too small
        # for the label, so we need one more sig fig. Hacking it
        # manually here.
        q_16, q_50, q_84 = corner.quantile(self.samples2[:, 3],
                                           [0.16, 0.5, 0.84])
        q_m, q_p = q_50-q_16, q_84-q_50
        fmt = "{{0:{0}}}".format(".4f").format
        Ltitle = r"${{{0}}}_{{-{1}}}^{{+{2}}}$"
        Ltitle = r"$L = $" + Ltitle.format(fmt(q_50), fmt(q_m), fmt(q_p))
        fig.axes[21].set_title(Ltitle, fontsize=16)

        left = 0.55
        bottom = 0.55
        width = 0.45
        height = 0.45
        ax = fig.add_axes([left, bottom, width, height])

        xx, yy = np.meshgrid(np.linspace(-1, 1, 300), np.linspace(-1, 1, 300))

        set_coeffs(mapvals, self.planet)

corner

Make some beautiful corner plots

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

69 / 100
Full package analysis