Skip to content

Instantly share code, notes, and snippets.

View matthewfeickert's full-sized avatar

Matthew Feickert matthewfeickert

View GitHub Profile
@matthewfeickert
matthewfeickert / roussou_debug.py
Last active October 29, 2020 03:42
David Rousso toys notebook converted to script
import numpy as np
import pyhf
stopRHadron_spec = {
'channels': [
{
'name': 'channel1',
'samples': [
{
'data': [1.364790054231882],
@matthewfeickert
matthewfeickert / CMakeLists.txt
Last active July 1, 2020 06:12
Minimal failing exampe of CMake
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 14)
project(testing_frugal)
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.8.0
@matthewfeickert
matthewfeickert / .gitignore
Last active July 10, 2020 08:43
xAH CMake FetchContent problem
*.asetup.save
build/
submitDir/
@matthewfeickert
matthewfeickert / README.md
Last active July 15, 2020 03:08
Python dependency thoughts

This got long, so TLDR: Micky's reactions are what I would call "correct". If people want reproducible environments that's great, but pip freeze is not going to get you there.

The answer is (like most things in life) it depends. What are you trying to do? I tend to split along this line into two idea groups: "libraries" and "applications".

At this point I'd suggest that you read the following to make sure that we're on the same page about these words.

Hopefully you read them, but the TLDR on those is:

  • Libraries are supposed to work in an ecosystem of things and so should strive to only require the minimum restrictions on dependencies that will still gaurentee a stable API. Here you probably just want to have the core dependencies be specified with minimum version numbers or
@matthewfeickert
matthewfeickert / README.md
Last active July 29, 2020 19:41
pip is going to break your pip freeze requirements.txt so hard in October

Example of --use-feature=2020-resolver breaking a pip freeze requirements.txt

Breaking Example

If the environment that is created from

$ python -m pip install -r requirements_original.txt
@matthewfeickert
matthewfeickert / .gitignore
Last active August 21, 2020 08:04
Notes on choices of asymptotic test statistics in the LHC-era of likelihood-based analyses
.ipynb_checkpoints*
@matthewfeickert
matthewfeickert / .gitignore
Last active October 29, 2020 04:49
Henry's hist demo
.ipynb_checkpoints/
@matthewfeickert
matthewfeickert / .gitignore
Last active October 29, 2020 23:44
hist, uproot4 issue
.ipynb_checkpoints/
@matthewfeickert
matthewfeickert / README.md
Last active November 23, 2020 22:27
Example GPU benchmarking script

Benchmarking of pyhf pseudoexperiments on CPU and GPU vs. ROOT

Setup

Install pyhf with the JAX backend in a virtual environment either locally from the Git repo

python -m pip install --editable .[jax]
@matthewfeickert
matthewfeickert / README.md
Last active December 11, 2020 04:40
Interacting with JSON in R for Lauren

Writing and Reading JSON with jsonlite

Using the jsonlite library in R you can read, write, and manipulate JSON data.

This Gist contains an example (write_json.R) of writing a list containing ecological "data types" and arrays of column data types to a JSON file using jsonlite::write_json.

That JSON file nicely serializes a mapping of the key values (e.g., "FSH", "IHI") — the ecological data types — to the associated data — the column data types.

To use this serialization (a data structure written to file) an example is given (read_json.R) in which it is read into a data frame using jsonlite::read_json.