{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Arithmetic is modular when using integer types, and no error is raised on overflow."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cumulative_sum(a)[-1]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " may not be equal to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "sum(a)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for floating-point values since "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "sum"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " may use a pairwise summation routine, reducing the roundoff-error. See "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "sum",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "numpy:cumulative_sum"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for more information."
            }
          ]
        }
      ],
      "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": "cumulative_sum_along_axis",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A new array holding the result is returned unless "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "out"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is specified, in which case a reference to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "out"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is returned. The result has the same shape as "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "include_initial=False"
                    },
                    {
                      "__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": "Return the cumulative sum of the elements along a given axis."
            }
          ]
        }
      ],
      "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": "x",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Input array."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Axis along which the cumulative sum is computed. The default (None) is only allowed for one-dimensional arrays. For arrays with more than one dimension "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "axis"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is required."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "dtype",
              "annotation": "dtype, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Type of the returned array and of the accumulator in which the elements are summed.  If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "dtype"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is not specified, it defaults to the dtype of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", unless "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "out",
              "annotation": "ndarray, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "ufuncs-output-type",
                      "domain": null,
                      "role": "ref",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for more details."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "include_initial",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Boolean indicating whether to include the initial value (zeros) as the first value in the output. With "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "include_initial=True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " the shape of the output is different than the shape of the input. Default: "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "False"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function is an Array API compatible alternative to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.cumsum",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "numpy:cumsum"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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": "/dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/fromnumeric.py",
  "item_line": 2749,
  "item_type": "_ArrayFunctionDispatcher",
  "aliases": [
    "numpy.cumulative_sum"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a = np.array([1, 2, 3, 4, 5, 6])\na\nnp.cumulative_sum(a)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.cumulative_sum(a, dtype=float)  # specifies type of output value(s)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "b = np.array([[1, 2, 3], [4, 5, 6]])\nnp.cumulative_sum(b,axis=0)  # sum over rows for each of the 3 columns\nnp.cumulative_sum(b,axis=1)  # sum over columns for each of the 2 rows\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n``cumulative_sum(c)[-1]`` may not be equal to ``sum(c)``\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "c = np.array([1, 2e-9, 3e-9] * 1000000)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.cumulative_sum(c)[-1]\nc.sum()\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "diff",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "diff"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Calculate the n-th discrete difference along given axis."
            }
          ]
        }
      ],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "sum",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "numpy:cumulative_sum"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Sum array elements."
            }
          ]
        }
      ],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "trapezoid",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "trapezoid"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Integration of array values using composite trapezoidal rule."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "x",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "dtype",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "out",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "include_initial",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "cumulative_sum"
  },
  "references": null,
  "qa": "numpy:cumulative_sum",
  "arbitrary": [],
  "local_refs": [
    "axis",
    "cumulative_sum_along_axis",
    "dtype",
    "include_initial",
    "out",
    "x"
  ]
}