arviz 0.23.3__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. arviz/__init__.py +52 -367
  2. arviz-1.0.0rc0.dist-info/METADATA +182 -0
  3. arviz-1.0.0rc0.dist-info/RECORD +5 -0
  4. {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
  5. {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
  6. arviz/data/__init__.py +0 -55
  7. arviz/data/base.py +0 -596
  8. arviz/data/converters.py +0 -203
  9. arviz/data/datasets.py +0 -161
  10. arviz/data/example_data/code/radon/radon.json +0 -326
  11. arviz/data/example_data/data/centered_eight.nc +0 -0
  12. arviz/data/example_data/data/non_centered_eight.nc +0 -0
  13. arviz/data/example_data/data_local.json +0 -12
  14. arviz/data/example_data/data_remote.json +0 -58
  15. arviz/data/inference_data.py +0 -2386
  16. arviz/data/io_beanmachine.py +0 -112
  17. arviz/data/io_cmdstan.py +0 -1036
  18. arviz/data/io_cmdstanpy.py +0 -1233
  19. arviz/data/io_datatree.py +0 -23
  20. arviz/data/io_dict.py +0 -462
  21. arviz/data/io_emcee.py +0 -317
  22. arviz/data/io_json.py +0 -54
  23. arviz/data/io_netcdf.py +0 -68
  24. arviz/data/io_numpyro.py +0 -497
  25. arviz/data/io_pyjags.py +0 -378
  26. arviz/data/io_pyro.py +0 -333
  27. arviz/data/io_pystan.py +0 -1095
  28. arviz/data/io_zarr.py +0 -46
  29. arviz/data/utils.py +0 -139
  30. arviz/labels.py +0 -210
  31. arviz/plots/__init__.py +0 -61
  32. arviz/plots/autocorrplot.py +0 -171
  33. arviz/plots/backends/__init__.py +0 -223
  34. arviz/plots/backends/bokeh/__init__.py +0 -166
  35. arviz/plots/backends/bokeh/autocorrplot.py +0 -101
  36. arviz/plots/backends/bokeh/bfplot.py +0 -23
  37. arviz/plots/backends/bokeh/bpvplot.py +0 -193
  38. arviz/plots/backends/bokeh/compareplot.py +0 -167
  39. arviz/plots/backends/bokeh/densityplot.py +0 -239
  40. arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
  41. arviz/plots/backends/bokeh/distplot.py +0 -183
  42. arviz/plots/backends/bokeh/dotplot.py +0 -113
  43. arviz/plots/backends/bokeh/ecdfplot.py +0 -73
  44. arviz/plots/backends/bokeh/elpdplot.py +0 -203
  45. arviz/plots/backends/bokeh/energyplot.py +0 -155
  46. arviz/plots/backends/bokeh/essplot.py +0 -176
  47. arviz/plots/backends/bokeh/forestplot.py +0 -772
  48. arviz/plots/backends/bokeh/hdiplot.py +0 -54
  49. arviz/plots/backends/bokeh/kdeplot.py +0 -268
  50. arviz/plots/backends/bokeh/khatplot.py +0 -163
  51. arviz/plots/backends/bokeh/lmplot.py +0 -185
  52. arviz/plots/backends/bokeh/loopitplot.py +0 -211
  53. arviz/plots/backends/bokeh/mcseplot.py +0 -184
  54. arviz/plots/backends/bokeh/pairplot.py +0 -328
  55. arviz/plots/backends/bokeh/parallelplot.py +0 -81
  56. arviz/plots/backends/bokeh/posteriorplot.py +0 -324
  57. arviz/plots/backends/bokeh/ppcplot.py +0 -379
  58. arviz/plots/backends/bokeh/rankplot.py +0 -149
  59. arviz/plots/backends/bokeh/separationplot.py +0 -107
  60. arviz/plots/backends/bokeh/traceplot.py +0 -436
  61. arviz/plots/backends/bokeh/violinplot.py +0 -164
  62. arviz/plots/backends/matplotlib/__init__.py +0 -124
  63. arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
  64. arviz/plots/backends/matplotlib/bfplot.py +0 -78
  65. arviz/plots/backends/matplotlib/bpvplot.py +0 -177
  66. arviz/plots/backends/matplotlib/compareplot.py +0 -135
  67. arviz/plots/backends/matplotlib/densityplot.py +0 -194
  68. arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
  69. arviz/plots/backends/matplotlib/distplot.py +0 -178
  70. arviz/plots/backends/matplotlib/dotplot.py +0 -116
  71. arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
  72. arviz/plots/backends/matplotlib/elpdplot.py +0 -189
  73. arviz/plots/backends/matplotlib/energyplot.py +0 -113
  74. arviz/plots/backends/matplotlib/essplot.py +0 -180
  75. arviz/plots/backends/matplotlib/forestplot.py +0 -656
  76. arviz/plots/backends/matplotlib/hdiplot.py +0 -48
  77. arviz/plots/backends/matplotlib/kdeplot.py +0 -177
  78. arviz/plots/backends/matplotlib/khatplot.py +0 -241
  79. arviz/plots/backends/matplotlib/lmplot.py +0 -149
  80. arviz/plots/backends/matplotlib/loopitplot.py +0 -144
  81. arviz/plots/backends/matplotlib/mcseplot.py +0 -161
  82. arviz/plots/backends/matplotlib/pairplot.py +0 -355
  83. arviz/plots/backends/matplotlib/parallelplot.py +0 -58
  84. arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
  85. arviz/plots/backends/matplotlib/ppcplot.py +0 -478
  86. arviz/plots/backends/matplotlib/rankplot.py +0 -119
  87. arviz/plots/backends/matplotlib/separationplot.py +0 -97
  88. arviz/plots/backends/matplotlib/traceplot.py +0 -526
  89. arviz/plots/backends/matplotlib/tsplot.py +0 -121
  90. arviz/plots/backends/matplotlib/violinplot.py +0 -148
  91. arviz/plots/bfplot.py +0 -128
  92. arviz/plots/bpvplot.py +0 -308
  93. arviz/plots/compareplot.py +0 -177
  94. arviz/plots/densityplot.py +0 -284
  95. arviz/plots/distcomparisonplot.py +0 -197
  96. arviz/plots/distplot.py +0 -233
  97. arviz/plots/dotplot.py +0 -233
  98. arviz/plots/ecdfplot.py +0 -372
  99. arviz/plots/elpdplot.py +0 -174
  100. arviz/plots/energyplot.py +0 -147
  101. arviz/plots/essplot.py +0 -319
  102. arviz/plots/forestplot.py +0 -304
  103. arviz/plots/hdiplot.py +0 -211
  104. arviz/plots/kdeplot.py +0 -357
  105. arviz/plots/khatplot.py +0 -236
  106. arviz/plots/lmplot.py +0 -380
  107. arviz/plots/loopitplot.py +0 -224
  108. arviz/plots/mcseplot.py +0 -194
  109. arviz/plots/pairplot.py +0 -281
  110. arviz/plots/parallelplot.py +0 -204
  111. arviz/plots/plot_utils.py +0 -599
  112. arviz/plots/posteriorplot.py +0 -298
  113. arviz/plots/ppcplot.py +0 -369
  114. arviz/plots/rankplot.py +0 -232
  115. arviz/plots/separationplot.py +0 -167
  116. arviz/plots/styles/arviz-bluish.mplstyle +0 -1
  117. arviz/plots/styles/arviz-brownish.mplstyle +0 -1
  118. arviz/plots/styles/arviz-colors.mplstyle +0 -2
  119. arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
  120. arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
  121. arviz/plots/styles/arviz-doc.mplstyle +0 -88
  122. arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
  123. arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
  124. arviz/plots/styles/arviz-greenish.mplstyle +0 -1
  125. arviz/plots/styles/arviz-orangish.mplstyle +0 -1
  126. arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
  127. arviz/plots/styles/arviz-purplish.mplstyle +0 -1
  128. arviz/plots/styles/arviz-redish.mplstyle +0 -1
  129. arviz/plots/styles/arviz-royish.mplstyle +0 -1
  130. arviz/plots/styles/arviz-viridish.mplstyle +0 -1
  131. arviz/plots/styles/arviz-white.mplstyle +0 -40
  132. arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
  133. arviz/plots/traceplot.py +0 -273
  134. arviz/plots/tsplot.py +0 -440
  135. arviz/plots/violinplot.py +0 -192
  136. arviz/preview.py +0 -58
  137. arviz/py.typed +0 -0
  138. arviz/rcparams.py +0 -606
  139. arviz/sel_utils.py +0 -223
  140. arviz/static/css/style.css +0 -340
  141. arviz/static/html/icons-svg-inline.html +0 -15
  142. arviz/stats/__init__.py +0 -37
  143. arviz/stats/density_utils.py +0 -1013
  144. arviz/stats/diagnostics.py +0 -1013
  145. arviz/stats/ecdf_utils.py +0 -324
  146. arviz/stats/stats.py +0 -2422
  147. arviz/stats/stats_refitting.py +0 -119
  148. arviz/stats/stats_utils.py +0 -609
  149. arviz/tests/__init__.py +0 -1
  150. arviz/tests/base_tests/__init__.py +0 -1
  151. arviz/tests/base_tests/test_data.py +0 -1679
  152. arviz/tests/base_tests/test_data_zarr.py +0 -143
  153. arviz/tests/base_tests/test_diagnostics.py +0 -511
  154. arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
  155. arviz/tests/base_tests/test_helpers.py +0 -18
  156. arviz/tests/base_tests/test_labels.py +0 -69
  157. arviz/tests/base_tests/test_plot_utils.py +0 -342
  158. arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
  159. arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
  160. arviz/tests/base_tests/test_rcparams.py +0 -317
  161. arviz/tests/base_tests/test_stats.py +0 -925
  162. arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
  163. arviz/tests/base_tests/test_stats_numba.py +0 -45
  164. arviz/tests/base_tests/test_stats_utils.py +0 -384
  165. arviz/tests/base_tests/test_utils.py +0 -376
  166. arviz/tests/base_tests/test_utils_numba.py +0 -87
  167. arviz/tests/conftest.py +0 -46
  168. arviz/tests/external_tests/__init__.py +0 -1
  169. arviz/tests/external_tests/test_data_beanmachine.py +0 -78
  170. arviz/tests/external_tests/test_data_cmdstan.py +0 -398
  171. arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
  172. arviz/tests/external_tests/test_data_emcee.py +0 -166
  173. arviz/tests/external_tests/test_data_numpyro.py +0 -434
  174. arviz/tests/external_tests/test_data_pyjags.py +0 -119
  175. arviz/tests/external_tests/test_data_pyro.py +0 -260
  176. arviz/tests/external_tests/test_data_pystan.py +0 -307
  177. arviz/tests/helpers.py +0 -677
  178. arviz/utils.py +0 -773
  179. arviz/wrappers/__init__.py +0 -13
  180. arviz/wrappers/base.py +0 -236
  181. arviz/wrappers/wrap_pymc.py +0 -36
  182. arviz/wrappers/wrap_stan.py +0 -148
  183. arviz-0.23.3.dist-info/METADATA +0 -264
  184. arviz-0.23.3.dist-info/RECORD +0 -183
  185. arviz-0.23.3.dist-info/top_level.txt +0 -1
arviz/data/io_zarr.py DELETED
@@ -1,46 +0,0 @@
1
- """Input and output support for zarr data."""
2
-
3
- from .converters import convert_to_inference_data
4
- from .inference_data import InferenceData
5
-
6
-
7
- def from_zarr(store):
8
- return InferenceData.from_zarr(store)
9
-
10
-
11
- from_zarr.__doc__ = InferenceData.from_zarr.__doc__
12
-
13
-
14
- def to_zarr(data, store=None, **kwargs):
15
- """
16
- Convert data to zarr, optionally saving to disk if ``store`` is provided.
17
-
18
- The zarr storage is using the same group names as the InferenceData.
19
-
20
- Parameters
21
- ----------
22
- store : zarr.storage, MutableMapping or str, optional
23
- Zarr storage class or path to desired DirectoryStore.
24
- Default (None) a store is created in a temporary directory.
25
- **kwargs : dict, optional
26
- Passed to :py:func:`convert_to_inference_data`.
27
-
28
- Returns
29
- -------
30
- zarr.hierarchy.group
31
- A zarr hierarchy group containing the InferenceData.
32
-
33
- Raises
34
- ------
35
- TypeError
36
- If no valid store is found.
37
-
38
-
39
- References
40
- ----------
41
- https://zarr.readthedocs.io/
42
-
43
- """
44
- inference_data = convert_to_inference_data(data, **kwargs)
45
- zarr_group = inference_data.to_zarr(store=store)
46
- return zarr_group
arviz/data/utils.py DELETED
@@ -1,139 +0,0 @@
1
- """Data specific utilities."""
2
-
3
- import warnings
4
- import numpy as np
5
-
6
- from ..utils import _var_names
7
- from .converters import convert_to_dataset
8
-
9
-
10
- def extract_dataset(
11
- data,
12
- group="posterior",
13
- combined=True,
14
- var_names=None,
15
- filter_vars=None,
16
- num_samples=None,
17
- rng=None,
18
- ):
19
- """Extract an InferenceData group or subset of it.
20
-
21
- .. deprecated:: 0.13
22
- `extract_dataset` will be removed in ArviZ 0.14, it is replaced by
23
- `extract` because the latter allows to obtain both DataSets and DataArrays.
24
- """
25
- warnings.warn(
26
- "extract_dataset has been deprecated, please use extract", FutureWarning, stacklevel=2
27
- )
28
-
29
- data = extract(
30
- data=data,
31
- group=group,
32
- combined=combined,
33
- var_names=var_names,
34
- filter_vars=filter_vars,
35
- num_samples=num_samples,
36
- rng=rng,
37
- )
38
- return data
39
-
40
-
41
- def extract(
42
- data,
43
- group="posterior",
44
- combined=True,
45
- var_names=None,
46
- filter_vars=None,
47
- num_samples=None,
48
- keep_dataset=False,
49
- rng=None,
50
- ):
51
- """Extract an InferenceData group or subset of it.
52
-
53
- Parameters
54
- ----------
55
- idata : InferenceData or InferenceData_like
56
- InferenceData from which to extract the data.
57
- group : str, optional
58
- Which InferenceData data group to extract data from.
59
- combined : bool, optional
60
- Combine ``chain`` and ``draw`` dimensions into ``sample``. Won't work if
61
- a dimension named ``sample`` already exists.
62
- var_names : str or list of str, optional
63
- Variables to be extracted. Prefix the variables by `~` when you want to exclude them.
64
- filter_vars: {None, "like", "regex"}, optional
65
- If `None` (default), interpret var_names as the real variables names. If "like",
66
- interpret var_names as substrings of the real variables names. If "regex",
67
- interpret var_names as regular expressions on the real variables names. A la
68
- `pandas.filter`.
69
- Like with plotting, sometimes it's easier to subset saying what to exclude
70
- instead of what to include
71
- num_samples : int, optional
72
- Extract only a subset of the samples. Only valid if ``combined=True``
73
- keep_dataset : bool, optional
74
- If true, always return a DataSet. If false (default) return a DataArray
75
- when there is a single variable.
76
- rng : bool, int, numpy.Generator, optional
77
- Shuffle the samples, only valid if ``combined=True``. By default,
78
- samples are shuffled if ``num_samples`` is not ``None``, and are left
79
- in the same order otherwise. This ensures that subsetting the samples doesn't return
80
- only samples from a single chain and consecutive draws.
81
-
82
- Returns
83
- -------
84
- xarray.DataArray or xarray.Dataset
85
-
86
- Examples
87
- --------
88
- The default behaviour is to return the posterior group after stacking the chain and
89
- draw dimensions.
90
-
91
- .. jupyter-execute::
92
-
93
- import arviz as az
94
- idata = az.load_arviz_data("centered_eight")
95
- az.extract(idata)
96
-
97
- You can also indicate a subset to be returned, but in variables and in samples:
98
-
99
- .. jupyter-execute::
100
-
101
- az.extract(idata, var_names="theta", num_samples=100)
102
-
103
- To keep the chain and draw dimensions, use ``combined=False``.
104
-
105
- .. jupyter-execute::
106
-
107
- az.extract(idata, group="prior", combined=False)
108
-
109
- """
110
- if num_samples is not None and not combined:
111
- raise ValueError("num_samples is only compatible with combined=True")
112
- if rng is None:
113
- rng = num_samples is not None
114
- if rng is not False and not combined:
115
- raise ValueError("rng is only compatible with combined=True")
116
- data = convert_to_dataset(data, group=group)
117
- var_names = _var_names(var_names, data, filter_vars)
118
- if var_names is not None:
119
- if len(var_names) == 1 and not keep_dataset:
120
- var_names = var_names[0]
121
- data = data[var_names]
122
- if combined:
123
- data = data.stack(sample=("chain", "draw"))
124
- # 0 is a valid seed se we need to check for rng being exactly boolean
125
- if rng is not False:
126
- if rng is True:
127
- rng = np.random.default_rng()
128
- # default_rng takes ints or sequences of ints
129
- try:
130
- rng = np.random.default_rng(rng)
131
- random_subset = rng.permutation(np.arange(len(data["sample"])))
132
- except TypeError as err:
133
- raise TypeError("Unable to initializate numpy random Generator from rng") from err
134
- except AttributeError as err:
135
- raise AttributeError("Unable to use rng to generate a permutation") from err
136
- data = data.isel(sample=random_subset)
137
- if num_samples is not None:
138
- data = data.isel(sample=slice(None, num_samples))
139
- return data
arviz/labels.py DELETED
@@ -1,210 +0,0 @@
1
- # pylint: disable=unused-argument
2
- """Utilities to generate labels from xarray objects."""
3
- from typing import Union
4
-
5
- __all__ = [
6
- "mix_labellers",
7
- "BaseLabeller",
8
- "DimCoordLabeller",
9
- "DimIdxLabeller",
10
- "MapLabeller",
11
- "NoVarLabeller",
12
- "NoModelLabeller",
13
- ]
14
-
15
-
16
- def mix_labellers(labellers, class_name="MixtureLabeller"):
17
- """Combine Labeller classes dynamically.
18
-
19
- The Labeller class aims to split plot labeling in ArviZ into atomic tasks to maximize
20
- extensibility, and the few classes provided are designed with small deviations
21
- from the base class, in many cases only one method is modified by the child class.
22
- It is to be expected then to want to use multiple classes "at once".
23
-
24
- This functions helps combine classes dynamically.
25
-
26
- For a general overview of ArviZ label customization, including
27
- ``mix_labellers``, see the :ref:`label_guide` page.
28
-
29
- Parameters
30
- ----------
31
- labellers : iterable of types
32
- Iterable of Labeller types to combine
33
- class_name : str, optional
34
- The name of the generated class
35
-
36
- Returns
37
- -------
38
- type
39
- Mixture class object. **It is not initialized**, and it should be
40
- initialized before passing it to ArviZ functions.
41
-
42
- Examples
43
- --------
44
- Combine the :class:`~arviz.labels.DimCoordLabeller` with the
45
- :class:`~arviz.labels.MapLabeller` to generate labels in the style of the
46
- ``DimCoordLabeller`` but using the mappings defined by ``MapLabeller``.
47
- Note that this works even though both modify the same methods because
48
- ``MapLabeller`` implements the mapping and then calls `super().method`.
49
-
50
- .. jupyter-execute::
51
-
52
- from arviz.labels import mix_labellers, DimCoordLabeller, MapLabeller
53
- l1 = DimCoordLabeller()
54
- sel = {"dim1": "a", "dim2": "top"}
55
- print(f"Output of DimCoordLabeller alone > {l1.sel_to_str(sel, sel)}")
56
- l2 = MapLabeller(dim_map={"dim1": "$d_1$", "dim2": r"$d_2$"})
57
- print(f"Output of MapLabeller alone > {l2.sel_to_str(sel, sel)}")
58
- l3 = mix_labellers(
59
- (MapLabeller, DimCoordLabeller)
60
- )(dim_map={"dim1": "$d_1$", "dim2": r"$d_2$"})
61
- print(f"Output of mixture labeller > {l3.sel_to_str(sel, sel)}")
62
-
63
- We can see how the mappings are taken into account as well as the dim+coord style. However,
64
- he order in the ``labellers`` arg iterator is important! See for yourself:
65
-
66
- .. jupyter-execute::
67
-
68
- l4 = mix_labellers(
69
- (DimCoordLabeller, MapLabeller)
70
- )(dim_map={"dim1": "$d_1$", "dim2": r"$d_2$"})
71
- print(f"Output of inverted mixture labeller > {l4.sel_to_str(sel, sel)}")
72
-
73
- """
74
- return type(class_name, labellers, {})
75
-
76
-
77
- class BaseLabeller:
78
- """WIP."""
79
-
80
- def dim_coord_to_str(self, dim, coord_val, coord_idx):
81
- """WIP."""
82
- return f"{coord_val}"
83
-
84
- def sel_to_str(self, sel: dict, isel: dict):
85
- """WIP."""
86
- if sel:
87
- return ", ".join(
88
- [
89
- self.dim_coord_to_str(dim, v, i)
90
- for (dim, v), (_, i) in zip(sel.items(), isel.items())
91
- ]
92
- )
93
- return ""
94
-
95
- def var_name_to_str(self, var_name: Union[str, None]):
96
- """WIP."""
97
- return var_name
98
-
99
- def var_pp_to_str(self, var_name, pp_var_name):
100
- """WIP."""
101
- var_name_str = self.var_name_to_str(var_name)
102
- pp_var_name_str = self.var_name_to_str(pp_var_name)
103
- if var_name_str == pp_var_name_str:
104
- return f"{var_name_str}"
105
- return f"{var_name_str} / {pp_var_name_str}"
106
-
107
- def model_name_to_str(self, model_name):
108
- """WIP."""
109
- return model_name
110
-
111
- def make_label_vert(self, var_name: Union[str, None], sel: dict, isel: dict):
112
- """WIP."""
113
- var_name_str = self.var_name_to_str(var_name)
114
- sel_str = self.sel_to_str(sel, isel)
115
- if not sel_str:
116
- return "" if var_name_str is None else var_name_str
117
- if var_name_str is None:
118
- return sel_str
119
- return f"{var_name_str}\n{sel_str}"
120
-
121
- def make_label_flat(self, var_name: str, sel: dict, isel: dict):
122
- """WIP."""
123
- var_name_str = self.var_name_to_str(var_name)
124
- sel_str = self.sel_to_str(sel, isel)
125
- if not sel_str:
126
- return "" if var_name_str is None else var_name_str
127
- if var_name_str is None:
128
- return sel_str
129
- return f"{var_name_str}[{sel_str}]"
130
-
131
- def make_pp_label(self, var_name, pp_var_name, sel, isel):
132
- """WIP."""
133
- names = self.var_pp_to_str(var_name, pp_var_name)
134
- return self.make_label_vert(names, sel, isel)
135
-
136
- def make_model_label(self, model_name, label):
137
- """WIP."""
138
- model_name_str = self.model_name_to_str(model_name)
139
- if model_name_str is None:
140
- return label
141
- if label is None or label == "":
142
- return model_name_str
143
- return f"{model_name_str}: {label}"
144
-
145
-
146
- class DimCoordLabeller(BaseLabeller):
147
- """WIP."""
148
-
149
- def dim_coord_to_str(self, dim, coord_val, coord_idx):
150
- """WIP."""
151
- return f"{dim}: {coord_val}"
152
-
153
-
154
- class IdxLabeller(BaseLabeller):
155
- """WIP."""
156
-
157
- def dim_coord_to_str(self, dim, coord_val, coord_idx):
158
- """WIP."""
159
- return f"{coord_idx}"
160
-
161
-
162
- class DimIdxLabeller(BaseLabeller):
163
- """WIP."""
164
-
165
- def dim_coord_to_str(self, dim, coord_val, coord_idx):
166
- """WIP."""
167
- return f"{dim}#{coord_idx}"
168
-
169
-
170
- class MapLabeller(BaseLabeller):
171
- """WIP."""
172
-
173
- def __init__(self, var_name_map=None, dim_map=None, coord_map=None, model_name_map=None):
174
- """WIP."""
175
- self.var_name_map = {} if var_name_map is None else var_name_map
176
- self.dim_map = {} if dim_map is None else dim_map
177
- self.coord_map = {} if coord_map is None else coord_map
178
- self.model_name_map = {} if model_name_map is None else model_name_map
179
-
180
- def dim_coord_to_str(self, dim, coord_val, coord_idx):
181
- """WIP."""
182
- dim_str = self.dim_map.get(dim, dim)
183
- coord_str = self.coord_map.get(dim, {}).get(coord_val, coord_val)
184
- return super().dim_coord_to_str(dim_str, coord_str, coord_idx)
185
-
186
- def var_name_to_str(self, var_name):
187
- """WIP."""
188
- var_name_str = self.var_name_map.get(var_name, var_name)
189
- return super().var_name_to_str(var_name_str)
190
-
191
- def model_name_to_str(self, model_name):
192
- """WIP."""
193
- model_name_str = self.var_name_map.get(model_name, model_name)
194
- return super().model_name_to_str(model_name_str)
195
-
196
-
197
- class NoVarLabeller(BaseLabeller):
198
- """WIP."""
199
-
200
- def var_name_to_str(self, var_name):
201
- """WIP."""
202
- return None
203
-
204
-
205
- class NoModelLabeller(BaseLabeller):
206
- """WIP."""
207
-
208
- def make_model_label(self, model_name, label):
209
- """WIP."""
210
- return label
arviz/plots/__init__.py DELETED
@@ -1,61 +0,0 @@
1
- """Plotting functions."""
2
-
3
- from .autocorrplot import plot_autocorr
4
- from .bpvplot import plot_bpv
5
- from .bfplot import plot_bf
6
- from .compareplot import plot_compare
7
- from .densityplot import plot_density
8
- from .distcomparisonplot import plot_dist_comparison
9
- from .distplot import plot_dist
10
- from .dotplot import plot_dot
11
- from .ecdfplot import plot_ecdf
12
- from .elpdplot import plot_elpd
13
- from .energyplot import plot_energy
14
- from .essplot import plot_ess
15
- from .forestplot import plot_forest
16
- from .hdiplot import plot_hdi
17
- from .kdeplot import plot_kde
18
- from .khatplot import plot_khat
19
- from .lmplot import plot_lm
20
- from .loopitplot import plot_loo_pit
21
- from .mcseplot import plot_mcse
22
- from .pairplot import plot_pair
23
- from .parallelplot import plot_parallel
24
- from .posteriorplot import plot_posterior
25
- from .ppcplot import plot_ppc
26
- from .rankplot import plot_rank
27
- from .separationplot import plot_separation
28
- from .traceplot import plot_trace
29
- from .tsplot import plot_ts
30
- from .violinplot import plot_violin
31
-
32
- __all__ = [
33
- "plot_autocorr",
34
- "plot_bpv",
35
- "plot_bf",
36
- "plot_compare",
37
- "plot_density",
38
- "plot_dist",
39
- "plot_dot",
40
- "plot_ecdf",
41
- "plot_elpd",
42
- "plot_energy",
43
- "plot_ess",
44
- "plot_forest",
45
- "plot_hdi",
46
- "plot_kde",
47
- "plot_khat",
48
- "plot_lm",
49
- "plot_loo_pit",
50
- "plot_mcse",
51
- "plot_pair",
52
- "plot_parallel",
53
- "plot_posterior",
54
- "plot_ppc",
55
- "plot_dist_comparison",
56
- "plot_rank",
57
- "plot_trace",
58
- "plot_ts",
59
- "plot_violin",
60
- "plot_separation",
61
- ]
@@ -1,171 +0,0 @@
1
- """Autocorrelation plot of data."""
2
-
3
- from ..data import convert_to_dataset
4
- from ..labels import BaseLabeller
5
- from ..sel_utils import xarray_var_iter
6
- from ..rcparams import rcParams
7
- from ..utils import _var_names, get_coords
8
- from .plot_utils import default_grid, filter_plotters_list, get_plotting_function
9
-
10
-
11
- def plot_autocorr(
12
- data,
13
- var_names=None,
14
- filter_vars=None,
15
- max_lag=None,
16
- combined=False,
17
- coords=None,
18
- grid=None,
19
- figsize=None,
20
- textsize=None,
21
- labeller=None,
22
- ax=None,
23
- backend=None,
24
- backend_config=None,
25
- backend_kwargs=None,
26
- show=None,
27
- ):
28
- r"""Bar plot of the autocorrelation function (ACF) for a sequence of data.
29
-
30
- The ACF plots are helpful as a convergence diagnostic for posteriors from MCMC
31
- samples which display autocorrelation.
32
-
33
- Parameters
34
- ----------
35
- data : InferenceData
36
- Any object that can be converted to an :class:`arviz.InferenceData` object
37
- refer to documentation of :func:`arviz.convert_to_dataset` for details
38
- var_names : list of str, optional
39
- Variables to be plotted. Prefix the variables by ``~`` when you want to exclude
40
- them from the plot. See :ref:`this section <common_var_names>` for usage examples.
41
- filter_vars : {None, "like", "regex"}, default None
42
- If `None` (default), interpret `var_names` as the real variables names. If "like",
43
- interpret `var_names` as substrings of the real variables names. If "regex",
44
- interpret `var_names` as regular expressions on the real variables names. See
45
- :ref:`this section <common_filter_vars>` for usage examples.
46
- coords: mapping, optional
47
- Coordinates of var_names to be plotted. Passed to :meth:`xarray.Dataset.sel`
48
- max_lag : int, optional
49
- Maximum lag to calculate autocorrelation. By Default, the plot displays the
50
- first 100 lag or the total number of draws, whichever is smaller.
51
- combined : bool, default False
52
- Flag for combining multiple chains into a single chain. If False, chains will be
53
- plotted separately.
54
- grid : tuple, optional
55
- Number of rows and columns. Defaults to None, the rows and columns are
56
- automatically inferred. See :ref:`this section <common_grid>` for usage examples.
57
- figsize : (float, float), optional
58
- Figure size. If None it will be defined automatically.
59
- Note this is not used if `ax` is supplied.
60
- textsize : float, optional
61
- Text size scaling factor for labels, titles and lines. If None it will be autoscaled based
62
- on `figsize`.
63
- labeller : Labeller, optional
64
- Class providing the method ``make_label_vert`` to generate the labels in the plot titles.
65
- Read the :ref:`label_guide` for more details and usage examples.
66
- ax : 2D array-like of matplotlib_axes or bokeh_figure, optional
67
- A 2D array of locations into which to plot the densities. If not supplied, ArviZ will create
68
- its own array of plot areas (and return it).
69
- backend : {"matplotlib", "bokeh"}, default "matplotlib"
70
- Select plotting backend.
71
- backend_config : dict, optional
72
- Currently specifies the bounds to use for bokeh axes. Defaults to value set in ``rcParams``.
73
- backend_kwargs : dict, optional
74
- These are kwargs specific to the backend being used, passed to
75
- :func:`matplotlib.pyplot.subplots` or :class:`bokeh.plotting.figure`.
76
- For additional documentation check the plotting method of the backend.
77
- show : bool, optional
78
- Call backend show function.
79
-
80
- Returns
81
- -------
82
- axes : matplotlib_axes or bokeh_figures
83
-
84
- See Also
85
- --------
86
- autocov : Compute autocovariance estimates for every lag for the input array.
87
- autocorr : Compute autocorrelation using FFT for every lag for the input array.
88
-
89
- Examples
90
- --------
91
- Plot default autocorrelation
92
-
93
- .. plot::
94
- :context: close-figs
95
-
96
- >>> import arviz as az
97
- >>> data = az.load_arviz_data('centered_eight')
98
- >>> az.plot_autocorr(data)
99
-
100
- Plot subset variables by specifying variable name exactly
101
-
102
- .. plot::
103
- :context: close-figs
104
-
105
- >>> az.plot_autocorr(data, var_names=['mu', 'tau'] )
106
-
107
-
108
- Combine chains by variable and select variables by excluding some with partial naming
109
-
110
- .. plot::
111
- :context: close-figs
112
-
113
- >>> az.plot_autocorr(data, var_names=['~thet'], filter_vars="like", combined=True)
114
-
115
-
116
- Specify maximum lag (x axis bound)
117
-
118
- .. plot::
119
- :context: close-figs
120
-
121
- >>> az.plot_autocorr(data, var_names=['mu', 'tau'], max_lag=200, combined=True)
122
- """
123
- data = convert_to_dataset(data, group="posterior")
124
- var_names = _var_names(var_names, data, filter_vars)
125
-
126
- # Default max lag to 100 or max length of chain
127
- if max_lag is None:
128
- max_lag = min(100, data["draw"].shape[0])
129
-
130
- if coords is None:
131
- coords = {}
132
-
133
- if labeller is None:
134
- labeller = BaseLabeller()
135
-
136
- plotters = filter_plotters_list(
137
- list(
138
- xarray_var_iter(
139
- get_coords(data, coords), var_names, combined, dim_order=["chain", "draw"]
140
- )
141
- ),
142
- "plot_autocorr",
143
- )
144
- rows, cols = default_grid(len(plotters), grid=grid)
145
-
146
- autocorr_plot_args = dict(
147
- axes=ax,
148
- plotters=plotters,
149
- max_lag=max_lag,
150
- figsize=figsize,
151
- rows=rows,
152
- cols=cols,
153
- combined=combined,
154
- textsize=textsize,
155
- labeller=labeller,
156
- backend_kwargs=backend_kwargs,
157
- show=show,
158
- )
159
-
160
- if backend is None:
161
- backend = rcParams["plot.backend"]
162
- backend = backend.lower()
163
-
164
- if backend == "bokeh":
165
- autocorr_plot_args.update(backend_config=backend_config)
166
-
167
- # TODO: Add backend kwargs
168
- plot = get_plotting_function("plot_autocorr", "autocorrplot", backend)
169
- axes = plot(**autocorr_plot_args)
170
-
171
- return axes