Skip to content

Instantly share code, notes, and snippets.

View mxposed's full-sized avatar

Nick Markov mxposed

View GitHub Profile
fig, ax = plt.subplots(figsize=(8, 8))
sc.pl.umap(ds, color="cell_type", legend_loc="on data", size=10, ax=ax, show=False)
shrink_by = 0.1
xlim = ax.get_xlim()
ylim = ax.get_ylim()
xbound = xlim[0] + (xlim[1] - xlim[0]) * shrink_by
ybound = ylim[0] + (ylim[1] - ylim[0]) * shrink_by
b = ax.spines["bottom"]
@wlchn
wlchn / QuickSelect median of medians.js
Last active September 5, 2021 01:37 — forked from LeeYeeze/QuickSelect median of medians.js
Median of medians javascript - find median in an unsorted array, worst-case complexity O(n).
// Median of medians: https://en.wikipedia.org/wiki/Median_of_medians
// find median in an unsorted array, worst-case complexity O(n).
export const selectMedian = (arr, compare) => {
return selectK(arr, Math.floor(arr.length / 2), compare);
};
export const selectK = (arr, k, compare) => {
if (!Array.isArray(arr) || arr.length === 0 || arr.length - 1 < k) {
return;
}