@@ -389,12 +389,42 @@ def test_logical_with_nas(self):
389
389
assert_series_equal (result , expected )
390
390
391
391
def test_neg (self ):
392
- # what to do?
393
- assert_frame_equal (- self .frame , - 1 * self .frame )
392
+ numeric = pd .DataFrame ({
393
+ 'a' : [- 1 , 0 , 1 ],
394
+ 'b' : [1 , 0 , 1 ],
395
+ })
396
+ boolean = pd .DataFrame ({
397
+ 'a' : [True , False , True ],
398
+ 'b' : [False , False , True ]
399
+ })
400
+ timedelta = pd .Series (pd .to_timedelta ([- 1 , 0 , 10 ]))
401
+ not_numeric = pd .DataFrame ({'string' : ['a' , 'b' , 'c' ]})
402
+ assert_frame_equal (- numeric , - 1 * numeric )
403
+ assert_frame_equal (- boolean , ~ boolean )
404
+ assert_series_equal (- timedelta , pd .to_timedelta (- 1 * timedelta ))
405
+ with pytest .raises (TypeError ):
406
+ (+ not_numeric )
394
407
395
408
def test_invert (self ):
396
409
assert_frame_equal (- (self .frame < 0 ), ~ (self .frame < 0 ))
397
410
411
+ def test_pos (self ):
412
+ numeric = pd .DataFrame ({
413
+ 'a' : [- 1 , 0 , 1 ],
414
+ 'b' : [1 , 0 , 1 ],
415
+ })
416
+ boolean = pd .DataFrame ({
417
+ 'a' : [True , False , True ],
418
+ 'b' : [False , False , True ]
419
+ })
420
+ timedelta = pd .Series (pd .to_timedelta ([- 1 , 0 , 10 ]))
421
+ not_numeric = pd .DataFrame ({'string' : ['a' , 'b' , 'c' ]})
422
+ assert_frame_equal (+ numeric , + 1 * numeric )
423
+ assert_frame_equal (+ boolean , (+ 1 * boolean ).astype (bool ))
424
+ assert_series_equal (+ timedelta , pd .to_timedelta (+ 1 * timedelta ))
425
+ with pytest .raises (TypeError ):
426
+ (+ not_numeric )
427
+
398
428
def test_arith_flex_frame (self ):
399
429
ops = ['add' , 'sub' , 'mul' , 'div' , 'truediv' , 'pow' , 'floordiv' , 'mod' ]
400
430
if not compat .PY3 :
0 commit comments