Skip to content

Instantly share code, notes, and snippets.

View ashlaban's full-sized avatar
💭
Codin'

Kim Albertsson ashlaban

💭
Codin'
View GitHub Profile
@ashlaban
ashlaban / ArgumentParserDelegator.py
Last active August 29, 2019 14:29
A simple extension of `argparse.ArgumentParser` that supports multiple subcommands à la `program.py model path/to/model train --epochs 200` where `model` and `train` are distinct subcommands with their own corresponding (sub)parser.
import argparse
from collections import namedtuple as Namedtuple
class ArgumentParserDelegator(argparse.ArgumentParser):
'''Supports mutliple nested subparsers (structured parser)
A structured parser is one that supports multiple 'stages', or
'subcommands'.
@ashlaban
ashlaban / unique_ptr.cxx
Created August 20, 2019 09:43
Testing out unique pointers
#include <memory>
#include <vector>
int main(int argc, char** argv) {
// Create a unique pointer
auto a = std::make_unique<int>(argc);
// One can get a reference to its contents!
int const & b = *a;
#
# NOTE: Requires that you have run `python create_dataset.py`
# from https://github.com/stwunsch/tmva_mnist first.
#
import ROOT
from resnet import ResnetBuilder
# Setup TMVA
@ashlaban
ashlaban / resnet.py
Last active June 24, 2019 15:51
Taken from: https://github.com/raghakot/keras-resnet and adapted to accept flat array as input. Warning, hacky.
from __future__ import division
import six
from keras.models import Model
from keras.layers import (
Input,
Reshape,
Activation,
Dense,
Flatten
@ashlaban
ashlaban / params.py
Created October 26, 2018 13:06
Debating the proper formatting of python function definitions with long names and parameter names
# version 1
def function_with_snake_case_and_long_name(fix_param1, fix_param2,
keyword_param1='some default',
keyword_param2='some other defualt'):
# TODO: Implement function body
pass
# version 2
def function_with_snake_case_and_long_name(
void test() {
// === Provokes error
// root -l -q test.C
// or
// lldb -- root.exe -l -q test.C
// break set --name TH1::KolmogorovTest
const size_t NBINS = 200;
@ashlaban
ashlaban / build-root.sh
Last active May 17, 2017 17:08
Configuring and building ROOT
# Configuring and building ROOT
#
# The three lines for Python is to make cmake pick up the brew installation
# instead of the system one (important if you want to use pyROOT).
# Modify as you please.
#
cd /path/to/where/you/build/root
cmake /path/to/root/src \