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

Method put

numpy/ma/core.py:4770–4853  ·  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

4768 raise ValueError(errmsg)
4769
4770 def put(self, indices, values, mode='raise'):
4771 """
4772 Set storage-indexed locations to corresponding values.
4773
4774 Sets self._data.flat[n] = values[n] for each n in indices.
4775 If `values` is shorter than `indices` then it will repeat.
4776 If `values` has some masked values, the initial mask is updated
4777 in consequence, else the corresponding values are unmasked.
4778
4779 Parameters
4780 ----------
4781 indices : 1-D array_like
4782 Target indices, interpreted as integers.
4783 values : array_like
4784 Values to place in self._data copy at target indices.
4785 mode : {'raise', 'wrap', 'clip'}, optional
4786 Specifies how out-of-bounds indices will behave.
4787 'raise' : raise an error.
4788 'wrap' : wrap around.
4789 'clip' : clip to the range.
4790
4791 Notes
4792 -----
4793 `values` can be a scalar or length 1 array.
4794
4795 Examples
4796 --------
4797 >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4)
4798 >>> x
4799 masked_array(
4800 data=[[1, --, 3],
4801 [--, 5, --],
4802 [7, --, 9]],
4803 mask=[[False, True, False],
4804 [ True, False, True],
4805 [False, True, False]],
4806 fill_value=999999)
4807 >>> x.put([0,4,8],[10,20,30])
4808 >>> x
4809 masked_array(
4810 data=[[10, --, 3],
4811 [--, 20, --],
4812 [7, --, 30]],
4813 mask=[[False, True, False],
4814 [ True, False, True],
4815 [False, True, False]],
4816 fill_value=999999)
4817
4818 >>> x.put(4,999)
4819 >>> x
4820 masked_array(
4821 data=[[10, --, 3],
4822 [--, 999, --],
4823 [7, --, 30]],
4824 mask=[[False, True, False],
4825 [ True, False, True],
4826 [False, True, False]],
4827 fill_value=999999)

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
test_put_nomaskMethod · 0.80

Calls 4

getmaskFunction · 0.85
getmaskarrayFunction · 0.85
make_maskFunction · 0.85
resizeMethod · 0.45

Tested by 12

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
workerMethod · 0.64