{
  "__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": "user:how-to-partition",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There are a few NumPy functions that are similar in application, but which provide slightly different results, which may cause confusion if one is not sure when and how to use them. The following guide aims to list these functions and describe their recommended usage."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The functions mentioned here are"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.linspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:linspace"
                      },
                      "kind": "module"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.arange",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:arange"
                      },
                      "kind": "module"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.geomspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:geomspace"
                      },
                      "kind": "module"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.logspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:logspace"
                      },
                      "kind": "module"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.meshgrid",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:meshgrid"
                      },
                      "kind": "module"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "numpy.mgrid",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "numpy.ogrid",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "How to create arrays with regularly-spaced values"
        }
      ],
      "level": 0,
      "target": "how-to-partition"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "1D domains (intervals)"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Both "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.linspace",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:linspace"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.arange",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:arange"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " provide ways to partition an interval (a 1D domain) into equal-length subintervals. These partitions will vary depending on the chosen starting and ending points, and the "
            },
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "step"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (the length  of the subintervals)."
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Strong",
                      "__tag": 4048,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Use"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.arange",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:arange"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " "
                    },
                    {
                      "__type": "Strong",
                      "__tag": 4048,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "if you want integer steps."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.arange",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:arange"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " relies on step size to determine how many elements are in the   returned array, which excludes the endpoint. This is determined through the   "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "step"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " argument to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "arange"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Example      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.arange(0, 10, 2)  # np.arange(start, stop, step)\narray([0, 2, 4, 6, 8])",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The arguments "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "start"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "stop"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " should be integer or real, but not   complex numbers. "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.arange",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:arange"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is similar to the Python built-in   "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "range",
                      "domain": "py",
                      "role": "class",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Floating-point inaccuracies can make "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "arange"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " results with floating-point   numbers confusing. In this case, you should use "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.linspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:linspace"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " instead."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Strong",
                      "__tag": 4048,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Use"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.linspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:linspace"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " "
                    },
                    {
                      "__type": "Strong",
                      "__tag": 4048,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "if you want the endpoint to be included in the\n  result, or if you are using a non-integer step size."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.linspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:linspace"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "can"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " include the endpoint and determines step size from the   "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "num",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " argument, which specifies the number of elements in the returned   array."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The inclusion of the endpoint is determined by an optional boolean   argument "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "endpoint"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", which defaults to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Note that selecting   "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "endpoint=False"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " will change the step size computation, and the subsequent   output for the function."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Example      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.linspace(0.1, 0.2, num=5)  # np.linspace(start, stop, num)\narray([0.1  , 0.125, 0.15 , 0.175, 0.2  ])\n>>> np.linspace(0.1, 0.2, num=5, endpoint=False)\narray([0.1, 0.12, 0.14, 0.16, 0.18])",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.linspace",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:linspace"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " can also be used with complex arguments      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.linspace(1+1.j, 4, 5, dtype=np.complex64)\narray([1.  +1.j  , 1.75+0.75j, 2.5 +0.5j , 3.25+0.25j, 4.  +0.j  ],\n      dtype=complex64)",
                  "execution_status": null
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "linspace"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " vs. "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "arange"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Unexpected results may happen if floating point values are used as "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "step"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "    in "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "numpy.arange"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". To avoid this, make sure all floating point conversion    happens after the computation of results. For example, replace"
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> list(np.arange(0.1,0.4,0.1).round(1))\n[0.1, 0.2, 0.3, 0.4]  # endpoint should not be included!",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "with"
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> list(np.arange(1, 4, 1) / 10.0)\n[0.1, 0.2, 0.3]  # expected result",
                  "execution_status": null
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Note that"
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.arange(0, 1.12, 0.04)\narray([0.  , 0.04, 0.08, 0.12, 0.16, 0.2 , 0.24, 0.28, 0.32, 0.36, 0.4 ,\n       0.44, 0.48, 0.52, 0.56, 0.6 , 0.64, 0.68, 0.72, 0.76, 0.8 , 0.84,\n       0.88, 0.92, 0.96, 1.  , 1.04, 1.08, 1.12])",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "and"
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.arange(0, 1.08, 0.04)\narray([0.  , 0.04, 0.08, 0.12, 0.16, 0.2 , 0.24, 0.28, 0.32, 0.36, 0.4 ,\n       0.44, 0.48, 0.52, 0.56, 0.6 , 0.64, 0.68, 0.72, 0.76, 0.8 , 0.84,\n       0.88, 0.92, 0.96, 1.  , 1.04])",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "These differ because of numeric noise. When using floating point values, it    is possible that "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "0 + 0.04 * 28 < 1.12"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", and so "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "1.12"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is in the    interval. In fact, this is exactly the case       "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> 1.12/0.04\n28.000000000000004",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "But "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "0 + 0.04 * 27 >= 1.08"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " so that 1.08 is excluded       "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> 1.08/0.04\n27.0",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Alternatively, you could use "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.arange(0, 28)*0.04"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " which would always    give you precise control of the end point since it is integral      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> np.arange(0, 28)*0.04\narray([0.  , 0.04, 0.08, 0.12, 0.16, 0.2 , 0.24, 0.28, 0.32, 0.36, 0.4 ,\n       0.44, 0.48, 0.52, 0.56, 0.6 , 0.64, 0.68, 0.72, 0.76, 0.8 , 0.84,\n       0.88, 0.92, 0.96, 1.  , 1.04, 1.08])",
                  "execution_status": null
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Other examples"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.geomspace"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is similar to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.linspace"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but with numbers spaced evenly on a log scale (a geometric progression). The endpoint is included in the result."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Example    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> np.geomspace(2, 3, num=5)\narray([2.        , 2.21336384, 2.44948974, 2.71080601, 3.        ])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.logspace"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is similar to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.geomspace"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but with the start and end points specified as logarithms (with base 10 as default)    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> np.logspace(2, 3, num=5)\narray([ 100.        ,  177.827941  ,  316.22776602,  562.34132519, 1000.        ])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In linear space, the sequence starts at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "base ** start"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " ("
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "base"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to the power of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "start"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") and ends with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "base ** stop"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> np.logspace(2, 3, num=5, base=2)\narray([4.        , 4.75682846, 5.65685425, 6.72717132, 8.        ])",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "geomspace"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " and "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "logspace"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "N-D domains can be partitioned into "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "grids"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This can be done using one of the following functions."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "N-D domains"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The purpose of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.meshgrid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is to create a rectangular grid out of a set of one-dimensional coordinate arrays."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Given arrays        "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> x = np.array([0, 1, 2, 3])\n>>> y = np.array([0, 1, 2, 3, 4, 5])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meshgrid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will create two coordinate arrays, which can be used to generate the coordinate pairs determining this grid.     "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> xx, yy = np.meshgrid(x, y)\n>>> xx\narray([[0, 1, 2, 3],\n       [0, 1, 2, 3],\n       [0, 1, 2, 3],\n       [0, 1, 2, 3],\n       [0, 1, 2, 3],\n       [0, 1, 2, 3]])\n>>> yy\narray([[0, 0, 0, 0],\n       [1, 1, 1, 1],\n       [2, 2, 2, 2],\n       [3, 3, 3, 3],\n       [4, 4, 4, 4],\n       [5, 5, 5, 5]])\n\n>>> import matplotlib.pyplot as plt\n>>> plt.plot(xx, yy, marker='.', color='k', linestyle='none')",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "meshgrid"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.mgrid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can be used as a shortcut for creating meshgrids. It is not a function, but when indexed, returns a multidimensional meshgrid."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> xx, yy = np.meshgrid(np.array([0, 1, 2, 3]), np.array([0, 1, 2, 3, 4, 5]))\n>>> xx.T, yy.T\n(array([[0, 0, 0, 0, 0, 0],\n        [1, 1, 1, 1, 1, 1],\n        [2, 2, 2, 2, 2, 2],\n        [3, 3, 3, 3, 3, 3]]),\n array([[0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5]]))\n\n>>> np.mgrid[0:4, 0:6]\narray([[[0, 0, 0, 0, 0, 0],\n        [1, 1, 1, 1, 1, 1],\n        [2, 2, 2, 2, 2, 2],\n        [3, 3, 3, 3, 3, 3]],\n<BLANKLINE>\n       [[0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5],\n        [0, 1, 2, 3, 4, 5]]])",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "mgrid"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similar to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.mgrid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.ogrid"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " returns an "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "open"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " multidimensional meshgrid. This means that when it is indexed, only one dimension of each returned array is greater than 1. This avoids repeating the data and thus saves memory, which is often desirable."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "These sparse coordinate grids are intended to be used with "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "broadcasting",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". When all coordinates are used in an expression, broadcasting still leads to a fully-dimensional result array."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> np.ogrid[0:4, 0:6]\n(array([[0],\n        [1],\n        [2],\n        [3]]), array([[0, 1, 2, 3, 4, 5]]))",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "All three methods described here can be used to evaluate function values on a grid."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> g = np.ogrid[0:4, 0:6]\n>>> zg = np.sqrt(g[0]**2 + g[1]**2)\n>>> g[0].shape, g[1].shape, zg.shape\n((4, 1), (1, 6), (4, 6))\n>>> m = np.mgrid[0:4, 0:6]\n>>> zm = np.sqrt(m[0]**2 + m[1]**2)\n>>> np.array_equal(zm, zg)\nTrue",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "ogrid"
        }
      ],
      "level": 2,
      "target": null
    }
  ],
  "local_refs": []
}