{ "cells": [ { "cell_type": "markdown", "metadata": { "nbgrader": { "grade": false, "locked": false, "schema_version": 1, "solution": false } }, "source": [ "
RuntimeWarning
when you run the above cell, saying that an \"invalid value\" was encountered. Sometimes, it is possible for NaNs to appear in an array without your knowledge: for example, if you multiply infinity (np.inf
) by zero. So, NumPy is warning us that it has encountered NaNs (the \"invalid value\") in case we weren't aware. We knew there were NaNs because we put them there, so in this scenario we can safely ignore the warning. However, if you encounter a warning like this in the future and you weren't expecting it, make sure you investigate the source of the warning!\n",
"threshold
, which takes an array and returns a new array with values thresholded by the mean of the array.\n",
"raise
keyword. For example, to raise a ValueError
, you would do raise ValueError(message)
, where message
is a string explaining specifically what the error was.