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

Function recursive_fill_fields

numpy/lib/recfunctions.py:32–68  ·  view source on GitHub ↗

Fills fields from output with fields from input, with support for nested structures. Parameters ---------- input : ndarray Input array. output : ndarray Output array. Notes ----- * `output` should be at least the same size as `input` Exampl

(input, output)

Source from the content-addressed store, hash-verified

30
31@array_function_dispatch(_recursive_fill_fields_dispatcher)
32def recursive_fill_fields(input, output):
33 """
34 Fills fields from output with fields from input,
35 with support for nested structures.
36
37 Parameters
38 ----------
39 input : ndarray
40 Input array.
41 output : ndarray
42 Output array.
43
44 Notes
45 -----
46 * `output` should be at least the same size as `input`
47
48 Examples
49 --------
50 >>> import numpy as np
51 >>> from numpy.lib import recfunctions as rfn
52 >>> a = np.array([(1, 10.), (2, 20.)], dtype=[('A', np.int64), ('B', np.float64)])
53 >>> b = np.zeros((3,), dtype=a.dtype)
54 >>> rfn.recursive_fill_fields(a, b)
55 array([(1, 10.), (2, 20.), (0, 0.)], dtype=[('A', '<i8'), ('B', '<f8')])
56
57 """
58 newdtype = output.dtype
59 for field in newdtype.names:
60 try:
61 current = input[field]
62 except ValueError:
63 continue
64 if current.dtype.names is not None:
65 recursive_fill_fields(current, output[field])
66 else:
67 output[field][:len(current)] = current
68 return output
69
70
71def _get_fieldspec(dtype):

Callers 5

test_simple_flexibleMethod · 0.90
test_masked_flexibleMethod · 0.90
drop_fieldsFunction · 0.85
_keep_fieldsFunction · 0.85
append_fieldsFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_simple_flexibleMethod · 0.72
test_masked_flexibleMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…