Skip to content

Instantly share code, notes, and snippets.

View jpata's full-sized avatar

Joosep Pata jpata

View GitHub Profile
@jpata
jpata / gist:9e7e92173001b4e13eebc87cbf25984e
Created December 21, 2022 09:47
awkward vector numba error message
cat err.log
vector 0.10.0
awkward 2.0.2
numba 0.56.4
Traceback (most recent call last):
File "test.py", line 24, in <module>
match_jets(vec1, vec2, 0.3)
File "/usr/local/lib/python3.8/dist-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
error_rewrite(e, 'typing')
File "/usr/local/lib/python3.8/dist-packages/numba/core/dispatcher.py", line 409, in error_rewrite
@jpata
jpata / example.py
Created November 24, 2022 09:01
pkdgrav3 compilation
import pynbody
import matplotlib.pyplot as plt
import numpy as np
s = pynbody.load("./pkdgrav3/examples/example.00140")
plt.figure(figsize=(6,5))
b = np.linspace(-0.5, 0.5, 256)
plt.hist2d(s["pos"][:, 0], s["pos"][:, 1], bins=(b, b), cmap="Blues");
plt.colorbar()
import tensorflow as tf
import numpy as np
#download model_full from https://jpata.web.cern.ch/jpata/2101.08578/v2/model_full.tar.gz
#untar the archive
#note that the custom loss is not included!
model = tf.keras.models.load_model("model_full")
model.summary()
#(batch size, elements in event, features)
@jpata
jpata / 32066.patch
Created November 23, 2020 10:59
32066 remove friend class
diff --git a/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h b/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
index f5d44be83fc..65ab6127780 100644
--- a/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
+++ b/CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h
@@ -6,14 +6,8 @@
#include "CondFormats/Serialization/interface/Serializable.h"
-namespace reco {
- class MustacheSCParametersHelper;
@jpata
jpata / test_root.py
Created May 11, 2020 16:54
ROOT histogram bins
import ROOT
from test_uproot import vals
if __name__ == "__main__":
h = ROOT.TH1D("h", "h", 10, 0, 1)
for v in vals:
h.Fill(v)
print("h1")
@jpata
jpata / mylib.cc
Created May 23, 2019 17:32
numba CFFI class method C wrapper
//compile with g++ -fPIC mylib.cc -shared -o mylib.dylib
class MyClass {
public:
MyClass(const char* filename) {
//do something with filename
}
double func(int a) {
//an expensive C++ function
@jpata
jpata / example_job.jdl
Last active September 4, 2019 20:25
Example Tier2 batch job
Universe = vanilla
Executable = example_job.sh
Arguments = 10
#The logs directory must exist
Log = logs/example_job.$(Cluster).log
Output = logs/example_job.out.$(Cluster).$(Process)
Error = logs/example_job.err.$(Cluster).$(Process)
@jpata
jpata / simple_loop.cc
Created August 24, 2018 18:41
Simple event loop on NanoAOD
//Compile with:
//c++ `root-config --cflags --libs --evelibs` -Wno-unsequenced -O3 code/simple_loop.cc -o simple_loop
#include <iostream>
#include <map>
#include <string>
#include <TFile.h>
#include <TROOT.h>
#include <TH1D.h>
@jpata
jpata / files
Last active April 4, 2017 16:08
[SingleElectron]
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_1.root = 0
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_10.root = 14136
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_100.root = 27350
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_101.root = 25062
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_102.root = 22851
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_103.root = 30098
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_104.root = 25321
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_105.root = 13815
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_106.root = 14586
@jpata
jpata / diff-setup.py
Created September 20, 2016 10:06
root_numpy setup.py patch
diff --git a/setup.py b/setup.py
index 6569037..48d1603 100755
--- a/setup.py
+++ b/setup.py
@@ -80,8 +80,9 @@ librootnumpy = Extension(
extra_compile_args=root_cflags + [
'-Wno-unused-function',
'-Wno-write-strings',
+ '-mmacosx-version-min=10.7'
],