MCPcopy Index your code
hub / github.com/numpy/numpy / reshape

Function reshape

numpy/ma/core.py:7647–7694  ·  view source on GitHub ↗

Returns an array containing the same data with a new shape. Refer to `MaskedArray.reshape` for full documentation. See Also -------- MaskedArray.reshape : equivalent function Examples -------- Reshaping a 1-D array: >>> a = np.ma.array([1, 2, 3, 4]) >>> n

(a, new_shape, order='C')

Source from the content-addressed store, hash-verified

7645
7646
7647def reshape(a, new_shape, order='C'):
7648 """
7649 Returns an array containing the same data with a new shape.
7650
7651 Refer to `MaskedArray.reshape` for full documentation.
7652
7653 See Also
7654 --------
7655 MaskedArray.reshape : equivalent function
7656
7657 Examples
7658 --------
7659 Reshaping a 1-D array:
7660
7661 >>> a = np.ma.array([1, 2, 3, 4])
7662 >>> np.ma.reshape(a, (2, 2))
7663 masked_array(
7664 data=[[1, 2],
7665 [3, 4]],
7666 mask=False,
7667 fill_value=999999)
7668
7669 Reshaping a 2-D array:
7670
7671 >>> b = np.ma.array([[1, 2], [3, 4]])
7672 >>> np.ma.reshape(b, (1, 4))
7673 masked_array(data=[[1, 2, 3, 4]],
7674 mask=False,
7675 fill_value=999999)
7676
7677 Reshaping a 1-D array with a mask:
7678
7679 >>> c = np.ma.array([1, 2, 3, 4], mask=[False, True, False, False])
7680 >>> np.ma.reshape(c, (2, 2))
7681 masked_array(
7682 data=[[1, --],
7683 [3, 4]],
7684 mask=[[False, True],
7685 [False, False]],
7686 fill_value=999999)
7687
7688 """
7689 # We can't use 'frommethod', it whine about some parameters. Dmmit.
7690 try:
7691 return a.reshape(new_shape, order=order)
7692 except AttributeError:
7693 _tmp = np.asarray(a).reshape(new_shape, order=order)
7694 return _tmp.view(MaskedArray)
7695
7696
7697def resize(x, new_shape):

Callers 2

test_on_ndarrayMethod · 0.90
__getitem__Method · 0.70

Calls 2

reshapeMethod · 0.80
viewMethod · 0.45

Tested by 1

test_on_ndarrayMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…