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

Method put

numpy/ma/core.py:4837–4921  ·  view source on GitHub ↗

Set storage-indexed locations to corresponding values. Sets self._data.flat[n] = values[n] for each n in indices. If `values` is shorter than `indices` then it will repeat. If `values` has some masked values, the initial mask is updated in consequence, else

(self, indices, values, mode='raise')

Source from the content-addressed store, hash-verified

4835 raise ValueError(errmsg)
4836
4837 def put(self, indices, values, mode='raise'):
4838 """
4839 Set storage-indexed locations to corresponding values.
4840
4841 Sets self._data.flat[n] = values[n] for each n in indices.
4842 If `values` is shorter than `indices` then it will repeat.
4843 If `values` has some masked values, the initial mask is updated
4844 in consequence, else the corresponding values are unmasked.
4845
4846 Parameters
4847 ----------
4848 indices : 1-D array_like
4849 Target indices, interpreted as integers.
4850 values : array_like
4851 Values to place in self._data copy at target indices.
4852 mode : {'raise', 'wrap', 'clip'}, optional
4853 Specifies how out-of-bounds indices will behave.
4854 'raise' : raise an error.
4855 'wrap' : wrap around.
4856 'clip' : clip to the range.
4857
4858 Notes
4859 -----
4860 `values` can be a scalar or length 1 array.
4861
4862 Examples
4863 --------
4864 >>> import numpy as np
4865 >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4)
4866 >>> x
4867 masked_array(
4868 data=[[1, --, 3],
4869 [--, 5, --],
4870 [7, --, 9]],
4871 mask=[[False, True, False],
4872 [ True, False, True],
4873 [False, True, False]],
4874 fill_value=999999)
4875 >>> x.put([0,4,8],[10,20,30])
4876 >>> x
4877 masked_array(
4878 data=[[10, --, 3],
4879 [--, 20, --],
4880 [7, --, 30]],
4881 mask=[[False, True, False],
4882 [ True, False, True],
4883 [False, True, False]],
4884 fill_value=999999)
4885
4886 >>> x.put(4,999)
4887 >>> x
4888 masked_array(
4889 data=[[10, --, 3],
4890 [--, 999, --],
4891 [7, --, 30]],
4892 mask=[[False, True, False],
4893 [ True, False, True],
4894 [False, True, False]],

Callers 15

test_attributesMethod · 0.80
test_putMethod · 0.80
test_simpleMethod · 0.80
test_emptyMethod · 0.80
test_simpleMethod · 0.80
test_emptyMethod · 0.80
putFunction · 0.80
apply_along_axisFunction · 0.80
test_testPutMethod · 0.80
test_putMethod · 0.80

Calls 4

getmaskFunction · 0.85
getmaskarrayFunction · 0.85
make_maskFunction · 0.85
resizeMethod · 0.80

Tested by 13

test_attributesMethod · 0.64
test_putMethod · 0.64
test_simpleMethod · 0.64
test_emptyMethod · 0.64
test_simpleMethod · 0.64
test_emptyMethod · 0.64
test_testPutMethod · 0.64
test_putMethod · 0.64
test_put_nomaskMethod · 0.64
test_put_hardmaskMethod · 0.64