@@ -122,21 +122,14 @@ def test_struct_array_dims(self):
122
122
"""
123
123
# GH837, GH861
124
124
# checking array subraction when dims are the same
125
- p_data = np .array ([('John' , 180 ), ('Stacy' , 150 ), ('Dick' , 200 )],
125
+ # note: names need to be in sorted order to align consistently with
126
+ # pandas < 0.24 and >= 0.24.
127
+ p_data = np .array ([('Abe' , 180 ), ('Stacy' , 150 ), ('Dick' , 200 )],
126
128
dtype = [('name' , '|S256' ), ('height' , object )])
127
-
128
- p_data_1 = np .array ([('John' , 180 ), ('Stacy' , 150 ), ('Dick' , 200 )],
129
- dtype = [('name' , '|S256' ), ('height' , object )])
130
-
131
- p_data_2 = np .array ([('John' , 180 ), ('Dick' , 200 )],
132
- dtype = [('name' , '|S256' ), ('height' , object )])
133
-
134
129
weights_0 = DataArray ([80 , 56 , 120 ], dims = ['participant' ],
135
130
coords = {'participant' : p_data })
136
-
137
131
weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
138
- coords = {'participant' : p_data_1 })
139
-
132
+ coords = {'participant' : p_data })
140
133
actual = weights_1 - weights_0
141
134
142
135
expected = DataArray ([1 , - 4 , - 5 ], dims = ['participant' ],
@@ -145,31 +138,27 @@ def test_struct_array_dims(self):
145
138
assert_identical (actual , expected )
146
139
147
140
# checking array subraction when dims are not the same
148
- p_data_1 = np .array ([('John' , 180 ), ('Stacy' , 151 ), ('Dick' , 200 )],
149
- dtype = [('name' , '|S256' ), ('height' , object )])
150
-
141
+ p_data_alt = np .array ([('Abe' , 180 ), ('Stacy' , 151 ), ('Dick' , 200 )],
142
+ dtype = [('name' , '|S256' ), ('height' , object )])
151
143
weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
152
- coords = {'participant' : p_data_1 })
153
-
144
+ coords = {'participant' : p_data_alt })
154
145
actual = weights_1 - weights_0
155
146
156
147
expected = DataArray ([1 , - 5 ], dims = ['participant' ],
157
- coords = {'participant' : p_data_2 })
148
+ coords = {'participant' : p_data [[ 0 , 2 ]] })
158
149
159
150
assert_identical (actual , expected )
160
151
161
152
# checking array subraction when dims are not the same and one
162
153
# is np.nan
163
- p_data_1 = np .array ([('John' , 180 ), ('Stacy' , np .nan ), ('Dick' , 200 )],
164
- dtype = [('name' , '|S256' ), ('height' , object )])
165
-
154
+ p_data_nan = np .array ([('Abe' , 180 ), ('Stacy' , np .nan ), ('Dick' , 200 )],
155
+ dtype = [('name' , '|S256' ), ('height' , object )])
166
156
weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
167
- coords = {'participant' : p_data_1 })
168
-
157
+ coords = {'participant' : p_data_nan })
169
158
actual = weights_1 - weights_0
170
159
171
160
expected = DataArray ([1 , - 5 ], dims = ['participant' ],
172
- coords = {'participant' : p_data_2 })
161
+ coords = {'participant' : p_data [[ 0 , 2 ]] })
173
162
174
163
assert_identical (actual , expected )
175
164
0 commit comments