{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:routines.err",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Error handling settings are stored in "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "python:contextvars",
              "domain": "py",
              "role": "mod",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " allowing different threads or async tasks to have independent configurations. For more information, see "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "thread_safety",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "reference:thread_safety"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Floating point error handling"
        }
      ],
      "level": 0,
      "target": "fp_error_handling"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The default is to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "'warn'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "invalid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "divide"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "overflow"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "'ignore'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "underflow"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ".  But this can be changed, and it can be set individually for different kinds of exceptions. The different behaviors are:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'ignore'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Take no action when the exception occurs."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'warn'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Print a "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "RuntimeWarning",
                      "domain": "py",
                      "role": "exc",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (via the Python "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "warnings",
                      "domain": "py",
                      "role": "mod",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " module)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'raise'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Raise a "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "FloatingPointError",
                      "domain": "py",
                      "role": "exc",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'call'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Call a specified function."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'print'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Print a warning directly to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "stdout"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'log'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Record error in a Log object."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "These behaviors can be set for all kinds of errors or specific ones:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "all"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "apply to all numeric exceptions"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "invalid"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "when NaNs are generated"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "divide"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "divide by zero (for integers as well!)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "overflow"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "floating point overflows"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "underflow"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "floating point underflows"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that integer divide-by-zero is handled by the same machinery."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The error handling mode can be configured "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.errstate",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:errstate"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " context manager."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "How numpy handles numerical exceptions"
        }
      ],
      "level": 1,
      "target": "misc-error-handling"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> with np.errstate(all='warn'):\n...     np.zeros(5, dtype=np.float32) / 0.0\n<python-input-1>:2: RuntimeWarning: invalid value encountered in divide\narray([nan, nan, nan, nan, nan], dtype=float32)",
          "execution_status": null
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> with np.errstate(under='ignore'):\n...     np.array([1.e-100])**10\narray([0.])",
          "execution_status": null
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> with np.errstate(invalid='raise'):\n...     np.sqrt(np.array([-1.]))\n...\nTraceback (most recent call last):\n  File \"<python-input-1>\", line 2, in <module>\n    np.sqrt(np.array([-1.]))\n    ~~~~~~~^^^^^^^^^^^^^^^^^\nFloatingPointError: invalid value encountered in sqrt",
          "execution_status": null
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> def errorhandler(errstr, errflag):\n...     print(\"saw stupid error!\")\n>>> with np.errstate(call=errorhandler, all='call'):\n...     np.zeros(5, dtype=np.int32) / 0\nsaw stupid error!\narray([nan, nan, nan, nan, nan])",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Examples"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    seterr\n    geterr\n    seterrcall\n    geterrcall\n    errstate",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Setting and getting error handling"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}