{
  "__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": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "results",
              "annotation": "list of lists",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "For each element "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "self.data[i]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " of this tree, "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "results[i]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a list of the indices of its neighbors in "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "other.data"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Find all pairs of points between "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "self"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "other"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " whose distance is at most r."
            }
          ]
        }
      ],
      "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": "other",
              "annotation": "KDTree instance",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The tree containing points to search against."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "r",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The maximum distance, has to be positive."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "p",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Which Minkowski norm to use.  "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "p"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " has to meet the condition "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "1 <= p <= infinity"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "eps",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Approximate search.  Branches of the tree are not explored if their nearest points are further than "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "r/(1+eps)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", and branches are added in bulk if their furthest points are nearer than "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "r * (1+eps)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ".  "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "eps"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " has to be non-negative."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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": "/scipy/spatial/_kdtree.py",
  "item_line": 563,
  "item_type": "function",
  "aliases": [
    "scipy.spatial.KDTree.query_ball_tree"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "You can search all pairs of points between two kd-trees within a distance:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.spatial import KDTree\nrng = np.random.default_rng()\npoints1 = rng.random((15, 2))\npoints2 = rng.random((15, 2))\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.figure(figsize=(6, 6))\nplt.plot(points1[:, 0], points1[:, 1], \"xk\", markersize=14)\nplt.plot(points2[:, 0], points2[:, 1], \"og\", markersize=14)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "kd_tree1 = KDTree(points1)\nkd_tree2 = KDTree(points2)\nindexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "for i in range(len(indexes)):\n    for j in indexes[i]:\n        plt.plot([points1[i, 0], points2[j, 0]],\n            [points1[i, 1], points2[j, 1]], \"-r\")\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-9b9827e4d90a2d7a.png"
        }
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "self",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "other",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "r",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "p",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "2.0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "eps",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0.0"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "query_ball_tree"
  },
  "references": null,
  "qa": "scipy.spatial._kdtree:KDTree.query_ball_tree",
  "arbitrary": [],
  "local_refs": [
    "eps",
    "other",
    "p",
    "r",
    "results"
  ]
}