plot-io 0.12.0__py3-none-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plot_io/__init__.py +73 -0
- plot_io/_methods.py +1691 -0
- plot_io/_native/__init__.py +199 -0
- plot_io/_native/__main__.py +197 -0
- plot_io/_native/_api.py +457 -0
- plot_io/_native/bin/windows-arm64.dll +0 -0
- plot_io/_native/kernels.py +335 -0
- plot_io/_native/manifest.json +49 -0
- plot_io/axis.py +1347 -0
- plot_io/boxes.py +1156 -0
- plot_io/canvas.py +389 -0
- plot_io/color/__init__.py +3 -0
- plot_io/color/data.py +1646 -0
- plot_io/color/maps.py +922 -0
- plot_io/color/values.py +295 -0
- plot_io/color/variants.py +1246 -0
- plot_io/colorbar.py +1426 -0
- plot_io/columns.py +614 -0
- plot_io/decorations.py +920 -0
- plot_io/defaults.py +809 -0
- plot_io/density.py +113 -0
- plot_io/ext.py +68 -0
- plot_io/facets.py +240 -0
- plot_io/figure.py +788 -0
- plot_io/formatters.py +97 -0
- plot_io/genome/__init__.py +17 -0
- plot_io/genome/adapters.py +356 -0
- plot_io/genome/combine.py +123 -0
- plot_io/genome/contacts.py +508 -0
- plot_io/genome/intervals.py +750 -0
- plot_io/genome/lanes.py +191 -0
- plot_io/genome/layout.py +184 -0
- plot_io/genome/links.py +364 -0
- plot_io/genome/pack.py +27 -0
- plot_io/genome/readers.py +145 -0
- plot_io/genome/regions.py +228 -0
- plot_io/genome/scale.py +349 -0
- plot_io/genome/series.py +344 -0
- plot_io/genome/signal.py +621 -0
- plot_io/genome/sites.py +782 -0
- plot_io/genome/sources.py +459 -0
- plot_io/genome/testing.py +161 -0
- plot_io/geometry.py +289 -0
- plot_io/groups.py +308 -0
- plot_io/guides.py +503 -0
- plot_io/helpers/__init__.py +17 -0
- plot_io/helpers/clustermap.py +202 -0
- plot_io/helpers/dendrogram.py +172 -0
- plot_io/helpers/grids.py +304 -0
- plot_io/helpers/qq.py +334 -0
- plot_io/helpers/raincloud.py +249 -0
- plot_io/helpers/tree.py +214 -0
- plot_io/helpers/volcano.py +505 -0
- plot_io/hints.py +125 -0
- plot_io/kernels.py +740 -0
- plot_io/labels.py +566 -0
- plot_io/layers/__init__.py +100 -0
- plot_io/layers/base.py +630 -0
- plot_io/layers/context.py +87 -0
- plot_io/layers/core.py +446 -0
- plot_io/layers/geoms.py +1362 -0
- plot_io/layers/grammar.py +586 -0
- plot_io/layers/paint.py +614 -0
- plot_io/layers/pipeline.py +170 -0
- plot_io/layers/positions.py +431 -0
- plot_io/layers/stats.py +1088 -0
- plot_io/layout.py +1381 -0
- plot_io/legend.py +605 -0
- plot_io/levels.py +509 -0
- plot_io/limits.py +124 -0
- plot_io/lines.py +42 -0
- plot_io/mapped.py +522 -0
- plot_io/markers.py +110 -0
- plot_io/markup.py +128 -0
- plot_io/numbers.py +354 -0
- plot_io/occupancy.py +295 -0
- plot_io/plot.py +597 -0
- plot_io/presets/__init__.py +51 -0
- plot_io/presets/_util.py +153 -0
- plot_io/presets/area.py +145 -0
- plot_io/presets/bar.py +261 -0
- plot_io/presets/box.py +400 -0
- plot_io/presets/catpoints.py +177 -0
- plot_io/presets/contour.py +353 -0
- plot_io/presets/curves.py +30 -0
- plot_io/presets/dots.py +355 -0
- plot_io/presets/ecdf.py +97 -0
- plot_io/presets/errorbar.py +106 -0
- plot_io/presets/errors.py +296 -0
- plot_io/presets/fill.py +74 -0
- plot_io/presets/heatmap.py +322 -0
- plot_io/presets/hexbin.py +198 -0
- plot_io/presets/hist.py +391 -0
- plot_io/presets/hist2d.py +87 -0
- plot_io/presets/kde.py +162 -0
- plot_io/presets/kde2d.py +147 -0
- plot_io/presets/line.py +143 -0
- plot_io/presets/pie.py +502 -0
- plot_io/presets/regression.py +115 -0
- plot_io/presets/scatter.py +194 -0
- plot_io/presets/stem.py +100 -0
- plot_io/presets/violin.py +323 -0
- plot_io/py.typed +0 -0
- plot_io/registry.py +82 -0
- plot_io/render.py +480 -0
- plot_io/rows.py +491 -0
- plot_io/scales.py +103 -0
- plot_io/seams.py +138 -0
- plot_io/settings.py +807 -0
- plot_io/shapes.py +66 -0
- plot_io/sharing.py +232 -0
- plot_io/sizemaps.py +97 -0
- plot_io/spec.py +240 -0
- plot_io/states.py +216 -0
- plot_io/styles/__init__.py +307 -0
- plot_io/styles/library.py +397 -0
- plot_io/tables.py +138 -0
- plot_io/text.py +412 -0
- plot_io/ticks.py +400 -0
- plot_io/times.py +287 -0
- plot_io/titles.py +225 -0
- plot_io/transform.py +114 -0
- plot_io/types.py +13604 -0
- plot_io/units.py +768 -0
- plot_io/validators.py +1029 -0
- plot_io/values.py +190 -0
- plot_io-0.12.0.dist-info/METADATA +215 -0
- plot_io-0.12.0.dist-info/RECORD +130 -0
- plot_io-0.12.0.dist-info/WHEEL +4 -0
- plot_io-0.12.0.dist-info/licenses/LICENSE +28 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"""ctypes wrappers of the library's functions (stats.c, plot.c, colormap.c).
|
|
2
|
+
Inputs are ``array('d')``; :mod:`plot_io.kernels` holds the functions the rest of plot_io
|
|
3
|
+
calls."""
|
|
4
|
+
|
|
5
|
+
import array
|
|
6
|
+
import ctypes
|
|
7
|
+
|
|
8
|
+
from vec_io import threads as _threads
|
|
9
|
+
|
|
10
|
+
from . import _api, check, ctx, lib, ptr, take
|
|
11
|
+
|
|
12
|
+
#: Function names of :func:`scaled` and :func:`extent` -> their codes (plio_api.h).
|
|
13
|
+
FUNCTIONS = {None if k == "none" else k: v for k, v in _api.CODES["FN"].items()}
|
|
14
|
+
#: Codes of colormap.c (plio_api.h).
|
|
15
|
+
COLORMAP_MODES = _api.CODES["CMAP"]
|
|
16
|
+
COLORMAP_SPACES = _api.CODES["SPACE"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _zeros(n):
|
|
20
|
+
return array.array("d", bytes(8 * n))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _points(x, y, w=None):
|
|
24
|
+
return _api.Points(n=min(len(x), len(y)), x=ptr(x), y=ptr(y), w=ptr(w))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def function_code(function):
|
|
28
|
+
try:
|
|
29
|
+
return FUNCTIONS[function]
|
|
30
|
+
except (KeyError, TypeError):
|
|
31
|
+
names = ", ".join(repr(k) for k in FUNCTIONS)
|
|
32
|
+
raise ValueError(f"unknown function {function!r} (use {names})") from None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def scaled(values, scale, offset, function, low, high, under, over, nan, linthresh=1.0,
|
|
36
|
+
below=None, above=None):
|
|
37
|
+
n = len(values)
|
|
38
|
+
out = _zeros(n)
|
|
39
|
+
s = _api.Scale(function=function_code(function), has_nan=int(nan is not None),
|
|
40
|
+
has_below=int(below is not None), has_above=int(above is not None),
|
|
41
|
+
scale=scale, offset=offset, linthresh=linthresh, low=low, high=high,
|
|
42
|
+
under=under, over=over, nan_value=0.0 if nan is None else nan,
|
|
43
|
+
below=0.0 if below is None else below, above=0.0 if above is None else above)
|
|
44
|
+
check(lib().plio_scaled(ctx(), s, ptr(values), n, ptr(out)), "scaled")
|
|
45
|
+
return out
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def extent(values, function):
|
|
49
|
+
out = array.array("d", [0.0, 0.0])
|
|
50
|
+
count = lib().plio_extent(ctx(), ptr(values), len(values), function_code(function), ptr(out))
|
|
51
|
+
check(count, "extent")
|
|
52
|
+
return count, out[0], out[1]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def quantiles(values, qs):
|
|
56
|
+
qs = array.array("d", qs)
|
|
57
|
+
out = _zeros(len(qs))
|
|
58
|
+
check(lib().plio_quantiles(ctx(), ptr(values), len(values), ptr(qs), len(qs), ptr(out)),
|
|
59
|
+
"quantiles")
|
|
60
|
+
return list(out)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def box_stats(values, mode, a, b):
|
|
64
|
+
"""``(count, [mean, q1, median, q3, low, high], outliers array('d'))``; ``mode`` a
|
|
65
|
+
``_api.WHISKERS_*`` code."""
|
|
66
|
+
out = _zeros(6)
|
|
67
|
+
outliers_ptr = ctypes.c_void_p()
|
|
68
|
+
k = ctypes.c_int64()
|
|
69
|
+
rc = lib().plio_box_stats(ctx(), _api.Whiskers(mode=mode, a=a, b=b), ptr(values),
|
|
70
|
+
len(values), ptr(out), ctypes.byref(outliers_ptr),
|
|
71
|
+
ctypes.addressof(k))
|
|
72
|
+
check(rc, "box_stats")
|
|
73
|
+
outliers = array.array("d")
|
|
74
|
+
if k.value:
|
|
75
|
+
outliers.frombytes(take(outliers_ptr.value, 8 * k.value))
|
|
76
|
+
return rc, list(out), outliers
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def argsort(values, descending):
|
|
80
|
+
n = len(values)
|
|
81
|
+
out = array.array("q", bytes(8 * n))
|
|
82
|
+
check(lib().plio_argsort(ctx(), ptr(values), n, int(descending), ptr(out)), "argsort")
|
|
83
|
+
return out
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def take_rows(values, k, indices, base=None, n=None):
|
|
87
|
+
"""Rows ``indices`` (``array('q')``) of ``values`` (``array('d')``, rows of ``k``), or of
|
|
88
|
+
``n`` rows at address ``base`` when given. Large gathers are split over the worker
|
|
89
|
+
threads."""
|
|
90
|
+
m = len(indices)
|
|
91
|
+
out = array.array("d", [0.0]) * (m * k) if m * k else array.array("d")
|
|
92
|
+
if not m:
|
|
93
|
+
return out
|
|
94
|
+
if base is None:
|
|
95
|
+
base, n = ptr(values), len(values) // k
|
|
96
|
+
f = lib().plio_take
|
|
97
|
+
ip, op = ptr(indices), ptr(out)
|
|
98
|
+
step = max(65536, -(-m // (4 * _threads.count()))) if m * k >= 1 << 20 else m
|
|
99
|
+
|
|
100
|
+
def run(i0):
|
|
101
|
+
j = min(i0 + step, m) - i0
|
|
102
|
+
return check(f(ctx(), base, n, k, ip + 8 * i0, j, op + 8 * k * i0), "take", IndexError)
|
|
103
|
+
|
|
104
|
+
_threads.map_ordered(run, range(0, m, step))
|
|
105
|
+
return out
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def group_summary(values, rows, cols, groups, ngroups, threshold):
|
|
109
|
+
"""``(sums, counts, counts above, sums above)`` of the finite values, each
|
|
110
|
+
``array('d')`` of ``ngroups`` x ``cols``, of the ``rows`` x ``cols`` matrix ``values``;
|
|
111
|
+
``groups`` (``array('q')``) holds each row's group, or -1 to leave it out."""
|
|
112
|
+
cells = ngroups * cols
|
|
113
|
+
out = _zeros(4 * cells)
|
|
114
|
+
s = _api.Summary(rows=rows, cols=cols, groups=ngroups, threshold=threshold,
|
|
115
|
+
group=ptr(groups))
|
|
116
|
+
check(lib().plio_group_summary(ctx(), s, ptr(values), ptr(out)), "group_summary")
|
|
117
|
+
return out[:cells], out[cells:2 * cells], out[2 * cells:3 * cells], out[3 * cells:]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def colors_at(values, table, steps, under, over, bad):
|
|
121
|
+
"""RGBA (``array('d')``, 4 per value) of a color lookup: ``table`` holds 4 doubles per
|
|
122
|
+
entry, evenly sampled, or one per step starting at ``steps``; see stats.c."""
|
|
123
|
+
n = len(values)
|
|
124
|
+
out = _zeros(4 * n)
|
|
125
|
+
lut = _api.Lookup(m=len(table) // 4, table=ptr(table), steps=ptr(steps),
|
|
126
|
+
flags=sum(bit for bit, c in zip((1, 2, 4), (under, over, bad))
|
|
127
|
+
if c is not None))
|
|
128
|
+
for name, c in (("under", under), ("over", over), ("bad", bad)):
|
|
129
|
+
if c is not None:
|
|
130
|
+
getattr(lut, name)[:] = [float(v) for v in c[:4]]
|
|
131
|
+
check(lib().plio_colors_at(ctx(), lut, ptr(values), n, ptr(out)), "colors_at")
|
|
132
|
+
return out
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def cells(values, lo, hi, levels, split):
|
|
136
|
+
"""``(out, bad count)``: color table indices (``levels`` > 0) or positions (``levels`` 0) of
|
|
137
|
+
``values`` over [lo, hi], as ``array('d')``; see stats.c."""
|
|
138
|
+
n = len(values)
|
|
139
|
+
out = _zeros(n)
|
|
140
|
+
m = _api.CellMap(lo=lo, hi=hi, levels=levels, split=int(split))
|
|
141
|
+
bad = check(lib().plio_cells(ctx(), m, ptr(values), n, ptr(out)), "cells")
|
|
142
|
+
return out, bad
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def colormap_eval(stops, mode, space, ts):
|
|
146
|
+
"""RGBA (``array('d')``, 4 per value) at positions ``ts`` (``array('d')``) of the map
|
|
147
|
+
with ``stops`` ``(position, rgba)``; see colormap.c."""
|
|
148
|
+
pos = array.array("d", [p for p, _ in stops])
|
|
149
|
+
rgba = array.array("d", [v for _, c in stops for v in c])
|
|
150
|
+
n = len(ts)
|
|
151
|
+
out = _zeros(4 * n)
|
|
152
|
+
s = _api.Stops(m=len(stops), mode=COLORMAP_MODES[mode], space=COLORMAP_SPACES[space],
|
|
153
|
+
pos=ptr(pos), rgba=ptr(rgba))
|
|
154
|
+
check(lib().plio_colormap_eval(ctx(), s, ptr(ts), n, ptr(out)), "colormap_eval")
|
|
155
|
+
return out
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# --------------------------------------------------------------------------
|
|
159
|
+
# plot.c
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def histogram(values, edges, weights):
|
|
163
|
+
out = _zeros(max(len(edges) - 1, 0))
|
|
164
|
+
check(lib().plio_histogram(ctx(), ptr(values), len(values), ptr(weights), ptr(edges),
|
|
165
|
+
len(edges), ptr(out)),
|
|
166
|
+
"histogram")
|
|
167
|
+
return out
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def histogram2d(x, y, weights, x_edges, y_edges):
|
|
171
|
+
out = _zeros(max(len(x_edges) - 1, 0) * max(len(y_edges) - 1, 0))
|
|
172
|
+
check(lib().plio_histogram2d(ctx(), _api.Points(n=len(x), x=ptr(x), y=ptr(y), w=ptr(weights)),
|
|
173
|
+
ptr(x_edges), len(x_edges), ptr(y_edges), len(y_edges), ptr(out)),
|
|
174
|
+
"histogram2d")
|
|
175
|
+
return out
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def hexbin(x, y, weights, x0, y0, dx, dy, nx, ny):
|
|
179
|
+
out = _zeros(2 * nx * ny)
|
|
180
|
+
g = _api.Hexgrid(nx=nx, ny=ny, x0=x0, y0=y0, dx=dx, dy=dy)
|
|
181
|
+
check(lib().plio_hexbin(ctx(), _api.Points(n=len(x), x=ptr(x), y=ptr(y), w=ptr(weights)), g,
|
|
182
|
+
ptr(out)), "hexbin")
|
|
183
|
+
return out
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def moments(values, weights):
|
|
187
|
+
"""``(count, sum w, sum w^2, mean, sum w d^2, sum w d^3)``."""
|
|
188
|
+
out = _zeros(5)
|
|
189
|
+
rc = check(lib().plio_moments(ctx(), ptr(values), ptr(weights), len(values), ptr(out)),
|
|
190
|
+
"moments")
|
|
191
|
+
return (rc, *out)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def moments2(x, y, weights):
|
|
195
|
+
"""``(count, sum w, sum w^2, mean x, mean y, sum w dx^2, sum w dy^2, sum w dx dy)``."""
|
|
196
|
+
out = _zeros(7)
|
|
197
|
+
rc = check(lib().plio_moments2(ctx(), _points(x, y, weights), ptr(out)), "moments2")
|
|
198
|
+
return (rc, *out)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def ecdf(values, weights):
|
|
202
|
+
n = len(values)
|
|
203
|
+
xs, cs = _zeros(n), _zeros(n)
|
|
204
|
+
m = check(lib().plio_ecdf(ctx(), ptr(values), ptr(weights), n, ptr(xs), ptr(cs)), "ecdf")
|
|
205
|
+
return xs[:m], cs[:m]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def kde(values, weights, lo, hi, n, bandwidth, cumulative):
|
|
209
|
+
out = _zeros(n)
|
|
210
|
+
g = _api.KdeGrid(m=n, cumulative=int(cumulative), lo=lo, hi=hi, bw=bandwidth)
|
|
211
|
+
check(lib().plio_kde(ctx(), g, ptr(values), ptr(weights), len(values), ptr(out)), "kde")
|
|
212
|
+
return out
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _take_doubles(p, n):
|
|
216
|
+
out = array.array("d")
|
|
217
|
+
if n:
|
|
218
|
+
out.frombytes(take(p, 8 * n))
|
|
219
|
+
elif p:
|
|
220
|
+
take(p, 0)
|
|
221
|
+
return out
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _take_int64(p, n):
|
|
225
|
+
out = array.array("q")
|
|
226
|
+
if n:
|
|
227
|
+
out.frombytes(take(p, 8 * n))
|
|
228
|
+
return out
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _grid(grid, w, h, xs, ys):
|
|
232
|
+
return _api.Grid(w=w, h=h, g=ptr(grid), xs=ptr(xs), ys=ptr(ys))
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def contour_lines(grid, w, h, xs, ys, level):
|
|
236
|
+
xy, starts, closed = ctypes.c_void_p(), ctypes.c_void_p(), ctypes.c_void_p()
|
|
237
|
+
k = lib().plio_contour_lines(ctx(), _grid(grid, w, h, xs, ys), level, ctypes.byref(xy),
|
|
238
|
+
ctypes.byref(starts), ctypes.byref(closed))
|
|
239
|
+
check(k, "contour_lines")
|
|
240
|
+
st = _take_int64(starts.value, k + 1) if k else array.array("q")
|
|
241
|
+
flags = take(closed.value, k) if k else b""
|
|
242
|
+
pts = _take_doubles(xy.value, 2 * st[-1] if k else 0)
|
|
243
|
+
if not k and starts.value:
|
|
244
|
+
take(starts.value, 0)
|
|
245
|
+
return pts, st, flags
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def contour_bands(grid, w, h, xs, ys, lo, hi):
|
|
249
|
+
xy, starts = ctypes.c_void_p(), ctypes.c_void_p()
|
|
250
|
+
k = lib().plio_contour_bands(ctx(), _grid(grid, w, h, xs, ys), lo, hi, ctypes.byref(xy),
|
|
251
|
+
ctypes.byref(starts))
|
|
252
|
+
check(k, "contour_bands")
|
|
253
|
+
st = _take_int64(starts.value, k + 1)
|
|
254
|
+
pts = _take_doubles(xy.value, 2 * st[-1] if len(st) else 0)
|
|
255
|
+
return pts, st
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def lowess(x, y, frac, iterations, delta):
|
|
259
|
+
out = _zeros(len(x))
|
|
260
|
+
args = _api.LowessArgs(frac=frac, iterations=iterations, delta=delta)
|
|
261
|
+
check(lib().plio_lowess(ctx(), args, ptr(x), ptr(y), len(x), ptr(out)),
|
|
262
|
+
"lowess")
|
|
263
|
+
return out
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def swarm(positions, sizes, uniform, slot_width):
|
|
267
|
+
out = _zeros(len(positions))
|
|
268
|
+
rc = check(lib().plio_swarm(ctx(), ptr(positions), ptr(sizes), 0 if uniform else 1,
|
|
269
|
+
len(positions), slot_width, ptr(out)),
|
|
270
|
+
"swarm")
|
|
271
|
+
return out, rc
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def kde2d(x, y, weights, h, tx, ty, grid=None):
|
|
275
|
+
"""Density at the targets ``(tx, ty)``: exact sums, or through a lattice of at least
|
|
276
|
+
``grid`` points per side (see plot.c), with the blur and the sampling split over the
|
|
277
|
+
worker threads. Results do not depend on the split."""
|
|
278
|
+
f = lib()
|
|
279
|
+
m = min(len(tx), len(ty))
|
|
280
|
+
pts = _points(x, y, weights)
|
|
281
|
+
kern = _api.Kernel2d(h11=h[0], h12=h[1], h22=h[2])
|
|
282
|
+
what = "kde2d"
|
|
283
|
+
if grid is None:
|
|
284
|
+
out = _zeros(m)
|
|
285
|
+
check(f.plio_kde2d_exact(ctx(), pts, kern, ptr(tx), ptr(ty), m, ptr(out)), what)
|
|
286
|
+
return out
|
|
287
|
+
params = _zeros(12)
|
|
288
|
+
ns = check(f.plio_kde2d_setup(ctx(), pts, kern, grid, ptr(params)), what)
|
|
289
|
+
if not ns:
|
|
290
|
+
nan = float("nan")
|
|
291
|
+
return array.array("d", (0.0 if tx[i] - tx[i] == 0 and ty[i] - ty[i] == 0 else nan
|
|
292
|
+
for i in range(m)))
|
|
293
|
+
gu, gv, L = int(params[3]), int(params[4]), int(params[9])
|
|
294
|
+
delta, var = params[2], params[10]
|
|
295
|
+
lat, tmp = _zeros(gu * gv), _zeros(gu * gv)
|
|
296
|
+
check(f.plio_kde2d_bin(ctx(), pts, ptr(params), ptr(lat)), what)
|
|
297
|
+
|
|
298
|
+
def blur(src, dst, rows, cols):
|
|
299
|
+
b = _api.Blur(rows=rows, cols=cols, L=L, delta=delta, var=var)
|
|
300
|
+
step = max(8, -(-rows // (4 * _threads.count())))
|
|
301
|
+
_threads.map_ordered(
|
|
302
|
+
lambda r0: check(f.plio_kde2d_blur(ctx(), b, ptr(src), ptr(dst), r0,
|
|
303
|
+
min(r0 + step, rows)), what),
|
|
304
|
+
range(0, rows, step))
|
|
305
|
+
|
|
306
|
+
blur(lat, tmp, gv, gu) # along v
|
|
307
|
+
check(f.plio_transpose(ctx(), ptr(tmp), ptr(lat), gv, gu), what)
|
|
308
|
+
blur(lat, tmp, gu, gv) # along u: tmp holds gu rows of gv
|
|
309
|
+
out = _zeros(m)
|
|
310
|
+
base = out.buffer_info()[0]
|
|
311
|
+
step = 65536
|
|
312
|
+
|
|
313
|
+
def sample(i0):
|
|
314
|
+
k = min(i0 + step, m) - i0
|
|
315
|
+
check(f.plio_kde2d_sample(ctx(), ptr(params), ptr(tmp), ptr(tx) + 8 * i0,
|
|
316
|
+
ptr(ty) + 8 * i0, k, base + 8 * i0), what)
|
|
317
|
+
|
|
318
|
+
if m:
|
|
319
|
+
_threads.map_ordered(sample, range(0, m, step))
|
|
320
|
+
return out
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
#: Codes of cluster.c (plio_api.h).
|
|
324
|
+
LINKAGE_METHODS = _api.CODES["LINKAGE"]
|
|
325
|
+
LINKAGE_METRICS = _api.CODES["METRIC"]
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def linkage(data, n, d, method, metric):
|
|
329
|
+
"""The ``(n - 1) x 4`` merges (``array('d')``) of ``n`` rows of ``d`` values, or of a
|
|
330
|
+
condensed distance vector (``metric`` "precomputed"); see cluster.c."""
|
|
331
|
+
z = ctypes.c_void_p()
|
|
332
|
+
args = _api.LinkageArgs(n=n, d=d, method=LINKAGE_METHODS[method],
|
|
333
|
+
metric=LINKAGE_METRICS[metric], data=ptr(data))
|
|
334
|
+
k = check(lib().plio_linkage(ctx(), args, ctypes.byref(z)), "linkage")
|
|
335
|
+
return _take_doubles(z.value, 4 * k)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"abi": 5,
|
|
3
|
+
"cflags": [
|
|
4
|
+
"-ffreestanding",
|
|
5
|
+
"-nostdlib",
|
|
6
|
+
"-fno-builtin",
|
|
7
|
+
"-fno-stack-protector",
|
|
8
|
+
"-O2",
|
|
9
|
+
"-fPIC",
|
|
10
|
+
"-fvisibility=hidden",
|
|
11
|
+
"-g0",
|
|
12
|
+
"-std=c11",
|
|
13
|
+
"-Wall",
|
|
14
|
+
"-Wextra",
|
|
15
|
+
"-Werror",
|
|
16
|
+
"-Wframe-larger-than=4096",
|
|
17
|
+
"-ffp-contract=off",
|
|
18
|
+
"-fno-math-errno"
|
|
19
|
+
],
|
|
20
|
+
"files": {
|
|
21
|
+
"linux-aarch64.so": {
|
|
22
|
+
"sha256": "55f6c8121722cf5fe95505cbbfaf3129bc99ee99dbed3a1917eadbaa84f4e72f",
|
|
23
|
+
"size": 72944,
|
|
24
|
+
"target": "aarch64-linux-musl"
|
|
25
|
+
},
|
|
26
|
+
"linux-x86_64.so": {
|
|
27
|
+
"sha256": "ad9da1225399d1a7bc4f05af9f346665967647c66c073176a3fb2514a4d7a65e",
|
|
28
|
+
"size": 88816,
|
|
29
|
+
"target": "x86_64-linux-musl"
|
|
30
|
+
},
|
|
31
|
+
"macos-arm64.dylib": {
|
|
32
|
+
"sha256": "cb1b3f7a43ea640fe1a22b53af14adcc8809816777a66bb2a6768d486126c18a",
|
|
33
|
+
"size": 117936,
|
|
34
|
+
"target": "aarch64-macos"
|
|
35
|
+
},
|
|
36
|
+
"windows-arm64.dll": {
|
|
37
|
+
"sha256": "6eff70aefdbcb0e289bfc10402aa20785640deef0ec8486131991776a54acbcc",
|
|
38
|
+
"size": 69632,
|
|
39
|
+
"target": "aarch64-windows-gnu"
|
|
40
|
+
},
|
|
41
|
+
"windows-x86_64.dll": {
|
|
42
|
+
"sha256": "4fc839a73a103cd0c78abb073b5fd19c083933434e9ecb48a084ce3033ade76c",
|
|
43
|
+
"size": 91136,
|
|
44
|
+
"target": "x86_64-windows-gnu"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"source_sha256": "1bd1a5c31bba3b2db0bbee55030e22e237544d79733df6cabd4c7fce0d26a7d3",
|
|
48
|
+
"zig": "0.15.1"
|
|
49
|
+
}
|