internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: arviz-devs/arviz

Issue:
Show API link en examples
## Tell us about it

Currently each example in the gallery contains: an image, the code used to generate it, and a link to download the code. It would be great to add a link to the API section of the docs corresponding to the function used.

## Thoughts on implementation

This should happen automatically. A new feature should be added to `gallery_generator.py` using a reular expression to get the function name and then writing the corresponding link. 


Discussion:
@OriolAbril  I'd like to work on this issue.

Resolving patch:
diff --git a/doc/sphinxext/gallery_generator.py b/doc/sphinxext/gallery_generator.py
--- a/doc/sphinxext/gallery_generator.py
+++ b/doc/sphinxext/gallery_generator.py
@@ -40,6 +40,7 @@ def execfile(filename, globals=None, locals=None):
 .. image:: {img_file}
 
 **Python source code:** :download:`[download source: {fname}]<{fname}>`
+**API documentation:** {api_name} 
 
 .. literalinclude:: {fname}
     :lines: {end_line}-
@@ -54,6 +55,7 @@ def execfile(filename, globals=None, locals=None):
     :source-position: none
 
 **Python source code:** :download:`[download source: {fname}]<{fname}>`
+**API documentation:** {api_name} 
 
 .. literalinclude:: {fname}
     :lines: {end_line}-
@@ -236,6 +238,18 @@ def thumbfilename(self):
         pngfile = self.modulename + "_thumb.png"
         return pngfile
 
+    @property
+    def apiname(self):
+        with open(op.join(self.target_dir, self.pyfilename), "r") as file:
+            regex = r"az\.(plot\_[a-z_]+)\("
+            name = re.findall(regex, file.read())
+        apitext = name[0] if name else ""
+        return (
+            "`{apitext} <../../generated/arviz.{apitext}>`_".format(apitext=apitext)
+            if apitext
+            else "No API Documentation available"
+        )
+
     @property
     def sphinxtag(self):
         return self.modulename
@@ -380,6 +394,7 @@ def main(app):
                 fname=ex.pyfilename,
                 absfname=op.join(target_dir, ex.pyfilename),
                 img_file=ex.pngfilename,
+                api_name=ex.apiname,
             )
             with open(op.join(target_dir, ex.rstfilename), "w") as f:
                 f.write(output)


Test patch:
Repository: arviz-devs/arviz

Issue:
Add documentation example for combining InferenceData
## Tell us about it

Add documentation for combining `az.InferenceData`

https://github.com/arviz-devs/arviz/pull/547





Discussion:
@OriolAbril Picking up the work left by @Shashankjain12 . Hope that's okay.

Resolving patch:
diff --git a/arviz/data/inference_data.py b/arviz/data/inference_data.py
--- a/arviz/data/inference_data.py
+++ b/arviz/data/inference_data.py
@@ -276,6 +276,49 @@ def concat(*args, dim=None, copy=True, inplace=False, reset_dim=True):
     InferenceData
         A new InferenceData object by default.
         When `inplace==True` merge args to first arg and return `None`
+
+    Examples
+    --------
+    Use ``concat`` method to concatenate InferenceData objects. This will concatenates over
+    unique groups by default. We first create an ``InferenceData`` object:
+
+    .. ipython::
+
+        In [1]: import arviz as az
+           ...: import numpy as np
+           ...: data = {
+           ...:     "a": (["chain", "draw", "a_dim"], np.random.normal(size=(4, 100, 3))),
+           ...:     "b": (["chain", "draw"], np.random.normal(size=(4, 100))),
+           ...: }
+           ...: coords = {"a_dim": ["x", "y", "z"]}
+           ...: dataA = az.from_dict(data, coords=coords, dims={"a": ["a_dim"]})
+           ...: dataA
+
+    We have created an ``InferenceData`` object with default group 'posterior'. Now, we will
+    create another ``InferenceData`` object:
+
+    .. ipython::
+
+        In [1]: dataB = az.from_dict(prior=data, coords=coords, dims={"a": ["a_dim"]})
+           ...: dataB
+
+    We have created another ``InferenceData`` object with group 'prior'. Now, we will concatenate
+    these two ``InferenceData`` objects:
+
+    .. ipython::
+
+        In [1]: az.concat(dataA, dataB)
+
+    Now, we will concatenate over chain (or draw). It requires identical groups and variables.
+    Here we are concatenating two identical ``InferenceData`` objects over dimension chain:
+
+    .. ipython::
+
+        In [1]: az.concat(dataA, dataA, dim="chain")
+
+    It will create an ``InferenceData`` with the original group 'posterior'. In similar way,
+    we can also concatenate over draws.
+
     """
     # pylint: disable=undefined-loop-variable, too-many-nested-blocks
     if len(args) == 0:


Test patch:
Repository: arviz-devs/arviz

Issue:
plot_posterior writes auto instead of point estimate name
**Describe the bug**
`plot_posterior` should write the name of the point estimate, however it currently writes `auto` if `auto` is passed as point estimate. This can be seen in the [docs example](https://arviz-devs.github.io/arviz/examples/matplotlib/mpl_plot_posterior.html)

**Expected behavior**
It should write the name of the point estimate used (taken from rcParams).

**Additional context**
ArviZ master



Discussion:
Hi @OriolAbril, I would like to work on this.

Resolving patch:
diff --git a/arviz/plots/posteriorplot.py b/arviz/plots/posteriorplot.py
--- a/arviz/plots/posteriorplot.py
+++ b/arviz/plots/posteriorplot.py
@@ -188,6 +188,11 @@ def plot_posterior(
         if not 1 >= credible_interval > 0:
             raise ValueError("The value of credible_interval should be in the interval (0, 1]")
 
+    if point_estimate == "auto":
+        point_estimate = rcParams["plot.point_estimate"]
+    elif point_estimate not in {"mean", "median", "mode", None}:
+        raise ValueError("The value of point_estimate must be either mean, median, mode or None.")
+
     plotters = filter_plotters_list(
         list(xarray_var_iter(get_coords(data, coords), var_names=var_names, combined=True)),
         "plot_posterior",


Test patch:
Repository: arviz-devs/arviz

Issue:
Import fails when run using a Bokeh server
**Description of bug**
The import of `arviz` errors when running with a [Bokeh server](https://docs.bokeh.org/en/latest/docs/user_guide/server.html).

The resulting error is:
```
output_notebook.__doc__ += "\n\n" + _copy_docstring("bokeh.plotting", "output_notebook") Traceback (most recent call last):
  File "/Users/golmschenk/Code/ramjet/venv/lib/python3.7/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
    exec(self._code, module.__dict__)
  File "/Users/golmschenk/Code/ramjet/minimal_example/main.py", line 1, in <module>
    import arviz
  File "/Users/golmschenk/Code/ramjet/venv/lib/python3.7/site-packages/arviz/__init__.py", line 31, in <module>
    from .plots import backends
  File "/Users/golmschenk/Code/ramjet/venv/lib/python3.7/site-packages/arviz/plots/backends/__init__.py", line 195, in <module>
    output_notebook.__doc__ += "\n\n" + _copy_docstring("bokeh.plotting", "output_notebook")
TypeError: can only concatenate str (not "NoneType") to str
```


**To Reproduce**

1. Have `bokeh` and `arviz` installed.
2. Create a Python file which only contains `import arviz`.
3. From the terminal, run `bokeh serve <file_name>.py`.
4. Open the localhost server link in a browser.

**Expected behavior**
`arviz` should be imported without error.

**Additional context**
`arviz` appears to be setting a docstring based off `_copy_docstring("bokeh.plotting", "output_notebook")`, however, in this context, `_copy_docstring("bokeh.plotting", "output_notebook")` is `None`.

Package versions:
```
arviz==0.7.0
bokeh==2.0.1
```



Discussion:
A workaround for the time being is to explicitly force `output_notebook`'s docstring to a string value before importing `arviz`. For example, the following code allows `arviz` to import without error.
```
from bokeh import plotting
plotting.output_notebook.__doc__ = ''
import arviz
```
Thanks for the temporary solution. Let's fix that docstring function to handle None.

Resolving patch:
diff --git a/arviz/plots/backends/__init__.py b/arviz/plots/backends/__init__.py
--- a/arviz/plots/backends/__init__.py
+++ b/arviz/plots/backends/__init__.py
@@ -192,6 +192,8 @@ def _copy_docstring(lib, function):
     except ImportError:
         doc = "Failed to import function {} from {}".format(function, lib)
 
+    if not isinstance(doc, str):
+        doc = ""
     return doc
 
 


Test patch:
Repository: arviz-devs/arviz

Issue:
Inconsistent capitalization in `plot_hdi` docstring
**Describe the bug**
Docs have inconsistent capitalization
![image](https://user-images.githubusercontent.com/7213793/82233398-d020d700-98e4-11ea-812c-588628ed753e.png)


**To Reproduce**
https://arviz-devs.github.io/arviz/generated/arviz.plot_hdi.html#arviz.plot_hdi

**Expected behavior**
Consistency across arg docstrings



Discussion:
Hey, I'm new to Open Source and would like to contribute and work on this issue. How can I help?
Hi @neha-shah99, welcome! You have already done the first step which is to indicate what you plan to work on, this way we can prevent two people working on the same issue. 

Roughly speaking the steps are: creating a fork of the project, edit the fork and submit a pull request to merge the changes to the main repository. We have a [contributing guide](https://github.com/arviz-devs/arviz/blob/master/CONTRIBUTING.md#steps) which details every step and common commands needed for these steps. If you still have doubts or have suggestions on how to improve it do not hesitate to ask either here or in [gitter](https://gitter.im/arviz-devs/community)

Resolving patch:
diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py
--- a/arviz/plots/hdiplot.py
+++ b/arviz/plots/hdiplot.py
@@ -33,13 +33,13 @@ def plot_hdi(
     Parameters
     ----------
     x : array-like
-        Values to plot
+        Values to plot.
     y : array-like
-        values from which to compute the hdi. Assumed shape (chain, draw, \*shape).
+        Values from which to compute the hdi. Assumed shape (chain, draw, \*shape).
     hdi_prob : float, optional
         Probability for the highest density interval. Defaults to 0.94.
     color : str
-        Color used for the limits of the hdi and fill. Should be a valid matplotlib color
+        Color used for the limits of the hdi and fill. Should be a valid matplotlib color.
     circular : bool, optional
         Whether to compute the hdi taking into account `x` is a circular variable
         (in the range [-np.pi, np.pi]) or not. Defaults to False (i.e non-circular variables).
@@ -49,11 +49,11 @@ def plot_hdi(
         Defaults to True.
     smooth_kwargs : dict, optional
         Additional keywords modifying the Savitzky-Golay filter. See Scipy's documentation for
-        details
+        details.
     fill_kwargs : dict
         Keywords passed to `fill_between` (use fill_kwargs={'alpha': 0} to disable fill).
     plot_kwargs : dict
-        Keywords passed to hdi limits
+        Keywords passed to hdi limits.
     ax: axes, optional
         Matplotlib axes or bokeh figures.
     backend: str, optional
@@ -64,7 +64,7 @@ def plot_hdi(
     show : bool, optional
         Call backend show function.
     credible_interval: float, optional
-        deprecated: Please see hdi_prob
+        Deprecated: Please see hdi_prob
 
     Returns
     -------


Test patch:
Repository: arviz-devs/arviz

Issue:
HPD plot shows values over each other
Hey All,

I am trying to figure out how to change the plot_posterior function to show the actual values.  In one of my plots, where it is small, I get numbers writing over each other.  Any help/advice?

![image](https://user-images.githubusercontent.com/605973/85463990-c71ec780-b56c-11ea-95f6-3706e6ef72a1.png)



Discussion:
Hi  @drachimera , thanks for taking the time to report this problem. I am not sure there is a good solution from your side. Let me try to fix it.

Resolving patch:
diff --git a/arviz/plots/backends/matplotlib/posteriorplot.py b/arviz/plots/backends/matplotlib/posteriorplot.py
--- a/arviz/plots/backends/matplotlib/posteriorplot.py
+++ b/arviz/plots/backends/matplotlib/posteriorplot.py
@@ -69,7 +69,7 @@ def plot_posterior(
             rope=rope,
             ax_labelsize=ax_labelsize,
             xt_labelsize=xt_labelsize,
-            **kwargs
+            **kwargs,
         )
         idx += 1
         ax_.set_title(make_label(var_name, selection), fontsize=titlesize, wrap=True)
@@ -98,7 +98,7 @@ def _plot_posterior_op(
     ax_labelsize,
     xt_labelsize,
     round_to: Optional[int] = None,
-    **kwargs
+    **kwargs,
 ):  # noqa: D202
     """Artist to draw posterior."""
 
@@ -175,9 +175,23 @@ def display_rope():
             zorder=0,
             alpha=0.7,
         )
-        text_props = {"size": ax_labelsize, "horizontalalignment": "center", "color": "C2"}
-        ax.text(vals[0], plot_height * 0.2, vals[0], weight="semibold", **text_props)
-        ax.text(vals[1], plot_height * 0.2, vals[1], weight="semibold", **text_props)
+        text_props = {"size": ax_labelsize, "color": "C2"}
+        ax.text(
+            vals[0],
+            plot_height * 0.2,
+            f"{vals[0]} ",
+            weight="semibold",
+            horizontalalignment="right",
+            **text_props,
+        )
+        ax.text(
+            vals[1],
+            plot_height * 0.2,
+            f" {vals[1]}",
+            weight="semibold",
+            horizontalalignment="left",
+            **text_props,
+        )
 
     def display_point_estimate():
         if not point_estimate:
@@ -211,16 +225,16 @@ def display_hdi():
             ax.text(
                 hdi_i[0],
                 plot_height * 0.07,
-                round_num(hdi_i[0], round_to),
+                round_num(hdi_i[0], round_to) + " ",
                 size=ax_labelsize,
-                horizontalalignment="center",
+                horizontalalignment="right",
             )
             ax.text(
                 hdi_i[1],
                 plot_height * 0.07,
-                round_num(hdi_i[1], round_to),
+                " " + round_num(hdi_i[1], round_to),
                 size=ax_labelsize,
-                horizontalalignment="center",
+                horizontalalignment="left",
             )
             ax.text(
                 (hdi_i[0] + hdi_i[1]) / 2,


Test patch:
Repository: arviz-devs/arviz

Issue:
Fix negative values in std
edit. There is an error in the numeric_utils.

This is a wrong order of operations

    std_devs = np.diag(cov ** 0.5)

Correct order is

     std_devs = np.diag(cov) ** 0.5


Discussion:

Resolving patch:
diff --git a/arviz/numeric_utils.py b/arviz/numeric_utils.py
--- a/arviz/numeric_utils.py
+++ b/arviz/numeric_utils.py
@@ -124,7 +124,7 @@ def _fast_kde_2d(x, y, gridsize=(128, 128), circular=False):
 
     scotts_factor = len_x ** (-1 / 6)
     cov = _cov(xyi)
-    std_devs = np.diag(cov ** 0.5)
+    std_devs = np.diag(cov) ** 0.5
     kern_nx, kern_ny = np.round(scotts_factor * 2 * np.pi * std_devs)
 
     inv_cov = np.linalg.inv(cov * scotts_factor ** 2)


Test patch:
Repository: arviz-devs/arviz

Issue:
Doc builds are failing on master
Seems like something in khat bokeh is causing issues. Will look into it if no one beats me to it. Adding a better picture

![image](https://user-images.githubusercontent.com/7213793/89737459-fbb7e700-da25-11ea-8967-4c415408092d.png)


https://dev.azure.com/ArviZ/ArviZ/_build/results?buildId=3176&view=logs&j=5e60a62b-366f-55f7-ec2d-5209191ccb17&t=d329c065-fdc0-50e4-eb39-ac3f74121b84&l=1099


Discussion:
My ~monster~ pr fixes this.

https://github.com/arviz-devs/arviz/pull/1335
Nope, it did not fix it, only part of it.

Resolving patch:
diff --git a/arviz/stats/density_utils.py b/arviz/stats/density_utils.py
--- a/arviz/stats/density_utils.py
+++ b/arviz/stats/density_utils.py
@@ -157,7 +157,7 @@ def _get_bw(x, bw, grid_counts=None, x_std=None, x_range=None):
             )
 
         bw_fun = _BW_METHODS_LINEAR[bw_lower]
-        bw = bw_fun(x, grid_counts, x_std, x_range)
+        bw = bw_fun(x, grid_counts=grid_counts, x_std=x_std, x_range=x_range)
     else:
         raise ValueError(
             (
@@ -544,6 +544,7 @@ def _kde_linear(
     custom_lims=None,
     cumulative=False,
     grid_len=512,
+    **kwargs,  # pylint: disable=unused-argument
 ):
     """One dimensional density estimation for linear data.
 
@@ -647,7 +648,14 @@ def _kde_linear(
 
 
 def _kde_circular(
-    x, bw="taylor", bw_fct=1, bw_return=False, custom_lims=None, cumulative=False, grid_len=512,
+    x,
+    bw="taylor",
+    bw_fct=1,
+    bw_return=False,
+    custom_lims=None,
+    cumulative=False,
+    grid_len=512,
+    **kwargs,  # pylint: disable=unused-argument
 ):
     """One dimensional density estimation for circular data.
 
@@ -744,7 +752,8 @@ def _kde_circular(
         return grid, pdf
 
 
-def _kde_convolution(x, bw, grid_edges, grid_counts, grid_len, bound_correction):
+# pylint: disable=unused-argument
+def _kde_convolution(x, bw, grid_edges, grid_counts, grid_len, bound_correction, **kwargs):
     """Kernel density with convolution.
 
     One dimensional Gaussian kernel density estimation via
@@ -779,7 +788,7 @@ def _kde_convolution(x, bw, grid_edges, grid_counts, grid_len, bound_correction)
     return grid, pdf
 
 
-def _kde_adaptive(x, bw, grid_edges, grid_counts, grid_len, bound_correction):
+def _kde_adaptive(x, bw, grid_edges, grid_counts, grid_len, bound_correction, **kwargs):
     """Compute Adaptive Kernel Density Estimation.
 
     One dimensional adaptive Gaussian kernel density estimation.


Test patch:
Repository: arviz-devs/arviz

Issue:
plot_posterior: add support for circular variables
Currently hpd intervals and mean/median computation assume variables are not circular. This is conceptually related to #339


Discussion:

Resolving patch:
diff --git a/arviz/plots/backends/bokeh/posteriorplot.py b/arviz/plots/backends/bokeh/posteriorplot.py
--- a/arviz/plots/backends/bokeh/posteriorplot.py
+++ b/arviz/plots/backends/bokeh/posteriorplot.py
@@ -209,7 +209,7 @@ def display_hdi(max_data):
         # np.ndarray with 2 entries, min and max
         # pylint: disable=line-too-long
         hdi_probs = hdi(
-            values, hdi_prob=hdi_prob, multimodal=multimodal, skipna=skipna
+            values, hdi_prob=hdi_prob, circular=circular, multimodal=multimodal, skipna=skipna
         )  # type: np.ndarray
 
         for hdi_i in np.atleast_2d(hdi_probs):
diff --git a/arviz/plots/backends/matplotlib/posteriorplot.py b/arviz/plots/backends/matplotlib/posteriorplot.py
--- a/arviz/plots/backends/matplotlib/posteriorplot.py
+++ b/arviz/plots/backends/matplotlib/posteriorplot.py
@@ -235,7 +235,7 @@ def display_hdi():
         # np.ndarray with 2 entries, min and max
         # pylint: disable=line-too-long
         hdi_probs = hdi(
-            values, hdi_prob=hdi_prob, multimodal=multimodal, skipna=skipna
+            values, hdi_prob=hdi_prob, circular=circular, multimodal=multimodal, skipna=skipna
         )  # type: np.ndarray
 
         for hdi_i in np.atleast_2d(hdi_probs):


Test patch:
Repository: arviz-devs/arviz

Issue:
plot_pair axis labels no longer include coords
**Describe the bug**
Using `plot_pair` with a selection of `coords`, I got a plot where the axis labels only show `var_names`, so different `coords` get the same label.

**To Reproduce**
```
test_idata = arviz.from_dict(
    posterior = dict(a=numpy.random.rand(1, 10, 3), b=numpy.random.rand(1 ,10, 1)),
    dims={'a':['a_dim',]},
    coords=dict(a_dim=['test_A', 'test_B', 'test_C'])
)
arviz.plot_pair(
    test_idata, 
    coords=dict(a_dim=['test_A', 'test_B']),
    kind='kde'
);
```

![grafik](https://user-images.githubusercontent.com/45510988/106592082-56527b80-654f-11eb-95ed-c9041188c4c0.png)


**Expected behavior**
Axis labels should also include the `coords` to be unique (in this case a_test_A or similar).

**Additional context**
arviz_version : 0.11.0



Discussion:
I will look into it asap. This is completely unexpected :/. Does this already happen with 0.11 or on development version? (both will show 0.11 as version) 
I tested it with the 0.11 release. Thanks for looking into it!

Resolving patch:
diff --git a/arviz/plots/pairplot.py b/arviz/plots/pairplot.py
--- a/arviz/plots/pairplot.py
+++ b/arviz/plots/pairplot.py
@@ -10,8 +10,8 @@
 from .plot_utils import (
     get_plotting_function,
     xarray_to_ndarray,
-    filter_plotters_list,
     xarray_var_iter,
+    make_label,
 )
 
 
@@ -194,11 +194,10 @@ def plot_pair(
     # Get posterior draws and combine chains
     dataset = convert_to_dataset(data, group=group)
     var_names = _var_names(var_names, dataset, filter_vars)
-    plotters = filter_plotters_list(
-        list(xarray_var_iter(get_coords(dataset, coords), var_names=var_names, combined=True)),
-        "plot_pair",
+    plotters = list(
+        xarray_var_iter(get_coords(dataset, coords), var_names=var_names, combined=True)
     )
-    flat_var_names = [plotter[0] for plotter in plotters]
+    flat_var_names = [make_label(var_name, selection) for var_name, selection, _ in plotters]
 
     divergent_data = None
     diverging_mask = None


Test patch:
Repository: arviz-devs/arviz

Issue:
plot_posterior and plot_density give a mode outside of the hdi
## Short Description

I am plotting densities and I ask for a point estimate as 'mode'. The value of the mode is outside of the HDI.

## Code Example or link

az.plot_posterior(inference_data, point_estimate = 'mode', hdi_prob = 0.9, var_names = ('a', 'b', 'c', 'sigma_lai'), figsize=(10,5), grid=(2,2))

The result looks like this https://postimg.cc/K4RpK4gg

az.__version__
Out[88]: '0.11.1'




Discussion:
HI @gdindi thanks for taking the time to report this issue.  I am not able to reproduce this error, could you share your data or share a minimal working example? 
Hi,

Here goes a minimal working example:

```
# get the data file here
# https://upload.disroot.org/r/7cWwZ7y7#vbkqLUsIKbTmTaCDYhNkt4xfRG/d0qSOeY84aD1JpbQ=
import arviz as az
import matplotlib.pyplot as plt
inf_data = az.from_netcdf("posterior_1.netcdf")
az.plot_posterior(inf_data.posterior, point_estimate = 'mode', hdi_prob = 0.9, var_names = ('a', 'b', 'c', 'sigma_lai'), figsize=(10,5), grid=(3,2))
plt.savefig("test.png")
```

Thank you.
Thanks. I find the problem and I will fix it later today.

Resolving patch:
diff --git a/arviz/plots/plot_utils.py b/arviz/plots/plot_utils.py
--- a/arviz/plots/plot_utils.py
+++ b/arviz/plots/plot_utils.py
@@ -586,7 +586,7 @@ def calculate_point_estimate(point_estimate, values, bw="default", circular=Fals
         else:
             point_value = np.mean(values)
     elif point_estimate == "mode":
-        if isinstance(values[0], float):
+        if values.dtype.kind == "f":
             if bw == "default":
                 if circular:
                     bw = "taylor"


Test patch: