Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f955945
Enhance `dpnp_array.fill` method
ndgrigorian Sep 17, 2024
13edd84
Fix missing disclaimer in dpnp_arraycreation.py
ndgrigorian Sep 17, 2024
4976a24
Import `dpnp_array` directly
ndgrigorian Sep 17, 2024
978a081
Skip `test_fill_with_numpy_scalar_ndarray`
ndgrigorian Sep 17, 2024
2686af9
Add dependencies to zeros and full kernels in `dpnp_fill`
ndgrigorian Sep 18, 2024
2a826b2
Remove redundant validation of first `dpnp_fill` argument
ndgrigorian Sep 18, 2024
6e2193b
Improve `dpnp_fill` array/scalar path logic
ndgrigorian Sep 18, 2024
08b6c26
Disallow inputs to `dpnp_fill` on separate queues
ndgrigorian Sep 18, 2024
c64dc0b
Adjust skip message for `test_fill_with_numpy_scalar_ndarray`
ndgrigorian Oct 14, 2024
9691cf0
Tweak error messages in `dpnp_fill`
ndgrigorian Oct 14, 2024
957b93a
Add tests for new `fill` method
ndgrigorian Oct 14, 2024
87e6560
Update docstring for `fill` method
ndgrigorian Oct 14, 2024
985b4fa
Fix pre-commit in cupy fill tests
ndgrigorian Oct 14, 2024
d8a3e65
Change `asarray` to `astype` in `dpnp_fill`
ndgrigorian Oct 22, 2024
70618e1
Expand TEST_SCOPE to include `test_fill.py`
ndgrigorian Oct 22, 2024
478397f
Remove redundant check from `dpnp_fill`
ndgrigorian Oct 22, 2024
f782d1c
Use `_cast_fill_val` private function from `dpctl.tensor._ctors`
ndgrigorian Oct 22, 2024
e29685e
Add tests per PR review by @antonwolfy
ndgrigorian Oct 22, 2024
bd30f85
Improve validation of `val` for `fill` method
ndgrigorian Oct 23, 2024
865867a
Add to permit NumPy bools as `dpnp_fill` scalar fill values
ndgrigorian Oct 24, 2024
4ba7186
Use `dpnp.bool` in `dpnp_fill` and make `isinstance` check more effic…
ndgrigorian Oct 24, 2024
48c8051
Replace branching for `fill` scalar type with `_cast_fill_value`
ndgrigorian Oct 24, 2024
8adc06a
Add additional tests for `fill`
ndgrigorian Oct 24, 2024
c91ab47
Merge branch 'master' into implement-efficient-fill-method
antonwolfy Oct 24, 2024
c4e0481
Merge branch 'master' into implement-efficient-fill-method
ndgrigorian Oct 24, 2024
387b542
Merge branch 'master' into implement-efficient-fill-method
ndgrigorian Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for new fill method
  • Loading branch information
ndgrigorian committed Oct 15, 2024
commit 957b93a094449168962a08819aeb8da00da7baab
61 changes: 61 additions & 0 deletions tests/test_fill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import dpctl
import numpy as np
Comment thread
ndgrigorian marked this conversation as resolved.
Resolved
Comment thread
ndgrigorian marked this conversation as resolved.
Resolved
import pytest
from dpctl.utils import ExecutionPlacementError
from numpy.testing import assert_array_equal

import dpnp as dnp


def test_fill_non_scalar():
a = dnp.ones(5, dtype="i4")
val = dnp.ones(2, dtype="i4")

with pytest.raises(ValueError):
a.fill(val)

with pytest.raises(TypeError):
a.fill(dict())
Comment thread
ndgrigorian marked this conversation as resolved.
Resolved


Comment thread
ndgrigorian marked this conversation as resolved.
Resolved
def test_fill_compute_follows_data():
q1 = dpctl.SyclQueue()
q2 = dpctl.SyclQueue()

a = dnp.ones(5, dtype="i4", sycl_queue=q1)
val = dnp.ones((), dtype=a.dtype, sycl_queue=q2)

with pytest.raises(ExecutionPlacementError):
a.fill(val)


def test_fill_strided_array():
a = dnp.zeros(100, dtype="i4")
b = a[::-2]

expected = dnp.tile(dnp.asarray([0, 1], dtype=a.dtype), 50)

b.fill(1)
assert_array_equal(b, 1)
assert_array_equal(a, expected)


@pytest.mark.parametrize("order", ["C", "F"])
def test_fill_strided_2d_array(order):
a = dnp.zeros((10, 10), dtype="i4", order=order)
b = a[::-2, ::2]

expected = dnp.copy(a)
expected[::-2, ::2] = 1

b.fill(1)
assert_array_equal(b, 1)
assert_array_equal(a, expected)


@pytest.mark.parametrize("order", ["C", "F"])
def test_fill_memset(order):
a = dnp.ones((10, 10), dtype="i4", order=order)
a.fill(0)

assert_array_equal(a, 0)