{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "isin",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "isin"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is an element-wise function version of the python keyword "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "in",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "isin(a, b)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is roughly equivalent to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.array([item in b for item in a])"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " if "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "a",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "b",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are 1-D sequences."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "element"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "test_elements"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are converted to arrays if they are not already. If "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "test_elements"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is a set (or other non-sequence collection) it will be converted to an object array with one element, rather than an array of the values contained in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "test_elements"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This is a consequence of the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "array",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "array",
                "version": "*",
                "kind": "api",
                "path": "array"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " constructor's way of handling non-sequence collections. Converting the set to a list usually gives the desired behavior."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "kind='table'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " tends to be faster than "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "kind='sort'",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " if the following relationship is true: "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "log10(len(test_elements)) > (log10(max(test_elements)-min(test_elements)) - 2.27) / 0.927"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but may use greater memory. The default value for "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "kind"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will be automatically selected based only on memory usage, so one may manually set "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "kind='table'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " if memory constraints can be relaxed."
            }
          ]
        }
      ],
      "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": "isin",
              "annotation": "ndarray, bool",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Has the same shape as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "element"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". The values "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "element[isin]",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "test_elements"
                    },
                    {
                      "__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": "Calculates "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "element in test_elements"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", broadcasting over "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "element"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " only. Returns a boolean array of the same shape as "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "element"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " that is True where an element of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "element"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "test_elements"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and False otherwise."
            }
          ]
        }
      ],
      "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": "element",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Input array."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "test_elements",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The values against which to test each value of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "element"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". This argument is flattened if it is an array or array_like. See notes for behavior with non-array-like parameters."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "assume_unique",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If True, the input arrays are both assumed to be unique, which can speed up the calculation.  Default is False."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "invert",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If True, the values in the returned array are inverted, as if calculating "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "element not in test_elements",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Default is False. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.isin(a, b, invert=True)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is equivalent to (but faster than) "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.invert(np.isin(a, b))"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "kind",
              "annotation": "{None, 'sort', 'table'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The algorithm to use. This will not affect the final result, but will affect the speed and memory use. The default, None, will select automatically based on memory considerations."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If 'sort', will use a mergesort-based approach. This will have   a memory usage of roughly 6 times the sum of the sizes of   "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "element"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " and "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "test_elements"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ", not accounting for size of dtypes."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If 'table', will use a lookup table approach similar   to a counting sort. This is only available for boolean and   integer arrays. This will have a memory usage of the   size of "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "element"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " plus the max-min value of "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "test_elements"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ".   "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "assume_unique"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " has no effect when the 'table' option is used."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If None, will automatically choose 'table' if   the required memory allocation is less than or equal to   6 times the sum of the sizes of "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "element"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " and "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "test_elements"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ",   otherwise will use 'sort'. This is done to not use   a large amount of memory by default, even though   'table' may be faster in most cases. If 'table' is chosen,   "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "assume_unique"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " will have no effect."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "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": "/numpy/lib/_arraysetops_impl.py",
  "item_line": 958,
  "item_type": "_ArrayFunctionDispatcher",
  "aliases": [
    "numpy.isin"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nelement = 2*np.arange(4).reshape((2, 2))\nelement\ntest_elements = [1, 2, 4, 8]\nmask = np.isin(element, test_elements)\nmask\nelement[mask]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe indices of the matched values can be obtained with `nonzero`:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.nonzero(mask)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe test can also be inverted:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "mask = np.isin(element, test_elements, invert=True)\nmask\nelement[mask]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBecause of how `array` handles sets, the following does not\nwork as expected:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "test_set = {1, 2, 4, 8}\nnp.isin(element, test_set)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCasting the set to a list gives the expected result:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.isin(element, list(test_set))\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "element",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "test_elements",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "assume_unique",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "invert",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "kind",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "isin"
  },
  "references": null,
  "qa": "numpy:isin",
  "arbitrary": [],
  "local_refs": [
    "assume_unique",
    "element",
    "invert",
    "isin",
    "kind",
    "test_elements"
  ]
}