From a98d83a50f995bc683afb9e2cb1a1a45f04aa781 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Fri, 21 Nov 2025 13:32:13 -0800 Subject: [PATCH 01/11] CI: Make CI timeout much shorter. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 43f9b4c9..4b050d42 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: - run: name: Build documentation - no_output_timeout: 60m + no_output_timeout: 5m environment: # Ensure this is same as store_artifacts path below DOCS_PATH: _build/html From 004415d051417a0b5b0ae7ac0a0b12fb064cff26 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 24 Nov 2025 15:01:27 -0800 Subject: [PATCH 02/11] DOC: Add short_title for better navbar rendering. This enables shorter titles in the left navigation bar of the site, which is a minor improvement in readability (cuts down on the amount of vertical space used per item in the dropdowns!). --- content/mooreslaw-tutorial.md | 1 + content/save-load-arrays.md | 1 + content/tutorial-air-quality-analysis.md | 1 + content/tutorial-static_equilibrium.md | 1 + content/tutorial-style-guide.md | 1 + content/tutorial-svd.md | 1 + 6 files changed, 6 insertions(+) diff --git a/content/mooreslaw-tutorial.md b/content/mooreslaw-tutorial.md index cedc32d9..9fc216d2 100644 --- a/content/mooreslaw-tutorial.md +++ b/content/mooreslaw-tutorial.md @@ -1,4 +1,5 @@ --- +short_title: Moore's Law jupytext: text_representation: extension: .md diff --git a/content/save-load-arrays.md b/content/save-load-arrays.md index 2620bfaf..704f3475 100644 --- a/content/save-load-arrays.md +++ b/content/save-load-arrays.md @@ -1,4 +1,5 @@ --- +short_title: Sharing Array Data jupytext: text_representation: extension: .md diff --git a/content/tutorial-air-quality-analysis.md b/content/tutorial-air-quality-analysis.md index fda0dbf3..30b51dca 100644 --- a/content/tutorial-air-quality-analysis.md +++ b/content/tutorial-air-quality-analysis.md @@ -1,4 +1,5 @@ --- +short_title: Analyzing Air Quality jupytext: formats: ipynb,md:myst text_representation: diff --git a/content/tutorial-static_equilibrium.md b/content/tutorial-static_equilibrium.md index 868d777f..2d1a4d3e 100644 --- a/content/tutorial-static_equilibrium.md +++ b/content/tutorial-static_equilibrium.md @@ -1,4 +1,5 @@ --- +short_title: Static Equilibrium jupytext: text_representation: extension: .md diff --git a/content/tutorial-style-guide.md b/content/tutorial-style-guide.md index 24c6bef3..f0f49e52 100644 --- a/content/tutorial-style-guide.md +++ b/content/tutorial-style-guide.md @@ -1,4 +1,5 @@ --- +short_title: Style Guide jupytext: text_representation: extension: .md diff --git a/content/tutorial-svd.md b/content/tutorial-svd.md index d2c0adb6..f7ab3c5c 100644 --- a/content/tutorial-svd.md +++ b/content/tutorial-svd.md @@ -1,4 +1,5 @@ --- +short_title: Linear Algebra on n-D arrays jupytext: text_representation: extension: .md From a887e6ec65a16bfbf1529505cd75b36e841bad19 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 24 Nov 2025 15:07:40 -0800 Subject: [PATCH 03/11] MAINT: Rm text_processing.py from content. --- content/text_preprocessing.py | 188 ---------------------------------- 1 file changed, 188 deletions(-) delete mode 100644 content/text_preprocessing.py diff --git a/content/text_preprocessing.py b/content/text_preprocessing.py deleted file mode 100644 index cdfa3ad0..00000000 --- a/content/text_preprocessing.py +++ /dev/null @@ -1,188 +0,0 @@ -import pandas as pd -import argparse -import numpy as np -import re # (https://docs.python.org/3/library/re.html) for tokenising textual data -import string # (https://docs.python.org/3/library/string.html) for string operations - -# Creating the random instance -rng = np.random.default_rng() - -class TextPreprocess: - """Text Preprocessing for a Natural Language Processing model.""" - - - def cleantext(self, df, text_column, remove_stopwords = True, remove_punc = True): - """Function to clean text data by removing stopwords, tags and punctuation. - - Parameters - ---------- - df : pandas dataframe - The dataframe housing the input data. - text_column : str - Column in dataframe whose text is to be cleaned. - remove_stopwords : bool - if True, remove stopwords from text - remove_punc : bool - if True, remove punctuation suymbols from text - - Returns - ------- - Numpy array - Cleaned text. - - """ - data = df - # converting all characters to lowercase - data[text_column] = data[text_column].str.lower() - - # List of common stopwords taken from https://gist.github.com/sebleier/554280 - stopwords = [ "a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "as", "at", "be", "because", - "been", "before", "being", "below", "between", "both", "but", "by", "could", "did", "do", "does", "doing", "down", "during", - "each", "few", "for", "from", "further", "had", "has", "have", "having", "he", "he'd", "he'll", "he's", "her", "here", - "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", - "is", "it", "it's", "its", "itself", "let's", "me", "more", "most", "my", "myself", "nor", "of", "on", "once", "only", "or", - "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "she", "she'd", "she'll", "she's", "should", - "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", - "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", - "very", "was", "we", "we'd", "we'll", "we're", "we've", "were", "what", "what's", "when", "when's", "where", "where's", - "which", "while", "who", "who's", "whom", "why", "why's", "with", "would", "you", "you'd", "you'll", "you're", "you've", - "your", "yours", "yourself", "yourselves" ] - - def remove_stopwords(data, column): - data[f'{column} without stopwords'] = data[column].apply(lambda x : ' '.join([word for word in x.split() if word not in (stopwords)])) - return data - - def remove_tags(string): - result = re.sub('<*>','',string) - return result - - # remove html tags and brackets from text - if remove_stopwords: - data_without_stopwords = remove_stopwords(data, text_column) - data_without_stopwords[f'clean_{text_column}']= data_without_stopwords[f'{text_column} without stopwords'].apply(lambda cw : remove_tags(cw)) - if remove_punc: - data_without_stopwords[f'clean_{text_column}'] = data_without_stopwords[f'clean_{text_column}'].str.replace('[{}]'.format(string.punctuation), ' ', regex = True) - - X = data_without_stopwords[f'clean_{text_column}'].to_numpy() - - return X - - def split_data (self, X, y, split_percentile): - """Function to split data into training and testing data. - - Parameters - ---------- - X : Numpy Array - Contains textual data. - y : Numpy Array - Contains target data. - split_percentile : int - Proportion of training to testing data. - - - Returns - ------- - Tuple - Contains numpy arrays of test and training data. - - """ - y = np.array(list(map(lambda x: 1 if x=="positive" else 0, y))) - arr_rand = rng.random(X.shape[0]) - split = arr_rand < np.percentile(arr_rand, split_percentile) - X_train = X[split] - y_train = y[split] - X_test = X[~split] - y_test = y[~split] - - return (X_train, y_train, X_test, y_test) - - - def sent_tokeniser (self, x): - """Function to split text into sentences. - - Parameters - ---------- - x : str - piece of text - - Returns - ------- - list - sentences with punctuation removed. - - """ - sentences = re.split(r'(? Date: Mon, 24 Nov 2025 15:10:39 -0800 Subject: [PATCH 04/11] DOC: Rm blurb about non-executable tutorials. --- site/index.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/site/index.md b/site/index.md index ad8340c2..b026eacc 100644 --- a/site/index.md +++ b/site/index.md @@ -19,14 +19,6 @@ local copy of the `.ipynb` files, you can either [clone this repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) or use the download icon in the upper-right corner of each tutorial. -### Non-executable articles - -```{admonition} Help improve the tutorials! - -Want to make a valuable contribution to the tutorials? Consider contributing to -these existing articles to help make them fully executable and reproducible! -``` - ## Useful links and resources The following links may be useful: From 90792079d25b82628a05d17256c6d8ed633e6494 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 10:57:14 -0800 Subject: [PATCH 05/11] Update contributor guide for JB2 (#285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DOC: Rm bit about myst-nb and jupytext - different toolchain. * DOC: rm bit about why notebooks. Too much info for contrib landing page, and description of tooling is out-of-date. * DOC: Add quickstart for using jb2. * DOC: Same changes in readme. --------- Co-authored-by: Brigitta Sipőcz --- README.md | 49 ++++++++++++++++++++++++-------------------- site/contributing.md | 49 +++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 8dbce9ca..0209e32b 100644 --- a/README.md +++ b/README.md @@ -40,35 +40,40 @@ Images and real-life data make text more engaging and powerful, but be sure what you use is appropriately licensed and available. Here again, even a rough idea for artwork can be polished by others. -The NumPy tutorials are a curated collection of -[MyST-NB](https://myst-nb.readthedocs.io/) notebooks. These notebooks are used -to produce static websites and can be opened as notebooks in Jupyter using -[Jupytext](https://jupytext.readthedocs.io). +### Building the website -> __Note:__ You should use [CommonMark](https://commonmark.org) markdown -> cells. Jupyter only renders CommonMark. +```{note} +The NumPy tutorials are powered by [`jupyter-book`][jb-docs] and the +[`MyST` document engine][mystmd]. +See the linked documentation for further details. +``` + +[jb-docs]: https://jupyterbook.org/stable/ +[mystmd]: https://mystmd.org/ -### Why Jupyter Notebooks? +#### Quickstart -The choice of Jupyter Notebook in this repo instead of the usual format -([reStructuredText, through Sphinx](https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html)) -used in the main NumPy documentation has two reasons: +Set up a development environment with the dependencies listed in +`requirements.txt` and `site/requirements.txt`. +For example, using the built-in [`venv`][venv] module: - * Jupyter notebooks are a common format for communicating scientific - information. - * Jupyter notebooks can be launched in [Binder](https://www.mybinder.org), so that users can interact - with tutorials - * rST may present a barrier for some people who might otherwise be very - interested in contributing tutorial material. +```bash +python -m venv np-tutorials +source np-tutorials/bin/activate +python -m pip install -r requirements.txt -r site/requirements.txt +``` -#### Note +[venv]: https://docs.python.org/3/library/venv.html -You may notice our content is in markdown format (`.md` files). We review and -host notebooks in the [MyST-NB](https://myst-nb.readthedocs.io/) format. We -accept both Jupyter notebooks (`.ipynb`) and MyST-NB notebooks (`.md`). -If you want to author `MyST` notebooks in jupyterlab, check out the -[jupyterlab_myst](https://mystmd.org/guide/quickstart-jupyter-lab-myst) extension! +The site can then be built with: + +```bash +jupyter-book start --execute +``` +This will execute all the notebooks and start a web server to view the rendered +content locally. +View the rendered site by opening the ``localhost:30xy`` in your preferred browser (the exact port number will be printed in your terminal). ### Adding your own tutorials diff --git a/site/contributing.md b/site/contributing.md index 9fd31d4b..13ed7d44 100644 --- a/site/contributing.md +++ b/site/contributing.md @@ -12,37 +12,40 @@ Images and real-life data make text more engaging and powerful, but be sure what you use is appropriately licensed and available. Here again, even a rough idea for artwork can be polished by others. -The NumPy tutorials are a curated collection of -[MyST-NB](https://myst-nb.readthedocs.io/) notebooks. These notebooks are used -to produce static websites and can be opened as notebooks in Jupyter using -[Jupytext](https://jupytext.readthedocs.io). +## Building the website -> __Note:__ You should use [CommonMark](https://commonmark.org) markdown -> cells. Jupyter only renders CommonMark. +```{note} +The NumPy tutorials are powered by [`jupyter-book`][jb-docs] and the +[`MyST` document engine][mystmd]. +See the linked documentation for further details. +``` -## Why Jupyter Notebooks? +[jb-docs]: https://jupyterbook.org/stable/ +[mystmd]: https://mystmd.org/ -The choice of Jupyter Notebook in this repo instead of the usual format -([reStructuredText][rst]) -used in the main NumPy documentation has two reasons: +### Quickstart +Set up a development environment with the dependencies listed in +`requirements.txt` and `site/requirements.txt`. +For example, using the built-in [`venv`][venv] module: - * Jupyter notebooks are a common format for communicating scientific - information. - * Jupyter notebooks can be launched in [Binder](https://mybinder.org), so that users can interact - with tutorials - * rST may present a barrier for some people who might otherwise be very - interested in contributing tutorial material. +```bash +python -m venv np-tutorials +source np-tutorials/bin/activate +python -m pip install -r requirements.txt -r site/requirements.txt +``` -[rst]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html +[venv]: https://docs.python.org/3/library/venv.html -### Note +The site can then be built with: -You may notice our content is in markdown format (`.md` files). We review and -host notebooks in the [MyST-NB](https://myst-nb.readthedocs.io/) format. We -accept both Jupyter notebooks (`.ipynb`) and MyST-NB notebooks (`.md`). -If you want to author `MyST` notebooks in jupyterlab, check out the -[jupyterlab_myst](https://mystmd.org/guide/quickstart-jupyter-lab-myst) extension! +```bash +jupyter-book start --execute +``` + +This will execute all the notebooks and start a web server to view the rendered +content locally. +View the rendered site by opening the ``localhost:30xy`` in your preferred browser (the exact port number will be printed in your terminal). ## Adding your own tutorials From ce9ac49c477796ea0f79d9311d9c7b45988eee39 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 10:58:17 -0800 Subject: [PATCH 06/11] Split history site/contributing.md to CONTRIBUTING.md --- site/contributing.md => CONTRIBUTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename site/contributing.md => CONTRIBUTING.md (100%) diff --git a/site/contributing.md b/CONTRIBUTING.md similarity index 100% rename from site/contributing.md rename to CONTRIBUTING.md From 6d5b6cf39fd8dfc865ff3af4ffcb8101c1a642e2 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 10:58:17 -0800 Subject: [PATCH 07/11] Split history site/contributing.md to CONTRIBUTING.md --- site/contributing.md => temp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename site/contributing.md => temp (100%) diff --git a/site/contributing.md b/temp similarity index 100% rename from site/contributing.md rename to temp From 6572768f73f4c3b9b9662e608bcdef7e00d10064 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 10:58:17 -0800 Subject: [PATCH 08/11] Split history site/contributing.md to CONTRIBUTING.md --- temp => site/contributing.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename temp => site/contributing.md (100%) diff --git a/temp b/site/contributing.md similarity index 100% rename from temp rename to site/contributing.md From 05b892a4208f7b0d3c6a4c28cafc3a9610fbbe4b Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 11:00:22 -0800 Subject: [PATCH 09/11] MAINT: {include} contributing content in site. --- site/contributing.md | 117 +------------------------------------------ 1 file changed, 1 insertion(+), 116 deletions(-) diff --git a/site/contributing.md b/site/contributing.md index 13ed7d44..78caf34e 100644 --- a/site/contributing.md +++ b/site/contributing.md @@ -1,117 +1,2 @@ -# Contributing - -We very much welcome contributions! If you have an idea or proposal for a new -tutorial, please [open an issue](https://github.com/numpy/numpy-tutorials/issues) -with an outline. - -Don’t worry if English is not your first language, or if you can only come up -with a rough draft. Open source is a community effort. Do your best – we’ll help -fix issues. - -Images and real-life data make text more engaging and powerful, but be sure what -you use is appropriately licensed and available. Here again, even a rough idea -for artwork can be polished by others. - -## Building the website - -```{note} -The NumPy tutorials are powered by [`jupyter-book`][jb-docs] and the -[`MyST` document engine][mystmd]. -See the linked documentation for further details. +```{include} ../CONTRIBUTING.md ``` - -[jb-docs]: https://jupyterbook.org/stable/ -[mystmd]: https://mystmd.org/ - -### Quickstart - -Set up a development environment with the dependencies listed in -`requirements.txt` and `site/requirements.txt`. -For example, using the built-in [`venv`][venv] module: - -```bash -python -m venv np-tutorials -source np-tutorials/bin/activate -python -m pip install -r requirements.txt -r site/requirements.txt -``` - -[venv]: https://docs.python.org/3/library/venv.html - -The site can then be built with: - -```bash -jupyter-book start --execute -``` - -This will execute all the notebooks and start a web server to view the rendered -content locally. -View the rendered site by opening the ``localhost:30xy`` in your preferred browser (the exact port number will be printed in your terminal). - -## Adding your own tutorials - -If you have your own tutorial in the form of a Jupyter notebook (an `.ipynb` -file) and you'd like to try add it out to the repository, follow the steps below. - -### Create an issue - -Go to and create a new issue -with your proposal. -Give as much detail as you can about what kind of content you would like to -write (tutorial, how-to) and what you plan to cover. -We will try to respond as quickly as possible with comments, if applicable. - -### Check out our suggested template - -You can use this template to make your content consistent with our existing -tutorials. - -### Upload your content - -Remember to clear all outputs on your notebook before uploading it. - -
    -
    - - Fork this repository (if you haven't before). - - -
    - -
    - - In your own fork, create a new branch for your content. - - -
    - -
    - - Add your notebook to the content/ directory. - - -
    - -Update the environment.yml file with the dependencies for your tutorial -(only if you add new dependencies). - -
    - - Update this README.md to include your new entry. - - -
    - -
    - - Create a pull request. Make sure the "Allow edits and access to secrets by maintainers" option is selected so we can properly review your submission. - - -
    - -🎉 Wait for review! -
- -For more information about GitHub and its workflow, you can see -[this document][collab]. - -[collab]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests From 677b126e4816923ffc5f072b2b094976632f94e3 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 12:19:58 -0800 Subject: [PATCH 10/11] MAINT: Rm duplicated contributing info from README. --- README.md | 135 ------------------------------------------------------ 1 file changed, 135 deletions(-) diff --git a/README.md b/README.md index 0209e32b..5109e2c9 100644 --- a/README.md +++ b/README.md @@ -25,141 +25,6 @@ or navigate to any of the documents listed below and download it individually. 8. [Tutorial: Plotting Fractals](content/tutorial-plotting-fractals.ipynb) 9. [Tutorial: Analysing the impact of the lockdown on air quality in Delhi, India](content/tutorial-air-quality-analysis.md) - -## Contributing - -We very much welcome contributions! If you have an idea or proposal for a new -tutorial, please [open an issue](https://github.com/numpy/numpy-tutorials/issues) -with an outline. - -Don’t worry if English is not your first language, or if you can only come up -with a rough draft. Open source is a community effort. Do your best – we’ll help -fix issues. - -Images and real-life data make text more engaging and powerful, but be sure what -you use is appropriately licensed and available. Here again, even a rough idea -for artwork can be polished by others. - -### Building the website - -```{note} -The NumPy tutorials are powered by [`jupyter-book`][jb-docs] and the -[`MyST` document engine][mystmd]. -See the linked documentation for further details. -``` - -[jb-docs]: https://jupyterbook.org/stable/ -[mystmd]: https://mystmd.org/ - -#### Quickstart - -Set up a development environment with the dependencies listed in -`requirements.txt` and `site/requirements.txt`. -For example, using the built-in [`venv`][venv] module: - -```bash -python -m venv np-tutorials -source np-tutorials/bin/activate -python -m pip install -r requirements.txt -r site/requirements.txt -``` - -[venv]: https://docs.python.org/3/library/venv.html - -The site can then be built with: - -```bash -jupyter-book start --execute -``` - -This will execute all the notebooks and start a web server to view the rendered -content locally. -View the rendered site by opening the ``localhost:30xy`` in your preferred browser (the exact port number will be printed in your terminal). - -### Adding your own tutorials - -If you have your own tutorial in the form of a Jupyter notebook (a `.ipynb` -file) and you'd like to add it to the repository, follow the steps below. - - -#### Create an issue - -Go to [https://github.com/numpy/numpy-tutorials/issues](https://github.com/numpy/numpy-tutorials/issues) -and create a new issue with your proposal. Give as much detail as you can about -what kind of content you would like to write (tutorial, how-to) and what you -plan to cover. We will try to respond as quickly as possible with comments, if -applicable. - -#### Check out our suggested template - -You can use our [Tutorial Style Guide](content/tutorial-style-guide.md) to make -your content consistent with our existing tutorials. - -#### Upload your content - -
    -
    - - Fork this repository (if you haven't before). - - -
    - -
    - - In your own fork, create a new branch for your content. - - -
    - -
    - - Add your notebook to the content/ directory. - - -
    - -Update the environment.yml file with the dependencies for your -tutorial (only if you add new dependencies). - -
    - - Update this README.md to include your new entry. - - -
    - -Update the attribution section (below) to credit the original tutorial -author, if applicable. - -
    - - Create a pull request. - Make sure the "Allow edits and access to secrets by maintainers" option - is selected so we can properly review your submission. - - -
    - -:tada: Wait for review! -
- -For more information about GitHub and its workflow, you can see -[this document](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests). - - -### Building the Sphinx site locally - -Building the tutorials website, which is published at -https://github.com/numpy/numpy-tutorials, locally isn't necessary before making -a contribution, but may be helpful: - -```bash -conda env create -f environment.yml -conda activate numpy-tutorials -cd site -make html -``` - ## Translations While we don't have the capacity to translate and maintain translated versions From 20a4f7904e8d84d0a24924d7759ce1a6644b42b9 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 25 Nov 2025 12:47:43 -0800 Subject: [PATCH 11/11] MAINT: Rm old version pins from mpl links. --- content/mooreslaw-tutorial.md | 14 +++++++------- content/tutorial-plotting-fractals.md | 2 +- content/tutorial-static_equilibrium.md | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/content/mooreslaw-tutorial.md b/content/mooreslaw-tutorial.md index 9fc216d2..638853c4 100644 --- a/content/mooreslaw-tutorial.md +++ b/content/mooreslaw-tutorial.md @@ -60,8 +60,8 @@ You'll use these NumPy and Matplotlib functions: * [`np.log`](https://numpy.org/doc/stable/reference/generated/numpy.log.html): this function takes the natural log of all elements in a NumPy array * [`np.exp`](https://numpy.org/doc/stable/reference/generated/numpy.exp.html): this function takes the exponential of all elements in a NumPy array * [`lambda`](https://docs.python.org/3/library/ast.html?highlight=lambda#ast.Lambda): this is a minimal function definition for creating a function model -* [`plt.semilogy`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.semilogy.html): this function will plot x-y data onto a figure with a linear x-axis and $\log_{10}$ y-axis -[`plt.plot`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html): this function will plot x-y data on linear axes +* [`plt.semilogy`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.semilogy.html): this function will plot x-y data onto a figure with a linear x-axis and $\log_{10}$ y-axis +[`plt.plot`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html): this function will plot x-y data on linear axes * slicing arrays: view parts of the data loaded into the workspace, slice the arrays e.g. `x[:10]` for the first 10 values in the array, `x` * boolean array indexing: to view parts of the data that match a given condition use boolean operations to index an array * [`np.block`](https://numpy.org/doc/stable/reference/generated/numpy.block.html): to combine arrays into 2D arrays @@ -259,7 +259,7 @@ year. Now compare your model to the actual manufacturing reports. Plot the linear regression results and all of the transistor counts. Here, use -[`plt.semilogy`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.semilogy.html) +[`plt.semilogy`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.semilogy.html) to plot the number of transistors on a log-scale and the year on a linear scale. You have defined a three arrays to get to a final model @@ -280,11 +280,11 @@ $\text{transistor_count}_{\text{predicted}} = e^Be^{A\cdot \text{year}}$. +++ In the next plot, use the -[`fivethirtyeight`](https://matplotlib.org/3.1.1/gallery/style_sheets/fivethirtyeight.html) +[`fivethirtyeight`](https://matplotlib.org/gallery/style_sheets/fivethirtyeight.html) style sheet. The style sheet replicates elements. Change the matplotlib style with -[`plt.style.use`](https://matplotlib.org/3.3.2/api/style_api.html#matplotlib.style.use). +[`plt.style.use`](https://matplotlib.org/api/style_api.html#matplotlib.style.use). ```{code-cell} transistor_count_predicted = np.exp(B) * np.exp(A * year) @@ -329,9 +329,9 @@ $\text{transistor_count} = e^{B}e^{A\cdot \text{year}}$. A great way to compare these measurements is to compare your prediction and Moore's prediction to the average transistor count and look at the range of reported values for that year. Use the -[`plt.plot`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html) +[`plt.plot`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html) option, -[`alpha=0.2`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.artist.Artist.set_alpha.html), +[`alpha=0.2`](https://matplotlib.org/api/_as_gen/matplotlib.artist.Artist.set_alpha.html), to increase the transparency of the data. The more opaque the points appear, the more reported values lie on that measurement. The green $+$ is the average reported transistor count for 2017. Plot your predictions diff --git a/content/tutorial-plotting-fractals.md b/content/tutorial-plotting-fractals.md index a1921cea..beb64e6d 100644 --- a/content/tutorial-plotting-fractals.md +++ b/content/tutorial-plotting-fractals.md @@ -110,7 +110,7 @@ mesh = x + (1j * y) # Make mesh of complex plane Now we will apply our function to each value contained in the mesh. Since we used a universal function in our design, this means that we can pass in the entire mesh all at once. This is extremely convenient for two reasons: It reduces the amount of code needed to be written and greatly increases the efficiency (as universal functions make use of system level C programming in their computations). -Here we plot the absolute value (or modulus) of each element in the mesh after one “iteration” of the function using a [**3D scatterplot**](https://matplotlib.org/2.0.2/mpl_toolkits/mplot3d/tutorial.html#scatter-plots): +Here we plot the absolute value (or modulus) of each element in the mesh after one “iteration” of the function using a [**3D scatterplot**](https://matplotlib.org/stable/users/explain/toolkits/mplot3d.html#scatter-plots): ```{code-cell} ipython3 output = np.abs(f(mesh)) # Take the absolute value of the output (for plotting) diff --git a/content/tutorial-static_equilibrium.md b/content/tutorial-static_equilibrium.md index 2d1a4d3e..29164be9 100644 --- a/content/tutorial-static_equilibrium.md +++ b/content/tutorial-static_equilibrium.md @@ -78,7 +78,7 @@ This defines `forceA` as being a vector with magnitude of 1 in the $x$ direction It may be helpful to visualize these forces in order to better understand how they interact with each other. Matplotlib is a library with visualization tools that can be utilized for this purpose. -Quiver plots will be used to demonstrate [three dimensional vectors](https://matplotlib.org/3.3.4/gallery/mplot3d/quiver3d.html), but the library can also be used for [two dimensional demonstrations](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.quiver.html). +Quiver plots will be used to demonstrate [three dimensional vectors](https://matplotlib.org/gallery/mplot3d/quiver3d.html), but the library can also be used for [two dimensional demonstrations](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.quiver.html). ```{code-cell} fig = plt.figure()