Inherits from
- HasTraits: enthought.traits.has_traits.HasTraits
Attributes
- all_outputs
all_outputs = Property(Instance(set))
- ast
The AST that represents our behavior
ast = Instance(Node)
- codestring
codestring = Property
- conditional_outputs
conditional_outputs = Property(Instance(set))
- const_assign
const_assign = Property(Instance(tuple))
- filename
The name of the file this block represents, if any. For blocks that aren't files, the default value just shows repr(self). Annotates tracebacks.
filename = Instance(basestring)
- fromimports
fromimports = Property(Instance(set))
- grouped
Is this block the result of merging other blocks?
grouped = Bool(False)
- imports_ast
imports_ast = Property(Instance(Node))
- inputs
Input and output parameters
inputs = Property(Instance(set))
- no_filenames_in_tracebacks
Enabling this makes tracebacks less useful but speeds up Block.execute. The problem is that a code object has a unique filename ('co_filename'), so we can compile all of our sub-blocks' ASTs into a single code object only if we ignore the fact that they might each come from different files.
no_filenames_in_tracebacks = Bool(False)
- outputs
outputs = Property(Instance(set))
- sub_blocks
The sequence of sub-blocks that make up this block, if any. If we don't decompose into sub-blocks, 'sub_blocks' is None.
sub_blocks = List(__this)
- uuid
A unique identifier
uuid = Instance(UUID)
Inherited from base classes
Method summary
- __eq__(self, other)
- __getstate__(self)
- __hash__(self)
- __init__(self, x = (), file = None, grouped = False, **kw)
- __repr__(self)
- __setstate__(self, state)
- __str__(self)
- execute(self, local_context, global_context = { }, continue_on_errors = False)
- from_file(cls, f)
- from_string(cls, s)
- get_function(self, inputs = [ ], outputs = [ ])
- invalidate_cache(self)
- is_empty(self)
- remove_sub_block(self, uuid)
- restrict(self, inputs = (), outputs = ())
- validate_for_restriction(self)
Inherited from base classes
- __deepcopy__(self, memo)
- __prefix_trait__(self, name, is_set)
- __reduce_ex__(self, protocol)
- add_class_trait(cls, name, *trait)
- add_trait(self, name, *trait)
- add_trait_category(cls, category)
- add_trait_listener(self, object, prefix = '')
- all_trait_names(self)
- base_trait(self, name)
- class_default_traits_view(cls)
- class_editable_traits(cls)
- class_trait_names(cls, **metadata)
- class_trait_view(cls, name = None, view_element = None)
- class_trait_view_elements(cls)
- class_traits(cls, **metadata)
- clone_traits(self, traits = None, memo = None, copy = None, **metadata)
- configure_traits(self, filename = None, view = None, kind = None, edit = True, context = None, handler = None, id = '', scrollable = None, **args)
- copy_traits(self, other, traits = None, memo = None, copy = None, **metadata)
- copyable_trait_names(self, **metadata)
- default_traits_view(self)
- edit_traits(self, view = None, parent = None, kind = None, context = None, handler = None, id = '', scrollable = None, **args)
- editable_traits(self)
- has_traits_interface(self, *interfaces)
- on_trait_change(self, handler, name = None, remove = False, dispatch = 'same', priority = False, deferred = False)
- print_traits(self, show_help = False, **metadata)
- remove_trait(self, name)
- remove_trait_listener(self, object, prefix = '')
- reset_traits(self, traits = None, **metadata)
- set_trait_dispatch_handler(cls, name, klass, override = False)
- sync_trait(self, trait_name, object, alias = None, mutual = True, remove = False)
- trait(self, name, force = False, copy = False)
- trait_context(self)
- trait_get(self, *names, **metadata)
- trait_monitor(cls, handler, remove = False)
- trait_names(self, **metadata)
- trait_set(self, trait_change_notify = True, **traits)
- trait_setq(self, **traits)
- trait_subclasses(cls, all = False)
- trait_view(self, name = None, view_element = None)
- trait_view_elements(self)
- trait_views(self, klass = None)
- traits(self, **metadata)
- validate_trait(self, name, value)
Methods
- __eq__(self, other)
- __getstate__(self)
- __hash__(self)
- __init__(self, x = (), file = None, grouped = False, **kw)
- __repr__(self)
- __setstate__(self, state)
- __str__(self)
- execute(self, local_context, global_context = { }, continue_on_errors = False)
Execute the block in local_context, optionally specifying a global context. If continue_on_errors is specified, continue executing code after an exception is thrown and throw the exceptions at the end of execution. if more than one exception was thrown, combine them in a CompositeException
- from_file(cls, f)
Create a Block from a source file.
- from_string(cls, s)
Create a Block from a code string.
- get_function(self, inputs = [ ], outputs = [ ])
Return a function which takes the list of input variables as arguments and returns the given output_list.
These lists determine the calling order for the function.
- invalidate_cache(self)
Someone modified the block's internal ast. This method provides and explicit means to invalidating the cached __code object
- is_empty(self)
Return true if 'block' has an empty AST.
- remove_sub_block(self, uuid)
- restrict(self, inputs = (), outputs = ())
The minimal sub-block that computes 'outputs' from 'inputs'.
Consider the block:
x = expensive() x = 2 y = f(x, a) z = g(x, a) w = h(a)
This block has inputs 'a' (and 'f', 'g', 'h', and 'expensive'), and outputs 'x', 'y', 'z', and 'w'. If one is only interested in computing 'z', then lines 1, 3, and 5 can be omitted. Similarly, if one is only interested in propagating the effects of changing 'a', then lines 1 and 2 can be omitted. And if one only wants to recompute 'z' after changing 'a', then all but line 4 can be omitted.
In this fashion, 'restrict' computes the minimal sub-block that computes 'outputs' from 'inputs'. See the tests in 'block_test_case.BlockRestrictionTestCase' for concrete examples.
Assumes 'inputs' and 'outputs' are subsets of 'self.inputs' and 'self.outputs', respectively.
- validate_for_restriction(self)