Skip to content

Commit 3c28e7a

Browse files
Merge pull request #1016 from IntelPython/fill-array-method
the fill array method impl
2 parents 479e5a0 + 16fcac9 commit 3c28e7a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

dpnp/dpnp_array.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,32 @@ def dtype(self):
420420

421421
# 'dump',
422422
# 'dumps',
423-
# 'fill',
423+
424+
def fill(self, value):
425+
"""
426+
Fill the array with a scalar value.
427+
428+
Parameters
429+
----------
430+
value : scalar
431+
All elements of `a` will be assigned this value.
432+
433+
Examples
434+
--------
435+
>>> a = np.array([1, 2])
436+
>>> a.fill(0)
437+
>>> a
438+
array([0, 0])
439+
>>> a = np.empty(2)
440+
>>> a.fill(1)
441+
>>> a
442+
array([1., 1.])
443+
444+
"""
445+
446+
for i in range(self.size):
447+
self.flat[i] = value
448+
424449
# 'flags',
425450

426451
@property

tests/skipped_tests_gpu.tbl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAn
292292
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_diagonal2
293293
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_transposed_fill
294294
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_transposed_flatten
295-
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_fill_with_numpy_nonscalar_ndarray
296-
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_fill
297-
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_fill_with_numpy_scalar_ndarray
298295
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_flatten_copied
299296
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_flatten
300297
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_isinstance_numpy_copy

0 commit comments

Comments
 (0)