Skip to content

BUG: mgrid result sensitive to data type #16466

@cortwave

Description

@cortwave

Using `np.mgrid' depends on slice dtype

Reproducing code example:

import numpy as np

a = np.mgrid[[slice(np.float32(0.1), np.float32(0.3), np.float32(0.1)) for _ in range(1)]]
# returns array([[0, 0, 0]])

b = np.mgrid[[slice(np.float64(0.1), np.float64(0.3), np.float64(0.1)) for _ in range(1)]]
# returns array([[0.1, 0.2]])

np.testing.assert_allclose(a, b)

Numpy/Python version information:

1.18.4 3.6.7 (default, Mar 27 2020, 15:56:09)
[GCC 6.5.0 20181026]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions