diff --git a/statannot/statannot.py b/statannot/statannot.py index 05e3009..2c618f0 100644 --- a/statannot/statannot.py +++ b/statannot/statannot.py @@ -468,10 +468,10 @@ def get_box_data(box_plotter, boxName): # Build the list of box data structure pairs box_struct_pairs = [] for i_box_pair, (box1, box2) in enumerate(box_pairs): - valid = box1 in box_names and box2 in box_names - if not valid: - raise ValueError("box_pairs contains an invalid box pair.") - pass + + if box1 not in box_names or box2 not in box_names: + raise ValueError(f"box_pairs contains an invalid box pair, expected {box1 if not box1 in box_names else box2} in {box_names}") + # i_box_pair will keep track of the original order of the box pairs. box_struct1 = dict(box_structs_dic[box1], i_box_pair=i_box_pair) box_struct2 = dict(box_structs_dic[box2], i_box_pair=i_box_pair)