Skip to content

Commit 9318418

Browse files
author
Lucas Einig
committed
Changes for Readthedocs
1 parent ace7441 commit 9318418

File tree

6 files changed

+150
-106
lines changed

6 files changed

+150
-106
lines changed

examples/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# California housing inputs and outputs
22
california-housing/data-out
33
california-housing/data-out-continuous
4+
5+
# img backups
6+
img/*.bkp

examples/california-housing.ipynb

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
"import os\n",
2121
"import sys\n",
2222
"\n",
23-
"abspath = os.path.abspath(\"\")\n",
24-
"sys.path.insert(0, os.path.join(abspath, \"..\", \"..\"))\n",
25-
"\n",
2623
"import yaml\n",
2724
"import itertools as itt\n",
2825
"\n",
2926
"import numpy as np\n",
3027
"import matplotlib.pyplot as plt\n",
3128
"from sklearn import datasets\n",
3229
"\n",
30+
"sys.path.append(os.path.join(os.path.abspath(\"\"), \"..\"))\n",
31+
"\n",
3332
"from infovar import DiscreteHandler, ContinuousHandler, StandardGetter\n",
3433
"from infovar.stats.ranking import prob_higher"
3534
]

examples/continuous-handler.ipynb

+14-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,26 @@
2020
"import numpy as np\n",
2121
"import matplotlib.pyplot as plt\n",
2222
"\n",
23+
"sys.path.append(os.path.join(os.path.abspath(\"\"), \"..\"))\n",
24+
"\n",
2325
"from infovar import ContinuousHandler, StandardGetter"
2426
]
2527
},
2628
{
2729
"cell_type": "markdown",
2830
"metadata": {},
29-
"source": []
31+
"source": [
32+
"## Context"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": null,
38+
"metadata": {},
39+
"outputs": [],
40+
"source": [
41+
"# Work in progress"
42+
]
3043
}
3144
],
3245
"metadata": {

examples/discrete-handler.ipynb

+55-94
Large diffs are not rendered by default.

examples/img/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Images used in notebooks in the `examples` directory. If you modify these images, remember to update the `docs/img` directory with the new images, so as to update the documentation as well.

infovar/handlers/discrete_handler.py

+75-8
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def _compute_stat(
329329
raise_error: bool = True,
330330
) -> Dict[str, Any]:
331331
"""
332+
TODO
332333
Modifies in-place the `entry` dictionnary.
333334
Adds or changes the three following entries of `entry`:
334335
- {stat}: computed only if current value is None.
@@ -595,11 +596,25 @@ def __str__(self):
595596

596597
# Helpers
597598

599+
@staticmethod
598600
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]]
600602
) -> Optional[List[Dict]]:
601603
"""
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.
603618
"""
604619
_x_names = set(x_names)
605620
for _item in data:
@@ -608,11 +623,25 @@ def _get_variables_content(
608623
return item
609624
return None
610625

626+
@staticmethod
611627
def _get_restriction_content(
612-
self, restr: str, data: List[Dict[str, Any]]
628+
restr: str, data: List[Dict[str, Any]]
613629
) -> Dict[str, Any]:
614630
"""
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.
616645
"""
617646
for _item in data:
618647
if _item["restriction"] == restr:
@@ -625,7 +654,21 @@ def _index_of(
625654
ls: Sequence[Dict[str, Sequence]], value: Sequence, key: str
626655
) -> Optional[int]:
627656
"""
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.
629672
"""
630673
try:
631674
index = [tuple(item[key]) for item in ls].index(tuple(value))
@@ -638,20 +681,44 @@ def _index_of_ranges(
638681
ls: Sequence[Dict[str, Dict]], value: Sequence, key: str
639682
) -> Optional[int]:
640683
"""
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_
642699
"""
643700
try:
644701
index = [item[key] for item in ls].index(value)
645702
except ValueError:
646703
index = None
647704
return index
648705

706+
@staticmethod
649707
def _check_inputs(
650-
self,
651708
inputs_dict: Dict[str, Any],
652709
) -> Dict[str, Any]:
653710
"""
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.
655722
"""
656723
inputs_dict = inputs_dict.copy()
657724
if "uncertainty" not in inputs_dict:

0 commit comments

Comments
 (0)