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

Method test_drop_fields

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

Source from the content-addressed store, hash-verified

71 ('b', [('ba', float), ('bb', int)])])]))
72
73 def test_drop_fields(self):
74 # Test drop_fields
75 a = np.array([(1, (2, 3.0)), (4, (5, 6.0))],
76 dtype=[('a', int), ('b', [('ba', float), ('bb', int)])])
77
78 # A basic field
79 test = drop_fields(a, 'a')
80 control = np.array([((2, 3.0),), ((5, 6.0),)],
81 dtype=[('b', [('ba', float), ('bb', int)])])
82 assert_equal(test, control)
83
84 # Another basic field (but nesting two fields)
85 test = drop_fields(a, 'b')
86 control = np.array([(1,), (4,)], dtype=[('a', int)])
87 assert_equal(test, control)
88
89 # A nested sub-field
90 test = drop_fields(a, ['ba', ])
91 control = np.array([(1, (3.0,)), (4, (6.0,))],
92 dtype=[('a', int), ('b', [('bb', int)])])
93 assert_equal(test, control)
94
95 # All the nested sub-field from a field: zap that field
96 test = drop_fields(a, ['ba', 'bb'])
97 control = np.array([(1,), (4,)], dtype=[('a', int)])
98 assert_equal(test, control)
99
100 # dropping all fields results in an array with no fields
101 test = drop_fields(a, ['a', 'b'])
102 control = np.array([(), ()], dtype=[])
103 assert_equal(test, control)
104
105 def test_rename_fields(self):
106 # Test rename fields

Callers

nothing calls this directly

Calls 2

drop_fieldsFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected