MCPcopy
hub / github.com/numpy/numpy / resize

Function resize

numpy/ma/core.py:7697–7759  ·  view source on GitHub ↗

Return a new masked array with the specified size and shape. This is the masked equivalent of the `numpy.resize` function. The new array is filled with repeated copies of `x` (in the order that the data are stored in memory). If `x` is masked, the new array will be masked, and

(x, new_shape)

Source from the content-addressed store, hash-verified

7695
7696
7697def resize(x, new_shape):
7698 """
7699 Return a new masked array with the specified size and shape.
7700
7701 This is the masked equivalent of the `numpy.resize` function. The new
7702 array is filled with repeated copies of `x` (in the order that the
7703 data are stored in memory). If `x` is masked, the new array will be
7704 masked, and the new mask will be a repetition of the old one.
7705
7706 See Also
7707 --------
7708 numpy.resize : Equivalent function in the top level NumPy module.
7709
7710 Examples
7711 --------
7712 >>> import numpy as np
7713 >>> import numpy.ma as ma
7714 >>> a = ma.array([[1, 2] ,[3, 4]])
7715 >>> a[0, 1] = ma.masked
7716 >>> a
7717 masked_array(
7718 data=[[1, --],
7719 [3, 4]],
7720 mask=[[False, True],
7721 [False, False]],
7722 fill_value=999999)
7723 >>> np.resize(a, (3, 3))
7724 masked_array(
7725 data=[[1, 2, 3],
7726 [4, 1, 2],
7727 [3, 4, 1]],
7728 mask=False,
7729 fill_value=999999)
7730 >>> ma.resize(a, (3, 3))
7731 masked_array(
7732 data=[[1, --, 3],
7733 [4, 1, --],
7734 [3, 4, 1]],
7735 mask=[[False, True, False],
7736 [False, False, True],
7737 [False, False, False]],
7738 fill_value=999999)
7739
7740 A MaskedArray is always returned, regardless of the input type.
7741
7742 >>> a = np.array([[1, 2] ,[3, 4]])
7743 >>> ma.resize(a, (3, 3))
7744 masked_array(
7745 data=[[1, 2, 3],
7746 [4, 1, 2],
7747 [3, 4, 1]],
7748 mask=False,
7749 fill_value=999999)
7750
7751 """
7752 # We can't use _frommethods here, as N.resize is notoriously whiny.
7753 m = getmask(x)
7754 if m is not nomask:

Callers 2

test_testCopySizeMethod · 0.90
test_copyMethod · 0.90

Calls 4

getmaskFunction · 0.85
get_masked_subclassFunction · 0.85
resizeMethod · 0.80
viewMethod · 0.45

Tested by 2

test_testCopySizeMethod · 0.72
test_copyMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…