Skip to content

Instantly share code, notes, and snippets.

View ajtritt's full-sized avatar

Andrew Tritt ajtritt

View GitHub Profile
@ajtritt
ajtritt / property_override.py
Created March 13, 2018 21:49
demonstrate override property
class MyClass(object):
def __init__(self, p):
self.__x = p
@property
def x(self):
return self.__x
@ajtritt
ajtritt / interval.py
Created March 28, 2018 03:01
An interval tree that only supports insertion and point-query
BLACK = 0
RED = 1
class Interval(object):
def __init__(self, start, end):
self.__start = start
self.__end = end
self.__max = end
self.__left = None
@ajtritt
ajtritt / convert_npy.py
Created August 3, 2020 20:55
Concatenate one or more .npy files into a dataset into an HDF5 file
import argparse
import sys
import h5py
import numpy as np
desc = '''
Concatenate one or more .npy files into a dataset into an HDF5 file
'''
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('output_h5', help='the .h5 file to write converted data to')
@ajtritt
ajtritt / ddp_bug_mwe.py
Created June 3, 2021 03:55
DDP bug MWE
import argparse
import os
import socket
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import transforms
from torchvision.datasets import MNIST
from torch.utils.data import DataLoader, random_split
import pytorch_lightning as pl