| 4557 | |
| 4558 | |
| 4559 | def test_setitem_errs(): |
| 4560 | x = da.ones((4, 4), chunks=(2, 2)) |
| 4561 | |
| 4562 | with pytest.raises(ValueError): |
| 4563 | x[x > 1] = x |
| 4564 | |
| 4565 | # Shape mismatch |
| 4566 | with pytest.raises(ValueError): |
| 4567 | x[[True, True, False, False], 0] = [2, 3, 4] |
| 4568 | |
| 4569 | with pytest.raises(ValueError): |
| 4570 | x[[True, True, True, False], 0] = [2, 3] |
| 4571 | |
| 4572 | with pytest.raises(ValueError): |
| 4573 | x[0, [True, True, True, False]] = [2, 3] |
| 4574 | |
| 4575 | with pytest.raises(ValueError): |
| 4576 | x[0, [True, True, True, False]] = [1, 2, 3, 4, 5] |
| 4577 | |
| 4578 | with pytest.raises(ValueError): |
| 4579 | x[da.from_array([True, True, True, False]), 0] = [1, 2, 3, 4, 5] |
| 4580 | |
| 4581 | with pytest.raises(ValueError): |
| 4582 | x[0, da.from_array([True, False, False, True])] = [1, 2, 3, 4, 5] |
| 4583 | |
| 4584 | with pytest.raises(ValueError): |
| 4585 | x[:, 0] = [2, 3, 4] |
| 4586 | |
| 4587 | with pytest.raises(ValueError): |
| 4588 | x[0, :] = [1, 2, 3, 4, 5] |
| 4589 | |
| 4590 | x = da.ones((4, 4), chunks=(2, 2)) |
| 4591 | |
| 4592 | # Too many indices |
| 4593 | with pytest.raises(IndexError): |
| 4594 | x[:, :, :] = 2 |
| 4595 | |
| 4596 | # 2-d boolean indexing a single dimension |
| 4597 | with pytest.raises(IndexError): |
| 4598 | x[[[True, True, False, False]], 0] = 5 |
| 4599 | |
| 4600 | # 2-d indexing a single dimension |
| 4601 | with pytest.raises(IndexError): |
| 4602 | x[[[1, 2, 3]], 0] = 5 |
| 4603 | |
| 4604 | # Multiple 1-d boolean/integer arrays |
| 4605 | with pytest.raises(NotImplementedError): |
| 4606 | x[[1, 2], [2, 3]] = 6 |
| 4607 | |
| 4608 | with pytest.raises(NotImplementedError): |
| 4609 | x[[True, True, False, False], [2, 3]] = 5 |
| 4610 | |
| 4611 | with pytest.raises(NotImplementedError): |
| 4612 | x[[True, True, False, False], [False, True, False, False]] = 7 |
| 4613 | |
| 4614 | # scalar boolean indexing |
| 4615 | with pytest.raises(NotImplementedError): |
| 4616 | x[True] = 5 |