MCPcopy Create free account
hub / github.com/numpy/numpy / reshape

Method reshape

numpy/ma/core.py:4686–4750  ·  view source on GitHub ↗

Give a new shape to the array without changing its data. Returns a masked array containing the same data, but with a new shape. The result is a view on the original array; if this is not possible, a ValueError is raised. Parameters ----------

(self, *s, **kwargs)

Source from the content-addressed store, hash-verified

4684
4685
4686 def reshape(self, *s, **kwargs):
4687 """
4688 Give a new shape to the array without changing its data.
4689
4690 Returns a masked array containing the same data, but with a new shape.
4691 The result is a view on the original array; if this is not possible, a
4692 ValueError is raised.
4693
4694 Parameters
4695 ----------
4696 shape : int or tuple of ints
4697 The new shape should be compatible with the original shape. If an
4698 integer is supplied, then the result will be a 1-D array of that
4699 length.
4700 order : {'C', 'F'}, optional
4701 Determines whether the array data should be viewed as in C
4702 (row-major) or FORTRAN (column-major) order.
4703
4704 Returns
4705 -------
4706 reshaped_array : array
4707 A new view on the array.
4708
4709 See Also
4710 --------
4711 reshape : Equivalent function in the masked array module.
4712 numpy.ndarray.reshape : Equivalent method on ndarray object.
4713 numpy.reshape : Equivalent function in the NumPy module.
4714
4715 Notes
4716 -----
4717 The reshaping operation cannot guarantee that a copy will not be made,
4718 to modify the shape in place, use ``a.shape = s``
4719
4720 Examples
4721 --------
4722 >>> x = np.ma.array([[1,2],[3,4]], mask=[1,0,0,1])
4723 >>> x
4724 masked_array(
4725 data=[[--, 2],
4726 [3, --]],
4727 mask=[[ True, False],
4728 [False, True]],
4729 fill_value=999999)
4730 >>> x = x.reshape((4,1))
4731 >>> x
4732 masked_array(
4733 data=[[--],
4734 [2],
4735 [3],
4736 [--]],
4737 mask=[[ True],
4738 [False],
4739 [False],
4740 [ True]],
4741 fill_value=999999)
4742
4743 """

Callers 15

testNormMethod · 0.80
testNormWrongDimMethod · 0.80
testNormWrongSizeMethod · 0.80
testScaleMethod · 0.80
testFloorMethod · 0.80
testFloorWrongTypeMethod · 0.80
testFloorWrongDimMethod · 0.80
testCeilMethod · 0.80
testCeilWrongTypeMethod · 0.80
testCeilWrongDimMethod · 0.80
testCeilNonArrayMethod · 0.80
testLUSplitMethod · 0.80

Calls 4

updateMethod · 0.80
_update_fromMethod · 0.80
getMethod · 0.45
viewMethod · 0.45

Tested by 15

testNormMethod · 0.64
testNormWrongDimMethod · 0.64
testNormWrongSizeMethod · 0.64
testScaleMethod · 0.64
testFloorMethod · 0.64
testFloorWrongTypeMethod · 0.64
testFloorWrongDimMethod · 0.64
testCeilMethod · 0.64
testCeilWrongTypeMethod · 0.64
testCeilWrongDimMethod · 0.64
testCeilNonArrayMethod · 0.64
testLUSplitMethod · 0.64