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

Method test_get_fieldstructure

numpy/lib/tests/test_recfunctions.py:144–169  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

142 assert_equal(test, ())
143
144 def test_get_fieldstructure(self):
145 # Test get_fieldstructure
146
147 # No nested fields
148 ndtype = np.dtype([('A', '|S3'), ('B', float)])
149 test = get_fieldstructure(ndtype)
150 assert_equal(test, {'A': [], 'B': []})
151
152 # One 1-nested field
153 ndtype = np.dtype([('A', int), ('B', [('BA', float), ('BB', '|S1')])])
154 test = get_fieldstructure(ndtype)
155 assert_equal(test, {'A': [], 'B': [], 'BA': ['B', ], 'BB': ['B']})
156
157 # One 2-nested fields
158 ndtype = np.dtype([('A', int),
159 ('B', [('BA', int),
160 ('BB', [('BBA', int), ('BBB', int)])])])
161 test = get_fieldstructure(ndtype)
162 control = {'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'],
163 'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']}
164 assert_equal(test, control)
165
166 # 0 fields
167 ndtype = np.dtype([])
168 test = get_fieldstructure(ndtype)
169 assert_equal(test, {})
170
171 def test_find_duplicates(self):
172 # Test find_duplicates

Callers

nothing calls this directly

Calls 3

get_fieldstructureFunction · 0.90
assert_equalFunction · 0.90
dtypeMethod · 0.45

Tested by

no test coverage detected