2
2
# pylint: disable-msg=E1101,W0612
3
3
4
4
from copy import copy , deepcopy
5
- from warnings import catch_warnings , simplefilter
6
5
7
6
import numpy as np
8
7
import pytest
12
11
from pandas .core .dtypes .common import is_scalar
13
12
14
13
import pandas as pd
15
- from pandas import DataFrame , MultiIndex , Panel , Series , date_range
14
+ from pandas import DataFrame , MultiIndex , Series , date_range
16
15
import pandas .util .testing as tm
17
16
from pandas .util .testing import assert_frame_equal , assert_series_equal
18
17
@@ -238,12 +237,6 @@ def test_metadata_propagation(self):
238
237
o2 = self ._construct (shape = 3 )
239
238
o2 .name = 'bar'
240
239
241
- # TODO
242
- # Once panel can do non-trivial combine operations
243
- # (currently there is an a raise in the Panel arith_ops to prevent
244
- # this, though it actually does work)
245
- # can remove all of these try: except: blocks on the actual operations
246
-
247
240
# ----------
248
241
# preserving
249
242
# ----------
@@ -255,63 +248,37 @@ def test_metadata_propagation(self):
255
248
256
249
# ops with like
257
250
for op in ['__add__' , '__sub__' , '__truediv__' , '__mul__' ]:
258
- try :
259
- result = getattr (o , op )(o )
260
- self .check_metadata (o , result )
261
- except (ValueError , AttributeError ):
262
- pass
251
+ result = getattr (o , op )(o )
252
+ self .check_metadata (o , result )
263
253
264
254
# simple boolean
265
255
for op in ['__eq__' , '__le__' , '__ge__' ]:
266
256
v1 = getattr (o , op )(o )
267
257
self .check_metadata (o , v1 )
268
-
269
- try :
270
- self .check_metadata (o , v1 & v1 )
271
- except (ValueError ):
272
- pass
273
-
274
- try :
275
- self .check_metadata (o , v1 | v1 )
276
- except (ValueError ):
277
- pass
258
+ self .check_metadata (o , v1 & v1 )
259
+ self .check_metadata (o , v1 | v1 )
278
260
279
261
# combine_first
280
- try :
281
- result = o .combine_first (o2 )
282
- self .check_metadata (o , result )
283
- except (AttributeError ):
284
- pass
262
+ result = o .combine_first (o2 )
263
+ self .check_metadata (o , result )
285
264
286
265
# ---------------------------
287
266
# non-preserving (by default)
288
267
# ---------------------------
289
268
290
269
# add non-like
291
- try :
292
- result = o + o2
293
- self .check_metadata (result )
294
- except (ValueError , AttributeError ):
295
- pass
270
+ result = o + o2
271
+ self .check_metadata (result )
296
272
297
273
# simple boolean
298
274
for op in ['__eq__' , '__le__' , '__ge__' ]:
299
275
300
276
# this is a name matching op
301
277
v1 = getattr (o , op )(o )
302
-
303
278
v2 = getattr (o , op )(o2 )
304
279
self .check_metadata (v2 )
305
-
306
- try :
307
- self .check_metadata (v1 & v2 )
308
- except (ValueError ):
309
- pass
310
-
311
- try :
312
- self .check_metadata (v1 | v2 )
313
- except (ValueError ):
314
- pass
280
+ self .check_metadata (v1 & v2 )
281
+ self .check_metadata (v1 | v2 )
315
282
316
283
def test_head_tail (self ):
317
284
# GH5370
@@ -325,12 +292,7 @@ def test_head_tail(self):
325
292
axis = o ._get_axis_name (0 )
326
293
setattr (o , axis , index (len (getattr (o , axis ))))
327
294
328
- # Panel + dims
329
- try :
330
- o .head ()
331
- except (NotImplementedError ):
332
- pytest .skip ('not implemented on {0}' .format (
333
- o .__class__ .__name__ ))
295
+ o .head ()
334
296
335
297
self ._compare (o .head (), o .iloc [:5 ])
336
298
self ._compare (o .tail (), o .iloc [- 5 :])
@@ -639,19 +601,12 @@ def test_sample(sel):
639
601
sample1 = df .sample (n = 1 , weights = 'easyweights' )
640
602
assert_frame_equal (sample1 , df .iloc [5 :6 ])
641
603
642
- # Ensure proper error if string given as weight for Series, panel, or
604
+ # Ensure proper error if string given as weight for Series or
643
605
# DataFrame with axis = 1.
644
606
s = Series (range (10 ))
645
607
with pytest .raises (ValueError ):
646
608
s .sample (n = 3 , weights = 'weight_column' )
647
609
648
- with catch_warnings (record = True ):
649
- simplefilter ("ignore" , FutureWarning )
650
- panel = Panel (items = [0 , 1 , 2 ], major_axis = [2 , 3 , 4 ],
651
- minor_axis = [3 , 4 , 5 ])
652
- with pytest .raises (ValueError ):
653
- panel .sample (n = 1 , weights = 'weight_column' )
654
-
655
610
with pytest .raises (ValueError ):
656
611
df .sample (n = 1 , weights = 'weight_column' , axis = 1 )
657
612
@@ -754,12 +709,9 @@ def test_squeeze(self):
754
709
# don't fail with 0 length dimensions GH11229 & GH8999
755
710
empty_series = Series ([], name = 'five' )
756
711
empty_frame = DataFrame ([empty_series ])
757
- with catch_warnings (record = True ):
758
- simplefilter ("ignore" , FutureWarning )
759
- empty_panel = Panel ({'six' : empty_frame })
760
712
761
713
[tm .assert_series_equal (empty_series , higher_dim .squeeze ())
762
- for higher_dim in [empty_series , empty_frame , empty_panel ]]
714
+ for higher_dim in [empty_series , empty_frame ]]
763
715
764
716
# axis argument
765
717
df = tm .makeTimeDataFrame (nper = 1 ).iloc [:, :1 ]
0 commit comments