@@ -329,6 +329,7 @@ def _compute_stat(
329
329
raise_error : bool = True ,
330
330
) -> Dict [str , Any ]:
331
331
"""
332
+ TODO
332
333
Modifies in-place the `entry` dictionnary.
333
334
Adds or changes the three following entries of `entry`:
334
335
- {stat}: computed only if current value is None.
@@ -595,11 +596,25 @@ def __str__(self):
595
596
596
597
# Helpers
597
598
599
+ @staticmethod
598
600
def _get_variables_content (
599
- self , x_names : List [str ], data : List [Dict [str , Any ]]
601
+ x_names : List [str ], data : List [Dict [str , Any ]]
600
602
) -> Optional [List [Dict ]]:
601
603
"""
602
- TODO
604
+ Returns the entry in `data` that match variable names `x_names`.
605
+ If no entry matches, returns None.
606
+
607
+ Parameters
608
+ ----------
609
+ x_names : List[str]
610
+ Variable names.
611
+ data : List[Dict[str, Any]]
612
+ List of entries.
613
+
614
+ Returns
615
+ -------
616
+ Optional[List[Dict]]
617
+ Matching entry, if exists. Else None.
603
618
"""
604
619
_x_names = set (x_names )
605
620
for _item in data :
@@ -608,11 +623,25 @@ def _get_variables_content(
608
623
return item
609
624
return None
610
625
626
+ @staticmethod
611
627
def _get_restriction_content (
612
- self , restr : str , data : List [Dict [str , Any ]]
628
+ restr : str , data : List [Dict [str , Any ]]
613
629
) -> Dict [str , Any ]:
614
630
"""
615
- TODO
631
+ Returns the entry in `data` that match restriction `restr`.
632
+ If no entry matches, returns None.
633
+
634
+ Parameters
635
+ ----------
636
+ restr : str
637
+ Restriction name.
638
+ data : List[Dict[str, Any]]
639
+ List of entries.
640
+
641
+ Returns
642
+ -------
643
+ Dict[str, Any]
644
+ Matching entry, if exists. Else None.
616
645
"""
617
646
for _item in data :
618
647
if _item ["restriction" ] == restr :
@@ -625,7 +654,21 @@ def _index_of(
625
654
ls : Sequence [Dict [str , Sequence ]], value : Sequence , key : str
626
655
) -> Optional [int ]:
627
656
"""
628
- Order of element and case are important.
657
+ Returns the index `i` of list `ls` with `ls[i][key] == value` where `value` is a list. Order of elements and case are important.
658
+
659
+ Parameters
660
+ ----------
661
+ ls : Sequence[Dict[str, Sequence]]
662
+ List of dictionnaries.
663
+ value : Sequence
664
+ Sequence to find.
665
+ key : str
666
+ Key of dictionnary to access `value`.
667
+
668
+ Returns
669
+ -------
670
+ Optional[int]
671
+ Index, if exists. Else None.
629
672
"""
630
673
try :
631
674
index = [tuple (item [key ]) for item in ls ].index (tuple (value ))
@@ -638,20 +681,44 @@ def _index_of_ranges(
638
681
ls : Sequence [Dict [str , Dict ]], value : Sequence , key : str
639
682
) -> Optional [int ]:
640
683
"""
641
- Order of element and case are important.
684
+ Returns the index `i` of list `ls` with `ls[i][key] == value` where `value` is a list. Order of elements and case are important.
685
+
686
+ Parameters
687
+ ----------
688
+ ls : Sequence[Dict[str, Dict]]
689
+ List of dictionnaries.
690
+ value : Sequence
691
+ Sequence to find.
692
+ key : str
693
+ Key of dictionnary to access `value`.
694
+
695
+ Returns
696
+ -------
697
+ Optional[int]
698
+ _description_
642
699
"""
643
700
try :
644
701
index = [item [key ] for item in ls ].index (value )
645
702
except ValueError :
646
703
index = None
647
704
return index
648
705
706
+ @staticmethod
649
707
def _check_inputs (
650
- self ,
651
708
inputs_dict : Dict [str , Any ],
652
709
) -> Dict [str , Any ]:
653
710
"""
654
- TODO
711
+ Verifies the validity of `inputs_dict`. If necessary, can return a modified version of it. It does not modify the argument in-place.
712
+
713
+ Parameters
714
+ ----------
715
+ inputs_dict : Dict[str, Any]
716
+ Settings dictionnary for statistics computation.
717
+
718
+ Returns
719
+ -------
720
+ Dict[str, Any]
721
+ Potentially amended settings dictionnary.
655
722
"""
656
723
inputs_dict = inputs_dict .copy ()
657
724
if "uncertainty" not in inputs_dict :
0 commit comments