# Introduction

By the Callysto development team

This is the one-stop training manual to help [Callysto](https://www.callysto.ca) Creators and Developers get started on the project. It contains best practices and guidelines for content creators to help standardize the code and notebooks produced for the Callysto project. It also contains processes and procedures used during notebook development and review.


# Quickstart Guide

This Quickstart assumes that you are familiar with Jupyter notebooks and Python. After getting set up with the Quickstart, please see additional sections in the training guide for more details.

## Programming language

To provide consistency, we use Python 3 in Jupyter notebooks. We also recommend using other standardized approaches as outlined in the Best Practices for Code Development section.

## Where to develop

It is recommended that you develop notebook using [hub.callysto.ca](https://hub.callysto.ca), as it is the environment teachers and students will use to run these notebooks.

### Setting up GitHub with hub.callysto.ca

We recommend setting up SSH authentication for interacting with GitHub. To do so, create a new private key on hub.callysto.ca and add the corresponding public key to your GitHub account as per the following instructions.

1. Using your GitHub email, open a terminal and create the key using the following command and hitting enter when prompted.

```
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```

Note that by default, the new key will overwrite any key stored in *.ssh/id\_rsa*, so don't accept the default path unless you either have no key stored here or no longer need the original private key file.

1. Copy the contents of your public key. This is easiest done by opening a new Jupyter notebook and copying the output of the following (the notebook will make it easier to copy and paste the key)

```
!cat .ssh/id_rsa.pub
```

1. Add the public key to your GitHub account at [github.com/settings/keys](https://github.com/settings/keys)

There are other options for interacting with GitHub as well. Please see [this page](https://developer.github.com/v3/guides/managing-deploy-keys/) for more information.

### Working Locally/Offline

It may be necessary or convenient to be able to run examples or develop on a local copy on your computer/laptop. This might be because you expect to be working without internet access, or working with complex git branches. Jupyter is easy to run after pip installing it, but it is best to match the entire environment (libraries, os, python version, etc.) as the Callysto Hub. The docker images used are hosted on the [callysto docker hub](https://hub.docker.com/u/callysto) and uses the [callysto/pims-r](https://hub.docker.com/r/callysto/pims-r/tags) image. This does require [installing docker](https://docs.docker.com/get-docker/) first.

You also need to clone the github repo in the directory you are working. From a terminal on a \*nix system, that can look like the following:

```
mkdir Callysto
cd Callysto
git clone https://github.com/callysto/curriculum-notebooks.git
docker run -it -p 8888:8888 -v "${PWD}":/home/jupyter --name callysto -d --rm callysto/pims-r:latest
docker logs callysto
```

The options we've added to the `docker run` command do the following:

* `-it` adds some terminal "niceness",
* `-p 8888:8888` gives access to the default port (8888),
* `-v "${PWD}":/home/jupyter` shares the file contents with the server,
* `--name callysto` names the container "callysto",
* `-d "detaches"` the container and lets us use the terminal,
* `--rm` removes the container after quitting (lets us re-use the callysto name in other runs).

The port mapping may need to be adjusted if other jupyter servers are running on your machine. The last 3 options itemized above can safely be omitted if you are comfortable managing docker containers, however, the port and volume mapping must always be included.

Following successful launch of the container, navigating to `localhost:8888` or using the address+token from the logs will start Jupyter in the web browser as expected. Changes to the files will be synced between the container and the directory where the repository was cloned.

If using this to develop and work with git branches, care should be taken that resources used do not exceed those available on the Callysto Hub: 1GB disk space, 2 GB RAM). Disk usage can be checked using, e.g., `du -sh curriculum-notebooks` and cannot exceed 1GB for usage on the Hub. RAM usage can be limited by adding a `-m 2G` to the docker run command.

## Version Control with Jupyter Notebooks

Jupyter notebooks are written in a JSON format that, when altered using the notebook interface, result in a very difficult to read git diff output. This is because when you change the contents of a given cell, it will have a downstream effect on the notebook's source code, metadata, and output files. At first you may know where to look based on your memory, but when trying to untangle a old notebook's commit history based on git diff there will be difficulties. For this reason it is recommended that you use a tool that makes code comparisons between versions more readable. Please see [this](https://nextjournal.com/schmudde/how-to-version-control-jupyter) article for more details.

## JIRA - what to work on and coordinating with others

JIRA is an issue tracking product that provides bug tracking, issue tracking, and project management functions. If your team is using JIRA, follow these steps to access it for the first time:

1. go to jira.cybera.ca
2. click on the "Can't access your account?" link
3. in the "Enter your username" field, enter your EMAIL ADDRESS and click "Send"
4. check your email for password reset instructions

This assumes that your account was already added to JIRA. If not, please contact your team leader or someone on the [Callysto Slack workspace](https://callysto.slack.com).

## Notebook Formatting

Please see the [Notebook Template](https://github.com/callysto/training-manual-live/blob/master/notebook_template.md) and [Notebook Format](https://github.com/callysto/training-manual-live/blob/master/NotebookFormat.md) sections for more details. Some examples of Callysto curriculum module notebooks can be found in this [GitHub repository](https://github.com/callysto/curriculum-notebooks).

## Contributing Notebooks

Once a notebook or other content has been developed, files should be pushed to a [GitHub branch](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository) off of the master repository.

Remember to `Restart and clear output` then `Shutdown` your notebooks before committing your work. This will avoid any odd Git issues that result from some of the git with Jupyter Notebooks issues mentioned above.

### Using GitHub

If you are new GitHub, here are a couple of guides to get started.

* [Simple Guide - the basics](http://rogerdudler.github.io/git-guide/)
* More [in-depth guide](https://www.atlassian.com/git/tutorials/what-is-version-control) with good explanations

## Slack team messaging

Slack is the messaging system used to communicate with the entire Callysto team. If you have not joined the [Callysto Slack workspace](https://callysto.slack.com) yet, contact your team leader to get added.


# Preface

The Callysto project is a collaboration between [the Pacific Institute of Mathematical Sciences (PIMS)](https://www.pims.math.ca/) and [Cybera Inc](https://www.cybera.ca/) and is funded by the Government of Canada through the [CanCode program](https://www.ic.gc.ca/eic/site/121.nsf/eng/home). Our overall goal is to bring elements of computational thinking into the K-12 curriculum by developing showcase curriculum modules using Jupyter technology and training K-12 teachers to use these modules in the classroom.

## The Purpose of This Guide

This training guide is meant to be a resource for Callysto creators and developers to get started on building content for the Callysto project.

### Why **Callysto**?

The open-source Jupyter technology is an important aspect of how we are delivering the curriculum materials we are developing. \[Callysto]\(<https://en.wikipedia.org/wiki/Callisto_(moon)>) is a moon of Jupiter and the `y` is our way of aligning ourselves to the larger [Project Jupyter](http://jupyter.org/).

### Developing for the Callysto Project

Callysto developer will commit to and create selected curriculum content modules in Jupyter notebooks. Our subject matter expert advisors will help to review the created content and provide any feedback.

## Things to Keep in Mind While Developing Content

When creating a notebook, keep your target audience in mind. For example, if your notebook is meant for Grade 5 students, the reading level and instructions should be no higher than Grade 5 (preferably a grade or two lower). You can check the reading level of text using some online tools (such as [this one](https://www.perrymarshall.com/grade/)), through tools built into [Word](https://support.office.com/en-us/article/get-your-document-s-readability-and-level-statistics-85b4969e-e80a-4777-8dd3-f7fc3c8b3fd2) and [Docs](https://support.google.com/docs/answer/39003?hl=en-GB), or with a [Python library](https://github.com/shivam5992/textstat).

As a Callysto creator and developer you may be far removed from the K-12 experience. Continuously ask yourself "Would someone who knows absolutely nothing about anything contained within this topic understand the explanation I've given?". It is imperative that you are clear and explicit in your explanations - but also in a way that your audience can understand.

## When Developing Code

In a similar way, when writing Python code you should aim for simplicity. For example

```python
def GCD(a, b):
    if isinstance(a, float) or isinstance(b,float):
        print("Those numbers are not integers!")
        return None

    while b:
        a, b = b, a % b
    return a
```

For someone with coding experience, that's fairly easy to understand. Run through a loop until `a mod b` is zero and you've the greatest common denominator. And it works every time! There's even error handling! Over all that's a pretty versatile function, and a neat little piece of code.

But now imagine you have never seen Python before. You don't know what `def` means, you have no clue what `while` does. What is `isinstance`? What's a `float`? `if`? Why is it spaced all funny? A percent sign? Even if this function was heavily commented, it might still be somewhat unapproachable for beginners. How would you go about constructing a simple Python example that would find greatest common divisors?

There might not be a great way to implement this particular example for a beginner audience. A better example might be to also introduce the idea of equivalent fractions, and ask them to find if two fractions are equivalent:

```python
# Change the numbers in each fraction then run this cell to check if they are equivalent fractions.
# If the two fractions are equivalent, the word "True" will be printed under this cell.
# Can you find three pairs of equivalent fractions?

10/5 == 124/62
```

While that might be less interesting code, it is more approachable for someone with no Python experience.

That being said, if you can create an intuitive, interesting, and interactive widget or visualization that requires some more "advanced" coding, you are also free to do so. Remember to consider your audience however.

### Conclusion

When creating notebooks for the Callysto project, be aware of the skill set of your audience. There will definitely be occasions where you can get more involved in the code and the explanations in cases like high school content. Even so, a lot of the people this content will be used by will have little to no experience with Python or even the subject you're trying to teach. We've summarized a few flexible guidelines for you to keep in mind:

1. **Keep it simple**.
2. Depending on what you are creating, you may need to write more complicated code. That's probably fine, but consider breaking it into small interactive chunks.
3. A simple example is almost always superior to a complicated one. Work your way up to the complicated examples.
4. Explain with words more than you explain with code.
5. Comment your code.
6. Comment your code some more.
7. If all you want is an interactive widget and not to use the code itself as a teaching tool, consider moving the code to a helper function in a separate file.
8. Always be conscious of your audience.


# What is Computational Thinking?

## What is Computational Thinking?

One of the goals of the Callysto project is to "Introduce computational thinking to K-12 students in Canada", so what is computational thinking? Computational thinking involves solving problems by designing questions and processes that can be computed. One way of describing the process of computational thinking is:

1. Decompose - break down the problem into parts
2. Recognize patterns - find trends in the problem
3. Design an algorithm - create a *series of steps* to solve the problem
4. Abstract - remove some specifics to generalize the solution
5. Evaluate - analyze the solution

It's important to notice that there was no mention of "programming" or "coding". Computational thinking within the scope of student learning is generally problem solving or testing in a way that works with technology.

> Thinking like a computer scientist means more than being able to program a computer. It requires thinking at multiple levels of abstraction [Wing 2006](https://www.cs.cmu.edu/~15110-s13/Wing06-ct.pdf)

Computational thinking is an analysis and problem-solving methodology. This is what the Callysto project is incorporating into the K-12 curricula.

Computational thinking can be taught:

* By incorporating it as a problem solving methodology in traditional lesson plans.
* Without any need to see/understand code.
* By defining/analyzing a problem as you may in order to solve the problem using a computational approach.
* By laying out algorithms which start at a problem definition and lead to a solution.
* In subjects other than math and science.

## What is Data Science?

Data science involves obtaining and communicating information from (usually large) sets of observations. This usually involves collecting, cleaning, manipulating, visualizing, and synthesizing data in order to gain insights and inform the decision-making process.

Data science is often about answering questions like:

* What happened (descriptive)
* Why did that happen? (diagnostic)
* What might happen next? (predictive)
* How can we make changes? (prescriptive)

## Summary

When developing Jupyter notebooks for the Callysto project, it may be appropriate to consider "teaching students to code" as a secondary goal. The highest priority is to introduce computational thinking and data science processes within activities or lessons that students would be doing anyway.

* Not all Jupyter notebooks need to teach the students how to code
* Demonstrate thought process while solving the problem
* How are you breaking down/formulating the problem?&#x20;
  * Why did you choose to do it that way?&#x20;
  * What methods are you using and why?&#x20;
* What data are important to finding your solution?&#x20;
* Which visualizations are you using and why?&#x20;

The goal of Callysto is to introduce students to the idea of computational thinking and data science within the regular curriculum. We are using Jupyter notebooks because they are designed around the idea of "literate programming", meaning that it is possible to explain not only your code, but the underlying theory, directly in the notebook itself. Jupyter notebooks allow us to break down a problem computationally and explain the solution process.

## External References

To get a better idea of computational thinking the following articles are good starting point:

* [J.M. Wing. 2006. Computational Thinking. Communications of the ACM. Vol. 49, No. 3](https://www.cs.cmu.edu/~15110-s13/Wing06-ct.pdf).
* [J.M. Wing. 2014. Computational Thinking Benefits Society. Social Issues in Computing blogpost ](http://socialissues.cs.toronto.edu/index.html%3Fp=279.html).


# Philosophy


# Goals of the Callysto Project

The immediate goal for the Callysto project is to create publicly accessible Jupyter notebooks (and other online resources) that demonstrate the merging of computational thinking into the K-12 curriculum for Alberta, BC and eventually across Canada.

A Jupyter notebook is a computer file that combines text, graphics, and computer code as a platform to deliver online content that is easily accessible through any web browser. A rich source of examples are here: [Jupyter Gallery](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks)

Each Jupyter notebook will address an outcome of the K-12 curriculum as specified by documents curated by the project leaders, and will incorporate both text and visuals to address the curriculum outcomes. Ideally they would include interactive features and could access live data from the web for creating up-to-the-minute information sources and analysis.

Imagine, for instance, a webpage that can download live Statistics Canada data and make analyses of population trends, income disparities across the country, patterns of home ownership, and so on. Or a webpage that demonstrates basic laws of physics, such as Newton's laws of motion, with a visual and computational component that shows these laws. These webpages would be live and interactive, so students and teachers can manipulate the computations, see the physical laws in motion, or apply their own analyses to the data. They can also use the notebooks as a model for creating their own tools for computational studies and content creation.

The project is funded into 2019, and will consist of three stages.

**Stage 1** (Present, to June 30, 2018): First suite of demos

The target is to convene 15 to 20 teams to work for four months creating demo notebooks and other deliverables specified below. Coordination and funding for the operations are provided by PIMS and Cybera, with a grant from CanCode. In this stage, teams will be formed under the supervision of site directors at PIMS institutions.

Stage 1 Deliverables:

* 100 Showcase Modules (5 to 10 per team) including curriculum modules identified by our K-12 advisors
* Examples of machine conversion of standard OER textbooks
* Validation of technology palette
* Scaffolding for scaling the whole project
* 100 daily users of the Callysto Hub

**Stage 2** (Summer 2018): Validation

Focus is on distributed content creation, delivery, and improvement process validated by face-to-face meetings and workshops. With 20 or more Callysto Teams in PIMS network in operation through the summer, aim to expand the audience of K-12 teachers through workshops and partner networks. Callysto Teams launch outside of the PIMS network. PIMS and Cybera are co-investing in the operations. Other partners may begin to contribute to Callysto.

Stage 2 Deliverables:

* Deployment and testing of resources with K-12 teachers and students
* Validation of resources with K-12 teachers and students
* Workshops for K-12 teachers (run with the help of creators and developers)
* Validation of authoring workflows
* Validation of K-12 and postsecondary collaboration model

**Stage 3** (2018-2019): Scaling

Callysto gains momentum with national and international partners. Teaching and learning enhancement funds align with the production and delivery of Callysto resources. Modules are showcased through K-12 and postsecondary networks. PIMS, Cybera, and other partners put forward funding to support Stage 3 and explore plans to sustain the Callysto Mission.

Stage 3 deliverables:

* Deployment and testing of resources with postsecondary instructors and students
* Computational Thinking assessment and effectiveness study performed by Professor Catherine Adams (University of Alberta)
* Validation of resources with postsecondary instructors and students
* Exploration of Callysto toolchain in research and data science activities in postsecondary


# Software tools - Eat Your Own Dogfood

"Eat your own dogfood" means that, as developers, we should be using the same tools we are developing for our clients. (The slogan originates with Microsoft.)

For the Callysto project, the tools we want Callysto creators and developers to use are:

* Jupyter notebooks, accessed on the [hub](https://hub.callysto.ca/).
* Python, Markdown, and HTML/Javascript programming languages for coding.

The advantages of using our our own tools are manifold:

* Content will work as expected across platforms.
* Machine independent performance.
* Universal development environment.
* Single platform to maintain.

However, some of the disadvantages of this approach include:

* Constant internet access is required.
* Server hosting the [hub](https://hub.callysto.ca/) needs to be constantly available.
* Packages you have locally will need to be installed on the [hub](https://hub.callysto.ca/).


# Notebook Design


# Notebook Format

In order to maintain a consistent format across notebooks, subjects, and authors there are some formatting and structure requirements in place, outlined below.

Note that all notebooks must follow CamelCase for directory names and kebab-case for filenames.

Your notebook is likely intended to *teach* something new. As this is the case, your notebook should contain the following points and follow this basic structure. You're free to add subsections relevant to these primary sections where applicable, however it is important that every notebook contains these five elements.

1. Introduction
   * What are you going to teach and why.
   * This section may contain background elements and subsections.
2. Background
   * Explain the subject matter you're going to be teaching
   * This section may contain examples and subsections.
3. Example(s)
   * Demonstrate what you've taught with analytic results, interactive widgets, animations, graphs and Python/R codes. &#x20;
   * This may also contain multiple subsections
4. Questions
   * Ask questions to test understanding of the material you've covered and keep the student engaged.
   * Questions may be spread throughout the document.
5. Conclusion
   * Restate important points and summarize your lesson - what did you teach and why.

Where the details behind these sections are explained below.

However, the basic format of the notebooks can be described as "Describe what you're going to teach in this notebook and why, provide further details of what you said you would teach, demonstrate what you have taught, and state those facts again."

### A Note About Visualizations

All of our demos should include eye-catching visualizations (static or interactive). For inspiration and instruction please visit our [Information Visualization](/infovis) section.

## Introductions

All notebooks for the Callysto project will require an introduction. In this section you will outline and motivate the content of your notebook so there is no ambiguity in regards to the content of your notebook. This is arguably the most important section of any notebook. This is the first section any student/teacher is going to read, and if your introduction is vague/bad, then the content you create is never going to get used. Below are some examples of both a bad and a good introduction

#### Bad Introduction

> In this notebook we go over how to use Python to plot functions.

This introduction is bad for a lot of reasons. Most prominently is *how* are you going to use Python functions and *why* is it important to learn that? As a general rule, if those two questions remain unanswered, the introduction needs some work.

#### Better Introduction

> In this notebook we will outline the use of Python's `matplotlib` libraries in order to create graphs of both data and functions. As creating graphs easily and flexibly is required for almost any serious analysis or study, it's important to understand how to use `matplotlib`. First we will outline some basic functionality of the `matplotlib` library in order to create some basic scatter plots of open source data. Once we're more comfortable with the use of `matplotlib` we will then introduce Python functions and how they can be used to plot mathematical functions using `matplotlib`. Finally, we will combine the two ideas and show you how to plot a scatter plot of data, as well as overlay a theoretical curve on that graph in order to test our model. Once you've worked your way through this notebook, you should be able to apply what you've learned to different data sets and functions.

This introduction is far superior to the last one. Not only have we introduced *what* we're doing we've also introduced *why* we're doing it, as well as given an overview of the topic we're going to cover. Your introduction should essentially act to both motivate the contents of the notebook, and act as a guide of what the notebook is going to cover.

### A Brief Note on "Eye Catching"

From conversations with K-12 teachers it may be useful to have an "eye catching" graphic in the first few lines in order to draw in your K-12 crowd. This is pretty flexible and can range from either a widget that you're going to go over how to build, to relevant YouTube videos or gifs. For example

> ## Introduction
>
> The rise of cryogenic technologies have been largely popularized by the work of one Philip J. Fry:
>
> ![alt text](https://media.giphy.com/media/ny8F1nqXDKrAY/giphy.gif)
>
> Where his groundbreaking work demonstrated the use of cryogenic freezing as a method of paradox-free unidirectional time travel...

may suffice as the first two sentences of an introduction. In this case, the "Eye Catching" graphic does **not** replace your introduction, it is simply **in addition**, or supplementary, to your introduction.

## Background and Examples

In principle a lot of the background can be included in the introduction, however sometimes it may be easier to write as its own section inter-weaved with various examples. With the flexibility that a Jupyter notebook provides it becomes very easy to "teach by example". Not only that, but we can make those examples interactive. The game you have to play in these sections is to not only explain the subject matter, but to also come up with some level of interactivity or visualization that will supplement the lesson. Your goal as a Callysto creator will be to demonstrate the subject matter you wish to teach by using interactive examples. See the examples below

#### Bad Example

If this was a crusty old textbook on introductory statistics, we might have an explanation and example something like this

> A coin toss has a fifty percent probability to return either heads or tails. However, this does not necessarily translate into returning an equal number of heads and tails during the experiment! For example, see the results of the Table below where in we flipped a coin some dozens of times

| Number of Trials | Head Count | Tail Count |
| ---------------- | :--------: | ---------: |
| 10               |      3     |          7 |
| 100              |     58     |         42 |
| 100000           |    50203   |      49797 |

> Peculiar! Notice how we don't get exactly a 50/50 split? Do these results agree with what you'd expect? Let's introduce some equations that will help explain why...

Now to be fair that started strong. It talked about the intuitive probability behind a coin toss, as well as the idea of statistical fluctuation. However, it then demonstrates that with a boring and perhaps confusing table. With Jupyter notebooks, we have the flexibility to create something more interactive such as below

#### Better Example

> A coin toss has a fifty percent probability to return either heads or tails. However, if we were to flip a coin 100 times would we expect an equal number of heads and tails? Try it out! Click "Toss those coins" on the widget below in order to simulate some coin tosses
>
> ![alt text](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2Faba083fdc2b302cc54d01b5e37b428127ddfd902.png?generation=1613092107548070\&alt=media)
>
> (Note: This widget can be used in the Math/FlippingCoins.ipynb if you're interested) Now try adjusting the "Head Prob..." slider for biased coins! Do the results agree with what you'd expect? Let's introduce some equations that will help explain why...

Notice how now we have something interactive such that the student is free to run as many trials as they like in order to help understand the process. Not to mention that as we've run away from the table format, we were also free to introduce the idea of biased coins.

Essentially the name of the game is interactivity and demonstrations. If there's a way for you to explain/visualize your content in an interactive way, it is strongly encouraged that you do that. Of course the code for the interactivity may get complicated. That's okay. Feel free to take advantage of the ability to hide blocks of code for the interactive widgets if that code went "out of scope" of what you're hoping to teach. However, it is important that you comment those codes well in case a teacher/student is curious about the underlying structure of those widgets.

Regardless, within the Jupyter notebooks you create you need to explain the background/provide examples and interactivity that will help you teach the subject matter to the students. And if that wasn't challenging enough, you have to find a way to communicate that in a way that is understandable to your K-12 audience.

## Questions

By asking questions about the lesson you're teaching throughout the notebook you will keep the students engaged and thinking about the content you have created. This will also help with the adoption of your content in the classroom as it will have more of a textbook/assignment feel. As an added bonus, the questions you're asking is a great way to test the quality of your explanations and content. Does the answer to the question you've asked not naturally develop form your explanations and examples? If not, you might consider refining your explanations such that no one can read one of your questions and react with complete bewilderment. As well, these questions can be open-ended and need not always be quantitative. Using this document as an example, some examples of bad and good questions are as follows

#### Bad Question

> Why is whoever wrote this notebook so adamant about showing us good and bad examples? Why don't they just get on with it?

This is a bad question because no where in the document have we discussed why I'm showing you so many examples, I've just been doing it. In this case, you the student, have no context or prior knowledge of this question, making it unfair and difficult to answer.

#### Better Question

> Does this notebook try to use both interactivity and examples as a teaching tool? Where was it successful and where was it not?

This is a better question as the notebook itself has provided you with the tools to answer this question yourself. Actually it would be great to get feedback on this question in order to improve this template.

## Conclusions

No notebook is complete without a conclusion. In this section you will summarize what you taught in the notebook, and how it might be useful in the future. This section not only helps "end" the notebook in a way that reiterates important points to the student, but it also acts as a sanity check for you to make sure you covered everything you wanted to. For example, back to our `matplotlib` introduction example, a bad conclusion would be

#### Bad Conclusion

> This notebook showed you how to use `matplotlib`.

First and foremost, a conclusion is not a sentence. This conclusion tells you nothing. What is the takeaway from a notebook has tried to teach? Why is it useful?

#### Better Conclusion

> This notebook has demonstrated some of the basics of the `matplotlib` library and Python functions in order to create graphs of both data and functions. We covered the basic syntax of `matpotlib` in order to create scatter plots, as well as how to use Python functions in order to visualize the trace of mathematical functions. This introduction will help you create your own graphics for other research projects, and should help you be prepared for more complicated visualizations in the future such as three dimensional plots and animations.

This is a lot better. Not only does it tell you what we learned in our theoretical notebook (notice how it parrots the introduction), it also tells you how this notebook will be useful in the future. A conclusion like this not only wraps up the lesson, it also lays out potential future learning objectives.

## Conclusion

In conclusion the basic outline of a notebook for Callysto is as follows

1. Introduction and Background
   * Describe what your notebook discusses and give some background information.
   * Be sure to include an "Eye Catching" graphic in the beginning of the notebook.
2. Examples
   * Teach the content you mentioned in your introduction. Use interactive widgets and animations to help "teach by example". Where applicable also use Python/R examples.
3. Include questions throughout/in its own section in order to engage the student/make it easier for a teacher to use your notebook.
4. Conclusion
5. Reiterate important learning objectives that you covered and explain where this knowledge is helpful.

There is quite a lot of freedom surrounding these points/how you end up organizing things that will certainly depend notebook to notebook. However, these four main points are required to be covered in every notebook. Any notebook that does not contain these elements will be considered incomplete.

​


# Template

## Introduction

**Motivate** and introduce the content and context of your notebook. **Why** are you creating this notebook? **What** will you teach? **Why** should the reader care?

### Naming Conventions

Your notebook name should be kebab-case and it should not contain your Jira task identifier. If your notebook is in a directory, your directory should have the same name as your notebook but in UpperCamelCase. All files should have descriptive names.

### Banners

The markdown to display the banner in the header should be

`![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)`

and in the footer

`[![Callysto.ca License](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true)](https://github.com/callysto/curriculum-notebooks/blob/master/LICENSE.md)`

### Organization

If you have files accompanying your notebook they should be in a directory along with your notebook. Images should all be in an `images` folder, with the exception of the [header](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true) and [footer](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true).

### Background

Include the background information about your content. Include examples and explanation to help guide your notebooks.

#### Examples

Use Python or your own explanations to provide **examples and interactivity** to help teach and showcase the concepts to the student.

#### Questions

Ask questions throughout your document to **keep the student engaged** and thinking about the content you've provided.

## Conclusion

Summarize your notebook. **Reiterate** the lesson and important takeaways.

### Sample Template Notebook

Refer to [this link](https://github.com/callysto/notebook-templates/blob/master/templates/Notebook_Template_With_TableContents.ipynb) to access a template notebook with magics, table of contents, banners, sample questions, headers and subheaders matching the bare bones template in this section.

**Does your notebook contain all these items? If not be sure to add them.**

After completing your notebook(s) and content review, make the recommended changes and open a pull request from your branch to master.


# Notebook Reviewer's Guide

This is a guide that outlines the review process for developed notebooks. The [first part](/notebook-design/reviews#part1) of the guide is for developers and outlines what you do after you complete a notebook. The [second part](/notebook-design/reviews#part2) of the guide is aimed at content reviewers (developers and/or subject matter experts) who will be assessing the content of notebooks developed for the Callysto project. Additionally this section will provide insight to developers on how your notebooks will be reviewed.

## Part 1: Notebook Reviews

Overall, there is a 2-step notebook review process: 1) Content review, then 2) Code review.

When a notebook has been developed and is ready to be committed to staging it will be first examined by a content reviewer and then by a code reviewer before it can be merged. Content and code reviewers are chosen based on their subject matter expertise and helps to ensure that only high quality content is pushed to staging.

### Notebook Review Process

*Huzzah I've completed my notebook!* After the initial euphoria has worn off, developers should follow these steps to complete the content and code review processes.

#### Content Review Steps

1. Demo your notebook at a sprint demo meeting.
   * Note, this may not always be possible but you should always aim to share your work with your colleagues. At worst, demo your notebook to your supervisor or have a colleague demo for you.
2. Once you've demoed and incorporated initial feedback, in Jira, change the **Status** of your Story from `In-Progress` to `Resolved`.
3. Then, click `Create Sub-Task` in your Jira Story and enter "content review" in the **Summary** field.
   * The sprint coordinator will then assign a subject matter expert to review the content of your notebook.
4. The content reviewer will review the notebook for content and submit their comments back to the developer. Once they have finished their review the **Status** of the Jira Sub-Task is changed from `In-Progress` to `Resolved`.
   * Review comments should be added directly to the Jira Sub-Task under the **Comments** section and/or the **Attachments** section if they are written in a separate file (e.g. markdown).
5. Once you have incorporated the content review feedback into your notebook, move the **Status** of the Jira Sub-Task from `Resolved` to `Closed (reviewed)`.

#### Code Review Steps

1. Once the content review is completed, then you should create a pull request to merge your notebook branch to the staging branch in [GitHub](https://github.com/callysto/curriculum-notebooks).
   * [Git workflow overview](https://training.callysto.ca/coding/github-workflow).
2. A code review will then be done by one of the code reviewers. Once you have satisfied any requested code changes, your branch will be merged. When this occurs change your Jira Story **Status** from `Resolved` to `Closed (reviewed)`.

## Part 2: Guide for Content Reviewers

Congratulations on being selected as a *Callysto Content Reviewer*. Although it may seem thankless, your input at this point can make the difference between a notebook that seems great on the surface but perhaps doesn't quite connect with its intended audience. As a subject matter expert in this area it is important for you to point out both the technical flaws with the content (not code) and where there are opportunities to make the notebook better (e.g. more interactive).

### Content Review Checklist

To start, it is good practice to begin with an "Overall Summary" of your findings about the notebook before detailing the specific changes that should be made. The following are areas to pay attention to when content reviewing a notebook in detail for Callysto are: 1. Is the recommended grade level for the notebook displayed in the first cell underneath the title? 1. Has the document been spell checked and does it use proper grammar?

* Does the notebook use full sentences, paragraphs and punctuation? &#x20;
  1. Does the notebook keep the target audience in mind?
  2. Is the grammar, narrative, examples, questions and exercises appropriate for the intended audience?
  3. If at any point you as a reviewer are left confused by a sentence/explanation, that sentence/explanation needs work.
  4. Does the notebook make sense?
  5. Does the notebook have a coherent narrative?
  6. Is the lesson/objective of the notebook obvious?
  7. Is the notebook well organized?
  8. Do sections lead well into each other - is there some logic connecting them?
  9. Is the spelling and grammar correct/appropriate for the audience the notebook is intended for?
  10. Does the notebook contain some sort of interactivity?
  11. Widgets, animations, filling in segments of code etc.
  12. Does the notebook demonstrate computational thinking in a way that is independent of understanding the underlying code?
  13. See [computational thinking](/computational-thinking)
  14. Not applicable for notebooks where teaching the student to code is the lesson.
  15. Does the notebook use an open data source to assist with the development of the notebook narrative and examples?
  16. If you feel there is an open data source that could assist with the lesson, please let the developer know so that they may incorporate it
  17. This may not be applicable in many cases.
  18. Don't suggest incorporation of open data simply for the sake of incorporating open data.
  19. Does the notebook complete its curriculum objective?

If the notebook you are reviewing has any of the issues listed above be *clear* and *specific*. For example instead of "your notebook is inappropriate for the intended audience" tell them *why*. Also tell them *where* the mistake or improvements are and provide actionable ways to fix it.

### Notebook Style Checklist

In addition to content, it is important to check to see if the notebook itself adheres to the Callysto style guide available [here](/notebook-design/notebook-format), or [here](/notebook-design/notebook-template) for a condensed version. A notebook should only pass content review if it has "good" style (or has a good reason not to have good style). Of course, you may be a teacher or outside the organization so you may not know what the Callysto style brand is. In this case, the style of the notebook can be updated via a separate Jira Sub-Task step such as a "style review" (To Be Determined).

Below is a list of common notebook aesthetic / style issues to watch out for:

1. Does the notebook use consistent title formatting?
   * Is the title of the notebook created with `# Title`?
   * Are main sections denoted with `## Section Title`?
   * Are subsections denoted with extra pound signs?
   * Is this done consistently?
2. Images
   * Do images possess a caption/is their relevance explained somewhere in adjacent text?
   * Does their placement make sense?
   * Is the image/font large enough to read?
3. Graphs
   * Is it compliant with the [infovis recommendations](https://github.com/callysto/training-manual/blob/master/markdown/infovis.md)?
   * Are all axes labelled?
     * With units (where applicable)?
   * Is the font large enough to read at a glance?
   * Is there a legend (where applicable)?
4. Tables
   * If the notebook contains data tables, is the column alignment consistent?
   * Is the table cut off due to the width of the window?
   * Do the column names make sense?
   * Do the column names contain units (where applicable)?
5. Inline code/code blocks in the markdown
   * Is inline code/variable references in the main body contained within back tics ( \` ) such that it renders as `variable`, so that it is distinguishable in the main body?
   * Are blocks of code to be discussed in triple back ticks ( \`\`\` ) such that they render similar to:

     ```python
     while True:
       # Infinite loops are okay in markdown
       print('''
             By adhering to basic style principles
             notebooks will be much more aesthetically pleasing.
             ''')
     ```
6. Mathematical typesetting
   * Are inline variables surrounded in dollar signs (for example`$x$`), such that it renders as $x$?
   * Are large expressions given their own line either with `$$ big math expression $$` or

     \`\begin{equation} &#x20;

     big math expression

     \end{equation}\`?

     * For example, something large and horrible like $$\left\[-\frac{\hbar^2}{2m}\nabla^2+V(\vec r) + \int \frac{e^2n\_\mathrm{s}\left(\vec r'\right)}{\left|\vec r-\vec r'\right|} ,{\mathrm d}^3r' + V\_\mathrm{XC}\[n\_\mathrm{s}(\vec r)]\(\vec r)\right] \varphi\_i(\vec r) = \varepsilon\_i \varphi\_i(\vec r)$$ should never appear in-line like this, and should be put in the proper equation environment.
     * If an equation is referenced in the discussion, is the equation numbered?
7. Colouring/fonts
   * Are any custom fonts/colours readable?
8. External links
   * Are they hidden with something like `[link to display](longlonglongwebsite.com)`?
     * Does the link work? Will the link still work in a few years or is the website likely to change?

In the case of these stylistic concerns, fixes should be easy and straightforward to communicate to the developer. Consistently upholding them makes our notebooks stylistically consistent between developers, visually pleasing, and easy to use.


# Development Team Structure and Process

## Callysto Development Teams and Sprint Process

### Callysto Development Teams

Teams will consist of 2 to 6 people:

* A university (PIMS) professor.
* 1 - 4 student developers (Callysto creators and developers).
* A K-12 teacher (or subject matter expert) advisor.

#### Roles

**University (PIMS) Professors** can assist in the content and in the supervision of the students (Callysto creators and developers).

**Callysto Creators and Developers** are student developers who are (or will become) Jupyter experts, and will be doing much of the coding, writing, and testing of the demonstrations under the direction of the professor and K-12 teacher. The goal of both "Callysto Creators" and "Callysto Developers" is the same: to create Jupyter notebooks for use by teachers and students in K-12 classes that demonstrate the use of Jupyter notebooks integrated into the course curriculum. The demonstrations will cover a variety of topics in math, science, social science, humanities and so forth. The demonstrations will also be used at conferences and workshops to showcase and train teachers and school administrators to use the technology. Workshops will also be used to prepare the developed Jupyter notebooks for use in the classroom.

**K-12 Teacher or Subject Matter Expert (dependent on availability)** are curriculum or subject matter experts that will advise which curriculum content to develop, as well as help to advise and/or review Jupyter notebook content once it has been created by the Callysto creators and developers. When available, they will be advisors during the sprint and/or will review the notebooks once they have been created.

#### Organization

Development teams will be primarily based at PIMS universities (for funding reasons), and report to the PIMS Site Directors and the Innovation Coordinator, Michael Lamoureux. The overall project manager is Byron Chu at Cybera, who will coordinate the activities of the creators and developers through the PIMS professors.

Callysto Developers, the students, will be writing code, mainly in Python on Jupyter notebooks, but also wrangling HTML code, eBook sources, Pandas for data analysis, and more, with the above stated goal of creating high quality demos. They will be reporting to a professor or instructor at the PIMS university, work closely with the Creators (K-12 teacher) on the team who will be suggesting curriculum topics to develop. Both Creators and Developers will use their own initiative and creativity to come up with exciting and innovative way to showcase the abilities of Jupyter in the K-12 context.

Development teams may also bring in subject matter experts from other places (eg Oceans researcher, Earth Sciences researchers) to use their work as source material for these demonstrations. Collaboration with these groups will be done under the continuing direction of your team leader.

Personnel will need to track and record their work hours, in order for us to track budgets and operations. Note there are constraints on the amount of time students can be working, as well as constraints on the K-12 teachers because of contracts and/or union rules.

## Callysto Development Sprints

Development teams will work work in an [agile scrum](https://en.wikipedia.org/wiki/Scrum_\(software_development\)) structure, where they will work in iterative 2-week sprint periods. During the 2-week period Callysto creators/developers will be assigned to selected development stories (e.g. develop a specific curriculum module in a Jupyter notebook) by their university (PIMS) professor. An assignment to the story is a commitment by the team to develop and complete the story during the 2-week sprint. Once a story has been completed it will be subject to review by an experienced developer (from the PIMS and/or Cybera development teams) and, when available, a K-12 teacher or subject matter expert.

Details on what stories are available and committed to can be found on the Callysto Curriculum [Jira board](https://jira.cybera.ca/).

Follow these steps to access JIRA for the first time:\
1\. Go to jira.cybera.ca\
2\. Click on the "Can't access your account?" link\
3\. In the "Enter your username" field, enter your EMAIL ADDRESS and click "Send"\
4\. Check your email for password reset instructions

NB: this assumes that your account was already added to JIRA. If not, please contact your PIMS leader or someone on the [Callysto Slack workspace](https://callysto.slack.com).

### Sprint Process

The agile process employed by Callysto involves meetings:

* **Sprint Planning** (1 hour bi-weekly usually on Monday)
  * This meeting marks the start of the sprint where teams select and commit to development stories from the backlog for the 2-week sprint period.
* **Sprint Demonstration and Backlog Grooming** (1 hour bi-weekly usually on the 2nd Friday of the sprint)
  * This meeting marks the end of the sprint period where development teams will demonstrate the notebooks they have created and their work can be marked as completed and ready for review by a subject matter expert.
    * Incomplete work for the sprint period can be carried over to the next 2-week sprint period.
  * the Backlog Grooming portion of the meeting is where new stories can be entered into the backlog and discussed for development during a future sprint.
* **Daily Stand-ups** (optional, everyday for a maximum of 15 minutes)
  * University (PIMS) leaders can decide to hold a daily stand-up meeting where each member of their development team explains:
    * What they completed yesterday
    * What they are planning on completing today
    * If they are encountering any road-blocks or impediments to the completion of their story

NB: Please ensure that your university (PIMS) leader invites you to these sprint meetings.

### Development Workflow

In most software development you will see some sort of development cycle. Our notebooks are no different, however it is important that we develop notebooks with the needs of educators and the K-12 curriculum in mind. For this reason, it is important to include their ideas and feedback at the early stages of content creation to ensure that our notebooks are relevant and useful.

![Our development workflow](https://i.imgur.com/OrcbCzO.jpg)


# Extensions

You can extend the use of Jupyter notebooks by importing external extensions, building your own magics, or even creating your own kernels.

## External extensions and libraries

Callysto has our own collection of importable extensions, [nbplus](/extensions/nbplus).

You can also use pip install `!pip3 install foo --user` where foo is the library you want to install. Generally this is discouraged, we want to have programs installed on the docker image of the server rather than in individual notebooks. This avoids having messy user facing installs and helps maintain consistency across the notebooks. However there are exceptions, if you are unsure ask the developer channel in slack.

We discourage the use of the extensions in the nbextensions package as many of them are unstable and may cause issues with the server. We also discourage use of plotting libraries outside of matplotlib/plot.ly/D3/mathbox, more about this can be found in the [plotting section](/infovis/plotting) of the manual. For tutorials and example implementations of standardized curriculum notebook tools, see <https://github.com/callysto/shorts/>.

### Requesting an extension added to the hub

If there is an extension you would like to add to the server please create a notebook demonstrating the basic use cases for the extension and then post the request on the developers slack channel.

## Magics

Magics allow you to use many different programming languages in Jupyter cells as well as extend the functionality of Jupyter by bringing useful functionality into the cell. Clone the [Magics Guide notebook](https://github.com/callysto/training-manual-live/tree/677053607ce6eed9f150168c9fe4ff28c99822b6/guides/MagicsGuide.ipynb) or [view it with nbviewer ](https://nbviewer.jupyter.org/github/callysto/training-manual-live/guides/blob/master/MagicsGuide.ipynb) for more information on using and creating magics.

## Kernels

The primary languages used by Callysto are Python 3, Javascript and HTML/CSS. All notebooks you create should be based on a Python 3 kernel (there may be exceptions). You can bring in additional kernels using magics (see subsection above).


# Notebook Binders, Pullers, and Viewers

**Binder:** To use Binder, go to this site <https://mybinder.org/> and paste in a copy of your Github repo with your notebooks. Read the notes on the site to figure out how to make this work. For instance, you need a file called requirements.txt that lists the Python packages that are needed to run.

Mybinder will give you something to copy, that looks like this:

```
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/mlamoureux/Callysto/master)
```

Paste that into a markdown cell. The result is a button that you can click on, like this:

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/mlamoureux/Callysto/master)

The notebook is then "live." You can edit it, make changes, run it. But it only exists ephemerally, which means it will disappear after some time. But, you can always download it directly onto your machine.

**GitHub:** GitHub will let you view a Jupyter notebook directly, but it doesn't actually run. Just type in the link in Markdown, like this: <https://github.com/mlamoureux/Callysto/blob/master/ASimplePlot.ipynb>

**Puller:** Under development.

**Viewer:** nbviewer lets you see a rendered Jupyter notebook, but it is not "live." That is, you can't make any changes. To use it, you take the web address `http://nbviewer.ipython.org/` and tack onto the end `url/` and the address of your notebook. Something like this:

<http://nbviewer.ipython.org/url/github.com/mlamoureux/Callysto/blob/master/ASimplePlot.ipynb>


# Nbplus

[nbplus](https://github.com/callysto/nbplus) (working title) is a collection of Callysto-made Python modules for Creators wanting greater interactivity and visual aesthetic in Jupyter notebooks. These tools reflect a desire for aggregation of reusable code and uniformity in how we develop interactive content.

## Getting Started

Submodules are installed separately.

Use the following command, replacing `<submodule>` with the name of a subdirectory in [nbplus](https://github.com/callysto/nbplus):

`pip install --upgrade --force-reinstall --user git+git://github.com/callysto/nbplus.git#egg=<submodule>\&subdirectory=<submodule>`

Once installed, import a submodule by referring to itself.

e.g.

```python
from geogebra.ggb import *
from nbvis.classes import D3, MathBox, Vis
```

To contribute, see the [repository](https://github.com/callysto/nbplus).

## Submodules

### [GeoGebra](/extensions/nbplus)

GeoGebra is an interactive mathematics application for visualization and interaction with geometry, algebra, statistics and calculus. We have developed a Jupyter magic so that GeoGebra may be used within notebooks.

### [nbvis](/extensions/nbplus)

This is a Python [wrapper library](https://en.wikipedia.org/wiki/Wrapper_library) for JavaScript-based visualizations in Jupyter, and provides a streamlined means of specifying and updating visualization code. We are actively supporting [D3.js](https://d3js.org/) and [MathBox.js](https://github.com/unconed/mathbox).

A sample guide outlining the creation of a slider bar using `nbvis` is available [here](https://github.com/callysto/training-manual-live/blob/extensions/guides/nbvisGuide.ipynb).

*class* `classes.D3(name, silent=True)` [\[`source`\]](https://github.com/callysto/nbplus/blob/master/nbvis/nbvis/widgets.py)

Containerizes D3 structures.

#### Parameters:

* *name* (`string`) – a unique identifier for a class instance
* *silent* (`boolean`) – toggles verbose output

#### Methods:

* `svg(height=None)` – appends code to display an [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) element
* `canvas(height=None)` – appends code to display a [Canvas](https://en.wikipedia.org/wiki/Canvas_element) element
* `require(*args)` – requires JavaScript modules from [unpkg](https://unpkg.com/) via [asynchronous modules definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition)&#x20;

#### Returns:

* D3 object class instance

#### Return type:

* `nbvis.classes.D3`

#### Usage:

```python
>>> D3.reset()
>>> foo = D3("foo", silent=False).svg(height=100)
>>> foo.require("d3-selection-multi", "d3-force-constant")
```

```
Reset list of D3 class instances!
New D3 object "foo" added to instances ...
Will require "d3-selection-multi", "d3-force-constant" ...
```

*class* `classes.MathBox(name, silent=True)` [\[`source`\]](https://github.com/callysto/nbplus/blob/master/nbvis/classes.py)

Containerizes MathBox structures.

#### Parameters:

* *name* (`string`) – a unique identifier for a class instance
* *silent* (`boolean`) – toggles verbose output

#### Methods:

* `canvas(height=None)` – appends code to display a [Canvas](https://en.wikipedia.org/wiki/Canvas_element) element
* `require(*args)` – requires JavaScript modules from [unpkg](https://unpkg.com/) via [asynchronous modules definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition)&#x20;

#### Returns:

* MathBox object class instance

#### Return type:

* `nbvis.classes.MathBox`

#### Usage:

```python
>>> bar = MathBox("bar").canvas(height=200)
```

```python
>>> bar = MathBox("bar", silent=True).canvas(height=300)
```

```
Replaced duplicate MathBox object "bar" ...
```

*class* `classes.Vis(*args, js="", silent=True)` [\[`source`\]](https://github.com/callysto/nbplus/blob/master/nbvis/classes.py)

#### Parameters:

* *\*args* (`D3` or `MathBox`) – specifies object class instances to be displayed immediately
* *js* (`string`) – prepends custom JavaScript before visualization code
* *silent* (`boolean`) – toggles verbose output

#### Methods:

* None

#### Returns:

* Visualization object class instance

#### Return type:

* `nbvis.classes.Vis`

#### Usage:

```python
>>> Vis(foo, bar, silent=False);
```

```
Found D3 instance of "foo" ...
Requiring "d3-selection-multi", "d3-force-constant" ...
Found MathBox instance of "bar" ...



<IPython.core.display.Javascript object>
```

*magic* `%%d3` [\[`source`\]](https://github.com/callysto/nbplus/blob/master/nbvis/magics.py)

Creates a global variable `d3_code` and appends the content of the cell to it for later use in a D3 object class instance.

#### Flags:

* to reset all code : `--reset`
* to queue code for later execution : `--queue` or `-q`

#### Usage:

```python
>>> import nbvis.magics
```

```javascript
%%d3 --reset --queue
// a JavaScript comment
var svg = d3.select("svg");
console.log(svg);
```

```
Initialized d3_code container!
Code added to D3 visualization queue ...
```

*magic* `%%mathbox` [\[`source`\]](https://github.com/callysto/nbplus/blob/master/nbvis/magics.py)

Creates a global variable `mathbox_code` and appends the content of the cell to it for later use in a MathBox object class instance.

#### Flags:

* to reset all code : `--reset`
* to queue code for later execution : `--queue` or `-q`

#### Usage:

```javascript
%%mathbox --queue
var view = mathbox
  .cartesian({
    range: [[-2, 2], [-1, 1], [-1, 1]],
    scale: [2, 1, 1],
  })
    .axis({
      axis: 1,
    })
    .axis({
      axis: 2,
    })
var axis = mathbox.select("cartesian > axis")
console.log(axis);
```

```
Initialized mathbox_code container!
Code added to MathBox visualization queue ...
```


# Geogebra

[GeoGebra](https://www.geogebra.org/) is a powerful tool for creating interactive classroom materials and visualizations that many teachers are familiar with.

## Why use Geogebra in Jupyter?

While GeoGebra allows a teacher to export their material to the GeoGebra website, the online interface makes it difficult to build a lesson around that material. The GeoGebra website will only display one applet at a time but a Jupyter notebook can display many. Jupyter is easier to use than the GeoGebra books. Jupyter also allows Geogebra to be embedded in a standard HTML web page without learning how to use their API or having a working knowledge of HTML.

The Jupyter environment allows the teacher to build a lesson in a Jupyter notebook containing rich text and mathematical equations, interspersed with interactive GeoGebra applets. This notebook can then be distributed to students, who will be able to not only interact with the GeoGebra, applets: they will also be able to edit and add text. This will allow a teacher to include questions to be answered with the help of the applets, which can be answered by students within the notebook itself.

We're working on a Python library to try to make this process as easy and seamless as possible while also providing you with powerful tools.

To get started using Geogebra in Jupyter, Clone the [Geogebra Guide notebook](https://github.com/callysto/shorts/blob/master/Geogebra.ipynb) or [view it with nbviewer](https://nbviewer.jupyter.org/github/callysto/shorts/blob/master/Geogebra.ipynb).


# Coding

Clone the [Coding Guide notebook](https://github.com/callysto/training-manual-live/blob/master/guides/CodingGuide.ipynb) or [view it with nbviewer](https://nbviewer.jupyter.org/github/callysto/training-manual-live/blob/master/guides/CodingGuide.ipynb).

Also take a look at the [Magics Guide notebook](https://github.com/callysto/training-manual-live/blob/master/guides/MagicsGuide.ipynb) by cloning it or [view it with nbviewer](https://nbviewer.jupyter.org/github/callysto/training-manual-live/blob/master/guides/MagicsGuide.ipynb).


# Jupyter, Under the Hood

Jupyter used to be called IPython so Jupyter notebook files end with the extension .ipynb. If code you copied off stack exchange is not working you can try changing any instances of "IPython" to "Jupyter" (note: there are edge cases where only "IPython" will work).

When you open a Jupyter notebook document, the associated kernel (in our case a Python3 kernel) is automatically launched. When the notebook is executed (either cell-by-cell or with menu Cell -> Run All), the kernel performs the computation and produces the results. If you are on Callysto hub (you should be), the Python3 kernel will use remote Callysto hub CPU, RAM, and GPU for the computations it runs. Note that the RAM is not released until the kernel is shut-down.

Magics complicate this process by accessing other kernels, be wary because the magic kernels may use the user's local resources rather than the remote server resources. This is especially relevant when you are using JavaScript or WebGL for graphics rendering. Try to do all of your resource heavy computations in Python and then pass the results to your other kernels.

Internally, notebook documents are JSON data with binary values (base64) encoded. This allows them to be read and manipulated programmatically by any programming language.

Notebooks can be exported to different static formats including HTML, reStructeredText, LaTeX, PDF, and slide shows (reveal.js) using Jupyter’s nbconvert utility.

Furthermore, any notebook document available from a public URL or on GitHub can be shared via nbviewer. This service loads the notebook document from the URL and renders it as a static web page. The resulting web page may thus be shared with others without their needing to install the Jupyter Notebook.

If you are interested in the low level details of Jupyter I suggest [these docs](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messaging) although they are beyond the scope of most of the work we will be doing with notebooks.

## The Hub

Project Jupyter created JupyterHub to support many users, Callysto hub (hub.callysto.ca) is an example of a Jupyter hub. With JupyterHub you can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server. We are using docker and kubernetes. You will not need to know details of the deployment however, if you find any bugs with the server please report them!


# Best Practices for Code Development

## Inherited Best Practices

We should attempt to follow the coding practices of the Python community as closely as possible. The folks who've taken the time to develop them have thought much more than any of us about what makes Python code easier to read. Assuming the majority of Python code outside Callysto also follows the community's style guide, this will also make outside resources easier to use.

[PEP 8](http://pep8.org) is considered the de-facto style guide of the Python community. Note that one of the first things it talks about is the importance of being willing to break the rules. This may be of special importance to this project, as we are not looking to teach Python so much as teach computational thinking, and sometimes what is natural and idiomatic in a particular language is just plain weird compared to the majority of other languages. Still, we should think hard about deviations from [PEP 8](http://pep8.org) and note them here.

## Following What's Already There

A simple, but effective, way to make sure you're following these coding guidelines is to first take a look at existing content and follow the style of that. If you notice something about the style that seems odd to you, that may be a good time to review these guidelines and/or the underlying [PEP 8](http://pep8.org) guidelines. In doing this, you may find that something in the repository isn't following these guidelines.

This will almost certainly happen with many people contributing code and as certain coding practices are modified. This section of the training manual won't assume the way your team is working. You may have an issue log that's kept to address later, you may have a single person in charge of the notebook that you inform, or if there's an appropriate Git process in place, you may be able to submit your own change and have it merged.

## Making Changes

Anyone should feel comfortable with suggesting changes to these best practices, as we will all likely discover some important and necessary ones along the way. Conforming to [PEP 8](http://pep8.org) when there's not a compelling reason to deviate will help avoid purely stylistic arguments. As the project gains momentum and more code, changes will be harder, so the sooner we discover any major changes we want to make, the better.

*Note:* If you're used to another language or following another style guide, it's natural for some things to feel awkward. This, in itself, isn't a great argument for a change to these guidelines. It's likely different things will feel awkward for everyone. When suggesting a change, be sure to consider the costs and benefits of making it. The more objective the argument you can make, the better its chances (provided it's also a good argument). But let's not let this stuff get out of control, either. At the end of the day, we should be spending most of our time actually writing code, not arguing over best practices.

## Consistent Name Spaces

When a module is imported by Python, the functions within it still need to be prefixed with the module's name. So, for example, a module called "fizz" with a function called "buzz" would be used in the following way:

```python
import fizz

fizz.buzz()
```

This is called namespacing and helps to avoid conflicts when functions are named similarly. While namespacing helps avoid conflicts, it can also make Python code harder to read when overused and when the module names themselves are long. There are variations of the `import` statement that can deal with these cases.

### Importing Using Local Names

A common variation used with certain popular packages is to create a shorter local name. For example, the `numpy` package is often imported like this:

```python
import numpy as np

x = np.array([2,3,1,0])
```

Aliasing modules like this is good practice when those modules are given the same local names by the community surrounding them. Numpy is a great example of this.

You should avoid defining your own local names. If there is a module without a community defined local name that you feel strongly should have one within our notebooks, make sure to bring it up with your fellow developers and team lead. If it is adopted, it will be something we'll want to do consistently in other modules within the project.

### Importing From

Functions (or submodules) that are used very often within a notebook can be specifically imported without a namespace:

```python
from os import path
from math import pi

some_path = path.join("folder1", "folder2", "file.txt")
radius = 5
area = pi * radius**2
```

There isn't a perfect rule for when and when not to do this, but here are some things to consider:

1. Does the function name tell someone reading the code enough about what it does without the module name? If you're writing a math notebook, using `cos` is probably pretty self explanatory, and there's no real need to remind people that it's from the math package by forcing them to read and write `math.cos`.
2. Does the module name help in understanding what the function does? For example, not only would `import join from os.path` conflict with the basic array `join` function, but it would also mislead readers as to the true purpose of `os.path.join`. The true purpose is to join path components with the path separator, so leaving at least enough of the module path to reflect this makes for clearer code.
3. When in doubt, or if you're using the package infrequently, put the module path with the function. This is the clearest way of avoiding namespace conflicts and allowing people to trace where functions are coming from.

Two other variations worth noting:

### Importing From, with Local Names

```python
from math import cos as cosine
```

This should probably be avoided in most cases, especially with standard Python libraries. The standard names will be easy to search for help outside of Callysto. The local names you might make up won't. However, there are cases where this may be useful. For example, if you find a rather obscure library with poorly named functions that nevertheless has one function (also poorly named) that's really, really useful, importing it this way would likely improve the readability of your code.

### Wildcard Imports

```python
from math import *
```

As noted in [PEP 8](http://pep8.org), you really shouldn't be doing this, as it's really easy to pollute your current namespace and wind up with weird bugs due to unintended function replacements. [PEP 8](http://pep8.org) notes some exceptions, and there's one exception noted below for our purposes.

### Local Names of Popular Packages

Here's a list of packages that we know of along with the local names you should use (based on local names used by the communities surrounding them) when importing and referencing them.

If there's a module that uses a common local name and is missing from this list, please add it.

```
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
```

## Managing Complexity

When developing a module, spend some time considering what aspects of computational thinking you're actually trying to demonstrate and whether or not you can assume any prerequisite knowledge in various programming concepts.

Whenever there is a need to reduce complexity without also reducing functionality (i.e. you want to show a fancy plot but not go over all of the necessary knowledge to produce that plot), consider extracting that complexity into a function in a separate Python file that is included in a notebook\_code subfolder:

```
/some_folder/
  my_awesome_notebook.ipynb
  notebook_code/
    my_awesome_support.py
```

Example **my\_awesome\_support.py**:

```python
import os
import numpy as np
import sys
import hashlib

def complex_fizz():
    md5 = hashlib.md5()
    for x in ["buzz", "fizz", "buzz"]:
        md5.update(x.encode("utf-8"))
    return md5.hexdigest()
```

Example **My Awesome Notebook.ipynb**:

```python
from notebook_code.my_awesome_support import *

complex_fizz()
os.mkdir('somedir')
```

You may note that the use of `import *` is discouraged in [PEP 8](http://pep8.org). In this case, we really do want to grab everything in the file. The functions we've defined in it are specifically for this notebook (so we're not worried about them clashing with existing functions), and we're bringing in imports, such as `os` and `numpy as np` that are already namespaced.

By maintaining the convention of placing helper code under a notebook\_code folder alongside the notebooks that use it, we make it easy to find this code for anyone who's curious. Don't go too crazy with this. Our main purpose of putting code like this in a separate file is to improve the ability to focus on the most important code in a notebook, not to obscure it. You'll likely only need one file per notebook and/or one file for common functionality between notebooks in the module. Try to keep imports of this code simple, as demonstrated above. For example, if you have the following:

```
notebook_module/
    notebook_a.ipynb
    notebook_b.ipynb
    notebook_code/
        common.py
        a.py
        b.py
```

**a.py**:

```python
from common import *
```

**b.py**:

```python
from common import *
```

**notebook\_a.ipynb**:

```python
from notebook_code.a import *
```

**notebook\_b.ipynb**:

```python
from notebook_code.b import *
```

This is really as complicated as things should ever get for most notebooks. And remember, you may not even need helper code. If your notebook code is simple enough and/or you can assume advanced users, you may not have much reason to do anything outside of it.

### Helper Packages

There likely won't be a need for more than one support file per notebook (or any at all), so we'll delay talking about more complex setups until they're needed. However, if we find we're extracting the same functions over and over again, this might be a sign that a separate package should be maintained.

This will involve some communication with your fellow developers, and it wouldn't hurt from time to time to browse any support `.py` files, as functions extracted here may become good candidates for a separate package if they are used often enough across notebooks. You likely won't see functions that are exactly the same, but if they are similar enough, consider extracting common functionality and rewriting as necessary.

Please don't start writing any packages on your own. We'll want to coordinate anything like this and consider the maintenance implications of having to roll out updates to packages used by many notebooks. However, please do bring up opportunities if you spot them.

## Folders

If your demo has many files associated with it (images,source code, etc.) it is best to keep them all organized into folders and subfolders, so users know what "package" to copy. Here's a suggested structure. You don't have to use every folder (if you don't store or use any data, for example, you won't need a "data" folder), but following similar names will help people navigate when using other notebooks:

```
Module_Name/
    notebook_one.ipynb
    notebook_two.ipynb
    images/
        image1.jpg
        image2.png
    data/
        .gitignore
        some_data.csv
        more_data.csv
    notebook_code/
        one.py
        two.py
```

Use the `.gitignore` file in `data` to ignore any files that you don't intend to store in Git when checking in changes to the notebook. For example, in one of your notebooks you may download some data but don't want people to have to continually download the data if they've already done it once. If you cache this under `data`, you don't want someone to accidentally check it in. Adding an entry to `.gitignore` will prevent that from happening. Or perhaps you encourage whoever's running the notebook to upload their own file to use in an exercise. You could create an `uploads` folder under `data` and ignore that, or just ignore all files of a particular filetype. If you're using a small amount of data that isn't sensitive, you may want to check it in with the notebook. In this case, you wouldn't include an entry in `.gitignore`, or if you're already ignoring files of that type, you'd want to make a special entry to *exclude* the file you want to check in from the ones ignored. Example:

```
*.csv
!i-still-want-to-be-under-version-control.csv
```

There's some [more information](https://help.github.com/articles/ignoring-files/) on ignoring files from the good folks at GitHub.

## Keeping it Simple

Consider the following example of two ways of creating an array of integers:

```python
x = [1,2,3,4]

import numpy as np
x = np.array([1,2,3,4])
```

This is an area where our experience with Python and especially some of the more popular packages may work against us. There are various optimizations and additions to arrays that make the use of `np.array` to create them worth the extra typing and effort to read. However, if you've never encountered an array before, this makes it much harder to understand what the code is doing.

For Callysto, we should prefer the first, simpler way of initializing an array. An added benefit (and something to also consider) is that this is also a common way of initializing an array in *many* languages.

Note that we can always convert a regular array into a numpy array internally if it is needed for some interesting package we want to use, even if this is less efficient, it allows us to hide the complexity up front.

List comprehensions (i.e. `x = [a for a in y]`) are generally considered "good Python" by the community. However, while many languages have mapping functions that serve a similar purpose, the syntax for list comprehensions is pretty unique to Python. When at all possible, you should use classic for-loops, even if you end up with less concise code:

```python
x = []
for a in y:
    x.append(a)
```

## Comments and readability

[PEP 8](http://pep8.org) has some great guidelines for comments in general. These guidelines are especially useful in any supporting python files.

But inside notebooks, also consider the other tool at your disposal: the markdown blocks themselves. If you've explained what you're doing in a code block in the markdown above it, there's no need to repeat that explanation in an actual code comment. With longer pieces of code, when you find yourself about to write a comment, consider whether it would be better to actually create another markdown block and continue your code below that.

Rule of thumb: the more important a particular section of code is to understand, the more likely it should be its own code block.

Good variable names, abstractions, modularization, and data structures are just as important for readability as comments.

Example: Which is easier to understand?

```python
nums = range(0,10)

x = 0 # even sum
y = 0 # odd sum

for num in nums:
    # check if the number is even
    if num % 2 == 0:
        x = x + num
    else:
        y = y + num
```

Or:

```python
nums = range(0,10)

even_sum = 0
odd_sum = 0

def is_even(x):
    return x % 2 == 0

for num in nums:
    if is_even(num):
        even_sum = even_sum + num
    else:
        odd_sum = odd_sum + num
```

The `is_even` function may be overkill once you get used to seeing the `%` operator enough. Combined with more appropriately named variables, however, it makes it much easier to follow what the code is doing. Once someone gets comfortable with the `filter` and `sum` functions, which are nice abstractions for certain operations over lists (and assuming we also define an `is_odd` function), we can write even more readable code:

```python
even_nums = filter(is_even, nums)
odd_nums = filter(is_odd, nums)
even_sum = sum(even_nums)
odd_sum = sum(odd_nums)
```

However, it's important to note that passing functions into functions is a more advanced programming concept, and the improved readability here relies heavily on the understanding of this concept.

## Packages

Be careful when installing Python packages. We don't want to have any install requirements for end users of these notebooks, so if there's a package you really need, this will eventually have to be communicated to the maintainers of hub.callysto.ca.

Keep a list of any packages you install this way and consider how much you really need it. How much code would you have to write in a supporting python file to do what the library is doing for you? Reinventing the wheel carries a cost (you likely haven't thought as much about the problem as the maintainers of an existing package created to solve it), but external dependences have their own costs.

### Installing packages on hub.callysto.ca

In the case where certain libraries are not installed when running or developing notebooks, users may install packages in their userspace via:

```
pip install PACKAGE_NAME --user
```

in a terminal session or

```
!pip install PACKAGE_NAME --user
```

in a notebook code block.

When installing packages in the userspace, it should be noted which are added in order to subsequently have the package installed system-wide (if it is a commonly used package). Alternatively, the notebook or a setup file should be configured to automatically install the packages on a user by user basis.


# Coding Mistakes to Avoid

Many of these are common mistakes we have seen in Jupyter notebook development. Feel free to add more to this file.

## Use textContent not innerHTML, for text inputs

In JS functions if you have a DOM element (divs, svg, etc.) .innerHTML, if you get information from a form, it executes when it reads the form data. Susceptible to XSS attacks. [Use textContent instead](https://stackoverflow.com/questions/16860287/security-comparison-of-eval-and-innerhtml-for-clientside-javascript), for more info you can read: <https://stackoverflow.com/questions/21311299/nodevalue-vs-innerhtml-and-textcontent-how-to-choose>

## Iframes

Iframes are good if you need to contain things, but if you want to access variables in those things then iframes are bad. Instead use magics and html and javascript function calls from the display library. It produces cleaner code too.

## System time

Do not make programs that are dependent on system time.

## Infovis

No pie charts or spaghetti plots. Avoid clutter, and volume comparisons. See the infovis section of the manual for more in depth information.

## Use Python for heavy processing

JS uses the browser aka local resources. Python uses the remote Callysto Hub resources. Ideally you will do any heavy processing in Python and then pass the results to JS. Try to avoid doing large processing tasks with the user's local resources.

## Do not parse HTML with regex

[Do not parse HTML with regex](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) or other level 2 languages.


# Markdown Language

A great feature of the Jupyter Notebooks is that they can contain formatted text, mathematical formula, and embedded images, via the use of the Markdown language.

Markdown is a rich language: a quick introduction to it is available here: <https://guides.github.com/features/mastering-markdown/>

Some quick points:

## Editing and typesetting

Within the Jupyter notebook, you simply type your text and Markdown symbols into a cell, and hit “shift-return” to typeset the cell into pretty text (and math). Click on the cell again to undo the typesetting, so you can edit and fix your text. Make sure, of course, that you have marked the cell as “Markdown” and not “Code.”

## Headers

Headers are made by starting the line with one or more hash marks #.

```
## This is a level-2 header, in text form
```

## Emphasis

Add emphasis by surrounding text with asterix or underscores.

`* italics * and ** bold **` yield *italics* and **bold** .

### Lists

Type this:

```
- Apple
- Orange
- Pear
```

to get a list like this:

* Apple
* Orange
* Pear

Use numbers instead, to get an enumerated list

#### Web links

Type this `[GitHub](http://github.com)` to get a clickable weblink like this: [GitHub](http://github.com)

#### Images

Type this `![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)` to embedd an image into your webpage:, like this: ![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)

#### Mathematics

Use the dollar sign `$`to indicate the start and end of LaTeX code for your math.

Here is the code for basic integral `$\int \cos(x) dx = \sin(x)$` which results in this display. $\int \cos(x) dx = \sin(x)$

To get the formula on a stand=alone line, use double dollar signs: `$$\int \cos(x) dx = \sin(x)$$` $$\int \cos(x) dx = \sin(x)$$

A cheat sheet with more details is available here: <https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet>


# Bug Reporting

## Who can report a bug?

### Internal

* Cybera & PIMS

### External

* Callysto creator (content creator / curriculum expert - professor, teachers etc)
* Callysto developer (Student developers)
* End users - Students, Teachers

## Where can they report a bug?

* Internal bug tracking - JIRA.
* External bug tracking - Bugs can be reported by creating an [issue](https://help.github.com/en/github/managing-your-work-on-github/creating-an-issue) on the Github [repo](https://github.com/callysto/curriculum-notebooks/issues).&#x20;

## How to report a bug?

* Three important aspects of bug reporting in general are:
  * Brief description of the bug, with steps on how to reproduce it.
  * Expected result
  * Actual result
* When writing down the steps to reproduce a bug,
  * It would be helpful to note down the environment details like web browser or other system information if thats relevant. Also, note down general details like name of the notebook, section of the notebook where you find the error, etc.
  * Add screenshots if possible and only if it adds to the explanation. Please note, for external bug reporting, screenshot uploads are not available natively in Github, therefore you may want to consider hosting your image and linking to it via [imgur](https://imgur.com/) or your host of choice. &#x20;


# Github Workflow

The following is a recommended git workflow for developing notebooks. Its main goals are to encourage regular commits of notebook code and to provide release coordinators with flexibility when preparing to merge content into the master branch. Make sure you obtain contributing permissions for the repository before attempting to make a branch.

## Levels

There two types of branches:

1. Master
2. Individual notebooks or stories

Most developers will do work solely within individual branches, making sure to occasionally fetch and merge changes from the master branch.

In a usual software development project, the second level would more commonly be referred to as *feature branches*. In this project, individual notebooks take the place of individual features.

## Working on a Branch

Keeping to a single notebook per *feature branch* gives release coordinators the flexibility to grab notebooks that are ready and leave those that are not when it comes time to prepare for a release.

More than one developer can work on the same notebook branch, and you shouldn't be terribly concerned with checking in polished work at this level, except to the extent that it may disrupt anyone else working with you on the same notebook. A little communication goes a long way here. That said, we expect that it will largely be a single developer working on a particular notebook at a time.

Get comfortable with making regular, small commits to your notebook branch, and push to GitHub fairly often. This makes merging easier down the line, makes it easier for other developers to review progress, and ensures that your work is backed up. Make sure you are only tracking files that you are editing (avoid git add \* where possible). Due to the metadata files in Jupyter Notebooks, often times just running a notebook will show up as changes in the code. In this case, use git reset HEAD or git reset --hard to match your branch to what's on the Github repo.

Occasionally developers working on the individual notebook branches will want to do the following:

```bash
git fetch
git merge master
```

to make sure they’re up to date with the upstream changes and are always ready to be merged into *master*. This will become more important the closer those individual notebook branches get to being integrated into *master*.

Notebooks will undergo reviews before being added to master. To do this, make a pull request in the repository and add at least one other person as a reviewer. In this process, the Travis continuous integration client will provide automatic code checks. To learn more about using Travis with Pythonm see [here.](https://towardsdatascience.com/extensive-python-testing-on-travis-ci-4c24db9bf961)

## Master Branch

This represents "releasable" code. In theory, anyone checking out code from the *master* branch should expect to see the best quality notebook code that we can offer. It won’t necessarily be bug free, but it's free of the bugs we know about (and that are serious enough to block a release).

## Commit Messages

Capitalize the first letter, no period. Use the imperative "Fix bug" not "Fixes bug" or "Fixed bug". Include the Jira task identifier in the commit message (not in the file title), for example: "CC-33 Add interactivity to the plots". For longer commit message write a short description followed by a blank line and then the longer description. Try to wrap at 72 characters, in Vim this is done with `:set textwidth=72`. Use the body to explain what and why but not how.

## Tagging

It’s often helpful to mark a specific commit of the master branch when that commit represents code we know has been "released" and will likely not be continually updated from Github until the next release. This can come in handy when tracking down bug reports that may or may not have been fixed since that release.

Individual developers working on notebook branches do not have to worry about tagging, but in the event that a release coordinator wants to tag a release, they can run the following:

```bash
git tag -a v1.0 -m "our first release"
```

## Common Commands

Here are some of the common commands that developers will be using:

### Committing and Pushing Code:

```bash
git add some_file
git add some_other_files*
git status
git commit
git push
```

### Create a Branch

This will create a branch locally and remotely, based off of *master*:

```bash
git checkout master # if not already there
git checkout -b branch_name
git push -u origin branch_name
```

### Merge Master into a Branch

```bash
# Fetch the remote branch and merge it into the local branch
git pull
git checkout branch_name # if not already there
git merge master
```

### Compare Changes to Committed Work:

```bash
git diff
```

### Compare Differences Between Branches:

```bash
git diff staging notebook_a
```

Compare with upstream changes on the same branch and then merge (more complicated than git pull, but also avoids potential surprise merge conflicts):

```bash
git fetch
git checkout branch_name
git diff origin/branch_name
# assuming the changes are okay...
git merge origin/branch_name
```

### Temporarily Stash Local Changes:

```bash
git stash
```

The moves local changes out of the way, making your repository look clean. It can be useful when you realize there are upstream changes but don't want to commit your current changes just to see those upstream changes.

When ready, you can then reapply your local changes via:

```bash
git stash pop
```


# Troubleshooting

Steps to go through if it is not working:

* Google.
* Turn the kernel off and then on again.
* Try incognito mode. Jupyter is nicer in incognito mode because browser caches will sometimes cause issues, especially the way Chrome does browser caching. Keep in mind however that the final notebook will need to be fully operational outside of incognito/private browsing.
* Try a different browser.
* Use the "inspect" tool built into your browser (ctrl-shift-i for Chrome).
* Try messaging the slack, you will probably get a fast answer there and your fellow developers can help you.
* If you are still stuck reach out to the appropriate person.

## Specific Issues

If you are using JavaScript `require` try switching it to `requirejs`. `require` sometimes stores JS in the cell's metadata which persists even after a restart and cache clear. `requirejs` *seems to* avoid this issue.

***

If you are getting the error "IOPub data rate exceeded" try to downsize what you are processing. We have upper bounds to avoid things like infinite loops crashing the servers. If you know that what you need to be processing is large you can contact cybera to have your data rate limit increased.

***

JavaScript is naturally asynchronous, while Python is not. This will cause problems when passing variables between these languages.

e.g. A variable that has not yet been initialized by JavaScript will be inaccessible to later Python code. Often this manifests during a "Run All" command sent to the kernel.

***

Travis failing unexpectedly due permissions issues when loading external files may be caused by notebooks attempting to write to files. At the moment we discourage notebooks writing to files, if possible find a way around the notebook writing to the file. If it is necessary for your notebook to write to a file please reopen issue [#77](https://github.com/callysto/curriculum-notebooks/issues/77).

***

If only one of multiple widgets is working check if they are both pushing data to the same `svg` object. This can be caused by Javascript loading that is not protected by a function. This results in consistent name spacing between the files being overwritten by the *last* declaration. Developers need to wrap animations like this in functions, or they need to be aware that variable declarations *are not safe* between files once they are loaded into Jupyter.

***

Loading D3 inside the notebook with `<script>` tags require the cells to be run twice in order for any javascript modules to be loaded in time - unless all your javascript is in the same cell (un-imported from an external file and under a `%%javascript` magic). Packages like `d3` need to be included with something like

```js
requirejs.config({
    paths: { 
        'd3': ['//cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3'], 
    },                                       
});

require(['d3'], function(d3) { what you want your script to do} )
```

inside the actual `.js` file *not* inside the notebook.

***

nbgitpuller automatic merge commits. **Situation**: You use a nbgitpuller link to clone a Github repository to hub.callysto.ca, make some changes to the notebook(s) in the hub, and then try to clone the repo again using the same nbgitpuller link. **Behaviour**: Please note that nbgitpuller will try to create an automatic commit to persist the changes that you made to the notebook(s). **Mitigation**: On a case by case basis, you might wish to drop the automatic commit before you set up a Pull Request. This behavior is explained in detail in the [nbgitpuller documentation](https://jupyterhub.github.io/nbgitpuller/topic/automatic-merging.html).


# Information Visualization

Information visualization is a key part of the notebooks. We want to bring visual thinking, interactivity, and resources so vast they require visualizatins, to the K-12 students and teachers.

## Background

### Why do we visualize data?

* External cognition
  * Use visualizations as external memory
  * Increase our problem solving capacity, beyond internal/mental processes
  * Connect to external data sources, extend our senses
* Knowledge crystallization
  * Gather information
  * Make sense of it with a representational framework
  * Package results for communication or action
* Discovery
  * Complex loops of interactions between data, visualization, and cognition
  * Can use imagination and exploration to leverage visualization and discover new ideas (use external world to increase our ability to think)

### 6 Ways that Visualizations Amplify Cognition

1. Increasing the memory and processing resources available to users
2. Reducing the search for information
3. Using visual representations to enhance the detection of patterns
4. Enabling perceptual inference operations
5. Using perceptual attention mechanisms for monitoring
6. Encoding information in a manipulable medium

### Limitations

* Computational
  * Primarily the notebooks use remote resources from the hub to run their code but sometimes use the user's local resources. Try to run most of the heavy processing in Python and then pass it to the visualization library of your choice.&#x20;
* Perceptual/Cognitive
  * Be sure to uphold accessibility standards! This is especially important in the context of this project, we do not want any children to be unnecessarily excluded or disadvantaged.
  * Generally avoid putting too much clutter on your graph, the perceptual system has limited capacity. If any aspects of your visualization move actively, you should expect those to distract from the rest of your visualization.
* Display
  * If you are creating visualizations with small details the display limits will be a factor. Many schools use old low resolution screens, don't assume it will look the same way it does on your expensive work computer. Avoid fine grained details.
  * Not all displays are calibrated correctly, if you use many colours which have to be discriminated from each other, be sure to use [color brewer](http://colorbrewer2.org) to select your colour scheme.

### Visual Encoding Principles

![Analyzing visual Encoding Via Marks and Channels](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2F873a34fdfb68aa8f5d45041b7ee369fc7a6f71d6.jpeg?generation=1613092108848838\&alt=media)

![Channels, Matching Expressiveness](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2F229a59f5dffb3616ce5c7ad911e1aed878f28378.jpeg?generation=1613092108735755\&alt=media)

Please avoid trying to encode information as 3D volume or curvature, these are difficult for people to process.

### Types of Data

1. Quantitative
2. Ordered&#x20;
3. Categorical

Special note: Although relational data (represented by graphs, networks, trees) is a subset of the above three, it requires different visualization strategies.

![Types of Data](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2F35cff519033468a691fa55b3a6fc521ca60df19f.jpeg?generation=1613092109201435\&alt=media)

The strategies at the top of the lists have been shown to be the most effective for visualizing that type of data. Strategies near the bottom of the lists should be avoided. For example hue is great to use for categorical data, shape is less ideal.

## Practical Tips

Disclaimer: these are generalizations, use your own discretion. There are many situations where you should ignore these guidelines.

* Avoid 3D if a 2D solution exists.
* Design Mantra for Interactivity "Overview first, zoom and filter, then details on demand" - Schneiderman (1996)
* Text labels should be useful (can be crucial), not cluttering the design.
* [Don't use pie charts](https://blog.funnel.io/why-we-dont-use-pie-charts-and-some-tips-on-better-data-visualizations), although this is [controversial](https://eagereyes.org/pie-charts)
* [Avoid](https://python-graph-gallery.com/125-small-multiples-for-line-chart/) using spaghetti plots where many lines are layered on top of each other.
* **Uphold accessibility standards!**

### Questions to ask yourself, is your visualization:

* Informative. What are you trying to communicate with your datavis and is this the best way to communicate it? What information do you want to convey, how can you make it clearest to the user? Do any aspects of your datavis distract from the information you are trying to convey?
* Representative. Is your data qualitative or quantitative? Discrete or continuous? Does your visualization match the data type?
* Intuitive. If someone looked at my datavis, would they immediately understand it?

## Useful Links

Use [Color brewer](http://colorbrewer2.org) to select your color schemes.

[Basics](https://eagereyes.org/section/basics) you should know.

[Further reading](https://eagereyes.org/section/techniques) on infovis techniques.

[Perceptual edge](http://www.perceptualedge.com/) is a treasure trove of infovis.

[A gallery](http://conceptviz.github.io/#/e30=) of concept visualizations.

[Callysto Shorts Jupyter Book](https://callysto.github.io/shorts-book/intro.html) of commonly used code in our notebooks.

P.S. If you would like to learn more about information visualization, reach out to India (<india@pims.math.ca>), she works in an infovis lab. Special thanks to Madison Elliott for providing many of these infovis outlines.


# Plotting

I strongly suggest learning matplotlib, then plot.ly, then D3 or Mathbox, in that order. You are not required to learn D3 or Mathbox although you will need to know how to use matplotlib and plot.ly.

[Here are some examples](https://python-graph-gallery.com/all-charts/) of python charts.

You can see some plotting functions at the bottom of [this](https://github.com/inygy/nserc-analysis/blob/master/SelectionsTemplate.ipynb) file. In the future we may attempt to turn these into generalized plotting functions.

## matplotlib

Matplotlib is the easiest, it is good for mockups and initial plots. You can import seaborn to make your matplotlib plots instantly look better or convert your matplotlib plot to a plot.ly plot for better interactivity.

[Example](http://pbpython.com/simple-graphing-pandas.html) of a simple graph with data

[How to](https://stackoverflow.com/questions/6974847/plot-with-non-numerical-data-on-x-axis-for-ex-dates) plot non numerical data on the x axis.

You can use [html5 to animate matplotlib](https://github.com/callysto/training-manual/blob/master/markdown/animate-graphs.md) however generally we suggest that you use plot.ly instead.

## Plot.ly

Plot.ly is good for interactivity. You can easily convert your matplotlib plots into plot.ly.

Plot.ly in Jupyter notebooks [tutorial](https://plot.ly/python/ipython-notebook-tutorial/)

[Plot data from a csv](https://plotly.com/python/plot-data-from-csv/)

Sample plot.ly graph, from a matplotlib plot:

`!pip install plotly --user;`

```
import numpy as np
import plotly.offline as py
from plotly.offline import init_notebook_mode, iplot
import plotly.tools as tls
import matplotlib.pylab as plt
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas

init_notebook_mode(connected=True)
fig = plt.Figure()
ax = fig.gca()
x = np.linspace(-10,10,200)
y = abs(x)
ax.plot(x,y)
canvas = FigureCanvas(fig)
plotly_fig = tls.mpl_to_plotly(fig)
py.iplot(plotly_fig)
```

The same plot using only plotly (preferred):

```
import numpy as np
import plotly.offline as py
from plotly.offline import init_notebook_mode, iplot
import plotly.tools as tls
import matplotlib.pylab as plt
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas

x = np.linspace(-10,10,200)
y = abs(x)

# Create a trace
trace = go.Scatter(
    x = x,
    y = y
)

data = [trace]

py.iplot(data, filename='absValue-plot')
```

## Advanced Plotting

Before starting there are a few distinctions you should know:

* WebGL: is the Javascript API that allows you to create 3D graphics in the browser.
* Three.js: a framework build on top of WebGL which makes it easier to create 3D graphics in the browser, it uses a canvas + WebGL to display the 3D scene.
* D3.js: a data visualisation library. It makes it easy to generate and modify graphics based on data. Does not do 3D although you could theoretically combine it with three.js or mathbox to get 3D functionality. Has mediocre docs but a lot of great examples. Steep learning curve, slow to program.
* Mathbox: uses three.js, WebGL and a few other libraries to create 3D graphics, 2D animated graphics, beautiful animated slideshows, render animated 3D objects with shaders in linear time, etc. Has a very steep learning curve and terrible docs.

You cannot easily convert from matplotlib/plot.ly to D3 or Mathbox. D3 and Mathbox are theoretically compatible with each other and could work in conjunction although it would require a prohibitive amount of knowledge of both. Usually the workflow would be to imagine a visualization you want, and then directly begin to create it in D3 or Mathbox.

### D3

D3 is similar to but far better than matplotlib or plot.ly. It has a large learning curve and you will mostly be on your own for debugging and troubleshooting. If you really need D3 help you can contact Eric, <eric.easthope@me.com>.

Frankly the docs on D3 are not a great way to learn it. I suggest building off of [examples](https://bl.ocks.org/mbostock).

It is easiest to do D3 mockups using [observable](https://beta.observablehq.com/) and then port them over to the notebook.

If you are especially keen you can try combining D3 with three.js or related.

### Mathbox

Mathbox can do almost anything you want and pushes the limits of computer graphics. However... it is not actively maintained, the docs are terrible, and the learning curve is very steep. Take a look at some of the pages of [acko.net](https://acko.net/blog/mathbox2/), feel free to explore some of the other pages to see more examples.


# Audio Generation

With a few lines of code, we can produce sound and play it within a Jupyter notebook. Consider incorporating audio components as you're developing a notebook.

We will import a few tools to make this possible, including pylab for plotting and numerical work.

```python
%matplotlib inline
from pylab import *
from IPython.display import Audio
```

We now set up five seconds of sound, sampled at 8000 times per second. We generate two pure tones together at 440 and 442 Hertz. This corresponds to a musical note at A above middle C. The slight difference in frequencies will cause a beating, or fluctuation of the sound at 2 beats per second.

```python
Fs = 8000.0
Len = 5
t = linspace(0,Len,Fs*Len)
f1 = 442.0
f2 = 440.0
signal = sin(2*pi*f1*t) + sin(2*pi*f2*t)

Audio(data=signal, rate=Fs)
```

&#x20;Your browser does not support the audio element.

We can analyse this signal with the Fourier transform. Plotting, we see the energy is concentrated at 440 Hz (and there is a mirror image in the frequency near 8000-440 Hz).

```python
freqs = t*Fs/Len # a list of frequencies, in Hertz
fsig = abs(fft(signal)) # Fourier transform of the signal
plot(freqs,fsig) # amplitude versus frequency
```

\[]

By zooming in on the relevant part of the signal, we can see the presence of energy at the two frequencies of 440 Hz and 442 Hz.

```python
plot(freqs[2100:2300],fsig[2100:2300])
```

\[]

Some note on audio in the computer.

The sound we hear with our ears are the rapid vibrations of air pressure on our eardrums, usually generated from vibrations of some object like a guitar string, drum head, or the vocal cords of a human. These sounds are represented as a function of time. In the computer, we represent this function as a list of numbers, or samples, that indicate the value of the function at a range of time values.

Usually, we sample at uniform time intervals. In the example above, we have 8000 samples per second, for a length of 5 seconds. The Nyquist-Shannon sampling theorem tells us that we need to sample at least as fast as twice the highest frequency that we want to reproduce.

Humans with exceptional hearing can hear frequencies up to 20,000 Hz (20 kHz). This suggests we should sample at least at 40,000 samples per second for high quality audio. In fact, a compact disk is sampled at 44100 samples per second, and digital audio tapes at 48000 samples per second.

But, since computer speakers are often of lower quality, we typically sample at lower rates like 8000, 10000, or 22050 samples per second. That give sound that is "good enough" and saves on computer memory.


# Animations - D3.js

All of our demos should involve snazzy, eye-catching visuals. As an example, here is a D3 animation with colourful balls to chase with your mouse. If you see nothing, click on "Reload" in your browser.

(The animation does not show up in the Gitbook Editor, only in the published version.)

\
\
circle {\
&#x20; stroke: #000;\
&#x20; stroke-opacity: .5;\
}\
\
&#x20;   \
\
var w = 600,\
&#x20;   h = 400;\
\
var nodes = d3.range(50).map(function() { return {radius: Math.random() \* 10 + 3}; }),\
&#x20;   color = d3.scale.category10();\
\
var force = d3.layout.force()\
&#x20;   .gravity(0.1)\
&#x20;   .charge(function(d, i) { return i ? 0 : -2000; })\
&#x20;   .nodes(nodes)\
&#x20;   .size(\[w, h]);\
\
var root = nodes\[0];\
root.radius = 0;\
root.fixed = true;\
\
force.start();\
\
var svg = d3.select("#body").append("svg:svg")\
&#x20;   .attr("width", w)\
&#x20;   .attr("height", h);\
\
svg.selectAll("circle")\
&#x20;   .data(nodes.slice(1))\
&#x20; .enter().append("svg:circle")\
&#x20;   .attr("r", function(d) { return d.radius - 2; })\
&#x20;   .style("fill", function(d, i) { return color(i % 17); });\
\
force.on("tick", function(e) {\
&#x20; var q = d3.geom.quadtree(nodes),\
&#x20;     i = 0,\
&#x20;     n = nodes.length;\
\
&#x20; while (++i < n) {\
&#x20;   q.visit(collide(nodes\[i]));\
&#x20; }\
\
&#x20; svg.selectAll("circle")\
&#x20;     .attr("cx", function(d) { return d.x; })\
&#x20;     .attr("cy", function(d) { return d.y; });\
});\
\
svg.on("mousemove", function() {\
&#x20; var p1 = d3.svg.mouse(this);\
&#x20; root.px = p1\[0];\
&#x20; root.py = p1\[1];\
&#x20; force.resume();\
});\
\
function collide(node) {\
&#x20; var r = node.radius + 16,\
&#x20;     nx1 = node.x - r,\
&#x20;     nx2 = node.x + r,\
&#x20;     ny1 = node.y - r,\
&#x20;     ny2 = node.y + r;\
&#x20; return function(quad, x1, y1, x2, y2) {\
&#x20;   if (quad.point && (quad.point !== node)) {\
&#x20;     var x = node.x - quad.point.x,\
&#x20;         y = node.y - quad.point.y,\
&#x20;         l = Math.sqrt(x \* x + y \* y),\
&#x20;         r = node.radius + quad.point.radius;\
&#x20;     if (l < r) {\
&#x20;       l = (l - r) / l \* .5;\
&#x20;       node.x -= x \*= l;\
&#x20;       node.y -= y \*= l;\
&#x20;       quad.point.x += x;\
&#x20;       quad.point.y += y;\
&#x20;     }\
&#x20;   }\
&#x20;   return x1 > nx2\
&#x20;       || x2 < nx1\
&#x20;       || y1 > ny2\
&#x20;       || y2 < ny1;\
&#x20; };\
}\
\
&#x20;  &#x20;


# Animations - HTML5

We can use html5 for animation, as suggested in this web page: <http://louistiao.me/posts/notebooks/embedding-matplotlib-animations-in-jupyter-notebooks/>

This seems to be the modern way to do animation in Python.

First step is to initialize some things in Python.

* we need %matplotlib inline to get things to plot right on the notebook
* we need numpy for the math
* se need matplotlib for plotting
* we need animation from matplotlib, and HTML from iPython.display to show the animations

We get all these with the following imports:

```python
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation, rc
from IPython.display import HTML
```

We now have four steps to get an animated plot

* set up the figure frame
* define the initializing function
* define the function that draws each frame of the animation
* call the animator function, which creates all the frames and saves them for you

Then we are ready to call "HTML" to display the animation.

```python
# First set up the figure, the axis, and the plot element we want to animate
fig, ax = plt.subplots()

ax.set_xlim(( 0, 2))
ax.set_ylim((-2, 2))

line, = ax.plot([], [], lw=2)
# NOTE: THIS WILL DISPLAY JUST AN EMPTY BOX.
```

![An empty plot](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2Fcbce4afab4ea65cb2ee441203788ff5b5944d674.png?generation=1613092108923527\&alt=media)

```python
# initialization function: plot the background of each frame
def init():
line.set_data([], [])
return (line,)
```

```python
# animation function. This is called sequentially
def animate(i):
x = np.linspace(0, 2, 1000)
y = np.sin(2 * np.pi * (x - 0.01 * i))
line.set_data(x, y)
return (line,)
```

```python
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=100, interval=20, blit=True)
```

```python
HTML(anim.to_html5_video())
```

&#x20;Your browser does not support the video tag.

Anytime you need the animation, you can call it up at will, with the following code:

```python
# equivalent to rcParams['animation.html'] = 'html5'
rc('animation', html='html5')
```


# Widgets for Interactivity

## Using Widgets

Widgets are interactive objects on the notebook: buttons, check boxes, sliders and drop-down menus that allow the user to control actions in the notebook in a simple "point-and-click" method.

Widgets are a quick way to get interactivity in your Jupyter displays. You can read more about them here: [Widget notes](http://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Basics.html)

Jupyter has its own version of widgets, based on iPython widgets. We use the **interact** command to access them.

Unfortunately, I can't seem to get this to show up in the Markdown files of this eBook. So you will have to experiment yourself in Jupyter, or read the reference above to see them live.

To get started, we import the **interact** function from the **ipywidgets** module.

```python
from ipywidgets import interact
```

### Basic Structure

A widget is something you see on the computer screen that you click on, or move with the computer mouse, or enter text and data. It then does something.

The key is to define a function that that will do that "something."

Here is a really simple function, it just returns whatever is input to it.

```python
def f(x):
    return x
```

Notice the argument of the function is called **x**. We will use this same **x** when calling up the interact command.

**Next:** We create the widgets by calling the **interact** function, using an argument type for **x**. The choice of type of data **x** will automatically select whether we get a slider, check box, text entry boxes, etc.

Here are a few examples. **Note:** It is useful to end the function call with a semicolon, to suppress useless output.

```python
interact(f,x=(0,10));  # a slider with integer outputs
```

```
6
```

```python
interact(f,x=(0.0,10.0)); # a slider with floating point outputs
```

```
4.9
```

```python
interact(f,x=True); # a check box with True/False output
```

```
True
```

```python
interact(f,x='Hello World'); # an editable text box
```

```
'Hello World'
```

```python
interact(f, x={'One': 1, 'Two': 2, 'Three': 3, 'Forty four': 44}); # a drop-down list
```

```
1
```

## Using Widgets in Plotting

Now let's do some more interesting examples where we get the widget to plot something interesting.

We will import some utility functions for plotting and numerics.

```python
%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
```

First we define the update function which will plot something interesting for us. In this case we plot the power function $$f(x) = x^k$$ for various values of $k$. We set a range of values from 0 to 1 to plot.

The **show** command in the function is important, to get the plot to display.

```python
x=linspace(0,1)

def update(k=0):
    plot(x,x**k)
    show()
```

Now we can the interact command using the update function, and a slider. Notice we use the argument **k** in this call, to match the **k** in the definition of function **update** above.

```python
interact(update,k=(1,10));
```

![png](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2Fe1f9e22f3b5b0978deaff73fa981eea16269a3c3.png?generation=1613092108410575\&alt=media)

We can do more complex plots with many sliders. For instance, let's explore the sine funciton as it ofter appears in signal processing. It can have an amplitude, frequency and phase. We define the appropriate function and include sliders for this.

$$t\mapsto A\sin(2\pi f t + \phi ).$$

When we define the function, we can include some default values in the argument list.

```python
t = linspace(0,1,1000)

def plot_sine(A=4,f=2,phi=0):
    plot(t,A*sin(2*pi*f*t + phi))
    axis([0,1,-6,6])
    show()
```

When calling the **interact** function, makes sure the list of parameters have the same names as the action function **plot\_sine**.

```python
interact(plot_sine,A=(0,10), f=(1,10), phi=(0,2*pi));
```

![png](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2F1db7fc50389912fe4db2a0f33c6fb1e814094cce.png?generation=1613092108165548\&alt=media)

## Other Graphics

You are not limited to simple 2D plots. The widgets can control more interesting graphics, as in this network example. This come from the site [github.com/jupyter-widgets/ipywidgets](https://github.com/jupyter-widgets/ipywidgets)

```python
import networkx as nx
```

```python
# wrap a few graph generation functions so they have the same signature

def random_lobster(n, m, k, p):
    return nx.random_lobster(n, p, p / m)

def powerlaw_cluster(n, m, k, p):
    return nx.powerlaw_cluster_graph(n, m, p)

def erdos_renyi(n, m, k, p):
    return nx.erdos_renyi_graph(n, p)

def newman_watts_strogatz(n, m, k, p):
    return nx.newman_watts_strogatz_graph(n, k, p)

def plot_random_graph(n, m, k, p, generator):
    g = generator(n, m, k, p)
    nx.draw(g)
    show()
```

```python
interact(plot_random_graph, n=(2,30), m=(1,10), k=(1,10), p=(0.0, 1.0, 0.001),
         generator={
             'lobster': random_lobster,
             'power law': powerlaw_cluster,
             'Newman-Watts-Strogatz': newman_watts_strogatz,
             u'Erdős-Rényi': erdos_renyi,
         });
```

![png](https://2570486336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBK9pCiaJetIt0dnUvG%2Fsync%2F74a8471cd0699f83c889d03a1fcb4d685bb34166.png?generation=1613092108219254\&alt=media)

```python
```


# Online Resources

## The Callysto Server

You can create and run your Jupyter notebooks using the callysto server that is maintained by Cybera and PIMS. Just click here:

<https://hub.callysto.ca>

Log in using your Google ID. Note you should stick to one ID, as each instance of an ID will give you a separate server, with separate file storage. Usually you want to keep all your code in one place, so use only one ID.

## The Callysto GitHub Repository

This is where we post our public demos, notebooks, etc.

<https://github.com/callysto>

## The Callysto Shorts Jupyter Book.

Contains examples of commonly used code in our books for interactivity and visualizations.

[Callysto Shorts Jupyter Book](https://callysto.github.io/shorts-book/intro.html)

### The Private Callysto GitHub Repository

This is where we post our private demos, for discussion and improvement before release.

<https://github.com/cybera/callysto-sample-notebooks>

## Jira Project Management Tool.

This is where we track what stories we are working on for the development sprints.

<https://jira.cybera.ca>

## Slack

This is where we quickly communicate and collaborate. Please get added to this if you are not already.

<https://callysto.slack.com>

## Intro to Syzygy

This is a related Jupyter project from PIMS, Cybera and Compute Canada.

<http://intro.syzygy.ca>

## Jupyter Notes

More about the Jupyter project.

<http://jupyter.org/>

## Markdown Language Notes

Some useful Markdown Language tips.

<https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet>

## Git Notes

Some useful GitHub tips.

<http://rogerdudler.github.io/git-guide/>


# Useful Links

Feel free to add your own links to the list! Just push your suggested additions.

## Educational Resources

These resources are very important as the curriculum modules chosen for development are from the current K-12 Alberta curriculum. Although Alberta is currently undergoing a curriculum review, the modules selected for development are core learning concepts (e.g. functions in math) that will apply to future curriculums. If you want more information about the curriculum module you are developing, please visit the links below.

[Alberta Curriculum for K-12](http://www.learnalberta.ca/ProgramsOfStudy.aspx?lang=en)

[Parent expectations, Alberta](http://www.learnalberta.ca/content/mychildslearning/index.html)

## Educational Resources for Children and Teachers

These resources were suggested to us by a group of K-12 teacher advisors. They contain information that is relevant to the development of Jupyter notebooks for the classroom.

[Curated collection of educational resources](https://nsdl.oercommons.org) sorted by grade and resource type.

[Collection of hundreds of lesson plans and learning activities for BC teachers](https://teachbcdb.bctf.ca) sorted by grade subject and resource type.

[Jupyter for kids](https://github.com/mikkokotila/jupyter4kids)

[How To teach Python To kids](http://www.mechanicalgirl.com/post/pygotham-2016-young-coders-or-how-teach-python-kids/)

[Usborn book: Python for kids](https://usborne.com/browse-books/catalogue/product/1/11315/coding-for-beginners-using-python/)

[Interactive resources for teachers (grades 4-6)](http://www.2learn.ca/kids/)

[Book: Doing Math with Python”](https://www.safaribooksonline.com/library/view/doing-math-with/9781457189999/)

## Notebook Examples

### Jupyter in the Classroom

[Question about using Jupyter notebooks at school](https://groups.google.com/forum/#!topic/jupyter-education/5C3ECsKdlWc)

[Example notebook for grade 6 Math](https://github.com/misterhay/Grade6Math)

### Interesting Jupyter Notebooks with Classroom Relevance

[Gallery of interesting Jupyter notebooks](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks)

[More interesting Jupyter notebooks](http://nb.bianp.net/sort/views/)

## Coding

[Callysto Shorts Jupyter Book](https://callysto.github.io/shorts-book/intro.html) of commonly used code in our notebooks.

[Textbooks and conversion](https://stackoverflow.com/questions/23292242/converting-to-not-from-ipython-notebook-format)

[Useful blog on Jupyter notebooks](https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/)

["A better way to code" by the creator of D3](https://medium.com/@mbostock/a-better-way-to-code-2b1d2876a3a0)

[Reference cells in markdown](https://stackoverflow.com/questions/28080066/how-to-reference-a-ipython-notebook-cell-in-markdown)

[Javascript to Python communication](http://jakevdp.github.io/blog/2013/06/01/ipython-notebook-javascript-python-communication/)

[Lecture notes on Jupyter and Python](http://nbviewer.jupyter.org/github/profjsb/python-bootcamp/tree/master/Lectures/) written in part by Fernando Perez, the creator of Jupyter.

[Jupyter modules](https://stackoverflow.com/questions/1031659/ipython-modules)

### Learn Python

[Learn Python with Python Challenge](http://www.pythonchallenge.com/)

[Interactive Python tutorials](http://www.learnpython.org/en/)

[The Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/writing/style/)

[Python interactive widgets](http://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html)

## Information Visualization

[Color brewer](http://colorbrewer2.org) to select your color schemes.

[Basics](https://eagereyes.org/section/basics) you should know.

[Further reading](https://eagereyes.org/section/techniques) on infovis techniques.

[Perceptual edge](http://www.perceptualedge.com/) is a treasure trove of infovis.

[A gallery](http://conceptviz.github.io/#/e30=) of concept visualizations.

## Databases

Please only list databases we are actively using or plan to use.

[Authorized learning resources database, Alberta](http://www.learnalberta.ca/alrdb.aspx#/)

[Alberta open data (school related)](https://open.alberta.ca/dataset?tags=Grade+10)


# Contacts

[Slack](http://callysto.slack.com)

## Developer Contacts

Project Manager, Byron Chu <byron.chu@cybera.ca>

* adds you to Jira
* leads sprint meetings
* if you are uncomfortable contacting your other team leaders for any reason please address your concerns with Byron

Lead Developer, India Heisz <india@pims.math.ca>

* general inquiries
* help with code
* questions about the project
* mathbox questions
* adds you to github
* developer team maintainer

Senior Developer, Eric Easthope <eric.easthope@me.com>

* nbplus maintainer
* leads work on Callysto coding extensions
* D3 questions and D3 code help

## Site Directors

University of British Columbia (Vancouver), Michael Lamoreux <mikel@pims.math.ca>

* coordinates meetings for all sites

University of Calgary, Cristian Rios <crios@ucalgary.ca>

University of Lethbridge, Sean Fitzpatrick <sean.fitzpatrick@uleth.ca>

University of Manitoba, Kirill Kopotun <pims@umanitoba.ca>

University of Saskatchewan, Gary Au <gary.au@usask.ca>

University of British Columbia (Okanagan), John Braun <john.braun@ubc.ca>

University of Victoria, Anthon Quas <aquas@uvic.ca>

Simon Fraser University, Cedric Chauve <cedric.chauve@sfu.ca>

PIMS Headquarters, Jim Colliander <director@pims.math.ca>


