Repository: arviz-devs/arviz

Issue:
`from_dict` missing in docs
Looks like `from_netcdf` shows up twice, and `from_dict` appears 0 times!

https://arviz-devs.github.io/arviz/api.html#data

Looks like a one line change in https://github.com/arviz-devs/arviz/blob/master/doc/api.rst

![image](https://user-images.githubusercontent.com/2295568/52542395-2b245f80-2d6d-11e9-9e9c-79f55d2ffea1.png)


Discussion:

Patch:
diff --git a/arviz/stats/stats.py b/arviz/stats/stats.py
index b31d2fb..7358e5b 100644
--- a/arviz/stats/stats.py
+++ b/arviz/stats/stats.py
@@ -629,13 +629,14 @@ def summary(
         Return format is either pandas.DataFrame {'wide', 'long'} or xarray.Dataset {'xarray'}.
     round_to : int
         Number of decimals used to round results. Defaults to 2.
-    stat_funcs : None or list
-        A list of functions used to calculate statistics. By default, the mean, standard deviation,
-        simulation standard error, and highest posterior density intervals are included.
+    stat_funcs : dict
+        A list of functions or a dict of functions with function names as keys used to calculate
+        statistics. By default, the mean, standard deviation, simulation standard error, and
+        highest posterior density intervals are included.
 
         The functions will be given one argument, the samples for a variable as an nD array,
         The functions should be in the style of a ufunc and return a single number. For example,
-        `np.sin`, or `scipy.stats.var` would both work.
+        `np.mean`, or `scipy.stats.var` would both work.
     extend : boolean
         If True, use the statistics returned by `stat_funcs` in addition to, rather than in place
         of, the default statistics. This is only meaningful when `stat_funcs` is not None.
@@ -697,13 +698,22 @@ def summary(
     metric_names = []
 
     if stat_funcs is not None:
-        for stat_func in stat_funcs:
-            metrics.append(
-                xr.apply_ufunc(
-                    _make_ufunc(stat_func), posterior, input_core_dims=(("chain", "draw"),)
+        if isinstance(stat_funcs, dict):
+            for stat_func_name, stat_func in stat_funcs.items():
+                metrics.append(
+                    xr.apply_ufunc(
+                        _make_ufunc(stat_func), posterior, input_core_dims=(("chain", "draw"),)
+                    )
                 )
-            )
-            metric_names.append(stat_func.__name__)
+                metric_names.append(stat_func_name)
+        else:
+            for stat_func in stat_funcs:
+                metrics.append(
+                    xr.apply_ufunc(
+                        _make_ufunc(stat_func), posterior, input_core_dims=(("chain", "draw"),)
+                    )
+                )
+                metric_names.append(stat_func.__name__)
 
     if extend:
         metrics.append(posterior.mean(dim=("chain", "draw")))
diff --git a/doc/api.rst b/doc/api.rst
index 5434346..e0f1161 100644
--- a/doc/api.rst
+++ b/doc/api.rst
@@ -69,8 +69,8 @@ Data
     to_netcdf
     from_netcdf
     from_cmdstan
+    from_dict
     from_emcee
-    from_netcdf
     from_pymc3
     from_pyro
     from_pystan


Test patch:
diff --git a/arviz/tests/test_stats.py b/arviz/tests/test_stats.py
index 17e831f..f9d80e1 100644
--- a/arviz/tests/test_stats.py
+++ b/arviz/tests/test_stats.py
@@ -140,8 +140,13 @@ def test_summary_unpack_order(order):
         assert col1 == col2
 
 
-def test_summary_stat_func(centered_eight):
-    assert summary(centered_eight, stat_funcs=[np.var]) is not None
+@pytest.mark.parametrize(
+    "stat_funcs", [[np.var], {"var": np.var, "var2": lambda x: np.var(x) ** 2}]
+)
+def test_summary_stat_func(centered_eight, stat_funcs):
+    arviz_summary = summary(centered_eight, stat_funcs=stat_funcs)
+    assert arviz_summary is not None
+    assert hasattr(arviz_summary, "var")
 
 
 def test_summary_nan(centered_eight):