2020 from_lists , from_string , from_frame , from_series ,
2121 zip_array_values , zip_array_items , nan_to_num )
2222from larray .core .axis import (
23- _to_ticks , _to_tick , _to_key , _retarget_warn_msg
23+ _to_ticks , _to_key , _retarget_warn_msg , _group_as_aggregated_label_msg
2424)
2525from larray .util .misc import LHDFStore
2626
3333# E241: multiple spaces after ','
3434
3535
36- GROUP_AS_AGGREGATED_LABEL_MSG_TEMPLATE = "Using a Group object which was used to create an aggregate to " \
37- "target its aggregated label is deprecated. " \
38- "Please use the aggregated label directly instead. " \
39- "In this case, you should use {potential_tick!r} instead of " \
40- "using {key!r}."
41-
42- def group_as_aggregated_label_msg (key ):
43- return GROUP_AS_AGGREGATED_LABEL_MSG_TEMPLATE .format (potential_tick = _to_tick (key ), key = key )
44-
45-
4636# ================== #
4737# Test Value Strings #
4838# ================== #
@@ -2471,26 +2461,32 @@ def test_getitem_on_group_agg(array):
24712461 # using an anonymous LGroup
24722462 lg1 = b [b_group1 ]
24732463 agg_arr = array .sum (a , c ).sum (b = (lg1 , b_group2 , b_group2 , all_b ))
2474- with must_warn (FutureWarning , msg = group_as_aggregated_label_msg (lg1 ), num_expected = 5 ):
2475- # the following should all be equivalent
2476- assert agg_arr [lg1 ].shape == (6 ,)
2477- assert agg_arr [(lg1 ,)].shape == (6 ,)
2478- # these last three are only syntactic sugar differences
2479- # (__getitem__ receives the *exact* same key)
2480- assert agg_arr [(lg1 , slice (None ))].shape == (6 ,)
2481- assert agg_arr [lg1 , slice (None )].shape == (6 ,)
2482- assert agg_arr [lg1 , :].shape == (6 ,)
2464+ msg = _group_as_aggregated_label_msg (lg1 )
2465+ # the following should all be equivalent
2466+ with must_raise (ValueError , msg = msg ):
2467+ agg_arr [lg1 ]
2468+ with must_raise (ValueError , msg = msg ):
2469+ agg_arr [(lg1 ,)]
2470+ with must_raise (ValueError , msg = msg ):
2471+ agg_arr [(lg1 , slice (None ))]
2472+ # only syntactic sugar differences (__getitem__ gets *exact* same key)
2473+ # agg_arr[lg1, slice(None)]
2474+ # agg_arr[lg1, :]
24832475
24842476 # using a named LGroup
24852477 lg1 = b [b_group1 ] >> 'g1'
24862478 agg_arr = array .sum (a , c ).sum (b = (lg1 , b_group2 , b_group2 , all_b ))
2487- with must_warn (FutureWarning , msg = group_as_aggregated_label_msg (lg1 ), num_expected = 5 ):
2488- # the following are all equivalent
2489- assert agg_arr [lg1 ].shape == (6 ,)
2490- assert agg_arr [(lg1 ,)].shape == (6 ,)
2491- assert agg_arr [(lg1 , slice (None ))].shape == (6 ,)
2492- assert agg_arr [lg1 , slice (None )].shape == (6 ,)
2493- assert agg_arr [lg1 , :].shape == (6 ,)
2479+ msg = _group_as_aggregated_label_msg (lg1 )
2480+ # the following should all be equivalent
2481+ with must_raise (ValueError , msg = msg ):
2482+ agg_arr [lg1 ]
2483+ with must_raise (ValueError , msg = msg ):
2484+ agg_arr [(lg1 ,)]
2485+ with must_raise (ValueError , msg = msg ):
2486+ agg_arr [(lg1 , slice (None ))]
2487+ # only syntactic sugar differences (__getitem__ gets *exact* same key)
2488+ # agg_arr[lg1, slice(None)]
2489+ # agg_arr[lg1, :]
24942490
24952491
24962492def test_getitem_on_group_agg_nokw (array ):
@@ -2512,24 +2508,32 @@ def test_getitem_on_group_agg_nokw(array):
25122508 # using an anonymous LGroup
25132509 lg1 = b [b_group1 ]
25142510 agg_arr = array .sum (a , c ).sum ((lg1 , b_group2 , b_group3 , all_b ))
2515- with must_warn (FutureWarning , msg = group_as_aggregated_label_msg (lg1 ), num_expected = 5 ):
2516- # the following are all equivalent
2517- assert agg_arr [lg1 ].shape == (6 ,)
2518- assert agg_arr [(lg1 ,)].shape == (6 ,)
2519- assert agg_arr [(lg1 , slice (None ))].shape == (6 ,)
2520- assert agg_arr [lg1 , slice (None )].shape == (6 ,)
2521- assert agg_arr [lg1 , :].shape == (6 ,)
2511+ # the following are all equivalent
2512+ msg = _group_as_aggregated_label_msg (lg1 )
2513+ with must_raise (ValueError , msg = msg ):
2514+ agg_arr [lg1 ]
2515+ with must_raise (ValueError , msg = msg ):
2516+ agg_arr [(lg1 ,)]
2517+ with must_raise (ValueError , msg = msg ):
2518+ agg_arr [(lg1 , slice (None ))]
2519+ # only syntactic sugar differences (__getitem__ gets *exact* same key)
2520+ # agg_arr[lg1, slice(None)]
2521+ # agg_arr[lg1, :]
25222522
25232523 # using a named LGroup
25242524 lg1 = b [b_group1 ] >> 'g1'
25252525 agg_arr = array .sum (a , c ).sum ((lg1 , b_group2 , b_group3 , all_b ))
2526- with must_warn (FutureWarning , msg = group_as_aggregated_label_msg (lg1 ), num_expected = 5 ):
2527- # the following are all equivalent
2528- assert agg_arr [lg1 ].shape == (6 ,)
2529- assert agg_arr [(lg1 ,)].shape == (6 ,)
2530- assert agg_arr [(lg1 , slice (None ))].shape == (6 ,)
2531- assert agg_arr [lg1 , slice (None )].shape == (6 ,)
2532- assert agg_arr [lg1 , :].shape == (6 ,)
2526+ msg = _group_as_aggregated_label_msg (lg1 )
2527+ # the following are all equivalent
2528+ with must_raise (ValueError , msg = msg ):
2529+ agg_arr [lg1 ]
2530+ with must_raise (ValueError , msg = msg ):
2531+ agg_arr [(lg1 ,)]
2532+ with must_raise (ValueError , msg = msg ):
2533+ agg_arr [(lg1 , slice (None ))]
2534+ # only syntactic sugar differences (__getitem__ gets *exact* same key)
2535+ # agg_arr[lg1, slice(None)]
2536+ # agg_arr[lg1, :]
25332537
25342538
25352539def test_filter_on_group_agg (array ):
@@ -2543,8 +2547,8 @@ def test_filter_on_group_agg(array):
25432547 # using a named LGroup
25442548 g1 = b [b_group1 ] >> 'g1'
25452549 agg_arr = array .sum (a , c ).sum (b = (g1 , b_group2 , b_group3 , all_b ))
2546- with must_warn ( FutureWarning , msg = group_as_aggregated_label_msg (g1 )):
2547- assert agg_arr .filter (b = g1 ). shape == ( 6 , )
2550+ with must_raise ( ValueError , msg = _group_as_aggregated_label_msg (g1 )):
2551+ agg_arr .filter (b = g1 )
25482552
25492553 # Note that agg_arr.filter(b=(g1,)) does NOT work. It might be a
25502554 # little confusing for users, because agg_arr[(g1,)] works but it is
@@ -2567,8 +2571,9 @@ def test_filter_on_group_agg(array):
25672571 # assert bya.filter(a=':17').shape == (12, 2, 6)
25682572
25692573 bya = array .sum (a = (a0to5_named , 5 , a6to13 , a14plus ))
2570- with must_warn (FutureWarning , msg = group_as_aggregated_label_msg (a0to5_named )):
2571- assert bya .filter (a = a0to5_named ).shape == (12 , 2 , 6 )
2574+ msg = _group_as_aggregated_label_msg (a0to5_named )
2575+ with must_raise (ValueError , msg = msg ):
2576+ bya .filter (a = a0to5_named )
25722577
25732578
25742579def test_sum_several_lg_groups (array ):
@@ -2583,12 +2588,11 @@ def test_sum_several_lg_groups(array):
25832588
25842589 # the result is indexable
25852590 # 1.a) by LGroup
2586- msg1 = group_as_aggregated_label_msg (lg1 )
2587- with must_warn (FutureWarning , msg = msg1 ):
2588- assert agg_arr .filter (b = lg1 ).shape == (19 , 2 , 6 )
2589- msg2 = group_as_aggregated_label_msg (lg2 )
2590- with must_warn (FutureWarning , msg = (msg1 , msg2 ), check_file = False ):
2591- assert agg_arr .filter (b = (lg1 , lg2 )).shape == (19 , 2 , 2 , 6 )
2591+ msg = _group_as_aggregated_label_msg (lg1 )
2592+ with must_raise (ValueError , msg = msg ):
2593+ agg_arr .filter (b = lg1 )
2594+ with must_raise (ValueError , msg = msg ):
2595+ agg_arr .filter (b = (lg1 , lg2 ))
25922596
25932597 # 1.b) by string (name of groups)
25942598 assert agg_arr .filter (b = 'lg1' ).shape == (19 , 2 , 6 )
0 commit comments