Skip to content

Instantly share code, notes, and snippets.

View APN-Pucky's full-sized avatar

Alexander Puck Neuwirth APN-Pucky

View GitHub Profile
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import tkinter as tk
# Sample data: dictionary mapping names to image paths
image_data = {
'Image 1': 'image1.jpg',
'Image 2': 'image2.jpg',
'Image 3': 'image3.jpg'
}
$ equery g --depth=5 jupyter
* Searching for jupyter ...
* dependency graph for dev-python/jupyter-1.0.0-r4
`-- dev-python/jupyter-1.0.0-r4 amd64
`-- dev-python/jupyter-core-5.4.0 (>=dev-python/jupyter-core-4.2.0) amd64 [python_targets_python3_10(-)? python_targets_python3_11(-)? python_targets_python3_12(-)?]
`-- dev-python/platformdirs-3.11.0 (>=dev-python/platformdirs-2.5) amd64 [python_targets_python3_10(-)? python_targets_python3_11(-)? python_targets_python3_12(-)?]
`-- dev-python/pypy3-7.3.13 (dev-python/pypy3) amd64
`-- dev-python/pypy3_10-7.3.13_p1 (=dev-python/pypy3_10-7.3.13*) amd64 [gdbm? ncurses? sqlite? tk?]
`-- dev-python/pypy3_10-exe-7.3.13 (>=dev-python/pypy3_10-exe-7.3.13) amd64 [bzip2(+) ncurses?]
\s*TopologyList\[(.*)\]\[(\s*Topology\[(\d+)\]\[(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*),?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*)?,?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*)?,?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*)?,?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*)?,?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Field\[(\d+)\]\s*)\]\s*)?,?(\s*Propagator\[(Incoming|Outgoing|Internal)\]\[(\s*Vertex\[(\d+)\]\[(\d+)\]\s*),(\s*Vertex\[(\d+)\]\[(\d+)
@APN-Pucky
APN-Pucky / iminuit.ipynb
Created June 21, 2022 12:52
iminuit.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@APN-Pucky
APN-Pucky / fix_relative_unc_to_absolute_unc.py
Created May 19, 2022 09:05
Fix relative to absolute uncertainties in xsec jsons
import json
import sys
def recursive_for_replace(data):
if "xsec_pb" in data and "unc_pb" in data:
data["unc_pb"] = data["unc_pb"] * data["xsec_pb"]
return
for k in data:
recursive_for_replace(data[k])
@APN-Pucky
APN-Pucky / fix_duplicate_key_in_json.py
Created May 19, 2022 08:36
Python script to merge jsons with duplicate indices of dicts
import json
import sys
def myhook(pairs):
d = {}
for k, v in pairs:
if k not in d:
d[k] = v
else:
d[k] = {**d[k],**v}
sed -i "s/static_cast<long double>//g" *.cc *.h
sed -i "s/long double/double/g" *.cc *.h
sed -i "s/\([0-9]*\.[0-9]*\)L/\1/g" *.cc *.h
sed -i "s/\([0-9][0-9]*\.[0-9]*\)L/\1/g" *.cc *.h
sed -i "s/\([0-9][0-9]*\.[0-9][0-9]*\)L/\1/g" *.cc *.h
from multiprocessing import Process,Queue
import time
def queued(q,f,*args,**kwargs):
q.put(f(*args,**kwargs))
def res(a):
return next(a)
def gen(f,*args,**kwargs):
q = Queue()
p = Process(target=queued,args=(q,f,*args),kwargs=kwargs)
yield p.start()
from scipy.odr import *
def fit_curve(datax,datay,function,p0=None,yerr=None,xerr=None):
model = Model(lambda p,x : function(x,*p))
realdata = RealData(datax,datay,sx=xerr,sy=yerr)
odr = ODR(realdata,model,beta0=p0)
out = odr.run()
return unp.uarray(out.beta,out.sd_beta)