How to add an electron to a lattice#

In this section, we show the steps required to add electrons to a lattice. First, construct the electrons (subtasks).

[1]:
import covalent as ct

@ct.electron
def identity(x):
    return x

@ct.electron
def square(x):
    return x * x

Secondly, construct a lattice (workflow) and perform the subtasks using the electrons defined above.

[2]:
@ct.lattice
def workflow(a):
    val_1 = identity(x=a)
    return square(x=val_1)

In order to add the identity electron to the lattice, we simply call the function and store the value in a variable that can then be either used to perform the next subtasks in the workflow or returned as the final result of the computation.