Misc
utils
Miscellaneous utility functions (stdlib only).
Do not import any other modules from this package here.
hook
Wraps a function in a Hook object, making it interceptable.
Decorating a function with @hook allows its behavior to be observed,
extended, or even completely replaced by downstream code.
Example usage:
@hook
def foo(state, t):
... # pure jax/torch/numpy code...
import time
def timing_interceptor(original_fn, *args, **kwargs):
start = time.perf_counter()
result = original_fn(*args, **kwargs)
end = time.perf_counter()
print(f"{original_fn.__name__} took {end - start:.4f}s")
return result
foo.intercept(timing_interceptor)
Source code in src/aerocore/utils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Hook
A callable that implements the middleware pattern.
__call__
__call__(*args: args, **kwargs: kwargs) -> S
Source code in src/aerocore/utils.py
54 55 | |
intercept
Source code in src/aerocore/utils.py
57 58 59 60 61 62 63 64 | |
debug
Log the function arguments and result.
Source code in src/aerocore/utils.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
column
plot
Lightweight matplotlib utils.
When developing on a remote host, you may want to view interactive plots
in a web browser. Tunnel port 8988 and use WEB=1 python3 scripts/{}.py
to enable the webagg backend.
Requires extras:
matplotlibpolarsfor additional plots
CMapCycler
CMapCycler(cmap_name: str = 'tab10')
Source code in src/aerocore/plot.py
33 34 35 36 | |
init_style
Source code in src/aerocore/plot.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
new_figure
Source code in src/aerocore/plot.py
76 77 78 79 80 81 82 | |
setup_xy
setup_xy(
ax: Axes,
x: Column,
y: Column,
title: Callable[[Column, Column], str]
| Literal["default"]
| str
| None = None,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Callable[[Column, Column], str] | Literal['default'] | str | None
|
a function that computes the title from x and y, a fixed string, or explicitly None. |
None
|
Source code in src/aerocore/plot.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
add_linear_trendline
add_linear_trendline(
ax: Axes,
x: Series,
y: Series,
*,
x_symbol: str = "x",
y_symbol: str = "y",
with_legend: bool = True,
**kwargs: Any,
) -> None
Note: legend is NOT added, call ax.legend() manually.
Source code in src/aerocore/plot.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
basic_scatter
Source code in src/aerocore/plot.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |