TODO
- Create a write-up on how this works
TODO
| class DbProviderHelper | |
| { | |
| const string AssemblyQualifiedName = "AssemblyQualifiedName"; | |
| const string Name = "Name"; | |
| const string InvariantName = "InvariantName"; | |
| const string Description = "Description"; | |
| internal class FactoryInfo | |
| { | |
| public string InvariantName { get; set; } |
| import inspect | |
| def raise_on_none(f): | |
| arg_spec = inspect.getargspec(f) | |
| def new_f(*args, **kwargs): | |
| bound_args = inspect.getcallargs(f, *args, **kwargs) | |
| if(any([bound_args[a]==None for a in arg_spec.args])): | |
| raise RuntimeError('Named arg is None') | |
| if(arg_spec.keywords != None): | |
| if(any([a==None for a in bound_args[arg_spec.keywords].values()])): | |
| raise RuntimeError('Keyword arg is None') |
| import inspect | |
| def ignore_unused_args(f): | |
| arg_spec = inspect.getargspec(f) | |
| def new_f(*args, **kwargs): | |
| new_kwargs = {key:kwargs[key] for key in arg_spec.args if key in kwargs} | |
| return f(*args, **new_kwargs) | |
| new_f.spec = arg_spec | |
| return new_f |
| # Assumes you have a np.array((height,width,3), dtype=float) as your HDR image | |
| import numpy as np | |
| f = open("xxx.hdr", "wb") | |
| f.write("#?RADIANCE\n# Made with Python & Numpy\nFORMAT=32-bit_rle_rgbe\n\n") | |
| f.write("-Y {0} +X {1}\n".format(image.shape[0], image.shape[1])) | |
| brightest = np.maximum(np.maximum(image[...,0], image[...,1]), image[...,2]) | |
| mantissa = np.zeros_like(brightest) |
| # -- Shapes ------------------------------------------------------------------- | |
| class Square: | |
| def __init__(self, side_length, color): | |
| self.name = 'square' | |
| self.side_length = side_length | |
| self.color = color | |
| class Circle: |
| class UniformGenerator: | |
| def __init__(self): | |
| self.uniform = random.uniform | |
| def next(self): | |
| return self.uniform(0,1) | |
| def haltonterm(i, base=2): | |
| h = 0 | |
| fac = 1.0/base |