Documentation for Python¶
Cell¶
To implement an ecto cell in Python, you need to inherit from the following class:
Tendril¶
You have the same functionalities as in C++ with Tendril:
-
class
ecto.
Tendril
¶ The Tendril is the slendor winding organ of ecto. It is a type erasing holder with meta data that enable introspection.
-
copy_value
((Tendril)arg1, (Tendril)arg2) → None :¶ Copy from one tendril to the other.
- C++ signature :
- void copy_value(boost::shared_ptr<ecto::tendril>,boost::shared_ptr<ecto::tendril>)
-
static
createT
((str)arg1) → Tendril :¶ Create a tendril of the c++ type.
- C++ signature :
- ecto::tendril createT(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
dirty
¶ Has the tendril changed since the last time?
-
doc
¶ A doc string that describes the purpose of this tendril.
-
get
((Tendril)arg1) → object :¶ Gets the python value of the object. May be None if python bindings for the type held do not have boost::python bindings available from the current scope.
- C++ signature :
- boost::python::api::object get(boost::shared_ptr<ecto::tendril>)
-
has_default
¶ Does the tendril have an explicit default value? Remember that the implicit default is always the default constructed type.
-
static
listT
() → object :¶ - C++ signature :
- boost::python::api::object listT()
-
load
((Tendril)arg1, (str)arg2) → None :¶ - C++ signature :
- void load(ecto::tendril {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
notify
((Tendril)arg1) → None :¶ Force updates.
- C++ signature :
- void notify(ecto::tendril {lvalue})
-
required
¶ Is this tendril required to be connected?
-
save
((Tendril)arg1) → str :¶ - C++ signature :
- std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > save(ecto::tendril)
-
set
((Tendril)arg1, (object)arg2) → None :¶ Assuming the value held by the tendril has boost::python bindings, this will copy the value of the given python object into the value held by the tendril.
- C++ signature :
- void set(boost::shared_ptr<ecto::tendril>,boost::python::api::object)
-
type_name
¶ The type of the value held by the tendril.
-
user_supplied
¶ Has the value been set by the user?
-
val
¶ The value held by the tendril. It requires boost::python bindings to be accessible from python. If none are available it will be None.
-
And similaryl with an ecto.Tendrils:
-
class
ecto.
Tendrils
¶ -
at
((Tendrils)arg1, (str)arg2) → Tendril :¶ - C++ signature :
- boost::shared_ptr<ecto::tendril> at(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
clear
((Tendrils)arg1) → None :¶ D.clear() -> None. Remove all items from D.
- C++ signature :
- void clear(ecto::tendrils {lvalue})
-
declare
((Tendrils)arg1, (str)arg2, (str)arg3) → None :¶ - C++ signature :
- void declare(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
declare( (Tendrils)arg1, (str)arg2, (str)arg3, (object)arg4) -> None :
- C++ signature :
- void declare(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,boost::python::api::object)
declare( (Tendrils)arg1, (str)arg2, (Tendril)arg3) -> None :
- C++ signature :
- void declare(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,boost::shared_ptr<ecto::tendril>)
-
static
fromkeys
((object)arg1, (object)arg2) → object :¶ Tendrils.fromkeys(S,v) -> New Tendrils with keys from S and values equal to v.
- C++ signature :
- boost::python::api::object fromkeys(boost::python::api::object,boost::python::api::object)
-
get
((Tendrils)arg1, (str)arg2[, (object)default_val]) → object :¶ D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- C++ signature :
- boost::python::api::object get(ecto::tendrils,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > [,boost::python::api::object])
-
has_key
((Tendrils)arg1, (str)arg2) → bool :¶ D.has_key(k) -> True if D has a key k, else False
- C++ signature :
- bool has_key(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
items
((Tendrils)arg1) → list :¶ D.items() -> list of D’s (key, value) pairs, as 2-tuples
- C++ signature :
- boost::python::list items(ecto::tendrils)
-
iteritems
((object)arg1) → object :¶ D.iteritems() -> an iterator over the (key, value) items of D
- C++ signature :
- boost::python::objects::iterator_range<boost::python::return_value_policy<boost::python::return_by_value, boost::python::default_call_policies>, boost::iterators::transform_iterator<boost::python::std_map_indexing_suite<ecto::tendrils, false, boost::python::detail::final_std_map_derived_policies<ecto::tendrils, false> >::iteritems, std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::shared_ptr<ecto::tendril> > >, boost::iterators::use_default, boost::iterators::use_default> > iteritems(boost::python::back_reference<ecto::tendrils const&>)
-
iterkeys
((object)arg1) → object :¶ D.iterkeys() -> an iterator over the keys of D
- C++ signature :
- boost::python::objects::iterator_range<boost::python::return_value_policy<boost::python::return_by_value, boost::python::default_call_policies>, boost::iterators::transform_iterator<boost::python::std_map_indexing_suite<ecto::tendrils, false, boost::python::detail::final_std_map_derived_policies<ecto::tendrils, false> >::iterkeys, std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::shared_ptr<ecto::tendril> > >, boost::iterators::use_default, boost::iterators::use_default> > iterkeys(boost::python::back_reference<ecto::tendrils const&>)
-
itervalues
((object)arg1) → object :¶ D.itervalues() -> an iterator over the values of D
- C++ signature :
- boost::python::objects::iterator_range<boost::python::return_value_policy<boost::python::return_by_value, boost::python::default_call_policies>, boost::iterators::transform_iterator<boost::python::std_map_indexing_suite<ecto::tendrils, false, boost::python::detail::final_std_map_derived_policies<ecto::tendrils, false> >::itervalues, std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::shared_ptr<ecto::tendril> > >, boost::iterators::use_default, boost::iterators::use_default> > itervalues(boost::python::back_reference<ecto::tendrils const&>)
-
keys
((Tendrils)arg1) → list :¶ D.keys() -> list of D’s keys
- C++ signature :
- boost::python::list keys(ecto::tendrils)
-
load
((Tendrils)arg1, (std_istream)arg2) → None :¶ - C++ signature :
- void load(ecto::tendrils {lvalue},std::istream {lvalue})
-
notify
((Tendrils)arg1) → None :¶ - C++ signature :
- void notify(ecto::tendrils {lvalue})
-
pop
((Tendrils)arg1, (str)arg2) → object :¶ - C++ signature :
- boost::python::api::object pop(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- pop( (Tendrils)arg1, (str)arg2, (object)arg3) -> object :
D.pop(k[,d]) -> v, remove specified key and return the corresponding value If key is not found, d is returned if given, otherwise KeyError is raised
- C++ signature :
- boost::python::api::object pop(ecto::tendrils {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,boost::python::api::object)
-
popitem
((Tendrils)arg1) → object :¶ D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty
- C++ signature :
- boost::python::api::object popitem(ecto::tendrils {lvalue})
-
save
((Tendrils)arg1, (std_ostream)arg2) → None :¶ - C++ signature :
- void save(ecto::tendrils,std::ostream {lvalue})
-
update
((object)arg1, (object)arg2) → None :¶ D.update(E) -> None. Update D from E: for k in E: D[k] = E[k]
- C++ signature :
- void update(boost::python::api::object {lvalue},boost::python::api::object)
-
values
((Tendrils)arg1) → list :¶ D.values() -> list of D’s values
- C++ signature :
- boost::python::list values(ecto::tendrils)
-
Plasm¶
This is all you can do with a plasm in Python:
-
class
ecto.
Plasm
¶ -
activate_all
((Plasm)arg1) → None :¶ - C++ signature :
- void activate_all(ecto::plasm {lvalue})
-
cells
((Plasm)arg1) → list :¶ Grabs the current set of cells that are in the plasm.
- C++ signature :
- boost::python::list cells(ecto::plasm {lvalue})
-
check
((Plasm)arg1) → None :¶ - C++ signature :
- void check(ecto::plasm {lvalue})
-
configure_all
((Plasm)arg1) → None :¶ - C++ signature :
- void configure_all(ecto::plasm {lvalue})
-
connect
((Plasm)arg1, (list)connection_list) → None :¶ - C++ signature :
- void connect(ecto::plasm {lvalue},boost::python::list)
object connect(tuple args, dict kwds) :
- C++ signature :
- object connect(tuple args, dict kwds)
connect( (Plasm)arg1, (object)from_cell, (str)output_name, (object)to_cell, (str)intput_name) -> None :
- C++ signature :
- void connect(ecto::plasm {lvalue},boost::python::api::object,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,boost::python::api::object,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
connections
((Plasm)arg1) → list :¶ Grabs the current list based description of the graph. Its a list of tuples (from_cell, output_key, to_cell, input_key)
- C++ signature :
- boost::python::list connections(ecto::plasm {lvalue})
-
deactivate_all
((Plasm)arg1) → None :¶ - C++ signature :
- void deactivate_all(ecto::plasm {lvalue})
-
disconnect
((Plasm)arg1, (object)from_cell, (str)output_name, (object)to_cell, (str)intput_name) → None :¶ - C++ signature :
- void disconnect(ecto::plasm {lvalue},boost::python::api::object,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,boost::python::api::object,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
execute
((Plasm)arg1[, (object)niter=1]) → bool :¶ Executes the graph using a single threaded scheduler.
- C++ signature :
- bool execute(boost::shared_ptr<ecto::plasm> [,unsigned int=1])
-
insert
((Plasm)arg1, (object)cell) → None :¶ insert a black box into the graph
- C++ signature :
- void insert(ecto::plasm {lvalue},boost::python::api::object)
- insert( (Plasm)arg1, (_cell_cpp)cell) -> None :
insert cell into the graph
- C++ signature :
- void insert(ecto::plasm {lvalue},boost::shared_ptr<ecto::cell>)
-
load
((Plasm)arg1, (str)arg2) → None :¶ - C++ signature :
- void load(ecto::plasm {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
save
((Plasm)arg1, (str)arg2) → None :¶ - C++ signature :
- void save(ecto::plasm {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
-
viz
((Plasm)arg1) → str :¶ Get a graphviz string representation of the plasm.
- C++ signature :
- std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > viz(ecto::plasm)
-
BlackBox¶
You need to inherit from the following class when defining your BlackBox:
-
class
ecto.blackbox.
BlackBox
(*args, **kwargs)[source]¶ The BlackBox may be used as an encapsulation idiom within ecto, to declare reusable plasms.
A BlackBox is a meta-cell. 3 functions need to be implemented when inheriting. declare_fowards: defines the inputs/outputs/parameters that are forwarded to the inner cells. declare_cells: declare_io and declare_params should not be overriden but in order to have them work statically, information about the inner cells have to be given in declare_cells. declare_direct_params: a BlackBox can have its own parameters and this is where they are declared
-
cell
()[source]¶ Return an instance of the cell that backs this BlackBox. Useful for ecto.If, or other places that expect a cell
-
configure
(p, i, o)[source]¶ This function has the same meaning as in C++ and can be overriden by a child class.
This function should be used to allocate all cells internal to a BlackBox
Parameters: - p – an ecto.Tendrils object for the parameters
- i – an ecto.Tendrils object for the inputs
- o – an ecto.Tendrils object for the outputs
-
connections
(p)[source]¶ This function has to be overriden by a child class.
Parameters: p – an already filled ecto.Tendrils for the parameters that can be used to decide on certain connections Returns: an iterable of tendril connections.
-
classmethod
declare_cells
(p)[source]¶ This function can be overriden by a child class.
Given some parameters, define the characteristics of the cells.
Parameters: p – an ecto.Tendrils() object Returns: a dictionary of the form: {‘cell_name’: BlackBoxCellInfo_call, ‘cell_name’: cell_instance}
-
static
declare_direct_params
(p)[source]¶ This function can be overriden by a child class.
This function declares normal parameters for the BlackBox, i.e. you need to declare them using p.declare(‘key_name’, ‘key_docs’, default_value) like you would in a normal Python cell.
If you want to have your cell expose different parameters according to different parameters sent to the constructor of the BlackBox, you can make this function non-static. declare_params and declare_io (that are static) might then fail if called statically but they are not used to build a BlackBox.
Parameters: p – an ecto.Tendrils() object
-
classmethod
declare_forwards
(_p)[source]¶ This function can be overriden by a child class.
Parameters: _p – an ecto.Tendrils object from which some logic can be done to know what to forward. This function will be called after declare_direct_params which fills ‘p’ with BlackBox specific parameters (non-forwarded) Returns: a tuple of three dictionaries definining the params/input/output forwarded to/from the inner cells. It has the format: {‘cell_name’: ‘all’, ‘cell_name’: [BlackBoxForward_call1, BlackBoxForward_call2]}
-
classmethod
declare_io
(p, i, o)[source]¶ This function has the same meaning as in C++ and should NOT be overriden by a child class.
Parameters: - p – an ecto.Tendrils object for the parameters
- i – an ecto.Tendrils object for the inputs
- o – an ecto.Tendrils object for the outputs
-
classmethod
declare_params
(p, **kwargs)[source]¶ This method should NOT be overridden by a child class.
This function returns the parameter tendrils but as there are two kinds (namely the BlackBox ones defined in “declare_direct_params” and the forwarded parameters), there are two levels of parameters. If you just call the function with no kwargs, you get the default parametes. But if you know the parameters you will send to your BlackBox constructor, call declare_params with it and you will have a “runtime estimate” of your parameters.
Parameters: - p – an ecto.Tendrils() object
- kwargs – anything sent to the constructor of the BlackBox
-
-
ecto.blackbox.
BlackBoxCellInfo
(python_class, params=None, name=None)[source]¶ Function to define the information of a cell in
ecto.blackbox.BlackBox.declare_cells()
Parameters: - python_class – a Class object describing the cell
- params – a dictionary of parameters that will be sent to the constructor of the cell (with the forwarded parameters if any, and they have priority over forwards)
- name – the name of the cell when instantiating it
Returns: a _BlackBoxCellInfo object which is a private namedtuple that users should not interact with
-
ecto.blackbox.
BlackBoxForward
(key, new_key=None, new_doc=None, new_default=None)[source]¶ Function to define the information of a forward in
ecto.blackbox.BlackBox.declare_forwards()
Parameters: - key – tendril to forward from the cell
- new_key – the name under which the tendril will be forwarded. If not given or None or emtpy, it will be the same
- new_doc – the new documentation of the tendril. If not given or None or emtpy, it will be the same
- new_default – the new default value of the tendril. If not given or None or emtpy, it will be the same
Returns: a _BlackBoxForward object which is a private namedtuple that users should not interact with