This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bla(object): | |
def __init__(self, a): | |
self.a = a | |
class Bleh(object): | |
def __init__(self, bla): | |
self.bla = bla | |
def __getattr__(self, name): | |
return getattr(self.bla, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Observation(models.Model): | |
invalid = models.BooleanField(default=False) | |
class Beam(models.Model): | |
observation = models.ForeignKey(Observation) | |
field = models.ForeignKey(Field) | |
class Field(models.Model): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factory_function(): | |
default_par = "something" | |
default_foo = "something else" | |
def returned_function(x, par=default_par, foo=default_foo): | |
print "x is " + str(x) | |
print "par is " + str(par) | |
print "foo is " + str(foo) | |
return returned_function | |
fn = factory_function() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyrap.measures import measures | |
import os | |
import sys | |
from io import BytesIO | |
from tempfile import SpooledTemporaryFile | |
from contextlib import contextmanager | |
@contextmanager | |
def redirect_stream(stream, destination): | |
old_stream = os.dup(stream.fileno()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
class DataAccessor(object): | |
__metaclass__ = abc.ABCMeta | |
@abc.abstractproperty | |
def wcs(self): | |
pass | |
@abc.abstractproperty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def function1(*args, **kwargs): | |
print "in function 1: ", args, kwargs | |
function2(*args, **kwargs) | |
def function2(*args, **kwargs): | |
print "in function 2: ", args, kwargs | |
print "local variables are:", locals() | |
function3(locals()) | |
def function3(*args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass(object): | |
def method1(self): | |
print "super m1" | |
def method2(self): | |
print "super m2" | |
def method3(self): | |
print "super m3" | |
self.method1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass(object): | |
def method1(self): | |
print "super m1" | |
class OtherSuperclass(object): | |
def method1(self): | |
print "other m1" | |
class MySub(MyClass, OtherSuperclass): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int& get_reference(int& a) { | |
return a; | |
} | |
int get_value(int x) { | |
return x; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from matplotlib import pyplot | |
with open('1sub-noepoll-notmpfs.log', 'r') as f: | |
noepoll_notmpfs = numpy.array([float(x) for x in f.readlines()]) | |
with open('1sub-epoll-notmpfs.log', 'r') as f: | |
epoll_notmpfs = numpy.array([float(x) for x in f.readlines()]) | |
with open('1sub-epoll-tmpfs.log', 'r') as f: |
OlderNewer