• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nz-gravity / LogPSplinePSD / 16308981650

16 Jul 2025 02:36AM UTC coverage: 74.293% (-1.4%) from 75.644%
16308981650

push

github

avivajpeyi
refactoring to use a common parent class

76 of 108 branches covered (70.37%)

Branch coverage included in aggregate %.

246 of 280 new or added lines in 7 files covered. (87.86%)

6 existing lines in 1 file now uncovered.

843 of 1129 relevant lines covered (74.67%)

1.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.93
/src/log_psplines/plotting/__init__.py
1
from typing import Tuple
2✔
2

3
import arviz as az
2✔
4
import matplotlib.pyplot as plt
2✔
5
import numpy as np
2✔
6
from jax import numpy as jnp
2✔
7
from numpyro.infer import MCMC
2✔
8

9
from .pdgrm import plot_pdgrm
2✔
10

11
__all__ = ["plot_pdgrm", "plot_trace"]
2✔
12

13

14
def plot_trace(mcmc: MCMC, fname=None):
2✔
UNCOV
15
    inf_obj = az.from_numpyro(mcmc)
×
UNCOV
16
    ax = az.plot_trace(inf_obj)
×
UNCOV
17
    plt.tight_layout()
×
UNCOV
18
    if fname is not None:
×
UNCOV
19
        plt.savefig(fname)
×
UNCOV
20
        plt.close(ax.flatten()[0].figure)
×
21

22

23
def plot_basis(basis: np.ndarray, fname=None) -> Tuple[plt.Figure, plt.Axes]:
2✔
24
    """Plot the basis functions, and a histogram of the basis values"""
25
    fig, axes = plt.subplots(1, 2, figsize=(6, 4))
2✔
26

27
    ax = axes[0]
2✔
28
    for b in basis.T:
2✔
29
        ax.plot(b)
2✔
30
    print(basis.T.shape)
2✔
31
    ax.set_xlabel("Sample Index")
2✔
32
    ax.set_ylabel("Basis Value")
2✔
33

34
    # min non-zero value for histogram'
35
    basis_vals = basis.ravel()
2✔
36
    min_b = np.min(basis_vals[basis_vals > 0])
2✔
37
    max_b = np.max(basis_vals)
2✔
38
    min_b = np.max([min_b, 1e-1])  # avoid log(0)
2✔
39

40
    ax = axes[1]
2✔
41
    ax.hist(
2✔
42
        basis_vals,
43
        bins=np.geomspace(min_b, max_b, 50),
44
        density=True,
45
        alpha=0.7,
46
    )
47
    ax.set_xlabel("Basis Value")
2✔
48
    ax.set_xscale("log")
2✔
49
    # add a textbox of the sparsity of the basis
50
    sparsity = np.mean(basis == 0)
2✔
51
    ax.text(
2✔
52
        0.05,
53
        0.95,
54
        f"Sparsity: {sparsity:.2f}",
55
        transform=ax.transAxes,
56
        fontsize=12,
57
        verticalalignment="top",
58
    )
59

60
    plt.tight_layout()
2✔
61

62
    if fname is not None:
2✔
63
        plt.savefig(fname)
2✔
64
        plt.close(fig)
2✔
65

66
    return fig, ax
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc