{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:arrays.classes",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Subclassing a "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "numpy.ndarray"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is possible but if your goal is to create an array with "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "modified"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " behavior, as do dask arrays for distributed computation and cupy arrays for GPU-based computation, subclassing is discouraged. Instead, using numpy's "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "dispatch mechanism",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "user:basics.dispatch"
                  },
                  "kind": "exists"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is recommended."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "ndarray",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can be inherited from (in Python or in C) if desired. Therefore, it can form a foundation for many useful classes. Often whether to sub-class the array object or to simply use the core array component as an internal part of a new class is a difficult decision, and can be simply a matter of choice. NumPy has several tools for simplifying how your new object interacts with other array objects, and so the choice may not be significant in the end. One way to simplify the question is by asking yourself if the object you are interested in can be replaced as a single array or does it really require two or more arrays at its core."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "asarray",
              "domain": null,
              "role": "func",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " always returns the base-class ndarray. If you are confident that your use of the array object can handle any subclass of an ndarray, then "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "asanyarray",
              "domain": null,
              "role": "func",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can be used to allow subclasses to propagate more cleanly through your subroutine. In principle, a subclass could redefine any aspect of the array and therefore, under strict guidelines, "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "asanyarray",
              "domain": null,
              "role": "func",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " would rarely be useful. However, most subclasses of the array object will not redefine certain aspects of the array object such as the buffer interface, or the attributes of the array. One important example, however, of why your subroutine may not be able to handle an arbitrary subclass of an array is that matrices redefine the \"*\" operator to be matrix-multiplication, rather than element-by-element multiplication."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Standard array subclasses"
        }
      ],
      "level": 0,
      "target": "arrays.classes"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso :ref:`Subclassing ndarray <basics.subclassing>`"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "NumPy provides several hooks that classes can customize:"
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Special attributes and methods"
        }
      ],
      "level": 1,
      "target": "special-attributes-and-methods"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "It is strongly advised "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "not"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " to use the matrix subclass.  As described below, it makes writing functions that deal consistently with matrices and regular arrays very difficult. Currently, they are mainly used for interacting with "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "scipy.sparse"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". We hope to provide an alternative for this use, however, and eventually remove the "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "matrix"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " subclass."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "matrix",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " objects inherit from the ndarray and therefore, they have the same attributes and methods of ndarrays. There are six important differences of matrix objects, however, that may lead to unexpected results when you use matrices but expect them to act like arrays:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix objects can be created using a string notation to allow    Matlab-style syntax where spaces separate columns and semicolons    (';') separate rows."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix objects are always two-dimensional. This has far-reaching    implications, in that m.ravel() is still two-dimensional (with a 1    in the first dimension) and item selection returns two-dimensional    objects so that sequence behavior is fundamentally different than    arrays."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix objects over-ride multiplication to be    matrix-multiplication. "
                    },
                    {
                      "__type": "Strong",
                      "__tag": 4048,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Make sure you understand this for\n   functions that you may want to receive matrices. Especially in\n   light of the fact that asanyarray(m) returns a matrix when m is\n   a matrix."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix objects over-ride power to be matrix raised to a power. The    same warning about using power inside a function that uses    asanyarray(...) to get an array object holds for this fact."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The default __array_priority\\__ of matrix objects is 10.0, and    therefore mixed operations with ndarrays always produce matrices."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrices have special attributes which make calculations easier.    These are"
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ".. autosummary:: \n    :toctree:generated/\n    matrix.T\n       matrix.H\n       matrix.I\n       matrix.A",
                  "execution_status": null
                }
              ]
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "warning",
          "base_type": "warning",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "warning "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Matrix objects over-ride multiplication, '"
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "', and power, '*"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "', to be matrix-multiplication and matrix power, respectively. If your subroutine can accept sub-classes and you do not convert to base- class arrays, then you must use the ufuncs multiply and power to be sure that you are performing the correct operation for all inputs."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The matrix class is a Python subclass of the ndarray and can be used as a reference for how to construct your own subclass of the ndarray. Matrices can be created from other matrices, strings, and anything else that can be converted to an "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " . The name \"mat \"is an alias for \"matrix \"in NumPy."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    matrix\n    asmatrix\n    bmat",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Example 1: Matrix creation from a string"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Example 2: Matrix creation from a nested sequence"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Example 3: Matrix creation from an array"
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Matrix objects"
        }
      ],
      "level": 1,
      "target": "matrix-objects"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Memory-mapped files are useful for reading and/or modifying small segments of a large file with regular layout, without reading the entire file into memory. A simple subclass of the ndarray uses a memory-mapped file for the data buffer of the array. For small files, the over-head of reading the entire file into memory is typically not significant, however for large files using memory mapping can save considerable resources."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Memory-mapped-file arrays have one additional method (besides those they inherit from the ndarray): "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": ".flush() <memmap.flush>",
              "domain": null,
              "role": "meth",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " which must be called manually by the user to ensure that any changes to the array actually get written to disk."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    memmap\n    memmap.flush",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Example:"
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Memory-mapped file arrays"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso :ref:`routines.array-creation.char`"
                }
              ]
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "chararray",
                  "reference": {
                    "__type": "RefInfo",
                    "__tag": 4000,
                    "module": "numpy",
                    "version": "*",
                    "kind": "api",
                    "path": "numpy.char:chararray"
                  },
                  "kind": "module"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " class exists for backwards compatibility with Numarray, it is not recommended for new development. Starting from numpy 1.4, if one needs arrays of strings, it is recommended to use arrays of "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dtype",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "object_",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ", "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "bytes_",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " or "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "str_",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ", and use the free functions in the "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "numpy.char",
                  "reference": {
                    "__type": "RefInfo",
                    "__tag": 4000,
                    "module": "numpy",
                    "version": "*",
                    "kind": "api",
                    "path": "numpy.char"
                  },
                  "kind": "module"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " module for fast vectorized string operations."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "These are enhanced arrays of either "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "str_",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " type or "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "bytes_",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " type.  These arrays inherit from the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "ndarray",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but specially-define the operations "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "+"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "*"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "%"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on a (broadcasting) element-by-element basis.  These operations are not available on the standard "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "ndarray",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of character type. In addition, the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "chararray",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.char:chararray"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has all of the standard "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "str",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (and "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "bytes",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") methods, executing them on an element-by-element basis. Perhaps the easiest way to create a chararray is to use "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "self.view(chararray) <ndarray.view>",
              "domain": null,
              "role": "meth",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " where "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "self"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is an ndarray of str or unicode data-type. However, a chararray can also be created using the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "chararray",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.char:chararray"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " constructor, or via the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.char.array",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.char:array"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " function:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    char.chararray\n    char.array",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Another difference with the standard ndarray of str data-type is that the chararray inherits the feature introduced by Numarray that white-space at the end of any element in the array will be ignored on item retrieval and comparison operations."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Character arrays ("
        },
        {
          "__type": "InlineRole",
          "__tag": 4003,
          "value": "numpy.char",
          "domain": null,
          "role": "mod",
          "inventory": null
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": ")"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso :ref:`routines.array-creation.rec`, :ref:`routines.dtype`,"
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "arrays.dtypes",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "reference:arrays.dtypes"
                  },
                  "kind": "exists"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "NumPy provides the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "recarray",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " class which allows accessing the fields of a structured array as attributes, and a corresponding scalar data type object "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "record",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    recarray\n    record",
          "execution_status": null
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The pandas DataFrame is more powerful than record array. If possible, please use pandas DataFrame instead."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Record arrays"
        }
      ],
      "level": 1,
      "target": "arrays.classes.rec"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso :ref:`maskedarray`"
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Masked arrays ("
        },
        {
          "__type": "InlineRole",
          "__tag": 4003,
          "value": "numpy.ma",
          "domain": null,
          "role": "mod",
          "inventory": null
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": ")"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For backward compatibility and as a standard \"container \"class, the UserArray from Numeric has been brought over to NumPy and named "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.lib.user_array.container",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.lib.user_array:container"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " The container class is a Python class whose self.array attribute is an ndarray. Multiple inheritance is probably easier with numpy.lib.user_array.container than with the ndarray itself and so it is included by default. It is not documented here beyond mentioning its existence because you are encouraged to use the ndarray class directly if you can."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    numpy.lib.user_array.container",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Standard container class"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Iterators are a powerful concept for array processing. Essentially, iterators implement a generalized for-loop. If "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "myiter"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is an iterator object, then the Python code      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "for val in myiter:\n    ...\n    some code involving val\n    ...",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "calls "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "val = next(myiter)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " repeatedly until "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "StopIteration",
              "domain": null,
              "role": "exc",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is raised by the iterator. There are several ways to iterate over an array that may be useful: default iteration, flat iteration, and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-dimensional enumeration."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Array iterators"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The default iterator of an ndarray object is the default Python iterator of a sequence type. Thus, when the array object itself is used as an iterator. The default behavior is equivalent to      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "for i in range(arr.shape[0]):\n    val = arr[i]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This default iterator selects a sub-array of dimension "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N-1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " from the array. This can be a useful construct for defining recursive algorithms. To loop over the entire array requires "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for-loops."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Default iteration"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ndarray.flat",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As mentioned previously, the flat attribute of ndarray objects returns an iterator that will cycle over the entire array in C-style contiguous order."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here, I've used the built-in enumerate iterator to return the iterator index as well as the value."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Flat iteration"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ndenumerate",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Sometimes it may be useful to get the N-dimensional index while iterating. The ndenumerate iterator can achieve this."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "N-dimensional enumeration"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    broadcast",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The general concept of broadcasting is also available from Python using the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "broadcast",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " iterator. This object takes "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " objects as inputs and returns an iterator that returns tuples providing each of the input sequence elements in the broadcasted result."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Iterator for broadcasting"
        }
      ],
      "level": 2,
      "target": null
    }
  ],
  "local_refs": []
}