Skip to content

Instantly share code, notes, and snippets.

View riga's full-sized avatar

Marcel Rieger riga

View GitHub Profile
@riga
riga / gen_interface_numpy.h
Last active December 19, 2024 15:15
Numpy random generator with C API
/*
Interface for accessing Numpy's random number generators and configurable
bit generators via its C API. Usage example in main.cpp below.
Author: Marcel Rieger
*/
#include <string>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
@riga
riga / seeds.py
Last active January 15, 2025 14:14
Deterministic seeds per event and per jet
# coding: utf-8
"""
Pseudo code for generating deterministic event and jet seeds,
to be used in random number generators with consistent output.
The seeds use the entire uint64 space and are proven to be
uniformly distributed using bijective hashing.
It requires a list of the first 200 primes plus some event
@riga
riga / test.ipynb
Last active August 28, 2024 13:39
jax2xla2aot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@riga
riga / srvstatic
Last active June 7, 2024 11:57
static server
#!/usr/bin/env python
# coding: utf-8
# python imports
import os
import cherrypy
class Server(object):
@riga
riga / job.jdl
Last active February 8, 2024 19:19
htcondor test
universe = vanilla
executable = job.sh
log = /dev/null
should_transfer_files = YES
transfer_input_files = job.sh
when_to_transfer_output = ON_EXIT
output = out.txt
error = err.txt
notification = Never
initialdir = /afs/cern.ch/user/m/mrieger/htctest
@riga
riga / pytorch_grad_stop.py
Created October 30, 2023 09:15
Test partial gradient stopping in PyTorch
# coding: utf-8
"""
Setup via
> pip install torch torchvision
"""
from __future__ import annotations
from contextlib import contextmanager
@riga
riga / tasks.py
Last active August 26, 2023 18:21
Dynamic law workflows
# coding: utf-8
import law
class LongRunning(law.Task):
def output(self):
return law.LocalFileTarget("$PWD/data/long_running.json")
@riga
riga / evaluate_klub.py
Last active July 11, 2023 09:09
Evaluation script for KLUB samples
# coding: utf-8
from __future__ import annotations
import os
from fnmatch import fnmatch
from multiprocessing import Pool as ProcessPool
from typing import Any
from tqdm import tqdm
@riga
riga / nano_unique.py
Created July 5, 2023 09:18
Merge two NanoAOD files while removing duplicate events
#!/usr/bin/env python3
# coding: utf-8
"""
Script that merges the events tree of two NanoAOD files, removing duplicates identified
by event number, run number and luminosity block.
> nano_unique.py in1.root in2.root out.root
NOTE: This is just a first draft whose performance could surely be improved
# coding: utf-8
import dask_awkward as dak
import awkward as ak
# located at https://cernbox.cern.ch/remote.php/dav/public-files/rvipIIozKQAypwu/calib.parquet
input_path = "calib.parquet"