phi.dsl module
The Phi DSL is all about combining functions in useful ways, enabling a declarative approach that can improve clarity, readability and lead to shorter code. All valid expression of the DSL can be compiled to a function using P.Make
or applied to a value using P.Pipe
.
Phi offers the following constructs/expressions, try to read their documentation in order:
Function
: any function of arity 1 is an element of the languageComposition
: allows to sequentially compose functionsBranch
: lets to create a branched computation that returns a list with the results of each branchInput
: allows you to specify an input value, compiles to a (constant) function that returns the same value no matter the inputWith
: lets you to specify a context manager for the expresion (uses thewith
statemente)Record
: lets to create a branched computation with named branches that returns a record-like structure with the results of each branchRead
&Write
: allow you to create a reference to the value at some point and read it latter on.F
Any expresion can appear inside any other expresion in a nested fasion. They correct way to think about this is that each sub-expression will be compiled to a function of arity 1, therefore from the parent expresion's point of view all of its elements are just functions.
""" The Phi DSL is all about combining functions in useful ways, enabling a declarative approach that can improve clarity, readability and lead to shorter code. All valid expression of the DSL can be compiled to a function using `P.Make` or applied to a value using `P.Pipe`. Phi offers the following constructs/expressions, **try to read their documentation in order**: * **`phi.dsl.Function`**: any function of arity 1 is an element of the language * **`phi.dsl.Composition`**: allows to sequentially compose functions * **`phi.dsl.Branch`**: lets to create a branched computation that returns a list with the results of each branch * **`phi.dsl.Input`**: allows you to specify an input value, compiles to a (constant) function that returns the same value no matter the input * **`phi.dsl.With`**: lets you to specify a context manager for the expresion (uses the `with` statemente) * **`phi.dsl.Record`**: lets to create a branched computation with named branches that returns a record-like structure with the results of each branch * **`phi.dsl.Read` & `phi.dsl.Write`**: allow you to create a reference to the value at some point and read it latter on.F Any expresion can appear inside any other expresion in a nested fasion. They correct way to think about this is that each sub-expression will be compiled to a function of arity 1, therefore from the parent expresion's point of view all of its elements are just functions. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from .utils import identity from . import utils from abc import ABCMeta, abstractmethod from inspect import isclass import functools ############################### # Helpers ############################### class _NoValue(object): def __repr__(self): return "NoValue" _NO_VALUE = _NoValue() class Ref(object): """docstring for Ref.""" def __init__(self, name, value=_NO_VALUE): super(Ref, self).__init__() self.name = name self.value = value def __call__(self, *optional): if self.value is _NO_VALUE: raise Exception("Trying to read Ref('{0}') before assignment".format(self.name)) return self.value def set(self, x): self.value = x return x class CompilationContextManager(object): COMPILATION_GLOBAL_REFS = None WITH_GLOBAL_CONTEXT = _NO_VALUE def __init__(self, next_refs, next_with_global_context): self.previous_refs = CompilationContextManager.COMPILATION_GLOBAL_REFS self.next_refs = next_refs self.previous_with_global_context = CompilationContextManager.WITH_GLOBAL_CONTEXT self.next_with_global_context = next_with_global_context def __enter__(self): CompilationContextManager.COMPILATION_GLOBAL_REFS = self.next_refs CompilationContextManager.WITH_GLOBAL_CONTEXT = self.next_with_global_context def __exit__(self, *args): CompilationContextManager.COMPILATION_GLOBAL_REFS = self.previous_refs CompilationContextManager.WITH_GLOBAL_CONTEXT = self.previous_with_global_context @classmethod def set_ref(cls, ref): #Copy to avoid stateful behaviour cls.COMPILATION_GLOBAL_REFS = cls.COMPILATION_GLOBAL_REFS.copy() if ref.name in cls.COMPILATION_GLOBAL_REFS: other_ref = cls.COMPILATION_GLOBAL_REFS[ref.name] # merge state: borg pattern other_ref.__dict__.update(ref.__dict__) else: cls.COMPILATION_GLOBAL_REFS[ref.name] = ref @classmethod def get_ref(cls, name): return cls.COMPILATION_GLOBAL_REFS[name] class _RecordObject(dict): """docstring for DictObject.""" def __init__(self, **kwargs): self.__dict__.update(kwargs) def __getattr__ (self, attr): return self[attr] def __setitem__(self, key, item): self.__dict__[key] = item def __getitem__(self, key): return self.__dict__[key] def __repr__(self): return repr(self.__dict__) def __len__(self): return len(self.__dict__) def __delitem__(self, key): del self.__dict__[key] def clear(self): return self.__dict__.clear() def copy(self): return self.__dict__.copy() def has_key(self, k): return self.__dict__.has_key(k) def pop(self, k, d=None): return self.__dict__.pop(k, d) def update(self, *args, **kwargs): return self.__dict__.update(*args, **kwargs) def keys(self): return self.__dict__.keys() def values(self): return self.__dict__.values() def items(self): return self.__dict__.items() def pop(self, *args): return self.__dict__.pop(*args) def __cmp__(self, dict): return cmp(self.__dict__, dict) def __contains__(self, item): return item in self.__dict__ def __iter__(self): return iter(self.__dict__) def __unicode__(self): return unicode(repr(self.__dict__)) ############################### # DSL Elements ############################### class Node(object): """docstring for Node.""" __metaclass__ = ABCMeta @abstractmethod def __compile__(self): pass class Function(Node): """ All basic/terminal elements of this language are callables (implement `__call__`) of arity 1. ### Examples Compiling a function just returns back the function Make(f) == f and piping through a function is just the same a applying the function P.Pipe(x, f) == f(x) """ def __init__(self, _f): super(Function, self).__init__() self._f= _f def __iter__(self): yield self def __compile__(self): return self._f def __str__(self): return "Fun({0})".format(self._f) _Identity = Function(identity) class Branch(Node): """ While `Composition` is sequential, `Branch` allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements `__iter__`) that is not a tuple and yields a valid expresion. After compilation the expresion: k = [f, g] is equivalent to k(x) = [ f(x), g(x) ] In general, the following rules apply after compilation: **General Branching** let fs = <some iterable of valid expressions> is equivalent to k(x) = [ f(x) for f in fs ] **Composing & Branching** A more common scenario however is to see how braching interacts with composing. The expression k = (f, [g, h]) is *almost* equivalent to k = [ (f, g), (f, h) ] As you see its as if `f` where distributed over the list. We say *almost* because what really happens is that the iterable is first compiled to a function and the whole sequence is then composed z(x) = [ g(x), h(x) ] k(x) = (f, z)(x) = z(f(x)) As you see `f` is only excecuted once. ### Examples form phi import P avg_word_length = P.Pipe( "1 22 333", lambda s: s.split(' '), # ['1', '22', '333'] lambda l: map(len, l), # [1, 2, 3] [ sum # 1 + 2 + 3 == 6 , len # len([1, 2, 3]) == 3 ], lambda l: l[0] / l[1] # sum / len == 6 / 3 == 2 ) assert avg_word_length == 2 The previous could also be done more briefly like this form phi import P, Obj avg_word_length = P.Pipe( "1 22 333", Obj.split(' '), # ['1', '22', '333'] P.map(len), # [1, 2, 3] [ sum # sum([1, 2, 3]) == 6 , len # len([1, 2, 3]) == 3 ], P[0] / P[1] # 6 / 3 == 2 ) assert avg_word_length == 2 In the example above the last expression P[0] / P[1] works for a couple of reasons 1. The previous expression returns a list 2. In general the expression `P[x]` compiles to a function with the form `lambda obj: obj[x]` 3. The class `Lambda` (the class from which the object `P` inherits) overrides most operators to create functions easily. For example, the expression (P * 2) / (P + 1) compile to a function of the form f(x) = (x * 2) / (x + 1) Check out the documentatio for Phi [lambdas](https://cgarciae.github.io/phi/lambdas.m.html). """ def __init__(self, iterable_code): branches = [ _parse(code) for code in iterable_code ] self.branches = functools.reduce(Branch._reduce_branches, branches, []) @staticmethod def _reduce_branches(branches, b): if len(branches) == 0: return [b] elif type(b) is not Write: return branches + [ b ] else: # type(b) is Write a = branches[-1] seq = _parse((a, b)) return branches[:-1] + [ seq ] @staticmethod def __parse__(iterable_code): iterable_code = list(iterable_code) return Branch(iterable_code) def __compile__(self): fs = [] for node in self.branches: node_f = node.__compile__() fs.append(node_f) def function(x): return [ f(x) for f in fs ] return function class Composition(Node): """ In this language tuples are used to express function composition. After compilation, the expression k = (f, g) be equivalent to k(x) = g(f(x)) As you see, its a little different from the mathematical definition. Excecution order flow from left to right, and this makes reading and reasoning about code structured in the way more easy. This bahaviour is based upon the `|>` (pipe) operator found in languages like F#, Elixir and Elm. You can pack as many expressions as you like and they will be applied in order to the data that is passed through them when compiled an excecuted. In general, the following rules apply after compilation: **General Sequence** k = (f0, f1, ..., fn-1, fn) is equivalent to k(x) = fn(fn-1(...(f1(f0(x))))) **Single Function** k = (f) is equivalent to k = f **Identity** The empty tuple k = () is equivalent to k(x) = x ### Examples from phi import P f = Make( lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 ) assert f(1) == 9 # ((1 * 2) + 1) ** 2 As you see, `Make`s `*args` are interpreted as a tuple which means all expressions contained are composed. The previous example using `P.Pipe` from phi import P assert 9 == P.Pipe( 1, lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 ) Again, `Pipe`'s signature is `Pipe(x, *args)` and `*args` is interpreted as a tuple which means all expressions contained are composed. """ def __init__(self, left_code, right_code): super(Composition, self).__init__() self.left = _parse(left_code) self.right = _parse(right_code) @staticmethod def __build__(right, *prevs): left = prevs[0] if len(prevs) == 1 else Composition.__build__(*prevs) return Composition(left, right) @staticmethod def __parse__(tuple_code): tuple_code = list(tuple_code) if len(tuple_code) == 0: return _Identity if len(tuple_code) == 1: return _parse(tuple_code[0]) tuple_code.reverse() return Composition.__build__(*tuple_code) def __compile__(self): f_left = self.left.__compile__() f_right = self.right.__compile__() f = utils.compose2(f_right, f_left) return f def __str__(self): return "Seq({0}, {1})".format(self.left, self.right) class Record(Node): """ List or iterables in general provide you a way to branch your computation in the DSL, but access to the values of each branch are then done by index, this might be a little inconvenient because it reduces readability. Record branches provide a way to create named branches via a dictionary object where the keys are the names of the branches and the values are valid expressions representing the computation of that branch. A special object is returned by this expression when excecuted, this object derives from `dict` and fully emulates it so you can treat it as such, however it also implements the `__getattr__` method, this lets you access a value as if it where a field if its key is a of type string. ### Examples from phi import P stats = P.Pipe( [1,2,3], dict( sum = sum , len = len ) ) assert stats.sum == 6 assert stats.len == 3 assert stats['sum'] == 6 assert stats['len'] == 3 Now lets image that we want to find the average value of the list, we could calculate it outside of the pipe doing something like `avg = stats.sum / stats.len`, however we could also do it inside the pipe using `P.Rec` or `phi.Rec` like this from phi import P, Rec avg = P.Pipe( [1,2,3], dict( sum = sum , len = len ), Rec.sum / Rec.len ) """ def __init__(self, dict_code): super(Record, self).__init__() self.nodes_dict = { key: _parse(code) for key, code in dict_code.items() } @staticmethod def __parse__(dict_code): return Record(dict_code) def __compile__(self): funs_dict = {} for key, node in self.nodes_dict.items(): f = node.__compile__() funs_dict[key] = f def function(x): return _RecordObject(**{key: f(x) for key, f in funs_dict.items() }) return function class With(Node): """ **With** def With(context_manager, *body): **Arguments** * **context_manager**: a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) object or valid expression from the DSL that returns a context manager. * ***body**: any valid expression of the DSL to be evaluated inside the context. `*body` is interpreted as a tuple so all expression contained are composed. As with normal python programs you sometimes might want to create a context for a block of code. You normally give a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) to the [with](https://docs.python.org/2/reference/compound_stmts.html#the-with-statement) statemente, in Phi you use `P.With` or `phi.With` **Context** Python's `with` statemente returns a context object through `as` keyword, in the DSL this object can be obtained using the `P.Context` method or the `phi.Context` function. ### Examples from phi import P, Obj, Context, With, Pipe text = Pipe( "text.txt", With( open, Context, Obj.read() ) ) The previous is equivalent to with open("text.txt") as f: text = f.read() """ def __init__(self, scope_code, *body_code): super(With, self).__init__() self.scope = _parse(scope_code, else_input=True) self.body = _parse(body_code) def __compile__(self): scope_f = self.scope.__compile__() body_fs = self.body.__compile__() def function(x): with scope_f(x) as scope: with self.set_scope(scope): return body_fs(x) return function def set_scope(self, new_scope): self.new_scope = new_scope self.old_scope = CompilationContextManager.WITH_GLOBAL_CONTEXT return self def __enter__(self): CompilationContextManager.WITH_GLOBAL_CONTEXT = self.new_scope def __exit__(self, *args): CompilationContextManager.WITH_GLOBAL_CONTEXT = self.old_scope class Read(Node): """ Giving names and saving parts of your computation to use then latter is useful to say the least. In the DSL the expression {'x'} behaves like just like the indentity except that as a side effect it creates a reference to that value which you can call latter. Here `{..}` is python's sytax for a set literal and `x` is a string with the name of the reference. To read the previous you would use the expression 'x' This is equivalent to a sort of function like this lambda z: read('x') where the input is totally ignored and a hypothetical `read` function is given the reference name and it should return its stored value (internally its not implemented like this). As you see strings in the DSL mean read from a reference and a set with a string means write to a reference. ### Example Lets see a common situation where you would use this from phi import P P.Pipe( input, fun_1, {'fun_1_val'} fun_2, [ fun_4 , ( 'fun_1_val', fun_5 ) ] ) Here you *save* the value outputed by `fun_1` and the load it as the initial value of the second branch. In normal python the previous would be *almost* equivalent to this x = fun_1(input) fun_1_val = x x = fun_2(x) x = [ fun_4(x) , fun_5(fun_1_val) ] return x ### Write special case When composing its aesthetically better to put writes in the same line as the function whos value its storing to make the intent a bit more clear: ( f, {'a'}, g ) Here we store the value of `f` in `'a'`, however, when you are inside a branch you will be tempted to do the following to get the same result: [ f, {'a'} , g ] However, if you flatten the text you realize you actually have 3 branches instead of 2 [ f, {'a'}, g ] and that wont save the value of `f` in `'a'` as you intended. To avoid this possible error, the DSL rewrites the expression during parsing to [ ( f, {'a'} ), g ] every time there is a write expression inside a branch expression. """ def __init__(self, name): super(Read, self).__init__() self.name = name def __compile__(self): f = lambda z: CompilationContextManager.get_ref(self.name).value return f class Write(Node): __doc__ = Read.__doc__ def __init__(self, ref): super(Write, self).__init__() self.ref = ref @staticmethod def __parse__(code): if len(code) == 0: return _Identity for ref in code: if not isinstance(ref, (str, Ref)): raise Exception("Parse Error: Sets can only contain strings or Refs, get {0}".format(code)) writes = tuple([ Write(ref) for ref in code ]) return _parse(writes) def __compile__(self): def f(x): ref = Ref(self.ref, x) if type(self.ref) is str else self.ref ref.set(x) CompilationContextManager.set_ref(ref) return x return f class Input(Node): """ Sometimes you might need to branch the computation but start one of the branches with a values different than the one being passed down, you could always solve it like this P.Pipe( ..., [ lambda z: my_value , ... ] ) Here we just made a lamda that took in the argument `z` but it was completely ignored and it always returns `my_value`, this is called a constant function. You could also do the same with `P.Val` or the top level function `phi.Val` from phi import P, Val P.Pipe( ..., [ Val(my_value) , ... ] )| """ def __init__(self, value): super(Input, self).__init__() self.value = value def __compile__(self): f = lambda x: self.value return f class If(Node): """docstring for If.""" def __init__(self, Predicate, *Then, **kwargs): Else = kwargs.get('Else', ()) self.Predicate = _parse(Predicate) self.Then = _parse(Then) self.Else_ = _parse(Else) def __compile__(self): Predicate = self.Predicate.__compile__() Then = self.Then.__compile__() Else = self.Else_.__compile__() f = lambda x: Then(x) if Predicate(x) else Else(x) return f def Else(self, *Else): self.Else_ = _parse(Else) return self ####################### ### FUNCTIONS ####################### def Compile(code, refs, create_ref_context=True): """ Hola """ ast = _parse(code) f = ast.__compile__() refs = { name: value if type(value) is Ref else Ref(name, value) for name, value in refs.items() } def g(x): with CompilationContextManager(refs, _NoValue): return f(x) return g if create_ref_context else f def _parse(code, else_input=False): #if type(code) is tuple: if isinstance(code, Node): return code elif hasattr(code, '__call__') or isclass(code): return Function(code) elif type(code) is str: return Read(code) elif type(code) is set: return Write.__parse__(code) elif type(code) is tuple: return Composition.__parse__(code) elif type(code) is dict: return Record.__parse__(code) elif hasattr(code, '__iter__') and not isclass(code): #leave last return Branch.__parse__(code) #its iterable elif else_input: return Input(code) else: raise Exception("Parse Error: Element not part of the DSL. Got: {0} of type {1}".format(code, type(code)))
Functions
def Compile(
code, refs, create_ref_context=True)
Hola
def Compile(code, refs, create_ref_context=True): """ Hola """ ast = _parse(code) f = ast.__compile__() refs = { name: value if type(value) is Ref else Ref(name, value) for name, value in refs.items() } def g(x): with CompilationContextManager(refs, _NoValue): return f(x) return g if create_ref_context else f
Classes
class Branch
While Composition
is sequential, Branch
allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements __iter__
) that is not a tuple and yields a valid expresion.
After compilation the expresion:
k = [f, g]
is equivalent to
k(x) = [ f(x), g(x) ]
In general, the following rules apply after compilation:
General Branching
let fs = <some iterable of valid expressions>
is equivalent to
k(x) = [ f(x) for f in fs ]
Composing & Branching
A more common scenario however is to see how braching interacts with composing. The expression
k = (f, [g, h])
is almost equivalent to
k = [ (f, g), (f, h) ]
As you see its as if f
where distributed over the list. We say almost because what really happens is that the iterable is first compiled to a function and the whole sequence is then composed
z(x) = [ g(x), h(x) ] k(x) = (f, z)(x) = z(f(x))
As you see f
is only excecuted once.
Examples
form phi import P avg_word_length = P.Pipe( "1 22 333", lambda s: s.split(' '), # ['1', '22', '333'] lambda l: map(len, l), # [1, 2, 3] [ sum # 1 + 2 + 3 == 6 , len # len([1, 2, 3]) == 3 ], lambda l: l[0] / l[1] # sum / len == 6 / 3 == 2 ) assert avg_word_length == 2
The previous could also be done more briefly like this
form phi import P, Obj avg_word_length = P.Pipe( "1 22 333", Obj.split(' '), # ['1', '22', '333'] P.map(len), # [1, 2, 3] [ sum # sum([1, 2, 3]) == 6 , len # len([1, 2, 3]) == 3 ], P[0] / P[1] # 6 / 3 == 2 ) assert avg_word_length == 2
In the example above the last expression
P[0] / P[1]
works for a couple of reasons
- The previous expression returns a list
- In general the expression
P[x]
compiles to a function with the formlambda obj: obj[x]
-
The class
Lambda
(the class from which the objectP
inherits) overrides most operators to create functions easily. For example, the expression(P * 2) / (P + 1)
compile to a function of the form
f(x) = (x * 2) / (x + 1)
Check out the documentatio for Phi lambdas.
class Branch(Node): """ While `Composition` is sequential, `Branch` allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements `__iter__`) that is not a tuple and yields a valid expresion. After compilation the expresion: k = [f, g] is equivalent to k(x) = [ f(x), g(x) ] In general, the following rules apply after compilation: **General Branching** let fs = <some iterable of valid expressions> is equivalent to k(x) = [ f(x) for f in fs ] **Composing & Branching** A more common scenario however is to see how braching interacts with composing. The expression k = (f, [g, h]) is *almost* equivalent to k = [ (f, g), (f, h) ] As you see its as if `f` where distributed over the list. We say *almost* because what really happens is that the iterable is first compiled to a function and the whole sequence is then composed z(x) = [ g(x), h(x) ] k(x) = (f, z)(x) = z(f(x)) As you see `f` is only excecuted once. ### Examples form phi import P avg_word_length = P.Pipe( "1 22 333", lambda s: s.split(' '), # ['1', '22', '333'] lambda l: map(len, l), # [1, 2, 3] [ sum # 1 + 2 + 3 == 6 , len # len([1, 2, 3]) == 3 ], lambda l: l[0] / l[1] # sum / len == 6 / 3 == 2 ) assert avg_word_length == 2 The previous could also be done more briefly like this form phi import P, Obj avg_word_length = P.Pipe( "1 22 333", Obj.split(' '), # ['1', '22', '333'] P.map(len), # [1, 2, 3] [ sum # sum([1, 2, 3]) == 6 , len # len([1, 2, 3]) == 3 ], P[0] / P[1] # 6 / 3 == 2 ) assert avg_word_length == 2 In the example above the last expression P[0] / P[1] works for a couple of reasons 1. The previous expression returns a list 2. In general the expression `P[x]` compiles to a function with the form `lambda obj: obj[x]` 3. The class `Lambda` (the class from which the object `P` inherits) overrides most operators to create functions easily. For example, the expression (P * 2) / (P + 1) compile to a function of the form f(x) = (x * 2) / (x + 1) Check out the documentatio for Phi [lambdas](https://cgarciae.github.io/phi/lambdas.m.html). """ def __init__(self, iterable_code): branches = [ _parse(code) for code in iterable_code ] self.branches = functools.reduce(Branch._reduce_branches, branches, []) @staticmethod def _reduce_branches(branches, b): if len(branches) == 0: return [b] elif type(b) is not Write: return branches + [ b ] else: # type(b) is Write a = branches[-1] seq = _parse((a, b)) return branches[:-1] + [ seq ] @staticmethod def __parse__(iterable_code): iterable_code = list(iterable_code) return Branch(iterable_code) def __compile__(self): fs = [] for node in self.branches: node_f = node.__compile__() fs.append(node_f) def function(x): return [ f(x) for f in fs ] return function
Ancestors (in MRO)
Instance variables
var branches
Methods
def __init__(
self, iterable_code)
def __init__(self, iterable_code): branches = [ _parse(code) for code in iterable_code ] self.branches = functools.reduce(Branch._reduce_branches, branches, [])
class CompilationContextManager
class CompilationContextManager(object): COMPILATION_GLOBAL_REFS = None WITH_GLOBAL_CONTEXT = _NO_VALUE def __init__(self, next_refs, next_with_global_context): self.previous_refs = CompilationContextManager.COMPILATION_GLOBAL_REFS self.next_refs = next_refs self.previous_with_global_context = CompilationContextManager.WITH_GLOBAL_CONTEXT self.next_with_global_context = next_with_global_context def __enter__(self): CompilationContextManager.COMPILATION_GLOBAL_REFS = self.next_refs CompilationContextManager.WITH_GLOBAL_CONTEXT = self.next_with_global_context def __exit__(self, *args): CompilationContextManager.COMPILATION_GLOBAL_REFS = self.previous_refs CompilationContextManager.WITH_GLOBAL_CONTEXT = self.previous_with_global_context @classmethod def set_ref(cls, ref): #Copy to avoid stateful behaviour cls.COMPILATION_GLOBAL_REFS = cls.COMPILATION_GLOBAL_REFS.copy() if ref.name in cls.COMPILATION_GLOBAL_REFS: other_ref = cls.COMPILATION_GLOBAL_REFS[ref.name] # merge state: borg pattern other_ref.__dict__.update(ref.__dict__) else: cls.COMPILATION_GLOBAL_REFS[ref.name] = ref @classmethod def get_ref(cls, name): return cls.COMPILATION_GLOBAL_REFS[name]
Ancestors (in MRO)
- CompilationContextManager
- __builtin__.object
Class variables
var COMPILATION_GLOBAL_REFS
var WITH_GLOBAL_CONTEXT
Instance variables
var next_refs
var next_with_global_context
var previous_refs
var previous_with_global_context
Methods
def __init__(
self, next_refs, next_with_global_context)
def __init__(self, next_refs, next_with_global_context): self.previous_refs = CompilationContextManager.COMPILATION_GLOBAL_REFS self.next_refs = next_refs self.previous_with_global_context = CompilationContextManager.WITH_GLOBAL_CONTEXT self.next_with_global_context = next_with_global_context
def get_ref(
cls, name)
@classmethod def get_ref(cls, name): return cls.COMPILATION_GLOBAL_REFS[name]
def set_ref(
cls, ref)
@classmethod def set_ref(cls, ref): #Copy to avoid stateful behaviour cls.COMPILATION_GLOBAL_REFS = cls.COMPILATION_GLOBAL_REFS.copy() if ref.name in cls.COMPILATION_GLOBAL_REFS: other_ref = cls.COMPILATION_GLOBAL_REFS[ref.name] # merge state: borg pattern other_ref.__dict__.update(ref.__dict__) else: cls.COMPILATION_GLOBAL_REFS[ref.name] = ref
class Composition
In this language tuples are used to express function composition. After compilation, the expression
k = (f, g)
be equivalent to
k(x) = g(f(x))
As you see, its a little different from the mathematical definition. Excecution order flow from left to right, and this makes reading and reasoning about code structured in the way more easy. This bahaviour is based upon the |>
(pipe) operator found in languages like F#, Elixir and Elm. You can pack as many expressions as you like and they will be applied in order to the data that is passed through them when compiled an excecuted.
In general, the following rules apply after compilation:
General Sequence
k = (f0, f1, ..., fn-1, fn)
is equivalent to
k(x) = fn(fn-1(...(f1(f0(x)))))
Single Function
k = (f)
is equivalent to
k = f
Identity
The empty tuple
k = ()
is equivalent to
k(x) = x
Examples
from phi import P f = Make( lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 ) assert f(1) == 9 # ((1 * 2) + 1) ** 2
As you see, Make
s *args
are interpreted as a tuple which means all expressions contained are composed. The previous example using P.Pipe
from phi import P assert 9 == P.Pipe( 1, lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 )
Again, Pipe
's signature is Pipe(x, *args)
and *args
is interpreted as a tuple which means all expressions contained are composed.
class Composition(Node): """ In this language tuples are used to express function composition. After compilation, the expression k = (f, g) be equivalent to k(x) = g(f(x)) As you see, its a little different from the mathematical definition. Excecution order flow from left to right, and this makes reading and reasoning about code structured in the way more easy. This bahaviour is based upon the `|>` (pipe) operator found in languages like F#, Elixir and Elm. You can pack as many expressions as you like and they will be applied in order to the data that is passed through them when compiled an excecuted. In general, the following rules apply after compilation: **General Sequence** k = (f0, f1, ..., fn-1, fn) is equivalent to k(x) = fn(fn-1(...(f1(f0(x))))) **Single Function** k = (f) is equivalent to k = f **Identity** The empty tuple k = () is equivalent to k(x) = x ### Examples from phi import P f = Make( lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 ) assert f(1) == 9 # ((1 * 2) + 1) ** 2 As you see, `Make`s `*args` are interpreted as a tuple which means all expressions contained are composed. The previous example using `P.Pipe` from phi import P assert 9 == P.Pipe( 1, lambda x: x * 2, lambda x: x + 1, lambda x: x ** 2 ) Again, `Pipe`'s signature is `Pipe(x, *args)` and `*args` is interpreted as a tuple which means all expressions contained are composed. """ def __init__(self, left_code, right_code): super(Composition, self).__init__() self.left = _parse(left_code) self.right = _parse(right_code) @staticmethod def __build__(right, *prevs): left = prevs[0] if len(prevs) == 1 else Composition.__build__(*prevs) return Composition(left, right) @staticmethod def __parse__(tuple_code): tuple_code = list(tuple_code) if len(tuple_code) == 0: return _Identity if len(tuple_code) == 1: return _parse(tuple_code[0]) tuple_code.reverse() return Composition.__build__(*tuple_code) def __compile__(self): f_left = self.left.__compile__() f_right = self.right.__compile__() f = utils.compose2(f_right, f_left) return f def __str__(self): return "Seq({0}, {1})".format(self.left, self.right)
Ancestors (in MRO)
- Composition
- Node
- __builtin__.object
Instance variables
var left
var right
Methods
def __init__(
self, left_code, right_code)
def __init__(self, left_code, right_code): super(Composition, self).__init__() self.left = _parse(left_code) self.right = _parse(right_code)
class Function
All basic/terminal elements of this language are callables (implement __call__
) of arity 1.
Examples
Compiling a function just returns back the function
Make(f) == f
and piping through a function is just the same a applying the function
P.Pipe(x, f) == f(x)
class Function(Node): """ All basic/terminal elements of this language are callables (implement `__call__`) of arity 1. ### Examples Compiling a function just returns back the function Make(f) == f and piping through a function is just the same a applying the function P.Pipe(x, f) == f(x) """ def __init__(self, _f): super(Function, self).__init__() self._f= _f def __iter__(self): yield self def __compile__(self): return self._f def __str__(self): return "Fun({0})".format(self._f)
Ancestors (in MRO)
Methods
def __init__(
self, _f)
def __init__(self, _f): super(Function, self).__init__() self._f= _f
class If
docstring for If.
class If(Node): """docstring for If.""" def __init__(self, Predicate, *Then, **kwargs): Else = kwargs.get('Else', ()) self.Predicate = _parse(Predicate) self.Then = _parse(Then) self.Else_ = _parse(Else) def __compile__(self): Predicate = self.Predicate.__compile__() Then = self.Then.__compile__() Else = self.Else_.__compile__() f = lambda x: Then(x) if Predicate(x) else Else(x) return f def Else(self, *Else): self.Else_ = _parse(Else) return self
Ancestors (in MRO)
Instance variables
var Else_
var Predicate
var Then
Methods
def __init__(
self, Predicate, *Then, **kwargs)
def __init__(self, Predicate, *Then, **kwargs): Else = kwargs.get('Else', ()) self.Predicate = _parse(Predicate) self.Then = _parse(Then) self.Else_ = _parse(Else)
def Else(
self, *Else)
def Else(self, *Else): self.Else_ = _parse(Else) return self
class Input
Sometimes you might need to branch the computation but start one of the branches with a values different than the one being passed down, you could always solve it like this
P.Pipe( ..., [ lambda z: my_value , ... ] )
Here we just made a lamda that took in the argument z
but it was completely ignored and it always returns my_value
, this is called a constant function. You could also do the same with P.Val
or the top level function phi.Val
from phi import P, Val P.Pipe( ..., [ Val(my_value) , ... ] )|
class Input(Node): """ Sometimes you might need to branch the computation but start one of the branches with a values different than the one being passed down, you could always solve it like this P.Pipe( ..., [ lambda z: my_value , ... ] ) Here we just made a lamda that took in the argument `z` but it was completely ignored and it always returns `my_value`, this is called a constant function. You could also do the same with `P.Val` or the top level function `phi.Val` from phi import P, Val P.Pipe( ..., [ Val(my_value) , ... ] )| """ def __init__(self, value): super(Input, self).__init__() self.value = value def __compile__(self): f = lambda x: self.value return f
Ancestors (in MRO)
Instance variables
var value
Methods
def __init__(
self, value)
def __init__(self, value): super(Input, self).__init__() self.value = value
class Node
docstring for Node.
class Node(object): """docstring for Node.""" __metaclass__ = ABCMeta @abstractmethod def __compile__(self): pass
Ancestors (in MRO)
- Node
- __builtin__.object
class Read
Giving names and saving parts of your computation to use then latter is useful to say the least. In the DSL the expression
{'x'}
behaves like just like the indentity except that as a side effect it creates a reference to that value which you can call latter. Here {..}
is python's sytax for a set literal and x
is a string with the name of the reference. To read the previous you would use the expression
'x'
This is equivalent to a sort of function like this
lambda z: read('x')
where the input is totally ignored and a hypothetical read
function is given the reference name and it should return its stored value (internally its not implemented like this). As you see strings in the DSL mean read from a reference and a set with a string means write to a reference.
Example
Lets see a common situation where you would use this
from phi import P P.Pipe( input, fun_1, {'fun_1_val'} fun_2, [ fun_4 , ( 'fun_1_val', fun_5 ) ] )
Here you save the value outputed by fun_1
and the load it as the initial value of the second branch. In normal python the previous would be almost equivalent to this
x = fun_1(input) fun_1_val = x x = fun_2(x) x = [ fun_4(x) , fun_5(fun_1_val) ] return x
Write special case
When composing its aesthetically better to put writes in the same line as the function whos value its storing to make the intent a bit more clear:
( f, {'a'}, g )
Here we store the value of f
in 'a'
, however, when you are inside a branch you will be tempted to do the following to get the same result:
[ f, {'a'} , g ]
However, if you flatten the text you realize you actually have 3 branches instead of 2
[ f, {'a'}, g ]
and that wont save the value of f
in 'a'
as you intended. To avoid this possible error, the DSL rewrites the expression during parsing to
[ ( f, {'a'} ), g ]
every time there is a write expression inside a branch expression.
class Read(Node): """ Giving names and saving parts of your computation to use then latter is useful to say the least. In the DSL the expression {'x'} behaves like just like the indentity except that as a side effect it creates a reference to that value which you can call latter. Here `{..}` is python's sytax for a set literal and `x` is a string with the name of the reference. To read the previous you would use the expression 'x' This is equivalent to a sort of function like this lambda z: read('x') where the input is totally ignored and a hypothetical `read` function is given the reference name and it should return its stored value (internally its not implemented like this). As you see strings in the DSL mean read from a reference and a set with a string means write to a reference. ### Example Lets see a common situation where you would use this from phi import P P.Pipe( input, fun_1, {'fun_1_val'} fun_2, [ fun_4 , ( 'fun_1_val', fun_5 ) ] ) Here you *save* the value outputed by `fun_1` and the load it as the initial value of the second branch. In normal python the previous would be *almost* equivalent to this x = fun_1(input) fun_1_val = x x = fun_2(x) x = [ fun_4(x) , fun_5(fun_1_val) ] return x ### Write special case When composing its aesthetically better to put writes in the same line as the function whos value its storing to make the intent a bit more clear: ( f, {'a'}, g ) Here we store the value of `f` in `'a'`, however, when you are inside a branch you will be tempted to do the following to get the same result: [ f, {'a'} , g ] However, if you flatten the text you realize you actually have 3 branches instead of 2 [ f, {'a'}, g ] and that wont save the value of `f` in `'a'` as you intended. To avoid this possible error, the DSL rewrites the expression during parsing to [ ( f, {'a'} ), g ] every time there is a write expression inside a branch expression. """ def __init__(self, name): super(Read, self).__init__() self.name = name def __compile__(self): f = lambda z: CompilationContextManager.get_ref(self.name).value return f
Ancestors (in MRO)
Instance variables
var name
Methods
def __init__(
self, name)
def __init__(self, name): super(Read, self).__init__() self.name = name
class Record
List or iterables in general provide you a way to branch your computation in the DSL, but access to the values of each branch are then done by index, this might be a little inconvenient because it reduces readability. Record branches provide a way to create named branches via a dictionary object where the keys are the names of the branches and the values are valid expressions representing the computation of that branch.
A special object is returned by this expression when excecuted, this object derives from dict
and fully emulates it so you can treat it as such, however it also implements the __getattr__
method, this lets you access a value as if it where a field if its key is a of type string.
Examples
from phi import P stats = P.Pipe( [1,2,3], dict( sum = sum , len = len ) ) assert stats.sum == 6 assert stats.len == 3 assert stats['sum'] == 6 assert stats['len'] == 3
Now lets image that we want to find the average value of the list, we could calculate it outside of the pipe doing something like avg = stats.sum / stats.len
, however we could also do it inside the pipe using P.Rec
or phi.Rec
like this
from phi import P, Rec avg = P.Pipe( [1,2,3], dict( sum = sum , len = len ), Rec.sum / Rec.len )
class Record(Node): """ List or iterables in general provide you a way to branch your computation in the DSL, but access to the values of each branch are then done by index, this might be a little inconvenient because it reduces readability. Record branches provide a way to create named branches via a dictionary object where the keys are the names of the branches and the values are valid expressions representing the computation of that branch. A special object is returned by this expression when excecuted, this object derives from `dict` and fully emulates it so you can treat it as such, however it also implements the `__getattr__` method, this lets you access a value as if it where a field if its key is a of type string. ### Examples from phi import P stats = P.Pipe( [1,2,3], dict( sum = sum , len = len ) ) assert stats.sum == 6 assert stats.len == 3 assert stats['sum'] == 6 assert stats['len'] == 3 Now lets image that we want to find the average value of the list, we could calculate it outside of the pipe doing something like `avg = stats.sum / stats.len`, however we could also do it inside the pipe using `P.Rec` or `phi.Rec` like this from phi import P, Rec avg = P.Pipe( [1,2,3], dict( sum = sum , len = len ), Rec.sum / Rec.len ) """ def __init__(self, dict_code): super(Record, self).__init__() self.nodes_dict = { key: _parse(code) for key, code in dict_code.items() } @staticmethod def __parse__(dict_code): return Record(dict_code) def __compile__(self): funs_dict = {} for key, node in self.nodes_dict.items(): f = node.__compile__() funs_dict[key] = f def function(x): return _RecordObject(**{key: f(x) for key, f in funs_dict.items() }) return function
Ancestors (in MRO)
Instance variables
var nodes_dict
Methods
def __init__(
self, dict_code)
def __init__(self, dict_code): super(Record, self).__init__() self.nodes_dict = { key: _parse(code) for key, code in dict_code.items() }
class Ref
docstring for Ref.
class Ref(object): """docstring for Ref.""" def __init__(self, name, value=_NO_VALUE): super(Ref, self).__init__() self.name = name self.value = value def __call__(self, *optional): if self.value is _NO_VALUE: raise Exception("Trying to read Ref('{0}') before assignment".format(self.name)) return self.value def set(self, x): self.value = x return x
Ancestors (in MRO)
- Ref
- __builtin__.object
Instance variables
var name
var value
Methods
def __init__(
self, name, value=NoValue)
def __init__(self, name, value=_NO_VALUE): super(Ref, self).__init__() self.name = name self.value = value
def set(
self, x)
def set(self, x): self.value = x return x
class With
With
def With(context_manager, *body):
Arguments
- context_manager: a context manager object or valid expression from the DSL that returns a context manager.
- *body: any valid expression of the DSL to be evaluated inside the context.
*body
is interpreted as a tuple so all expression contained are composed.
As with normal python programs you sometimes might want to create a context for a block of code. You normally give a context manager to the with statemente, in Phi you use P.With
or phi.With
Context
Python's with
statemente returns a context object through as
keyword, in the DSL this object can be obtained using the P.Context
method or the phi.Context
function.
Examples
from phi import P, Obj, Context, With, Pipe text = Pipe( "text.txt", With( open, Context, Obj.read() ) )
The previous is equivalent to
with open("text.txt") as f: text = f.read()
class With(Node): """ **With** def With(context_manager, *body): **Arguments** * **context_manager**: a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) object or valid expression from the DSL that returns a context manager. * ***body**: any valid expression of the DSL to be evaluated inside the context. `*body` is interpreted as a tuple so all expression contained are composed. As with normal python programs you sometimes might want to create a context for a block of code. You normally give a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) to the [with](https://docs.python.org/2/reference/compound_stmts.html#the-with-statement) statemente, in Phi you use `P.With` or `phi.With` **Context** Python's `with` statemente returns a context object through `as` keyword, in the DSL this object can be obtained using the `P.Context` method or the `phi.Context` function. ### Examples from phi import P, Obj, Context, With, Pipe text = Pipe( "text.txt", With( open, Context, Obj.read() ) ) The previous is equivalent to with open("text.txt") as f: text = f.read() """ def __init__(self, scope_code, *body_code): super(With, self).__init__() self.scope = _parse(scope_code, else_input=True) self.body = _parse(body_code) def __compile__(self): scope_f = self.scope.__compile__() body_fs = self.body.__compile__() def function(x): with scope_f(x) as scope: with self.set_scope(scope): return body_fs(x) return function def set_scope(self, new_scope): self.new_scope = new_scope self.old_scope = CompilationContextManager.WITH_GLOBAL_CONTEXT return self def __enter__(self): CompilationContextManager.WITH_GLOBAL_CONTEXT = self.new_scope def __exit__(self, *args): CompilationContextManager.WITH_GLOBAL_CONTEXT = self.old_scope
Ancestors (in MRO)
Instance variables
var body
var scope
Methods
def __init__(
self, scope_code, *body_code)
def __init__(self, scope_code, *body_code): super(With, self).__init__() self.scope = _parse(scope_code, else_input=True) self.body = _parse(body_code)
def set_scope(
self, new_scope)
def set_scope(self, new_scope): self.new_scope = new_scope self.old_scope = CompilationContextManager.WITH_GLOBAL_CONTEXT return self
class Write
Giving names and saving parts of your computation to use then latter is useful to say the least. In the DSL the expression
{'x'}
behaves like just like the indentity except that as a side effect it creates a reference to that value which you can call latter. Here {..}
is python's sytax for a set literal and x
is a string with the name of the reference. To read the previous you would use the expression
'x'
This is equivalent to a sort of function like this
lambda z: read('x')
where the input is totally ignored and a hypothetical read
function is given the reference name and it should return its stored value (internally its not implemented like this). As you see strings in the DSL mean read from a reference and a set with a string means write to a reference.
Example
Lets see a common situation where you would use this
from phi import P P.Pipe( input, fun_1, {'fun_1_val'} fun_2, [ fun_4 , ( 'fun_1_val', fun_5 ) ] )
Here you save the value outputed by fun_1
and the load it as the initial value of the second branch. In normal python the previous would be almost equivalent to this
x = fun_1(input) fun_1_val = x x = fun_2(x) x = [ fun_4(x) , fun_5(fun_1_val) ] return x
Write special case
When composing its aesthetically better to put writes in the same line as the function whos value its storing to make the intent a bit more clear:
( f, {'a'}, g )
Here we store the value of f
in 'a'
, however, when you are inside a branch you will be tempted to do the following to get the same result:
[ f, {'a'} , g ]
However, if you flatten the text you realize you actually have 3 branches instead of 2
[ f, {'a'}, g ]
and that wont save the value of f
in 'a'
as you intended. To avoid this possible error, the DSL rewrites the expression during parsing to
[ ( f, {'a'} ), g ]
every time there is a write expression inside a branch expression.
class Write(Node): __doc__ = Read.__doc__ def __init__(self, ref): super(Write, self).__init__() self.ref = ref @staticmethod def __parse__(code): if len(code) == 0: return _Identity for ref in code: if not isinstance(ref, (str, Ref)): raise Exception("Parse Error: Sets can only contain strings or Refs, get {0}".format(code)) writes = tuple([ Write(ref) for ref in code ]) return _parse(writes) def __compile__(self): def f(x): ref = Ref(self.ref, x) if type(self.ref) is str else self.ref ref.set(x) CompilationContextManager.set_ref(ref) return x return f
Ancestors (in MRO)
Instance variables
var ref
Methods
def __init__(
self, ref)
def __init__(self, ref): super(Write, self).__init__() self.ref = ref


Implements common geostatistical methods in a clean, straightforward, efficient manner. A quasi reboot of the SpatialTools R package.
| Version: | 0.1.1 |
| Imports: | sp, parallel, lattice, stats, optimx |
| Suggests: | testthat, gstat, geoR, spam, Matrix |
| Published: | 2015-12-22 |
| Author: | Joshua French |
| Maintainer: | Joshua French <joshua.french at ucdenver.edu> |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| NeedsCompilation: | no |
| In views: | Spatial |
| CRAN checks: | gear results |
| Reference manual: | gear.pdf |
| Package source: | gear_0.1.1.tar.gz |
| Windows binaries: | r-devel: gear_0.1.1.zip, r-release: gear_0.1.1.zip, r-oldrel: gear_0.1.1.zip |
| OS X binaries: | r-release: gear_0.1.1.tgz, r-oldrel: gear_0.1.1.tgz |
| Reverse suggests: | autoimage |
Please use the canonical form https://CRAN.R-project.org/package=gear to link to this page.


Class Coercion in Ruby C extensions
25 Jul 2015 GSoC-2015 · SymEngine · RubyHola Everyone! Our classes started this week, and there was less time during the week than I had expected. Anyways, I am at the completion of the Ruby wrappers for the Integer
and Rational
classes. It would have been complete last week itself if it weren’t for the deadlines I had for registration. Mostly because of the companies that will be coming to the campus this week to select interns. This time I really am going to complete it this weekend for sure.
Class Coercion
I didn’t know of this technique until Isuru suggested me not to modify the existing Ruby classes, and rather have a look at Class Coercion in Ruby. This is an elegant concept to get seamless inter-operation between existing classes and new classes without having to modify the default library code.
My aim was to support operation of SymEngine classes like Integer
, Rational
and Complex
with the existing classes Integer
and Rational
classes from the Ruby kernel. For that I had supported the operations in the C wrappers. Like, if the other parameter object passed to the method is not of a SymEngine type but a Ruby object, I would first convert it into the corresponding SymEngine object, and then use it for operation.
This supported all the operations of the kind a * 2
, where a
is an object of the type SymEngine::Integer
. But I had to support 2 * a
too. That meant (for me) changing the existing class. Overriding all the existing binary operations for it to support SymEngine
types, violating the open/closed principle. It was like this
class Fixnum
alias_method :old_add, :+
def +(other)
if other.is_a? SymEngine::Basic
SymEngine::Integer.new(self) + other
else
old_add other
end
end
alias_method :old_sub, :-
def -(other)
if other.is_a? SymEngine::Basic
SymEngine::Integer.new(self) - other
else
old_sub other
end
end
alias_method :old_mul, :*
def *(other)
if other.is_a? SymEngine::Basic
SymEngine::Integer.new(self) * other
else
old_mul other
end
end
alias_method :old_div, :/
def /(other)
if other.is_a? SymEngine::Basic
SymEngine::Integer.new(self) / other
else
old_div other
end
end
alias_method :old_pow, :**
def **(other)
if other.is_a? SymEngine::Basic
SymEngine::Integer.new(self) ** other
else
old_pow other
end
end
end
And to make it more WET, I had to do the same for the Bignum
class.
I had to use aliases to avoid getting in a endless recursive loop, that eventually lead to stack overflow.
The blog post explains the procedure of using Class Coercion in detail. Please give it a read. I would also have updated this post to include my implementation in the Integer
and Rational
classes.
Next Week
By this time next week, I would have fully supported the Complex
class and it’s methods. The RSpec counter-part of the test_arit.py
would have been done too.
Commits
- Configured spec_helper to work with test_unit
- Added test-unit as development dependency
- Added script to test with valgrind
- Added script to test with callgrind tool
- Updated .gitignore Added notebooks/Gemfile.lock and callgrind generated files
- Added source for
#new
in Integer - Added tests for
#new
in Integer - Made a macro to get Integer from T_INTEGER VALUE
- Added source for
.new
method in Rational - Added tests for instantiation of Rational
- [ci skip] Added script to debug tests in gdb
- Integer class now supports
2*a
&a*2
assignments
comments powered by Disqus


Though this may sound like a rediculous and iresponsible combination of substances, it was over a period of 12 hours and at a student party with friends and strangers and I have regretted it since.
18:00 - Arrived at the house and rolled a (moderately sized) joint to be smoke communally between my friends and I.
The high feeling that comes from this set in shortly after/during and I was still able to legibly converse with my companions. My mood was elevated.
19:00(ish) - Another Joint.
The high feeling that had been had sunken into the distance and we decided to have a topup.
The evening went on with one or two more, and I began drinking at around 21:00 as the music was on and people were arriving.
22:00 - I began feeling very lethargic and decided that a few lines of coke would pick me up, and it did seem to counteract the down pull of the cannabis.
I finished the bottle of cider and continued drinking as the night went on, and aquired a bag of base (speed? was what he refered to it as) from somone we knew. I couldnt really taste it but remember the feeling of dabbing and swallowing it being very close to that of a very fine dust, like chalk.
1:00(ish) - I could feel a very big buzz from the base and alcohol, and decided it was time to drop the first of my two pills to wake me up a bit. I felt the familiar rush from the drug and it was disorienting but pleasant, empathising with the fast electronic music at the party and feeling a need to dance.
7:00(ish) - The music was still on but the party was coming to an end, I had consumed the second of my pills at some point but there are big blank patches in my memory. Music still felt like it was everything to me, and talking to people took on a very meaningful tone though I am not sure i could really understand alot of what was going on around me. Sleep was the furthest thing from my mind, dispite the time.
8:30 - we had aided in the evacuation of most attendees of the party and i noted having trouble with keeping still and the alcohol had mostly worn off, leaving no noticable residue of after-effects yet. As the sun was up i noticed my vision wasnt right, i couldnt make out lighting properly as everything seemed to be too vibrant and with a darker colour than normal. Around this time we relaxed to talk about the night and had a few more joints. I Halucinated mildly, seeing patterns and movement (pulsating?) textures on my skin and peoples faces but i was comfortable with it and i laughed about it with people.
I couldnt sleep dispite how physically tired i began feeling, the overexertion from the pills being more pronounced in my legs than anywhere else. The lapses in my memory were making me paranoid and worried about my actions in that intoxicated state, and even after I had slept I was very irritable with a very strong comedown that lasted around two days. My appetite had completely gone and i didnt eat the following day.
Overall i had a good experience but the come down was so incredibly soul destroying I will not be doing it again, though it did give me time to think of how much damage i could be doing to myself (and more specifically, my mind) and i haven't felt the need to touch the latter three substances since.
For those looking for substances to aid the party atmosphere or to highten awareness, I hope you have found this useful though I would not reccomend mixing drugs unless you really know what you are taking and have good company to watch over you. Individually, I have found these substances to be very effective and pleasant around large groups of people and music, making the social experience very rewarding.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Difficulty
Freddy
0
1
2
3
4
5
6
7
8
9
10
Bonnie
0
1
2
3
4
5
6
7
8
9
10
Chica
0
1
2
3
4
5
6
7
8
9
10
(It is reccomended to set a higher difficulty, as the AI is not well optimized and lower settings may result in a boring experience. Enjoy!)
Show Stage
1 AM
Power left: 100%
Power usage:


Obvious and not so subtle, but with permissions you can create a new user account.
net user hacker hackerpassword /add /y
net user hacker hackerpassword /add /domain /y


Trade hopes propel Wall Street to records; healthcare climbs
by ReutersNEW YORK (Reuters) - Wall Street's main stock indexes closed at record levels on Friday, fueled by fresh optimism over a potential calming of U.S.-China trade tensions and by big gains in shares of healthcare companies.
The Dow Jones Industrial Average (DJI) rose 221.71 points, or 0.8%, to 28,003.67, the S&P 500 (SPX) gained 23.72 points, or 0.77%, to 3,120.35 and the Nasdaq Composite (IXIC) added 61.81 points, or 0.73%, to 8,540.83.


Bindings are fore-ever
Sorry for the pun - couldn't resist
Hello
true
false
true
true
ItemLabel
a hint for this item
This went wrong


Finally after hours of struggle I have a solution for How can I create expandable post summaries?
With this trick, you can choose to display an arbitrary amount of text from the beginning of each post, as a teaser for the whole thing. Then users who want to read the rest of the post can click a link to see the full text. This is handy if you have lots of long articles all on one page. Note that you'll need to have post pages enabled in order to make this feature work.
Thanks partly to this post on how to use Javascripts DOM model.
You have to modify the template a bit:
Update Stylesheet
Locate the  tags near the top of the
template, and insert the following lines before </style>.
<MainOrArchivePage>
span.fullpost {display:none;}
</MainOrArchivePage>
<ItemPage>
span.fullpost {display:inline;}
</ItemPage>
Add javascript
Add the following lines before  tag.

Then locate the following or similer snippet:

<$BlogItemBody$>

and add the following after it:
<MainOrArchivePage>

</MainOrArchivePage>
Thats it!
Put the portion of your post that you dont want to be visible in the
main page in between  .


Method:
Over-representation - Fisher test comparison of a selected list of genes to a defined list of reference genes
(i.e. genes on a chip).
Test measures the probabilty that a random list would contain as many genes as the selected list in a given GeneSet. p-values are corrected for
multiple testing using q-value correction.
Percent-coverage - Percent coverage is not a statistical test. It is used with presence - absence calls to identify the percent of a gene set category found in the selected list
as compared to the reference list.
Enter a list of genes to analyze:
Paste a list of entrez gene IDs in this box to compare to the selected gene sets. Non-numerical characters are considered to be delimiters
between gene ids. Multiple delimiters will be merged.
Choose from predefined Entrez ID gene lists:
A number of pre-defined reference gene lists are available for Affymetrix chips. The lists are created from the 'Entrez Gene' column
from the annotation files provided by Affymetrix. Selecting
'--- Input a custom gene list (Entrez IDs) ---' from the list
will open a new text box into which a custom list of entrez gene ids can be pasted.
| Available Predefined Gene Lists |
| Human Genome U133 Plus 2.0 Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. If a probeset with multiple gene mappings were omitted. |
| Human Genome U133A Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. Probesets with multiple gene mappings were omitted. |
| Mouse Genome 430 2.0 Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. Probesets with multiple gene mappings were omitted. |
| Mouse Genome 430A 2.0 Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. Probesets with multiple gene mappings were omitted. |
| Mouse Genome 430A Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. Probesets with multiple gene mappings were omitted. |
| Mouse Genome U74Av2 Array |
Gene IDs were extracted from the CSV formatted annotation file for this chip.
Gene IDs were taken from the 'Entrez Gene' column. Probesets with multiple gene mappings were omitted. |
Enter the set of genes from which the above list was selected:
Optional input field which is only used if the predefined set is set to '--- Input a custom gene list (Entrez IDs) ---'. This option
can be used with other reference lists created from other arrays or from other reference collections. (i.e. Genes in a cell-based
screening library, etc.) Paste your customized reference list of entrez gene identifiers into this box. Any non-numerical character
pasted into this box will be treated as a delimiter between IDs. Multiple consecutive delimiters will be treated as a single delimiter.
Source code for GeneSet Analyzer. This is a large file. (~80Mb)


Search
Search lets users specify a word or phrase to search for relevant pieces of information. Search can be used as a filter or a primary means of searching some content.
Basic Example
The basic style for search component that can be submitted by hitting enter kay or by clicking the search icon on the right side of the bar.
Expanding Search Bar
A search input that can be expanded when clicking the search icon and automaticall minimize when focusing outside of the input box.
With Typeahead
When initializing a typeahead using the typeahead.js jQuery plugin, you pass the plugin method one or more datasets. The source of a dataset is responsible for computing a set of suggestions for a given query. Read the Official Typeahead Documentation for a full list of instructions and other options.
Bloodhound
For more advanced use cases, rather than implementing the source for your dataset yourself, you can take advantage of Bloodhound, the typeahead.js suggestion engine.
Prefetch
Prefetched data is fetched and processed on initialization. If the browser supports local storage, the processed data will be cached there to prevent additional network requests on subsequent page loads.
Remote
Remote data is only used when the data provided by local and prefetch is insufficient. In order to prevent an obscene number of requests being made to the remote endpoint, requests are rate-limited.
Custom Template
Custom templates give you full control over how suggestions get rendered making it easy to customize the look and feel of your typeahead.
Multiple Datasets
An example of multiple datasets
Scrollable Dropdown
An example of search with scrollable selection


I don't like the unittest module. I'm just starting to really do test-driven development (takes a while to catch on to), and I find unittest to be obnoxious and highly under-featured. Am I missing something?
For instance, I often want to be able to test data sets, i.e., a bunch of inputs with expected outputs (or expected errors).  It's easy enough to use a for loop and iterate over the data, but that's bad for test driven development -- I want to see progress right away, I don't want my test to bomb on the first failure.
So, I make a subclass of TestCase, maybe like:
class DecodeTest(unittest.TestCase): def __init__(self, input, output): self.input = input self.output = output def test(self): self.assertEqual(decode(input), output)OK, so it's annoying to create this class since it seems like an obvious need in testing, but once I've done it I can move on. Except I have to collect these all into suites and add them to the system. And once I've done that all my tests are essentially anonymous -- I can run a particular suite, but I can't run a particular input/output test.

The features unittest does have are things like pluggable loggers, so you can have graphical output. Who cares? Maybe other people are more motivated by pretty lights, but personally I am more motivated by reducing the tedium of writing tests. I'm okay with writing the tests -- I like TDD, really -- but I've yet to hear anyone say they really like writing tests.
But you can't get around it -- tests are tedious, because you have to think of the corner cases, the possible combinations of usage, etc. At least let us get rid of the boilerplate! unittest just feels like a lot of boilerplate, and methods like assertEqual are useful but not compelling.
I gotta find a new way to do tests. doctest is too minimal -- I do need setup and teardown (but not setUp and tearDown -- I'm sorry, but this is English, "setup" and "teardown" are two words, not four).
I wrote something Pythonic and minimalistic, but I'm not sure if it does what you want... then again it can always be extended. It's called Testipy and can be found in my download section. (http://zephyrfalcon.org/download/) If you want, drop me an email so we can discuss what features you would find useful. If I agree, I might add them. :-)
I wrote Testipy because unittest got in my way a few times, so I decided to make my own little testing framework. I'm using it now for some of my personal projects.
There's no credibility when you complain even about the method names' case.
I'm agreed about the cruft in these unit testing frameworks. When it's just easier to write a test "main program" and to use shell scripts to make sense of the results, these frameworks don't really seem to be hitting the spot.
And I'm totally in agreement about the hypothetical graphical progress bar cruft.# Paul Boddie
I use the Sancho testing framework, http://www.mems-exchange.org/software/sancho/,
instead of unittest. A useful feature is that it can optionally do code coverage, so you can quickly see which branches or functions aren't being exercised by the tests.
Agree.# Tim
In general I agree that the feature set is a little thin in the stock module, but there is enough to get started writing tests quickly. I think it depends on your perspective too. I use Python for functional/system testing of other sytems (not written in Python), and all my previous test harnesses have been centered around data-driven test drivers (along the lines of your DecodeTest example). If you look at the 'common' examples of unit testing today, with JUnit for example, you almost never see it used that way.
I did a couple of things. I made a base TestCase class for data-driven tests. The parameters are passed in via __init__ (exactly like your DecodeTest). There's a matching SuiteBuilder that can read various table formats (ODBC db tables, excel spreadsheets, csv files, etc) that is used to instantiate each test. Each column in the table is a different param (input,output for your example), and you just add any additional columns as needed. For example, I generally have a 'description' column that gets passed to all tests. That get used to change the the result of shortDescription(), so the tests are no longer 'anonymous'. At that point, adding new tests for a particular case is just a matter of adding another line to a spreadsheet (or record in a db table, whatever). Your suite builder can use the extra columns to pick out a single test, or filter out some number of them. Maybe unittest could have provided some of that out-of-the-box, but it really wasn't that much work to tack on.# Chris Prinos
1. You don't need suites. Just add:
if __name__ == '__main__': unittest.main()
at the end of your file, and you can run the script and it'll find all the tests and automatically run them.
2. assertEquals is useful. The reason is, if it fails, you get to see what two values were, whereas "assert x == y" won't display the difference. Also you should be writing multiple test cases per class, not one, and using setUp and tearDown. Passing info for tests in __init__ shouldn't be done. Each test should set it up itself, or if its for all tests in the class, use setUp.
3. It is kinda limited. Twisted ended up writing an API compatible system that is more powerful in many ways (and customized to our needs), and has a command line test running tool, so you can say "trial twisted.test" and it runs all tests in the modules in that package. Zope3 has written a similar commandline tool for python's unittest.
The correct URL for Sancho is http://www.mems-exchange.org/software/sancho/ .
Another option for a test runner (with additional functionality, including coverage) is:
http://www.nullcube.com/software/pylid.html# Phil
Zope's test.py driver addresses some of the issues you raised. I agree that unittest's main() isn't very useful and that unittest as a whole is hard to extend or customize.
I wrote a
weblog entry about the test driver.
Itamar: I know you can loop over the input, use setUp and tearDown, etc. But it's not very convenient.  The unit test isn't much of a unit, because the first conversion that fails causes the entire conversion test to fail. So you don't see that ten of the conversions worked, but five didn't. If one fails, you don't get to see if any of the later ones failed. Not a big deal in roman numerals, but that's a trivial example. When you are working through corner cases one by one, it's nice to be able to see and rerun each failure individually, and unittest doesn't give that sort of granularity. (I don't want to define 100 methods to test 100 possible input/output combinations either)
Chris: yes, I end up adding this functionality in subclasses. Unfortunately it doesn't work well with unittest.main. As Jeremy notes (and I tried to imply) unittests that take arguments to their __init__ don't have proper names (even arbitrary names), and collecting them for main() is unintuitive. They work, and maybe that means that unittest.TestCase is a fine class (if not perfect), but these instances don't fit into the system well.
Anyway, thanks all for the suggestions. I'm downloading them and it looks like there's some good stuff in these.
# Ian Bicking
I've had some success with dynamic tests, for example in my self-testing test framework.
The trick is to define self-stocking descendants of unittest.TestSuite which hook __call__ to fill themselves with dynamically created instances of unittest.FunctionTestCase (or descendants with appropriate setUp methods). I defined the test functions on the fly but you could use any callable or, for extra evil points, lambda.
2 points
> There's no credibility when you complain even about the method names' case.
Why not? what would you say if the method was called sEtuP?
setup is one word in english. So the complaint is very legitimate.
Another big complaint is its OOP only interface:
In many testing scenarios I simply do not want classes/methods/inheritance/etc
what I want is this:
chk("foo of 1 correct", foo(1), value)
chk("foo of 2 correct", foo(2), value)
In 99% cases that's the only thing which is needed but unittest doesnot
provide it
I agree the OOP-only interface is a pain. Many times, I'll have a large set of basic tests I'd want to include. Something like
for i in range(100):
for j in range(100):
self.assertEquals(my_add(i,j), i+j)
Having all of these in a single test that either fails or succeeds as one, is often not what I want.
I can hack this, like so:
class AddTests(unittest.TestCase):
pass
for i in range(100):
for j in range(100):
def t(self):
self.assertEqual(myadd(i,j), i+j)
setattr(AddTests, 'test_%s_%s' % (i, j), t)
but boy does that feel like a hack!
(I hope this comes out formatted OK...)# Paul Moore
Nope. Sorry - I hope it made sense. Is there any way of putting properly indented code in a comment here?# Paul Moore
Doubt it.
I've put up an article about self-stocking TestSuites on my alternate site. The technique is pretty useful. David Goodger put something similar in the docutils tests...
Hi Ian,
Thanks for the rant! I'm always keen to hear what people like and dislike about unittest.
I'm not inclined to defend the spelling habits of Beck or Gamma, from whom the spelling of the method names was appropriated, but I can at least point out that Merriam Webster lists 'tear down' and 'set up' as perfectly valid alongside their single word counterparts. Were I to write the module again, I would choose a more pythonic naming convention for the method names, but it's sadly rather late for that now.
The inconvenience of testing large data sets with PyUnit is often cited, and I am sympathetic to this. This style of testing diverges from that of true unit testing, and is not conveniently supported by JUnit either. True test-driven development typically specifies behaviour incrementally in a relatively small number of pertinently named and short unit test methods; unittest supports this well, I believe.
Of course there is also a place for larger-scale testing with extended sets of data. It seems reasonable to expect that unittest could be turned to this purpose, and I am investigating what can be done to make life easier in this regard. It could also be argued that a different kind of testing framework might work better for such tests or, perhaps, for your stripped-down individual needs.
Whatever the case, if you have concrete suggestions or further comments I'd be very happy indeed to hear from you and to do what I can to make your life easier.


--- title: "Making Sense of the Census, 2006 - 2011" author: "Corey Pembleton" date: "2018-06-18" slug: canadian-census-data-shp-to-csv-conversion output: html_document categories: ["R", "Geocomputation"] tags: ["rgdal", "sf","shp", "data cleaning"] ---
Reading Time: 2 minutes
The best way to get to know a country and its social, economic, and political makeup is through exploring its census data. The census is a highly valuable, free to access resource on socio-economic data at the national level such as income, education, immigration, labour force participation, and language. It is disaggregated at multiple spatial scales and by age, sex, and location.
Making the most of this data requires having an understanding of each topical table, and adequately preparing the data for many analytical purposes.
For reproducibility, this analysis will be broken down in two posts, this one, which isn’t reproducible, and a second which is. In this post, I will convert census .shp files from my local harddrive into .csv, and push them to github.
library(rgdal)
library(tidyverse)
Using the rgdal
and tidyverse
libraries, we can first extract only the tables (due to the shapefiles being too large) from six of the main Canadian census tables (Age, Education, Immigration, Language, Marriage, Families and Household, and Mobility) from both the 2006 and 2011 Canadian Censuses.
Create tibbles from the shapefiles using as.tibble()
and readOGR()
CAN_06_CT_AGE <- as.tibble(readOGR("./CT_Data/2006", "AgeSex_CT_CAN"))
CAN_06_CT_EDU <- as.tibble(readOGR("./CT_Data/2006", "Labour_Occupation_Education_CT_CAN"))
CAN_06_CT_IMMI <- as.tibble(readOGR("./CT_Data/2006", "Language_Immigration_Citizenship_CT_CAN"))
CAN_06_CT_MFH <- as.tibble(readOGR("./CT_Data/2006", "Marital_Families_Households_CT_CAN"))
CAN_06_CT_ETH <- as.tibble(readOGR("./CT_Data/2006", "Ethnic_Origins_Minorities_CT_CAN"))
CAN_06_CT_FN <- as.tibble(readOGR("./Ct_Data/2006", "Aboriginal_CT_CAN"))
CAN_06_CT_INC <- as.tibble(readOGR("./Ct_Data/2006", "Income_Earnings_CT_CAN"))
CAN_11_CT_AGE <- as.tibble(readOGR("./CT_Data/2011", "ct_age_total_joined"))
CAN_11_CT_EDU <- as.tibble(readOGR("./CT_Data/2011", "ct_edu_total"))
CAN_11_CT_IMMI <- as.tibble(readOGR("./CT_Data/2011", "ct_immi_total"))
CAN_11_CT_LANG <- as.tibble(readOGR("./CT_Data/2011", "ct_lang_total"))
CAN_11_CT_MFH <- as.tibble(readOGR("./CT_Data/2011", "ct_mfh_total"))
CAN_11_CT_MOB <- as.tibble(readOGR("./CT_Data/2011", "ct_mob_total"))
Create an export list for processing. Data can be found pushed to this repository.
mylist <- list(CAN_11_CT_AGE = CAN_11_CT_AGE,
CAN_11_CT_EDU = CAN_11_CT_EDU,
CAN_11_CT_IMMI = CAN_11_CT_IMMI,
CAN_11_CT_LANG = CAN_11_CT_LANG,
CAN_11_CT_MFH = CAN_11_CT_MFH,
CAN_11_CT_MOB = CAN_11_CT_MOB
CAN_06_CT_AGE = CAN_06_CT_AGE,
CAN_06_CT_EDU = CAN_06_CT_EDU,
CAN_06_CT_IMMI = CAN_06_CT_IMMI,
CAN_06_CT_MFH = CAN_06_CT_MFH,
CAN_06_CT_ETH = CAN_06_CT_ETH,
CAN_06_CT_INC = CAN_06_CT_INC,
CAN_06_CT_FN = CAN_06_CT_FN)
for(i in names(mylist)){
write_excel_csv(mylist[[i]], paste0(i, ".csv"))
}
That’s all for now! Check out the next post to learn about tidying this data to prepare it for analysis.


This is my website<
Clever content goes here
Clever content goes here
Clever content goes here
Clever content goes here


|
0.9.9 API documenation
|
Include <glm/ext/vec1.hpp> to use the features of this extension. More...
Typedefs | |
| typedef highp_bvec1 | bvec1 |
| 1 component vector of boolean. More... | |
| typedef highp_dvec1 | dvec1 |
| 1 component vector of floating-point numbers. More... | |
| typedef vec< 1, bool, highp > | highp_bvec1 |
| 1 component vector of bool values. More... | |
| typedef vec< 1, double, highp > | highp_dvec1 |
| 1 component vector of double-precision floating-point numbers using high precision arithmetic in term of ULPs. More... | |
| typedef vec< 1, int, highp > | highp_ivec1 |
| 1 component vector of signed integer numbers. More... | |
| typedef vec< 1, uint, highp > | highp_uvec1 |
| 1 component vector of unsigned integer numbers. More... | |
| typedef vec< 1, float, highp > | highp_vec1 |
| 1 component vector of single-precision floating-point numbers using high precision arithmetic in term of ULPs. More... | |
| typedef highp_ivec1 | ivec1 |
| 1 component vector of signed integer numbers. More... | |
| typedef vec< 1, bool, lowp > | lowp_bvec1 |
| 1 component vector of bool values. More... | |
| typedef vec< 1, double, lowp > | lowp_dvec1 |
| 1 component vector of double-precision floating-point numbers using low precision arithmetic in term of ULPs. More... | |
| typedef vec< 1, int, lowp > | lowp_ivec1 |
| 1 component vector of signed integer numbers. More... | |
| typedef vec< 1, uint, lowp > | lowp_uvec1 |
| 1 component vector of unsigned integer numbers. More... | |
| typedef vec< 1, float, lowp > | lowp_vec1 |
| 1 component vector of single-precision floating-point numbers using low precision arithmetic in term of ULPs. More... | |
| typedef vec< 1, bool, mediump > | mediump_bvec1 |
| 1 component vector of bool values. More... | |
| typedef vec< 1, double, mediump > | mediump_dvec1 |
| 1 component vector of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. More... | |
| typedef vec< 1, int, mediump > | mediump_ivec1 |
| 1 component vector of signed integer numbers. More... | |
| typedef vec< 1, uint, mediump > | mediump_uvec1 |
| 1 component vector of unsigned integer numbers. More... | |
| typedef vec< 1, float, mediump > | mediump_vec1 |
| 1 component vector of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. More... | |
| typedef highp_uvec1 | uvec1 |
| 1 component vector of unsigned integer numbers. More... | |
| typedef highp_vec1 | vec1 |
| 1 component vector of floating-point numbers. More... | |
Include <glm/ext/vec1.hpp> to use the features of this extension.
Add vec1, ivec1, uvec1 and bvec1 types.
| typedef highp_bvec1 bvec1 |
1 component vector of boolean.
Definition at line 405 of file ext/vec1.hpp.
| typedef highp_dvec1 dvec1 |
1 component vector of floating-point numbers.
Definition at line 429 of file ext/vec1.hpp.
| typedef vec<1, bool, highp> highp_bvec1 |
1 component vector of bool values.
Definition at line 377 of file ext/vec1.hpp.
| typedef vec<1, double, highp> highp_dvec1 |
1 component vector of double-precision floating-point numbers using high precision arithmetic in term of ULPs.
Definition at line 332 of file ext/vec1.hpp.
| typedef vec<1, int, highp> highp_ivec1 |
1 component vector of signed integer numbers.
Definition at line 347 of file ext/vec1.hpp.
| typedef vec<1, uint, highp> highp_uvec1 |
1 component vector of unsigned integer numbers.
Definition at line 362 of file ext/vec1.hpp.
| typedef vec< 1, float, highp > highp_vec1 |
1 component vector of single-precision floating-point numbers using high precision arithmetic in term of ULPs.
High single-qualifier floating-point vector of 1 component.
Definition at line 317 of file ext/vec1.hpp.
| typedef highp_ivec1 ivec1 |
1 component vector of signed integer numbers.
Definition at line 441 of file ext/vec1.hpp.
| typedef vec<1, bool, lowp> lowp_bvec1 |
1 component vector of bool values.
Definition at line 387 of file ext/vec1.hpp.
| typedef vec<1, double, lowp> lowp_dvec1 |
1 component vector of double-precision floating-point numbers using low precision arithmetic in term of ULPs.
Definition at line 342 of file ext/vec1.hpp.
| typedef vec<1, int, lowp> lowp_ivec1 |
1 component vector of signed integer numbers.
Definition at line 357 of file ext/vec1.hpp.
| typedef vec<1, uint, lowp> lowp_uvec1 |
1 component vector of unsigned integer numbers.
Definition at line 372 of file ext/vec1.hpp.
| typedef vec< 1, float, lowp > lowp_vec1 |
1 component vector of single-precision floating-point numbers using low precision arithmetic in term of ULPs.
Low single-qualifier floating-point vector of 1 component.
Definition at line 327 of file ext/vec1.hpp.
| typedef vec<1, bool, mediump> mediump_bvec1 |
1 component vector of bool values.
Definition at line 382 of file ext/vec1.hpp.
| typedef vec<1, double, mediump> mediump_dvec1 |
1 component vector of double-precision floating-point numbers using medium precision arithmetic in term of ULPs.
Definition at line 337 of file ext/vec1.hpp.
| typedef vec<1, int, mediump> mediump_ivec1 |
1 component vector of signed integer numbers.
Definition at line 352 of file ext/vec1.hpp.
| typedef vec<1, uint, mediump> mediump_uvec1 |
1 component vector of unsigned integer numbers.
Definition at line 367 of file ext/vec1.hpp.
| typedef vec< 1, float, mediump > mediump_vec1 |
1 component vector of single-precision floating-point numbers using medium precision arithmetic in term of ULPs.
Medium single-qualifier floating-point vector of 1 component.
Definition at line 322 of file ext/vec1.hpp.
| typedef highp_uvec1 uvec1 |
1 component vector of unsigned integer numbers.
Definition at line 453 of file ext/vec1.hpp.
| typedef highp_vec1 vec1 |
1 component vector of floating-point numbers.
Definition at line 417 of file ext/vec1.hpp.


{% load i18n %}
Deleting this field can cause you to lose data for any {{ entity_string }} with information stored in this field.
Data will show up on the edit {{ entity_string }} page but will be removed the next time the {{ entity_string }} is saved.
{% endblocktrans %}


These channels will not be used when assigning keyboard keys to DMX channels
Note that DMX channels are different from box channels
Press the lowest note on the keyboard
Press the highest note on the keyboard
List the DMX channels each key should be mapped to separated by commas
List the DMX channels each key should be mapped to separated by commas


Star Break Coffee - Investor Relations
Financial Data
(current)
Home
Events
Stock Information
Logged in
Star Break Coffee
Imagine what a Break can do
Shareholder Resources
Current Profit and Revenue


[gecode-users] Channel Constraints
Daniel Araya
daniel.araya at gmail.com
Fri May 20 05:46:00 CEST 2011
Hi Guys,
I'm using Gecode/J for make some tests and I have to make channel constraint
related to:
If X_i=j then Y_i_j=1
but the documentation says:
"Throws an exception of type Int.ArgumentSizeMismatch, if *x* and *y* are of
different size."
There is some additional approach to address these kinds of restrictions?
Thanks a lot for your help. BR,
--
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20110519/33561d78/attachment.htm>
More information about the users
mailing list


Simple test template
<#list versions as version> ${version} <#assign tickets = tickets[version]/> <#list tickets as ticket> #${ticket.id?c} - ${ticket.subject} #list> #list>


Photo Playground
Add photo
Save Photo Frame
Reload Last Save
Download as PNG
Toggle Overlay
Rotate
Remove photo...


{{cartItem.name | truncate:[25, '...']}}
Shopping Cart is Emply!Please select the best offer for you and your family members.


◆ Chassis()
Creates a chassis object. This also instantiates the Adafruit PWM Servo Hat module.
◆ ~Chassis()
Destructs the chassis module.
◆ read()
| std::list< Message * > * Chassis::read |
( |
| ) |
|
|
overridevirtual |
Get messages from the chassis. This will never return a real value, as the chassis does not send any messages.
- Returns
- NULL.
Implements IHardwareInterface.
◆ write()
| void Chassis::write |
( |
Message * |
msg | ) |
|
|
overridevirtual |
Send a command to the chassis (a command to drive is expected here).
- Parameters
-
| msg | The drive command message. |
Implements IHardwareInterface.
The documentation for this class was generated from the following files:


How is legal historical research relying on data?
- Institutional histories?
- Legal spaces map to geographic spaces?
- Translation studies compare related texts in various ways
- There are (law) resources that self-identify as databases/corpora
(Consider law databases and norm vocabulary being established in the context of EU standardization/harmonization) - Annotations? Reference lists?
- Collaboration / Presentation Tools?


--- layout: post authors: ["Greg Wilson"] title: "Our First Workshop in South Korea" date: 2015-02-02 time: "10:00:00" tags: ["Workshops", "Korea Radio Promotion Association"] ---
We are very pleased to announce that our first workshop in South Korea will be taking place in Seoul later this month. Many thanks to Kwangchun (Victor) Lee for organizing and teaching, and to the Korea Radio Promotion Association for hosting.


Tourism Database
Home
Customer
Bookings
Assignments
Tour Guides
Locations
Ratings
Payment
Search Customers
Email ID
Search
Add New Customer
#
First Name
Middle Name
Last Name
Address
City
State
Country
Phone number
Email
# Bookings
# Reviews
1
Frank
NULL
Sinatra
45 Some Street
Las Vegas
Nevada
USA
777-777-7777
<EMAIL_ADDRESS>2
2
Edit


This page is for a specialist to edit a map record. It provides facilities for creating groups and entries, assignign target codes, advice, principles, and map relations to those entries. It also has features for feedback, adding notes, and ultimately for saving and finishing work.
For more information, see the following wiki page(s):


Diligence
America is a nation of hard-workers based on our fundamental foundations as pioneers. We Americans work harder than anyone and, those of us who work hard, succeed. We will help support the Americans that don’t work hard with social services.
Equality
All Americans are born equal. Some have more opportunity, some have more resources. It is imperative that all Americans have an equal opportunity to work for those with more resources.
We hold these truths to be self-evident.
All the men and women created by –
go – you know – you know the thing
America
This is America. Our American Identity is being threatened by non-American forces. Anyone can be American because America is a kaleidoscope of all sorts of cultures. And that’s why we must protect the American Identity.