Tutorial XX: Template

This tutorial walks you through the process of FILL IN. The reason behind when and why this is important should be briefly described in the remainder of this paragraph. If possible, this should be further elucidated by a complementary figure, which can be placed in the folder tutorials/img. Figure 1 serves an example of this below.

**Figure 1.** A template image

The remainder of this tutorial is organized as follows:

  • Section 1 does XXX.
  • Section 2 does YYY.
  • Section 3 does ZZZ.

1. Demonstrating the Functionality of Code

All sections in this tutorial should consist of blocks of text describing a specific method or set of methods in Flow, following by a code snippet demonstrating the described methods being used.

For example, let us say we want to show how to add two numbers in python. We might begin by introducing the numbers and methods we will use to do the addition:


In [ ]:
a = 1
b = 2

def add(a, b):
    return a + b

Then we could show the functionality of the methods as follows:


In [ ]:
add(a, b)

Whenever possible, sections should also be broken up into smaller subsections to help the reader more quickly identify which portion of the tutorial discusses which topic. This may be helpful to readers who are just interested in certain concept, e.g. just to find out how a specific parameter works. An example of this separation of subsections can be seen in Section 2.

2. Sequentially Building a Class

Classes, like lines of code presented in the prior section, should be described and written sequentially rather than all at once. An example of this can be for a class version of the add method, described below.

2.1 Introduce and Instantiate the Class

We begin by defining the class with its __init__ method, and import any necessary modules. Make sure there are enough comments in the code to make it s much self-explanatory as possible.


In [ ]:
import numpy as np


class Adder(object):

    def __init__(self, numbers):
        """Instantiate the Adder class.

        Parameters
        ----------
        numbers : array_like
            the numbers that should be added together.
        """
        self.numbers = numbers

2.2 Include (Sequentially) New Methods

Next, we add a new method to the class. We do this by recreating the class and having it inherit its previous properties. As an example of this, let us consider including a run method to the Adder class than adds the numbers that is provided to the class during instantiation.


In [ ]:
class Adder(Adder):  # continuing from the previous definition of Adder

    def run(self):
        return np.sum(self.numbers)

2.3 Demonstrate Functionality of the Class

Finally, we can demonstrate the functionality of the class, through testing and validating the class, as seen in the code snippet below.


In [ ]:
adder = Adder([1, 2, 3])

print("The sum of the values is:", adder.run())

3. Adding the Changes to the README and Website

Once you have completed your tutorial, you must include your new tutorial in all relevant descriptors of Flow's tutorials. This include adding it to both README and the Flow Website.

3.1 README

For one, begin by adding the new tutorial to the README.md file located in the tutorials/ directory (see the figure below). This should be included in your Pull Request (PR) whenever creating a new tutorial.

You just need to add your tutorial with the correct number and title under the last tutorial in the README.md:

**Tutorial XX:** Name of your tutorial.

3.2 Website

Next, you need to inform the Flow web designer to add your tutorial to the Flow website:

To do so, send the Title and the Github link to your tutorial to the Flow web designer.