{
  "__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-verify-bug",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In this how-to you will learn how to:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Verify the existence of a bug in NumPy"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Verify the fix, if any, made for the bug"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "While you walk through the verification process, you will learn how to:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Set up a Python virtual environment (using "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "virtualenv"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ")"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Install appropriate versions of NumPy, first to see the bug in action, then to   verify its fix"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Issue 16354"
                }
              ],
              "url": "https://github.com/numpy/numpy/issues/16354",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is used as an example."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This issue was:"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Strong",
                  "__tag": 4048,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Title"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ": "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "np.polymul return type is np.float64 or np.complex128 when given\n    an all-zero argument"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "np.polymul returns an object with type np.float64 when one argument is all\n    zero, and both arguments have type np.int64 or np.float32. Something\n    similar happens with all zero np.complex64 giving result type\n    np.complex128."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "This doesn't happen with non-zero arguments; there the result is as\n    expected."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "This bug isn't present in np.convolve."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Strong",
                  "__tag": 4048,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Reproducing code example"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "          "
                }
              ]
            },
            {
              "__type": "Code",
              "__tag": 4050,
              "value": ">>> import numpy as np\n>>> np.__version__\n'1.18.4'\n>>> a = np.array([1,2,3])\n>>> z = np.array([0,0,0])\n>>> np.polymul(a.astype(np.int64), a.astype(np.int64)).dtype\ndtype('int64')\n>>> np.polymul(a.astype(np.int64), z.astype(np.int64)).dtype\ndtype('float64')\n>>> np.polymul(a.astype(np.float32), z.astype(np.float32)).dtype\ndtype('float64')\n>>> np.polymul(a.astype(np.complex64), z.astype(np.complex64)).dtype\ndtype('complex128')\nNumpy/Python version information:\n>>> import sys, numpy; print(numpy.__version__, sys.version)\n1.18.4 3.7.5 (default, Nov  7 2019, 10:50:52) [GCC 8.3.0]",
              "execution_status": null
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Verifying bugs and bug fixes in NumPy"
        }
      ],
      "level": 0,
      "target": "how-to-verify-bug"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Create a new directory, enter into it, and set up a virtual environment using your preferred method. For example, this is how to do it using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "virtualenv"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on linux or macOS:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "virtualenv venv_np_bug\nsource venv_np_bug/bin/activate",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This ensures the system/global/default Python/NumPy installation will not be altered."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "1. Set up a virtual environment"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The report references NumPy version 1.18.4, so that is the version you need to install in this case."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Since this bug is tied to a release and not a specific commit, a pre-built wheel installed in your virtual environment via "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pip"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will suffice      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "pip install numpy==1.18.4",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Some bugs may require you to build the NumPy version referenced in the issue report. To learn how to do that, visit "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "Building from source",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "building:index"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "2. Install the NumPy version in which the bug was reported"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The issue reported in "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "#16354"
                }
              ],
              "url": "https://github.com/numpy/numpy/issues/16354",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is that the wrong "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dtype"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is returned if one of the inputs of the method "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.polymul",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:polymul"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is a zero array."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To reproduce the bug, start a Python terminal, enter the code snippet shown in the bug report, and ensure that the results match those in the issue      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> import numpy as np\n>>> np.__version__\n'...' # 1.18.4\n>>> a = np.array([1,2,3])\n>>> z = np.array([0,0,0])\n>>> np.polymul(a.astype(np.int64), a.astype(np.int64)).dtype\ndtype('int64')\n>>> np.polymul(a.astype(np.int64), z.astype(np.int64)).dtype\ndtype('...') # float64\n>>> np.polymul(a.astype(np.float32), z.astype(np.float32)).dtype\ndtype('...') # float64\n>>> np.polymul(a.astype(np.complex64), z.astype(np.complex64)).dtype\ndtype('...') # complex128",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As reported, whenever the zero array, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "z"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " in the example above, is one of the arguments to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.polymul",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:polymul"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", an incorrect "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dtype"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is returned."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "3. Reproduce the bug"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If the issue report for your bug has not yet been resolved, further action or patches need to be submitted."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In this case, however, the issue was resolved by "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "PR 17577"
                }
              ],
              "url": "https://github.com/numpy/numpy/pull/17577",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and is now closed. So you can try to verify the fix."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To verify the fix:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Uninstall the version of NumPy in which the bug still exists      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": "pip uninstall numpy",
                  "execution_status": null
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Install the latest version of NumPy      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": "pip install numpy",
                  "execution_status": null
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "In your Python terminal, run the reported code snippet you used to verify the    existence of the bug and confirm that the issue has been resolved      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": ">>> import numpy as np\n>>> np.__version__\n'...' # 1.18.4\n>>> a = np.array([1,2,3])\n>>> z = np.array([0,0,0])\n>>> np.polymul(a.astype(np.int64), a.astype(np.int64)).dtype\ndtype('int64')\n>>> np.polymul(a.astype(np.int64), z.astype(np.int64)).dtype\ndtype('int64')\n>>> np.polymul(a.astype(np.float32), z.astype(np.float32)).dtype\ndtype('float32')\n>>> np.polymul(a.astype(np.complex64), z.astype(np.complex64)).dtype\ndtype('complex64')",
                  "execution_status": null
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that the correct "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dtype"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is now returned even when a zero array is one of the arguments to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.polymul",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:polymul"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "4. Check for fixes in the latest version of NumPy"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Go to the "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "NumPy GitHub issues page"
                }
              ],
              "url": "https://github.com/numpy/numpy/issues",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and see if you can confirm the existence of any other bugs which have not been confirmed yet. In particular, it is useful for the developers to know if a bug can be reproduced on a newer version of NumPy."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Comments verifying the existence of bugs alert the NumPy developers that more than one user can reproduce the issue."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "5. Support NumPy development by verifying and fixing bugs"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}