@@ -272,12 +272,42 @@ def test_logical_with_nas(self):
272
272
assert_series_equal (result , expected )
273
273
274
274
def test_neg (self ):
275
- # what to do?
276
- assert_frame_equal (- self .frame , - 1 * self .frame )
275
+ numeric = pd .DataFrame ({
276
+ 'a' : [- 1 , 0 , 1 ],
277
+ 'b' : [1 , 0 , 1 ],
278
+ })
279
+ boolean = pd .DataFrame ({
280
+ 'a' : [True , False , True ],
281
+ 'b' : [False , False , True ]
282
+ })
283
+ timedelta = pd .Series (pd .to_timedelta ([- 1 , 0 , 10 ]))
284
+ not_numeric = pd .DataFrame ({'string' : ['a' , 'b' , 'c' ]})
285
+ assert_frame_equal (- numeric , - 1 * numeric )
286
+ assert_frame_equal (- boolean , ~ boolean )
287
+ assert_series_equal (- timedelta , pd .to_timedelta (- 1 * timedelta ))
288
+ with pytest .raises (TypeError ):
289
+ (+ not_numeric )
277
290
278
291
def test_invert (self ):
279
292
assert_frame_equal (- (self .frame < 0 ), ~ (self .frame < 0 ))
280
293
294
+ def test_pos (self ):
295
+ numeric = pd .DataFrame ({
296
+ 'a' : [- 1 , 0 , 1 ],
297
+ 'b' : [1 , 0 , 1 ],
298
+ })
299
+ boolean = pd .DataFrame ({
300
+ 'a' : [True , False , True ],
301
+ 'b' : [False , False , True ]
302
+ })
303
+ timedelta = pd .Series (pd .to_timedelta ([- 1 , 0 , 10 ]))
304
+ not_numeric = pd .DataFrame ({'string' : ['a' , 'b' , 'c' ]})
305
+ assert_frame_equal (+ numeric , + 1 * numeric )
306
+ assert_frame_equal (+ boolean , (+ 1 * boolean ).astype (bool ))
307
+ assert_series_equal (+ timedelta , pd .to_timedelta (+ 1 * timedelta ))
308
+ with pytest .raises (TypeError ):
309
+ (+ not_numeric )
310
+
281
311
def test_arith_flex_frame (self ):
282
312
ops = ['add' , 'sub' , 'mul' , 'div' , 'truediv' , 'pow' , 'floordiv' , 'mod' ]
283
313
if not compat .PY3 :
0 commit comments