Skip to content

Instantly share code, notes, and snippets.

@0x0L
0x0L / gen.py
Last active June 12, 2024 20:38
parallel_unique_merge.cpp
import numpy as np
N = 200
L = 10_000_000
p = 0.2
r = np.arange(L / p, dtype=int)
s = [
r[np.random.rand(r.shape[0]) > 1 - p]
for _ in range(N)
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <future>
#include <queue>
#include <condition_variable>
#include <mutex>
#include <functional>
from pathlib import Path
import numpy as np
import pandas as pd
class RaggedIndexer:
def __init__(self, counts):
self.stops = np.r_[0, np.cumsum(counts)]
self.starts = self.stops[:-1]
@0x0L
0x0L / root.sh
Last active July 7, 2023 07:59
Setup P3 EC2 Rocky 9
# https://rockylinux.org/cloud-images/
# AMI 0951577d22b8e8dd4 rocky 9.1
# Instance p3.2xlarge
dnf install -y epel-release
crb enable
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo
dnf module install -y nvidia-driver:latest
reboot
@0x0L
0x0L / DRE.py
Last active June 28, 2022 07:46
Deep Regression Ensembles
import numpy as np
from opt_einsum import contract
class DRE:
"""Deep Regression Ensemble
Parameters
----------
n_layers : int
Number of hidden layers.
@0x0L
0x0L / t.ipynb
Last active November 8, 2021 09:40
asyncpg / apache arrow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0x0L
0x0L / test.py
Created September 28, 2021 15:17
import os
from multiprocessing import get_context
from concurrent.futures import ProcessPoolExecutor
from concurrent.futures.thread import _global_shutdown_lock as L
os.register_at_fork(
before=L.acquire,
after_in_child=L._at_fork_reinit,
after_in_parent=L.release
@0x0L
0x0L / generic_linkage.py
Last active November 12, 2021 19:59
Clustering algorithms
import heapq
import numpy as np
def generic_linkage(D, method='single'):
N = D.shape[0]
S = set(range(N))
size = {i: 1 for i in range(N)}
d = {}
@0x0L
0x0L / sherman.py
Last active January 26, 2024 13:04
Fast moving window regressions
import numba
import numpy as np
@numba.jit(nopython=True, fastmath=True)
def move_regress(X, Y, w, fit_intercept=True):
"""Moving window multi-regressions
Solves the least-squares problems `Y[t-w+1:t+1] = X[t-w+1:t+1] @ B[t] + A[t]`
for `B` and `A` for all `t` in `[w-1, len(Y)-1]`.
@0x0L
0x0L / RMT autocorrelations.ipynb
Created January 12, 2020 21:41
RMT autocorrelations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.