Module eremitalpa.lib

Generic library functions.

Functions

def annotate_points(df: pandas.core.frame.DataFrame,
ax: matplotlib.axes._axes.Axes,
n: int = -1,
adjust: bool = True,
**kwds)

Label (x, y) points on a matplotlib ax.

Args

df
Pandas DataFrame with 2 columns, (x, y) respectively. Index contains the
labels.
n
Label this many points. Default (-1) annotates all points.
ax
Matplotlib ax
adjust
Use adjustText.adjust_text to try to prevent label overplotting.
**kwds
Passed to adjustText.adjustText
def cal_months_diff(date1: pandas._libs.tslibs.timestamps.Timestamp,
date0: pandas._libs.tslibs.timestamps.Timestamp) ‑> int

Number of calendar months between two dates (date1 - date0)

def compute_errorbars(trace: arviz.data.inference_data.InferenceData,
varname: str,
hdi_prob: float = 0.95) ‑> numpy.ndarray

Compute HDI widths for plotting with plt.errorbar.

Args

trace
E.g. the output from pymc.sample.
varname
Variable to compute error bars for.
hdi_prob
Width of the HDI.

Returns

(2, n) array of the lower and upper error bar sizes for passing to plt.errorbar.

def find_runs(arr: numpy.ndarray) ‑> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Find runs of consecutive items in an array.

Args

arr
An array

Returns

3-tuple containing run values, starts and lengths.

def log_df_func(f: Callable, *args, **kwargs)

Callable should return a DataFrame. Report time taken to call a function, and the shape of the resulting DataFrame.

def mean(values)
def split_pairs(values: Iterable, separation: float = 1.0) ‑> list

If values are repeated, e.g.:

1, 5, 5, 8

Then 'split' them by adding and subtracting half of separation (default=1.0 -> 0.5) from each item in the pair:

1, 4.5, 5.5, 8