{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Context manager that resets warning registry for catching warnings"
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "record",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Specifies whether warnings should be captured by a custom implementation of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "warnings.showwarning()"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and be appended to a list returned by the context manager. Otherwise None is returned by the context manager. The objects appended to the list are arguments whose attributes mirror the arguments to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "showwarning()"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "modules",
              "annotation": "sequence, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sequence of modules for which to reset warnings registry on entry and restore on exit. To work correctly, all 'ignore' filters should filter by one of these modules."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Warnings can be slippery, because, whenever a warning is triggered, Python adds a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "__warningregistry__"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " member to the "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "calling"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " module.  This makes it impossible to retrigger the warning in this module, whatever you put in the warnings filters.  This context manager accepts a sequence of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "modules"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as a keyword argument to its constructor and:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "stores and removes any "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "__warningregistry__"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " entries in given "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "modules"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "   on entry;"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "resets "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "__warningregistry__"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to its previous state on exit."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This makes it possible to trigger any warning afresh inside the context manager without disturbing the state of warnings outside."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For compatibility with Python, please consider all arguments to be keyword-only."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "build-install/usr/lib/python3.14/site-packages/numpy/testing/_private/utils.py",
  "item_line": 2214,
  "item_type": "class",
  "aliases": [
    "numpy.testing.clear_and_catch_warnings"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import warnings\nwith np.testing.clear_and_catch_warnings(\n        modules=[np._core.fromnumeric]):\n    warnings.simplefilter('always')\n    warnings.filterwarnings('ignore', module='np._core.fromnumeric')\n    # do something that raises a warning but ignore those in\n    # np._core.fromnumeric\n",
        "execution_status": "none"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "record",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "modules",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "()"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "clear_and_catch_warnings"
  },
  "references": null,
  "qa": "numpy.testing._private.utils:clear_and_catch_warnings",
  "arbitrary": [],
  "local_refs": [
    "modules",
    "record"
  ]
}