Skip to content

Instantly share code, notes, and snippets.

View jpivarski's full-sized avatar

Jim Pivarski jpivarski

  • Princeton, IRIS-HEP, PyHEP, Scikit-HEP
View GitHub Profile
@jpivarski
jpivarski / ReadOneBranch.java
Last active November 4, 2016 17:50
Performance test comparison of C++ ROOT and Java ROOT
import hep.io.root.core.RootInput;
import hep.io.root.*;
import hep.io.root.interfaces.*;
public class ReadOneBranch {
final static long itemsPerPrint = 100000L;
static long lastTime = 0L;
static long items = 0;
private static void printout() {
@jpivarski
jpivarski / xsimd.ipynb
Last active August 13, 2018 14:58
AVX-512 cumsum implementation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpivarski
jpivarski / hist.py
Last active April 22, 2019 07:46
Functional histogram slice proposal
import numbers
import math
import numpy
class Binning:
"Abstract superclass of all binning types. Only Regular is implemented."
def __init__(self, *args, **kwargs):
raise NotImplementedError
@jpivarski
jpivarski / growablebuffer.py
Last active April 1, 2020 16:40
GrowableBuffer in Numba
import sys
import operator
import numpy
# Note: these are pre-0.49 locations; things move around in Numba 0.49.
import numba
import numba.typing.arraydecl
# First, let's define the class in Python.

Requires scikit-hep/uproot4#35.

>>> import uproot4
>>> tbranchelement1 = uproot4.open("Event.root : T/fH")
>>> tbranchelement1
<TBranchElement 'fH' at 0x7f5ef03c92d0>
>>> tbranchelement1.interpretation
AsObjects(Model_TH1F)
>>> tbranchelement1.array(library="np", entry_stop=5)
@jpivarski
jpivarski / matplotlib-awkward.ipynb
Created July 29, 2020 16:36
Matplotlib should fail for unflattened arrays (as it does here)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
SELECT
DATE(timestamp) AS date,
details.system.name AS os,
file.project AS project,
REGEXP_REPLACE(file.version, "\\.[0123456789]{1,}$", "") AS version,
COUNT(*) AS count
FROM `the-psf.pypi.downloads*`
WHERE
_TABLE_SUFFIX BETWEEN '20160101' AND '20210224'
AND (file.project = "rootpy" OR
@jpivarski
jpivarski / assign-all-argtypes.py
Created May 26, 2021 21:34
Assigning ctypes argument types to all Awkward Array kernels from the YAML specification
import yaml
import awkward as ak
arg2key = {
"List[bool]": "np.bool_",
"Const[List[bool]]": "np.bool_",
"List[int8_t]": "np.int8",
"Const[List[int8_t]]": "np.int8",
"List[uint8_t]": "np.uint8",
@jpivarski
jpivarski / final-notebook.ipynb
Last active August 11, 2021 11:58
Replaced vibrating string's overtones with hydrogen atom in https://gist.github.com/endolith/3066664
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpivarski
jpivarski / avro-to-awkward.ipynb
Created January 11, 2022 21:18
Converting Avro Schemas into Awkward Forms
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.