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

Issue:
Correct comment in Dimension example plot
The comment in [this example](http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#dimensions) says `# create a new plot with a title`.  I expect this example was copied from the one below is demonstrating how to add a title.  This comment should be changed to `# create a new plot with specific dimensions`.



Discussion:

Resolving patch:
diff --git a/sphinx/source/docs/user_guide/source_examples/styling_dimensions.py b/sphinx/source/docs/user_guide/source_examples/styling_dimensions.py
--- a/sphinx/source/docs/user_guide/source_examples/styling_dimensions.py
+++ b/sphinx/source/docs/user_guide/source_examples/styling_dimensions.py
@@ -2,7 +2,7 @@
 
 output_file("dimensions.html")
 
-# create a new plot with a title
+# create a new plot with specific dimensions
 p = figure(plot_width=700)
 p.plot_height = 300
 


Test patch:
Repository: bokeh/bokeh

Issue:
embed/animated fails with "did not find model"
`Error rendering Bokeh items  Error: Did not find model ID_HERE in session`.



Discussion:
Confirmed no output, and the message above in JS console.

I got the same error for the animated example.
Is there any solution?

@wangsheng1001, not yet, we didn't have chance to get to this.

Just in case it helps: 

I encountered the same error when using the embedded feature with server data (see http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#server-data). I used the exact example, which says that figure() auto adds the figure to curdoc(). On loading the generated Javascript, I got that error. However it worked fine, once I added the plot to curdoc manually: 

```
from bokeh.client import push_session
from bokeh.embed import autoload_server
from bokeh.plotting import figure, curdoc

# Apparently figure() doesnt auto add the plot to curdoc()
plot = figure(title="Linegraph", plot_width=300, plot_height=300)
plot.line(x=[1,2,3,4,5], y=[3,2,3,4,2])

# THIS LINE FIXED IT:
curdoc().add_root(plot)

session = push_session(curdoc())
script = autoload_server(plot, session_id=session.id)

# Just writing the html file
f = open("index.html", "w")
pre = "<!DOCTYPE HTML><html><head></head><body><p>Plot here:</p>"
post = "</body></html>"
f.write(pre + script + post)
f.close
```

> `# figure() function auto-adds the figure to curdoc()`
> `p = figure(x_range=(-11, 11), y_range=(-11, 11))`

@bryevdv, is this true? I doubt it, because otherwise we wouldn't be able to layouts and such. It's `show()` at al. that does this.

It used to be true but is not anymore. I happened to fix and update this docstring last week. 

> On Oct 31, 2016, at 06:18, Mateusz Paprocki notifications@github.com wrote:
> 
> figure() function auto-adds the figure to curdoc()
> 
> p = figure(x_range=(-11, 11), y_range=(-11, 11))
> 
> @bryevdv, is this true? I doubt it, because otherwise we wouldn't be able to layouts and such. It's show() at al. that does this.
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

@bryevdv, OK. I was worried this is a deeper issue, but apparently it's just documentation and example(s) fixing what's required to be done.


Resolving patch:
diff --git a/examples/embed/animated.py b/examples/embed/animated.py
--- a/examples/embed/animated.py
+++ b/examples/embed/animated.py
@@ -45,6 +45,9 @@
 r = p.annular_wedge(0, 0, rmin, rmax, theta[:-1], theta[1:],
                     fill_color=colors, line_color="white")
 
+# add the plot to curdoc
+curdoc().add_root(p)
+
 # open a session which will keep our local doc in sync with server
 session = push_session(curdoc())
 


Test patch:
Repository: bokeh/bokeh

Issue:
embed/animated fails with "did not find model"
`Error rendering Bokeh items  Error: Did not find model ID_HERE in session`.



Discussion:
Confirmed no output, and the message above in JS console.

I got the same error for the animated example.
Is there any solution?

@wangsheng1001, not yet, we didn't have chance to get to this.

Just in case it helps: 

I encountered the same error when using the embedded feature with server data (see http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#server-data). I used the exact example, which says that figure() auto adds the figure to curdoc(). On loading the generated Javascript, I got that error. However it worked fine, once I added the plot to curdoc manually: 

```
from bokeh.client import push_session
from bokeh.embed import autoload_server
from bokeh.plotting import figure, curdoc

# Apparently figure() doesnt auto add the plot to curdoc()
plot = figure(title="Linegraph", plot_width=300, plot_height=300)
plot.line(x=[1,2,3,4,5], y=[3,2,3,4,2])

# THIS LINE FIXED IT:
curdoc().add_root(plot)

session = push_session(curdoc())
script = autoload_server(plot, session_id=session.id)

# Just writing the html file
f = open("index.html", "w")
pre = "<!DOCTYPE HTML><html><head></head><body><p>Plot here:</p>"
post = "</body></html>"
f.write(pre + script + post)
f.close
```

> `# figure() function auto-adds the figure to curdoc()`
> `p = figure(x_range=(-11, 11), y_range=(-11, 11))`

@bryevdv, is this true? I doubt it, because otherwise we wouldn't be able to layouts and such. It's `show()` at al. that does this.

It used to be true but is not anymore. I happened to fix and update this docstring last week. 

> On Oct 31, 2016, at 06:18, Mateusz Paprocki notifications@github.com wrote:
> 
> figure() function auto-adds the figure to curdoc()
> 
> p = figure(x_range=(-11, 11), y_range=(-11, 11))
> 
> @bryevdv, is this true? I doubt it, because otherwise we wouldn't be able to layouts and such. It's show() at al. that does this.
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

@bryevdv, OK. I was worried this is a deeper issue, but apparently it's just documentation and example(s) fixing what's required to be done.

Yes, a trivial fix I pushed a PR


Resolving patch:
diff --git a/examples/embed/animated.py b/examples/embed/animated.py
--- a/examples/embed/animated.py
+++ b/examples/embed/animated.py
@@ -40,7 +40,6 @@
 colors = ["FFFFCC", "#C7E9B4", "#7FCDBB", "#41B6C4", "#2C7FB8",
           "#253494", "#2C7FB8", "#41B6C4", "#7FCDBB", "#C7E9B4"] * 5
 
-# figure() function auto-adds the figure to curdoc()
 p = figure(x_range=(-11, 11), y_range=(-11, 11))
 r = p.annular_wedge(0, 0, rmin, rmax, theta[:-1], theta[1:],
                     fill_color=colors, line_color="white")


Test patch:
Repository: bokeh/bokeh

Issue:
Extend TextInput with `placeholder` 
`placeholder` and `pattern` are nice features in HTML to give the user info about the field and to validate the user-input.

Add `placeholder` and `pattern` to `TextInput` in python, extend `text_input.coffee` and the `text_input_template.eco` 



Discussion:
Just started to work on a PR.
`placeholder` works just fine - no problem.

But there is a big problem with `pattern`. 
In standard HTML the input is highlighted in red if user entered wrong values. This can be styled with `input:invalid`. But this is not working in `bokeh_js`. Everytime `value` is changed the input is rendered freshly. The `invalid` state gets lost (I think).
If I disable `@model.value = value` here: https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/widgets/text_input.coffee#L35 
the highlighting works fine.

What is the motivation to render the input every time the value is changed?

I'm not sure offhand, re-rendering might be an unintended mistake. The `model.value = value` should be there, because that's what causes e.g. callbacks in a bokeh server to trigger when the value changes. But it might be a mistake to have that also trigger a re-render. What above removing this line instead: https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/widgets/text_input.coffee#L22

I'll give it a try.

@bryevdv 

It only works if I comment L22 and L20
https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/widgets/text_input.coffee#L20

`super(options)` is calling `initialize` from `LayoutDOM` which does:

```
bind_bokeh_events: () ->
    @listenTo(@model, 'change', @render)
```

I really don't know if this is a good idea. I'm not familiar with the code and `coffee` is absolutely new to me.
I'm happy to help improve things, but I don't want to waste to much of your precious time.
If there is a **JS/coffee-Master** around to decide if it's okay to remove these lines!
I can test and make a PR.

ping @birdsarah any quick thoughts? It seems like an input widget should not need to re-render on every model change. Should that line be in `LayoutDOM`? It seems maybe subclasses should be able to decide to do that or not

@busino if `placeholder` is working fine, why don't you work up a PR for just that first? And we will figure out the other part over time. 


Resolving patch:
diff --git a/bokeh/models/widgets/inputs.py b/bokeh/models/widgets/inputs.py
--- a/bokeh/models/widgets/inputs.py
+++ b/bokeh/models/widgets/inputs.py
@@ -43,6 +43,10 @@ class TextInput(InputWidget):
     A callback to run in the browser whenever the user unfocuses the TextInput
     widget by hitting Enter or clicking outside of the text box area.
     """)
+    
+    placeholder = String(default="", help="""
+    Placeholder for empty input field
+    """)
 
 
 class AutocompleteInput(TextInput):


Test patch:
Repository: bokeh/bokeh

Issue:
Tabe completion on bokeh.palettes doesn't work in python 2
Due to a quirk in python 2, the global `_Palettes` is `None` in the global namespace of the dynamically generated `palettes` module. This causes the implementation of `__dir__` to fail in python 2.

```python
from bokeh import palettes
assert 'viridis' in dir(palettes)   # Fails on python 2
```



Discussion:

Resolving patch:
diff --git a/bokeh/palettes.py b/bokeh/palettes.py
--- a/bokeh/palettes.py
+++ b/bokeh/palettes.py
@@ -82,7 +82,10 @@
 
 """
 
-class _Palettes(object):
+import sys as _sys
+import types as _types
+
+class _PalettesModule(_types.ModuleType):
     @property
     def YlGn3(self):
         return ["#31a354", "#addd8e", "#f7fcb9"]
@@ -1601,6 +1604,9 @@ def __palettes__(self):
             __palettes__ += [ name + str(index) for index in sorted(palettes.keys()) ]
         return __palettes__
 
+    def __dir__(self):
+        return [name for name in dir(type(self)) if not name.startswith('_')]
+
     def _linear_cmap_func_generator(self, name, cmap):
         import math
         import numpy as np
@@ -1631,16 +1637,9 @@ def grey(self):
     def gray(self):
         return self._linear_cmap_func_generator('gray', self.Greys256)
 
-import sys as _sys
-import types as _types
-
-class _PalettesModule(_types.ModuleType, _Palettes):
-    def __dir__(self):
-        return list(self.__dict__.keys()) + \
-               [ name for name in dir(_Palettes) if not name.startswith("_") ]
 
 # need to explicitly transfer the docstring for Sphinx docs to build correctly
 _mod = _PalettesModule('bokeh.palettes')
 _mod.__doc__ = __doc__
 _sys.modules['bokeh.palettes'] = _mod
-del _mod
+del _mod, _sys, _types


Test patch:
diff --git a/bokeh/tests/test_palettes.py b/bokeh/tests/test_palettes.py
--- a/bokeh/tests/test_palettes.py
+++ b/bokeh/tests/test_palettes.py
@@ -15,3 +15,7 @@ def test_palettes_immutability():
 
 def test_all_palettes___palettes__():
     assert sum([ len(p) for p in pal.all_palettes.values() ]) == len(pal.__palettes__)
+
+def test_palettes_dir():
+    assert 'viridis' in dir(pal)
+    assert not '__new__' in dir(pal)
Repository: bokeh/bokeh

Issue:
Docstring not reflecting correct function signature.
https://github.com/bokeh/bokeh/blob/master/bokeh/io.py#L572

Docstring references invalid function call. 

is: push_notebook(handle)
should be: push_notebook(handle=handle)

tag: docs


Discussion:

Resolving patch:
diff --git a/bokeh/io.py b/bokeh/io.py
--- a/bokeh/io.py
+++ b/bokeh/io.py
@@ -569,7 +569,7 @@ def push_notebook(document=None, state=None, handle=None):
 
             # Update the plot title in the earlier cell
             plot.title = "New Title"
-            push_notebook(handle)
+            push_notebook(handle=handle)
 
     '''
     if state is None:


Test patch:
Repository: bokeh/bokeh

Issue:
Some named palettes raise ValueError
When creating a `ColorMapper` or an `Image`, the `palette` keyword argument supports string reference to some of the palettes in the `palettes` module, but not all. 

For example:

```
from bokeh.plotting import figure, output_file, show
from bokeh.palettes import Greys256

output_file("test_plot.html")

palette = "Greys256" # raises `ValueError: expected an element of Seq(Color), got 'Greys256'`
palette = Greys256 # works as expected
palette = "Inferno256" # works as expected

fig = figure(x_range=[0, 5], y_range=[0, 5])
fig.image([[range(5)]*5], x=[0], y=[0], dw=[5], dh=[5], palette=palette)
show(fig)
```

Python `2.7.12` and Bokeh `0.12.3`


Discussion:
This is precisely `Greys256` that's missing from `Palettes` enumerations, thus causing this error.

Resolving patch:
diff --git a/bokeh/palettes.py b/bokeh/palettes.py
--- a/bokeh/palettes.py
+++ b/bokeh/palettes.py
@@ -1437,7 +1437,7 @@ def Reds(self):
         return { 3: self.Reds3,     4: self.Reds4,     5: self.Reds5,     6: self.Reds6,     7: self.Reds7,     8: self.Reds8,     9: self.Reds9 }
     @property
     def Greys(self):
-        return { 3: self.Greys3,    4: self.Greys4,    5: self.Greys5,    6: self.Greys6,    7: self.Greys7,    8: self.Greys8,    9: self.Greys9 }
+        return { 3: self.Greys3,    4: self.Greys4,    5: self.Greys5,    6: self.Greys6,    7: self.Greys7,    8: self.Greys8,    9: self.Greys9,    256: self.Greys256 } # NOQA
     @property
     def PuOr(self):
         return { 3: self.PuOr3,     4: self.PuOr4,     5: self.PuOr5,     6: self.PuOr6,     7: self.PuOr7,     8: self.PuOr8,     9: self.PuOr9,     10: self.PuOr10,     11: self.PuOr11 } # NOQA
@@ -1590,6 +1590,7 @@ def all_palettes(self):
     @property
     def small_palettes(self):
         palettes = self.all_palettes
+        del palettes["Greys"][256]
         del palettes["Magma"][256]
         del palettes["Inferno"][256]
         del palettes["Plasma"][256]


Test patch:
Repository: bokeh/bokeh

Issue:
Merged toolbar is not created properly when row/column layouts added to gridplot 
Sometimes it is required to add complex structures to gridplot (i.e. column containing 2 figures with one big figure nearby).

Currently it is not working properly in terms of toolbar creation, because gridplot searches for immediate children Figures only.


Discussion:

Resolving patch:
diff --git a/bokeh/layouts.py b/bokeh/layouts.py
--- a/bokeh/layouts.py
+++ b/bokeh/layouts.py
@@ -368,9 +368,11 @@ def gridplot(*args, **kwargs):
         row_tools = []
         row_children = []
         for item in row:
-            if merge_tools and isinstance(item, Plot):
-                row_tools = row_tools + item.toolbar.tools
-                item.toolbar_location = None
+            if merge_tools:
+                if item is not None:
+                    for plot in item.select(dict(type=Plot)):
+                        row_tools = row_tools + plot.toolbar.tools
+                        plot.toolbar_location = None
             if item is None:
                 for neighbor in row:
                     if isinstance(neighbor, Plot):


Test patch:
diff --git a/bokeh/tests/test_layouts.py b/bokeh/tests/test_layouts.py
new file mode 100644
--- /dev/null
+++ b/bokeh/tests/test_layouts.py
@@ -0,0 +1,31 @@
+from bokeh.plotting import figure
+
+import bokeh.layouts as lyt
+
+def test_gridplot_merge_tools_flat():
+    p1, p2, p3, p4 = figure(), figure(), figure(), figure()
+
+    lyt.gridplot([[p1, p2], [p3, p4]], merge_tools=True)
+
+    for p in p1, p2, p3, p4:
+        assert p.toolbar_location is None
+
+def test_gridplot_merge_tools_with_None():
+    p1, p2, p3, p4 = figure(), figure(), figure(), figure()
+
+    lyt.gridplot([[p1, None, p2], [p3, p4, None]], merge_tools=True)
+
+    for p in p1, p2, p3, p4:
+        assert p.toolbar_location is None
+
+
+def test_gridplot_merge_tools_nested():
+    p1, p2, p3, p4, p5, p6, p7 = figure(), figure(), figure(), figure(), figure(), figure(), figure()
+    r1 = lyt.row(p1, p2)
+    r2 = lyt.row(p3, p4)
+    c = lyt.column(lyt.row(p5), lyt.row(p6))
+
+    lyt.gridplot([[r1, r2], [c, p7]], merge_tools=True)
+
+    for p in p1, p2, p3, p4, p5, p6, p7:
+        assert p.toolbar_location is None
Repository: bokeh/bokeh

Issue:
Replace `@$(...)` with `@$el.find(...)`
Unnecessary alias. Often people forget that `@$(...) != $(...)`.


Discussion:

Resolving patch:
diff --git a/sphinx/source/docs/user_guide/examples/extensions_putting_together.py b/sphinx/source/docs/user_guide/examples/extensions_putting_together.py
--- a/sphinx/source/docs/user_guide/examples/extensions_putting_together.py
+++ b/sphinx/source/docs/user_guide/examples/extensions_putting_together.py
@@ -25,7 +25,7 @@
     # like draw to the HTML canvas. In this case though, we change the
     # contents of the <div>, based on the current slider value.
     @$el.html("<h1>#{ @model.text }: #{ @model.slider.value }</h1>")
-    @$('h1').css({ 'color': '#686d8e', 'background-color': '#2a3153' })
+    @$el.find('h1').css({ 'color': '#686d8e', 'background-color': '#2a3153' })
 
 export class Custom extends LayoutDOM
 


Test patch:
Repository: bokeh/bokeh

Issue:
output_notebook raises javascript error if hide_banner=True
Using latest master the ``output_notebook`` function raises a Javascript error when ``hide_banner=True``, i.e. in a fresh notebook:

```python
from bokeh.io import output_notebook
output_notebook(hide_banner=True)
```

```
VM9236:92 Uncaught TypeError: Cannot set property 'textContent' of null(…)
```

This originates in the following embedded function:

```javascript
    function(Bokeh) {
      
      document.getElementById("759c6b76-37ad-4246-bc56-d762de3036d9").textContent = "BokehJS is loading...";
    },
```

When additionally setting ``resources=INLINE`` the JS code fails to get executed in the notebook entirely:

```python
from bokeh.io import output_notebook
output_notebook(hide_banner=True, resources=INLINE)
```

```javascript
Javascript error adding output!
TypeError: Cannot set property 'textContent' of null
See your browser Javascript console for more details.
```


Discussion:
jquery is more forgiving, e.g.:
```
$("foo").text("x")
[]
```
and `hide_banner` wasn't used to disable `FINALIZE_JS`. 

Resolving patch:
diff --git a/bokeh/util/notebook.py b/bokeh/util/notebook.py
--- a/bokeh/util/notebook.py
+++ b/bokeh/util/notebook.py
@@ -79,7 +79,7 @@ def _load_notebook_html(resources=None, verbose=False, hide_banner=False,
         elementid = '' if hide_banner else element_id,
         js_urls  = resources.js_files,
         css_urls = resources.css_files,
-        js_raw   = resources.js_raw + [FINALIZE_JS % element_id],
+        js_raw   = resources.js_raw + ([] if hide_banner else [FINALIZE_JS % element_id]),
         css_raw  = resources.css_raw_str,
         force    = 1,
         timeout  = load_timeout


Test patch:
Repository: bokeh/bokeh

Issue:
Custom models don't work in the notebook due to missing __file__
Another incarnation of our struggle with resolving custom models' module paths.



Discussion:

Resolving patch:
diff --git a/bokeh/util/compiler.py b/bokeh/util/compiler.py
--- a/bokeh/util/compiler.py
+++ b/bokeh/util/compiler.py
@@ -4,11 +4,12 @@
 logger = logging.getLogger(__name__)
 
 import io
+import os
+import sys
 import six
 import json
-import inspect
 import hashlib
-from os.path import dirname, join, abspath, exists
+from os.path import dirname, join, abspath, exists, isabs
 from subprocess import Popen, PIPE
 
 from ..model import Model
@@ -146,7 +147,8 @@ def nodejs_compile(code, lang="javascript", file=None):
     return _run_nodejs(compilejs_script, dict(code=code, lang=lang, file=file))
 
 class Implementation(object):
-    pass
+
+    file = None
 
 class Inline(Implementation):
 
@@ -213,11 +215,23 @@ def full_name(self):
 
     @property
     def file(self):
-        return abspath(inspect.getfile(self.cls))
+        module = sys.modules[self.cls.__module__]
+
+        if hasattr(module, "__file__"):
+            return abspath(module.__file__)
+        else:
+            return None
 
     @property
     def path(self):
-        return dirname(self.file)
+        path = getattr(self.cls, "__base_path__", None)
+
+        if path is not None:
+            return path
+        elif self.file is not None:
+            return dirname(self.file)
+        else:
+            return os.getcwd()
 
     @property
     def implementation(self):
@@ -225,7 +239,7 @@ def implementation(self):
 
         if isinstance(impl, six.string_types):
             if "\n" not in impl and impl.endswith(exts):
-                impl = FromFile(join(self.path, impl))
+                impl = FromFile(impl if isabs(impl) else join(self.path, impl))
             else:
                 impl = CoffeeScript(impl)
 


Test patch:
Repository: bokeh/bokeh

Issue:
Adding size attribute to MultiSelect model
Small feature request: it would be nice to have an attribute to toggle number of visible elements in MultiSelect. Note that this can't exactly be controlled by CSS (the height property can be used, but I'm not sure if there's an easy way to set it to exactly match the height of the options). Since the options can be dynamically set, it seems reasonable to me to also let the size attribute be dynamically set.

This is implemented in these commits: [commit1](https://github.com/azjps/bokeh/commit/504910486751c5e947edd9217f186ede87f82b48), [commit2 which is an unrelated typo fix](https://github.com/azjps/bokeh/commit/0ff1290210af58b59cbecbcd84e98dc6d1248349) I haven't submitted a PR yet, noticed that PR etiquette dictates to submit an issue first.


Discussion:

Resolving patch:
diff --git a/bokeh/models/widgets/inputs.py b/bokeh/models/widgets/inputs.py
--- a/bokeh/models/widgets/inputs.py
+++ b/bokeh/models/widgets/inputs.py
@@ -96,10 +96,16 @@ class MultiSelect(InputWidget):
     """)
 
     callback = Instance(Callback, help="""
-    A callback to run in the browser whenever the current dropdown value
+    A callback to run in the browser whenever the current selection value
     changes.
     """)
 
+    size = Int(default=4, help="""
+    The number of visible options in the dropdown list. (This uses the
+    ``select`` HTML element's ``size`` attribute. Some browsers might not
+    show less than 3 options.)
+    """)
+
 class Slider(InputWidget):
     """ Slider-based number selection widget.
 
diff --git a/examples/models/widgets.py b/examples/models/widgets.py
--- a/examples/models/widgets.py
+++ b/examples/models/widgets.py
@@ -45,7 +45,7 @@
 
 select = Select(options=["Option 1", "Option 2", "Option 3"])
 
-multi_select = MultiSelect(options=["Option 1", "Option 2", "Option 3"])
+multi_select = MultiSelect(options=["Option %d" % (i+1) for i in range(16)], size=6)
 
 slider = Slider(value=10, start=0, end=100)
 


Test patch:
Repository: bokeh/bokeh

Issue:
Docstring typo
`bokeh/models/glyphs.py`

```python
ys = NumberSpec(help="""		     
The x-coordinates for all the lines, given as a "list of lists".
     """)
```


Discussion:

Resolving patch:
diff --git a/bokeh/models/glyphs.py b/bokeh/models/glyphs.py
--- a/bokeh/models/glyphs.py
+++ b/bokeh/models/glyphs.py
@@ -507,7 +507,7 @@ class MultiLine(Glyph):
     """)
 
     ys = NumberSpec(help="""
-    The x-coordinates for all the lines, given as a "list of lists".
+    The y-coordinates for all the lines, given as a "list of lists".
     """)
 
     line_props = Include(LineProps, use_prefix=False, help="""


Test patch: