Skip to content

Instantly share code, notes, and snippets.

View blazetopher's full-sized avatar

Christopher Mueller blazetopher

View GitHub Profile
@blazetopher
blazetopher / hdf_leak.py
Last active December 11, 2015 02:38
Demonstrates memory leak when writing attributes using h5py & HDF
if __name__ == '__main__':
import time
import h5py
import os
rng = range(1000)
reps = range(3)
op = 'test.h5py'
if os.path.exists(op): os.remove(op)
@blazetopher
blazetopher / monitor_dict_to_csv.py
Last active December 10, 2015 22:29
Convert data output from process monitor webapp to csv
def monitor_dict_to_csv(data_dict, outfile):
import csv, os
if isinstance(data_dict, str) and os.path.exists(data_dict):
import json
data_dict = json.load(open(data_dict))
if os.path.exists(outfile):
os.remove(outfile)
with open(outfile, 'a') as f:
@blazetopher
blazetopher / objgraph_utils.py
Created January 7, 2013 18:58
Utilities for working with objgraph
#!/usr/bin/env python
"""
@package
@file objgraph_utils
@author Christopher Mueller
@brief
"""
@blazetopher
blazetopher / perf_trials.py
Last active December 10, 2015 13:08
Performance Trials for Coverage Model
#!/usr/bin/env python
# https://gist.github.com/4438441
from coverage_model import *
import numpy as np
import time
import objgraph
import gevent
from clint.textui import progress
@blazetopher
blazetopher / gist:4226235
Created December 6, 2012 17:19
hdf leak output
(cm)DEV014MAC001{09:15}::~/Development/OOI/Dev/code/coverage-model (extends_cat_type %) cmueller: bin/python hdf_leak.py -v
Pid: 66614
h5py Version: 2.1.0
Starting Memory: 16.35546875 MB
Running variable length string datatype
......
Ending Memory: 27.59375 MB
Consumption: 11.23828125 MB
Starting Memory: 27.59375 MB
@blazetopher
blazetopher / memory_trials.py
Created November 29, 2012 20:01
memory_trials
#!/usr/bin/env python
from coverage_model import *
import numpy as np
import time
import objgraph
import gevent
from clint.textui import progress
from guppy import hpy
import time
><> from scratch.brick_helpers import *
bh=BrickHelp()
val_arr = np.arange(100).reshape(10,10)
#sl = (slice(2,7),slice(3,8))
sl = (slice(1,None),slice(4,8))
bh.put_values_to_bricks(sl, val_arr[sl])
><> bh=BrickHelp()
@blazetopher
blazetopher / examples.py
Created November 14, 2012 14:46
coverage value insertion benchmark
def benchmark_value_sets(num_params=10, num_insertions=100):
# Instantiate a ParameterDictionary
pdict = ParameterDictionary()
# Create a set of ParameterContext objects to define the parameters in the coverage, add each to the ParameterDictionary
t_ctxt = ParameterContext('time', param_type=QuantityType(value_encoding=np.dtype('int64')))
t_ctxt.axis = AxisTypeEnum.TIME
t_ctxt.uom = 'seconds since 01-01-1970'
pdict.add_context(t_ctxt)
@blazetopher
blazetopher / 1. It starts off like this...
Created October 5, 2012 18:36
Functional persistence!!
><> from coverage_model.test.examples import *
><> cov=oneparamcov(False,False)
><> cov.insert_timesteps(100)
><> cov.num_timesteps
--> 110
@blazetopher
blazetopher / gist:3531725
Created August 30, 2012 16:01
np encoding type error
ERROR: test_dm_end_2_end (ion.services.dm.test.test_dm_end_2_end.TestDMEnd2End)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/cmueller/Development/OOI/Dev/code/coi-services/ion/services/dm/test/test_dm_end_2_end.py", line 249, in test_dm_end_2_end
dataset_id = self.create_dataset()
File "/Users/cmueller/Development/OOI/Dev/code/coi-services/ion/services/dm/test/test_dm_end_2_end.py", line 167, in create_dataset
dataset_id = self.dataset_management.create_dataset('test_dataset', parameter_dict=pdict, spatial_domain=sdom, temporal_domain=tdom)
File "/Users/cmueller/Development/OOI/Dev/code/coi-services/interface/services/dm/idataset_management_service.py", line 267, in create_dataset
return self.request(IonObject('dataset_management_create_dataset_in', **{'name': name,'datastore_name': datastore_name,'view_name': view_name,'stream_id': stream_id,'parameter_dict': parameter_dict or None,'spatial_domain': spatial_domain or