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

Method test_get_fieldstructure

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

Source from the content-addressed store, hash-verified

150 assert_equal(test, ())
151
152 def test_get_fieldstructure(self):
153 # Test get_fieldstructure
154
155 # No nested fields
156 ndtype = np.dtype([('A', '|S3'), ('B', float)])
157 test = get_fieldstructure(ndtype)
158 assert_equal(test, {'A': [], 'B': []})
159
160 # One 1-nested field
161 ndtype = np.dtype([('A', int), ('B', [('BA', float), ('BB', '|S1')])])
162 test = get_fieldstructure(ndtype)
163 assert_equal(test, {'A': [], 'B': [], 'BA': ['B', ], 'BB': ['B']})
164
165 # One 2-nested fields
166 ndtype = np.dtype([('A', int),
167 ('B', [('BA', int),
168 ('BB', [('BBA', int), ('BBB', int)])])])
169 test = get_fieldstructure(ndtype)
170 control = {'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'],
171 'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']}
172 assert_equal(test, control)
173
174 # 0 fields
175 ndtype = np.dtype([])
176 test = get_fieldstructure(ndtype)
177 assert_equal(test, {})
178
179 def test_find_duplicates(self):
180 # 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