{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Repeated diagonal offsets are disallowed."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The result from "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "diags_array"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the sparse equivalent of      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "np.diag(diagonals[0], offsets[0])\n+ ...\n+ np.diag(diagonals[k], offsets[k])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "diags_array"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " differs from "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "dia_array",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse._dia:dia_array"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " in the way it handles off-diagonals. Specifically, "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "dia_array",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.sparse._dia:dia_array"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " assumes the data input includes padding (ignored values) at the start/end of the rows for positive/negative offset, while "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "diags_array"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " assumes the input data has no padding. Each value in the input "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "diagonals"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is used."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 1.11"
                }
              ]
            }
          ]
        }
      ],
      "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": "new_array",
              "annotation": "dia_array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "dia_array",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.sparse._dia:dia_array"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " holding the values in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "diagonals"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " offset from the main diagonal as indicated in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "offsets"
                    },
                    {
                      "__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": "Construct a sparse array from diagonals."
            }
          ]
        }
      ],
      "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": "diagonals",
              "annotation": "sequence of array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sequence of arrays containing the array diagonals, corresponding to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "offsets"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "offsets",
              "annotation": "sequence of int or an int, optional",
              "desc": [
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "Diagonals to set (repeated offsets are not allowed):"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "BulletList",
                          "__tag": 4053,
                          "ordered": false,
                          "start": 1,
                          "children": [
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "k = 0  the main diagonal (default)"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "k > 0  the kth upper diagonal"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "k < 0  the kth lower diagonal"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "shape",
              "annotation": "tuple of int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Shape of the result. If omitted, a square array large enough to contain the diagonals is returned."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "format",
              "annotation": "{\"dia\", \"csr\", \"csc\", \"lil\", ...}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix format of the result. By default (format=None) an appropriate sparse array format is returned. This choice is subject to change."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "dtype",
              "annotation": "dtype, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Data type of the array.  If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "dtype"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is None, the output data type is determined by the data type of the input diagonals."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Up until SciPy 1.19, the default behavior will be to return an array with an inexact (floating point) data type.  In particular, integer input will be converted to double precision floating point.  This behavior is deprecated, and in SciPy 1.19, the default behavior will be changed to return an array with the same data type as the input diagonals.  To adopt this behavior before version 1.19, use "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "dtype=None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "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/sparse/_construct.py",
  "item_line": 273,
  "item_type": "function",
  "aliases": [
    "scipy.sparse.diags_array"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.sparse import diags_array\ndiagonals = [[1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 3.0], [1.0, 2.0]]\ndiags_array(diagonals, offsets=[0, -1, 2]).toarray()\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBroadcasting of scalars is supported (but shape needs to be\nspecified):\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "diags_array([1.0, -2.0, 1.0], offsets=[-1, 0, 1], shape=(4, 4)).toarray()\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIf only one diagonal is wanted (as in `numpy.diag`), the following\nworks as well:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "diags_array([1.0, 2.0, 3.0], offsets=1).toarray()\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "dia_array",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.sparse._dia:dia_array"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "constructor for the sparse DIAgonal format."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "diagonals",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "offsets",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "shape",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "format",
        "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": "<object object at 0x0000>"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "diags_array"
  },
  "references": null,
  "qa": "scipy.sparse._construct:diags_array",
  "arbitrary": [],
  "local_refs": [
    "diagonals",
    "dtype",
    "format",
    "new_array",
    "offsets",
    "shape"
  ]
}