Skip to content

Incorrect indexing with boolean arrays #11614

@stephenworsley

Description

@stephenworsley

Describe the issue:

For certain chunkings of dask arrays and certain boolean arrays, indexing these dask arrays by boolean arrays gives incorrects results. This appears to have been introduced in dask 2024.9.

Minimal Complete Verifiable Example:

>>> import dask.array
>>> import numpy as np
>>> x = np.arange(1980)
>>> dx = dask.array.from_array(x, chunks=[248])
>>> ib = np.zeros(1980, dtype=bool)
>>> ib[1560,1860] = True
>>> dx[ib].compute()
[1560 1816 1817 1561 1562 1818 1563 1819 1564 1820 1821 1565 1822 1566
 1823 1567 1824 1568 1825 1569 1826 1570 1827 1571 1572 1828 1573 1829
 1574 1830 1831 1575 1576 1832 1577 1833 1578 1834 1835 1579 1580 1836
 1581 1837 1838 1582 1583 1839 1584 1840 1585 1841 1842 1586 1587 1843
 1588 1844 1845 1589 1846 1590 1847 1591 1848 1592 1849 1593 1850 1594
 1595 1851 1852 1596 1597 1853 1854 1598 1855 1599 1600 1856 1857 1601
 1602 1858 1859 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613
 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627
 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655
 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683
 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697
 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711
 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739
 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753
 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767
 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781
 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
 1810 1811 1812 1813 1814 1815]
>>> x[ib]
[1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573
 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587
 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601
 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615
 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657
 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671
 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685
 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699
 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713
 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727
 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741
 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755
 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769
 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797
 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825
 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839
 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853
 1854 1855 1856 1857 1858 1859]

Anything else we need to know?:

Environment:

  • Dask version: 2024.9 onwards
  • Numpy version: 1.26.4
  • Python version: 3.11
  • Operating System: Linux
  • Install method (conda, pip, source): conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageNeeds a response from a contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions