- Getting started
- User Guide
- Examples
- API reference
- Developer Guide
Note
This documentation is for a development version. Click here for the latest stable release (v1.3.0).
nengo_spa.ast package¶
Submodules¶
nengo_spa.ast.base module¶
Basic classes for abstract syntax trees (ASTs) in NengoSPA.
-
nengo_spa.ast.base.
infer_types
(*nodes)[source]¶ Infers the most specific type for given nodes, sets end returns it.
This determines the most specific type for given nodes. If it is a specific vocabulary, this vocabulary will be set for all less specific vocabulary types (but not scalar types) on the given node. Then the type will be returned.
-
class
nengo_spa.ast.base.
Node
(type_)[source]¶ Bases:
object
Base class for nodes in the AST for NengoSPA operations.
- Parameters
- type_nengo_spa.types.Type
Type that the node evaluates to.
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
class
nengo_spa.ast.base.
Noop
(type_)[source]¶ Bases:
nengo_spa.ast.base.Node
Node that has no effect.
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
-
class
nengo_spa.ast.base.
Fixed
(type_)[source]¶ Bases:
nengo_spa.ast.base.Node
Base class for AST nodes that provide a fixed value.
-
class
nengo_spa.ast.base.
TypeCheckedBinaryOp
(expected_type, conversion=None)[source]¶ Bases:
object
Decorator to check the type of the other parameter of an operator.
If the other parameter is not an instance of expected_type, NotImplemented will be returned from the decorated method. If conversion is given it will be applied first.
- Parameters
- expected_typeclass
Type for which the operator is implemented.
- conversionfunction, optional
Used to convert other before checking its type.
-
expected_type
¶
-
conversion
¶
nengo_spa.ast.dynamic module¶
AST classes for dynamic operations (i.e. their output changes over time).
-
class
nengo_spa.ast.dynamic.
DynamicNode
(type_)[source]¶ Bases:
nengo_spa.ast.base.Node
Base class for AST node with an output that changes over time.
-
class
nengo_spa.ast.dynamic.
Transformed
(source, transform, type_)[source]¶ Bases:
nengo_spa.ast.dynamic.DynamicNode
AST node representing a transform.
- Parameters
- sourceNengoObject
Nengo object providing the output to apply the transform to.
- transformndarray
Transform to apply.
- type_nengo_spa.types.Type
The resulting type.
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
class
nengo_spa.ast.dynamic.
Summed
(sources, type_)[source]¶ Bases:
nengo_spa.ast.dynamic.DynamicNode
AST node representing the sum of multiple nodes.
- Parameters
- sourcessequence of NengoObject
Sequence of Nengo objects providing outputs to be summed.
- type_nengo_spa.types.Type
The resulting type.
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
class
nengo_spa.ast.dynamic.
ModuleOutput
(output, type_)[source]¶ Bases:
nengo_spa.ast.dynamic.DynamicNode
AST node representing the output of a SPA module.
- Parameters
- outputNengoObject
Nengo object providing the module output.
- type_nengo_spa.types.Type
The resulting type.
-
construct
()[source]¶ Implement the computation represented by the node.
- Returns
- NengoObject
Usually the object providing the computation result as output, but can be something else in certain cases.
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
nengo_spa.ast.expr_tree module¶
Representation of simple expression trees.
-
class
nengo_spa.ast.expr_tree.
Node
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
Leaf
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
EllipsisLeaf
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Leaf
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
UnaryOperator
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
BinaryOperator
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
property
lhs
¶
-
property
rhs
¶
-
property
-
class
nengo_spa.ast.expr_tree.
AttributeAccess
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
FunctionCall
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
-
class
nengo_spa.ast.expr_tree.
KeywordArgument
(value, precedence, children)[source]¶ Bases:
nengo_spa.ast.expr_tree.Node
Create new instance of Node(value, precedence, children)
nengo_spa.ast.symbolic module¶
AST classes for symbolic operations.
-
class
nengo_spa.ast.symbolic.
Symbol
(type_)[source]¶ Bases:
nengo_spa.ast.base.Fixed
-
property
expr
¶
-
property
-
class
nengo_spa.ast.symbolic.
FixedScalar
(value)[source]¶ Bases:
nengo_spa.ast.symbolic.Symbol
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
construct
()[source]¶ Implement the computation represented by the node.
- Returns
- NengoObject
Usually the object providing the computation result as output, but can be something else in certain cases.
-
property
expr
¶
-
-
class
nengo_spa.ast.symbolic.
PointerSymbol
(expr, type_=_TAnyVocab('TAnyVocab'))[source]¶ Bases:
nengo_spa.ast.symbolic.Symbol
-
connect_to
(sink, **kwargs)[source]¶ Implement the computation represented by the node and connect it.
- Parameters
- sinkNengoObject
Nengo object to connect to and transmit the result to.
- **kwargsdict
Additional keyword arguments to pass to
nengo.Connection
.
-
construct
()[source]¶ Implement the computation represented by the node.
- Returns
- NengoObject
Usually the object providing the computation result as output, but can be something else in certain cases.
-
property
expr
¶
-
-
class
nengo_spa.ast.symbolic.
PointerSymbolFactory
[source]¶ Bases:
object
Provides syntactic sugar to create PointerSymbol instances.
Use the
sym
instance of this class to create PointerSymbols like so:sym.foo # creates PointerSymbol('foo')
To create more complex symbolic expressions the following syntax is supported too:
sym('foo + bar * baz') # creates PointerSymbol('foo+bar*baz')