@@ -122,21 +122,14 @@ def test_struct_array_dims(self):
122122 """
123123 # GH837, GH861
124124 # 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 )],
126128 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-
134129 weights_0 = DataArray ([80 , 56 , 120 ], dims = ['participant' ],
135130 coords = {'participant' : p_data })
136-
137131 weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
138- coords = {'participant' : p_data_1 })
139-
132+ coords = {'participant' : p_data })
140133 actual = weights_1 - weights_0
141134
142135 expected = DataArray ([1 , - 4 , - 5 ], dims = ['participant' ],
@@ -145,31 +138,27 @@ def test_struct_array_dims(self):
145138 assert_identical (actual , expected )
146139
147140 # 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 )])
151143 weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
152- coords = {'participant' : p_data_1 })
153-
144+ coords = {'participant' : p_data_alt })
154145 actual = weights_1 - weights_0
155146
156147 expected = DataArray ([1 , - 5 ], dims = ['participant' ],
157- coords = {'participant' : p_data_2 })
148+ coords = {'participant' : p_data [[ 0 , 2 ]] })
158149
159150 assert_identical (actual , expected )
160151
161152 # checking array subraction when dims are not the same and one
162153 # 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 )])
166156 weights_1 = DataArray ([81 , 52 , 115 ], dims = ['participant' ],
167- coords = {'participant' : p_data_1 })
168-
157+ coords = {'participant' : p_data_nan })
169158 actual = weights_1 - weights_0
170159
171160 expected = DataArray ([1 , - 5 ], dims = ['participant' ],
172- coords = {'participant' : p_data_2 })
161+ coords = {'participant' : p_data [[ 0 , 2 ]] })
173162
174163 assert_identical (actual , expected )
175164
0 commit comments