File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -420,7 +420,32 @@ def dtype(self):
420
420
421
421
# 'dump',
422
422
# '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
+
424
449
# 'flags',
425
450
426
451
@property
Original file line number Diff line number Diff line change @@ -292,9 +292,6 @@ tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAn
292
292
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_diagonal2
293
293
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_transposed_fill
294
294
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
298
295
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_flatten_copied
299
296
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_flatten
300
297
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_isinstance_numpy_copy
You can’t perform that action at this time.
0 commit comments