numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturns
choose(indices, choices, out=None, mode='raise')

Given an array of integers and a list of n choice arrays, this method will create a new array that merges each of the choice arrays. Where a value in :None:None:`index` is i, the new array will have the value that choices[i] contains in the same place.

Parameters

indices : ndarray of ints

This array must contain integers in [0, n-1] , where n is the number of choices.

choices : sequence of arrays

Choice arrays. The index array and all of the choices should be broadcastable to the same shape.

out : array, optional

If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype .

mode : {'raise', 'wrap', 'clip'}, optional

Specifies how out-of-bounds indices will behave.

Returns

merged_array : array

Use an index array to construct a new array from a list of choices.

See Also

choose

equivalent function

Examples

This example is valid syntax, but we were not able to check execution
>>> choice = np.array([[1,1,1], [2,2,2], [3,3,3]])
... a = np.array([2, 1, 0])
... np.ma.choose(a, choice) masked_array(data=[3, 2, 1], mask=False, fill_value=999999)
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/ma/core.py#7346
type: <class 'function'>
Commit: