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

Issue:
docserver.py is not windows compatible
The `docserver.py` script is not windows compatible since it uses `os.fork`. Is there an alternative way of running a doc server on windows?



Discussion:
You can probably just run `python -m http.serve` on the build results. 

Alternatively, looking at the code:

```
    pid = os.fork()
    if pid != 0:
        # Parent process
        http_server.listen(PORT)
        IOLoop.instance().start()
    else:
        # Child process
        import time
        import webbrowser
        time.sleep(0.5)
        webbrowser.open("http://localhost:%d/en/latest/index.html" % PORT, new="tab")
```

The fork is just to be able to nicely open a web-browser, this could probably be put in a `try...except` block, or alternatively removed altogether, and the auto-browser open handled in the makefile somehow. But in the immediate term you can also just comment out everything except whats in the `try` block above


Resolving patch:
diff --git a/sphinx/docserver.py b/sphinx/docserver.py
--- a/sphinx/docserver.py
+++ b/sphinx/docserver.py
@@ -2,15 +2,21 @@
 
 import flask
 import os
+import threading
+import time
+import webbrowser
 
 from tornado.wsgi import WSGIContainer
 from tornado.httpserver import HTTPServer
 from tornado.ioloop import IOLoop
 
+
+
 _basedir = os.path.join("..", os.path.dirname(__file__))
 
 app = flask.Flask(__name__, static_path="/unused")
 PORT=5009
+http_server = HTTPServer(WSGIContainer(app))
 
 """this is a simple server to facilitate developing the docs.  by
 serving up static files from this server, we avoid the need to use a
@@ -32,21 +38,38 @@ def send_pic(filename):
         os.path.join(_basedir,"sphinx/_build/html/"), filename)
 
 
+def open_browser():
+    # Child process
+    time.sleep(0.5)
+    webbrowser.open("http://localhost:%d/en/latest/index.html" % PORT, new="tab")
+
+def serve_http():
+    http_server.listen(PORT)
+    IOLoop.instance().start()
+
+def shutdown_server():
+    ioloop = IOLoop.instance()
+    ioloop.add_callback(ioloop.stop)
+    print("Asked Server to shut down.")
+
+def ui():
+    time.sleep(0.5)
+    input("Press any key to exit...")
+
+
 if __name__ == "__main__":
-    http_server = HTTPServer(WSGIContainer(app))
+
     print("\nStarting Bokeh plot server on port %d..." % PORT)
     print("Visit http://localhost:%d/en/latest/index.html to see plots\n" % PORT)
 
-    pid = os.fork()
-    if pid != 0:
-        # Parent process
-        http_server.listen(PORT)
-        IOLoop.instance().start()
-    else:
-        # Child process
-        import time
-        import webbrowser
-        time.sleep(0.5)
-        webbrowser.open("http://localhost:%d/en/latest/index.html" % PORT, new="tab")
+    t_server = threading.Thread(target=serve_http)  
+    t_server.start()
+    t_browser = threading.Thread(target=open_browser)
+    t_browser.start()
 
+    ui()
 
+    shutdown_server()
+    t_server.join()
+    t_browser.join()
+    print("Server shut down.")


Test patch:
Repository: bokeh/bokeh

Issue:
Bar Plot plotting one value
Hi,

I have discovered following "Bug".
If I have an array looking like this:

```
types = ["car","car","car","car"]
```

and then trying to plot a barplot to look how many and which items in the array exist like this:

```
output_file("Types.html")
typePlot = Bar(types, title="types", tools=TOOLS, xlabel="Types", ylabel="Frequency")
tP = vplot(hplot(typePlot))
show(tP)
```

I get the plot which i expected but if there is only one type of value in the array it does not write the name of the type under the bar as it does with normally two or more different types of values in the barplot.
I hope you can fix this.

Regards,

Marko



Discussion:
That example code does nothing for me. This works, and shows the problem om my machine:

``` python

from bokeh.charts import Bar, output_file, show

types = ["car","car","car","car"]#, "duck", "duck", "cat"]

# Count occurances
df = dict(types=[], counts=[])
for name in set(types):
    df['types'].append(name)
    df['counts'].append(types.count(name))

output_file("Types.html")
typePlot = Bar(df, values='counts',label='types', title="types", xlabel="Types", ylabel="Frequency")
show(typePlot)
```


Resolving patch:
diff --git a/bokeh/charts/builders/bar_builder.py b/bokeh/charts/builders/bar_builder.py
--- a/bokeh/charts/builders/bar_builder.py
+++ b/bokeh/charts/builders/bar_builder.py
@@ -320,7 +320,7 @@ def Bar(data, label=None, values=None, color=None, stack=None, group=None, agg="
     chart = create_and_build(BarBuilder, data, **kw)
 
     # hide x labels if there is a single value, implying stacking only
-    if len(chart.x_range.factors) == 1:
+    if len(chart.x_range.factors) == 1 and not label:
         chart.below[0].visible = False
 
     return chart


Test patch:
diff --git a/bokeh/charts/tests/test_chart.py b/bokeh/charts/tests/test_chart.py
--- a/bokeh/charts/tests/test_chart.py
+++ b/bokeh/charts/tests/test_chart.py
@@ -171,3 +171,24 @@ def test_charts_theme_validation():
 
     with pytest.raises(ValueError):
         defaults.apply(p)
+
+
+def test_bar_chart_below_visibility():
+    from bokeh.charts import Bar
+    
+    # Visible because we have multiple bars
+    df = dict(types=['foo', 'bar'], counts=[3, 2])
+    p = Bar(df, values='counts')
+    p.below[0].visible
+    
+    # Visible because we excplicitly specify labels
+    df = dict(types=['foo'], counts=[3])
+    p = Bar(df, values='counts', label='types')
+    assert p.below[0].visible
+    
+    # Not visible because only one item and no labels
+    df = dict(types=['foo'], counts=[3])
+    p = Bar(df, values='counts')
+    assert not p.below[0].visible
+    
+
Repository: bokeh/bokeh

Issue:
Line picking is broken because glyph.glyph_view is no more
Failing example `plotting/file/line_select.py` -> picking fails, and console reports `TypeError: d0.glyph.glyph_view is undefined`. This is code used in a client project.

The `glyph_view` attribute was removed in https://github.com/bokeh/bokeh/commit/f004054b757c9f84969e2ec353d39b1986626e12, because it breaks the model-view separation. We should either put it back, or find a better way to achieve line picking.



Discussion:

Resolving patch:
diff --git a/examples/plotting/file/line_select.py b/examples/plotting/file/line_select.py
--- a/examples/plotting/file/line_select.py
+++ b/examples/plotting/file/line_select.py
@@ -10,13 +10,15 @@
 # The data is setup to have very different scales in x and y, to verify
 # that picking happens in pixels. Different widths are used to test that
 # you can click anywhere on the visible line.
-
+#
+# Note that the get_view() function used here is not documented and
+# might change in future versions of Bokeh.
 t = np.linspace(0, 0.1, 100)
 
 code = """
 d0 = cb_obj.get("selected")["0d"];
 if (d0.glyph) {
-    var color = d0.glyph.glyph_view.visuals.line.color.value();
+    var color = d0.get_view().visuals.line.line_color.value();
     var data = source.get('data');
     data['text'] = ['Selected the ' + color + ' line'];
     source.trigger('change');


Test patch:
Repository: bokeh/bokeh

Issue:
Docs for styling selection overlays
There is currently no way to style the box or poly overlays that various selection tools use. 



Discussion:
Note: as part of this work it would be good for selection tools on the python side to automatically configure themselves with an appropriate overlay, (exposed as a `.overlay` property) and configure the overlay with itself as the related tool. Additionally, `Plot.add_tool` should request from each tool any renderers to add to itself.

This was completed some time ago, line/fill props on box and poly overlays are now fully configurable, see e.g.:

https://github.com/bokeh/bokeh/blob/master/bokeh/models/annotations.py#L186-L233

But it looks like the docs in tools here are out of date:

https://github.com/bokeh/bokeh/blame/master/sphinx/source/docs/user_guide/tools.rst#L357

Keeping this open but changing to reflect task for docs update 


Resolving patch:
diff --git a/sphinx/source/docs/user_guide/source_examples/styling_tool_overlays.py b/sphinx/source/docs/user_guide/source_examples/styling_tool_overlays.py
--- a/sphinx/source/docs/user_guide/source_examples/styling_tool_overlays.py
+++ b/sphinx/source/docs/user_guide/source_examples/styling_tool_overlays.py
@@ -14,14 +14,18 @@
 
 plot.circle(x, y, size=5)
 
-plot.select_one(BoxSelectTool).overlay.fill_color = "firebrick"
-plot.select_one(BoxSelectTool).overlay.line_color = None
+select_overlay = plot.select_one(BoxSelectTool).overlay
 
-plot.select_one(BoxZoomTool).overlay.line_color = "olive"
-plot.select_one(BoxZoomTool).overlay.line_width = 8
-plot.select_one(BoxZoomTool).overlay.line_dash = "solid"
-plot.select_one(BoxZoomTool).overlay.fill_color = None
+select_overlay.fill_color = "firebrick"
+select_overlay.line_color = None
+
+zoom_overlay = plot.select_one(BoxZoomTool).overlay
+
+zoom_overlay.line_color = "olive"
+zoom_overlay.line_width = 8
+zoom_overlay.line_dash = "solid"
+zoom_overlay.fill_color = None
 
 plot.select_one(LassoSelectTool).overlay.line_dash = [10, 10]
 
-show(plot)
\ No newline at end of file
+show(plot)


Test patch:
Repository: bokeh/bokeh

Issue:
Log PID on server startup
Should log the process ID early on startup when the server starts. 



Discussion:

Resolving patch:
diff --git a/bokeh/command/subcommands/serve.py b/bokeh/command/subcommands/serve.py
--- a/bokeh/command/subcommands/serve.py
+++ b/bokeh/command/subcommands/serve.py
@@ -294,6 +294,8 @@
 from bokeh.util.string import nice_join
 from bokeh.settings import settings
 
+from os import getpid
+
 from ..subcommand import Subcommand
 from ..util import build_single_handler_applications, die
 
@@ -525,4 +527,6 @@ def show_callback():
                  address_string,
                  sorted(applications.keys()))
 
+        log.info("Staring Bokeh server with process id: %d" % getpid())
+
         server.start()


Test patch:
Repository: bokeh/bokeh

Issue:
Add new div widget example to user guide
Widget was added in #4021



Discussion:

Resolving patch:
diff --git a/sphinx/source/docs/user_guide/source_examples/interaction_div.py b/sphinx/source/docs/user_guide/source_examples/interaction_div.py
new file mode 100644
--- /dev/null
+++ b/sphinx/source/docs/user_guide/source_examples/interaction_div.py
@@ -0,0 +1,11 @@
+from bokeh.models.widgets import Div
+from bokeh.io import output_file, show, vform
+
+output_file("div.html")
+
+div = Div(text="""Your <a href="https://en.wikipedia.org/wiki/HTML">HTML</a>-supported text is initialized with the <b>text</b> argument.  The
+remaining div arguments are <b>width</b> and <b>height</b>. For this example, those values
+are <i>200</i> and <i>100</i> respectively.""",
+width=200, height=100)
+
+show(vform(div))


Test patch:
Repository: bokeh/bokeh

Issue:
Toggle button reverses state
If `Toggle` is started with an `active` state, eg: `Toggle(label="Play", active=True)`, it will start out correctly but then reset after the first toggle, flipping the functionality.

![toggle_bug](https://cloud.githubusercontent.com/assets/4411115/14642655/e977b086-0610-11e6-80b5-ecd58c8e6b61.gif)

Here is a code sample to reproduce the bug

``` python
from bokeh.client import push_session
from bokeh.plotting import figure, curdoc, vplot
import datetime
from bokeh.models.widgets import Toggle

x = datetime.datetime(1,1,1,22,0,00)

TOOLS = "pan,wheel_zoom,box_zoom,reset,save,box_select"

p1 = figure(title="Button Toggle Bug", tools=TOOLS, x_axis_type="datetime")

c1 = p1.circle([x, x + datetime.timedelta(0,1)], [0, 1], legend="Red", color="red")


# open a session to keep our local document in sync with server
session = push_session(curdoc())

play = True

def update():
    c1.data_source.data["x"].append(c1.data_source.data["x"][-1] + datetime.timedelta(0,1))
    c1.data_source.data["y"].append(c1.data_source.data["y"][-1] + (c1.data_source.data["y"][-2] / 2.0))

    if play:
        c1.data_source.trigger('data',  c1.data_source.data,  c1.data_source.data)

curdoc().add_periodic_callback(update, 500)

def play_pause(arg):
    global play
    play = not play


# add a button widget and configure with the call back
play_toggle = Toggle(label="Play", active=True)
play_toggle.on_click(play_pause)

curdoc().add_root(vplot(play_toggle, p1))

session.show() # open the document in a browser

session.loop_until_closed() # run forever
```

and it is a server plot, so you have to have `bokeh serve` running.

The version info is 

``` bash
09:20 $ bokeh info
Python version      :  2.7.11 |Anaconda 2.2.0 (x86_64)| (default, Dec  6 2015, 18:57:58)
IPython version     :  2.2.0
Bokeh version       :  0.11.1
BokehJS static path :  /Users/kevincolten/anaconda/lib/python2.7/site-packages/bokeh/server/static
```



Discussion:
For later reference:
Debugging should probably start [here](https://github.com/bokeh/bokeh/blob/384354170b517cf55a4e8443bf49b1a1ae075ce9/bokehjs/src/coffee/models/widgets/toggle.coffee#L42)

I would probably write the callback like:

``` python
def play_pause(arg):
    global play
    play = arg
```

But regardless, I can confirm that the produced arg is wrong.


Resolving patch:
diff --git a/bokeh/command/subcommands/serve.py b/bokeh/command/subcommands/serve.py
--- a/bokeh/command/subcommands/serve.py
+++ b/bokeh/command/subcommands/serve.py
@@ -527,6 +527,6 @@ def show_callback():
                  address_string,
                  sorted(applications.keys()))
 
-        log.info("Staring Bokeh server with process id: %d" % getpid())
+        log.info("Starting Bokeh server with process id: %d" % getpid())
 
         server.start()


Test patch:
Repository: bokeh/bokeh

Issue:
Histogram empty plot with negative values
We observed that plotting of an unique negative value vector does print an empty Histogram. This is quite an artificial test case, however we would like to report it.

```
from bokeh.models import Range1d
from bokeh.charts import Histogram, output_file, show, vplot, hplot, Bar, defaults

arr = [-21, -21, -21, -21, -21]

output_file("Hist.html")
p1 = Histogram(arr, title="Histogram", xlabel="Distances", ylabel="Counts", bins=2)
p1.x_range = Range1d(-25, 25) 

p = vplot(hplot(p1))
show(p)
```



Discussion:

Resolving patch:
diff --git a/bokeh/charts/builders/histogram_builder.py b/bokeh/charts/builders/histogram_builder.py
--- a/bokeh/charts/builders/histogram_builder.py
+++ b/bokeh/charts/builders/histogram_builder.py
@@ -46,9 +46,11 @@ def Histogram(data, values=None, label=None, color=None, agg="count",
     This chart implements functionality to provide convenience in optimal
     selection of bin count, but also for segmenting and comparing segments of
     the variable by a categorical variable.
-
+    
     Args:
-      data (:ref:`userguide_charts_data_types`): the data source for the chart
+      data (:ref:`userguide_charts_data_types`): the data source for the chart.
+        Must consist of at least 2 values. If all values are equal, the result
+        is a single bin with arbitrary width.
       values (str, optional): the values to use for producing the histogram using
         table-like input data
       label (str or list(str), optional): the categorical variable to use for creating
@@ -110,8 +112,8 @@ class HistogramBuilder(BarBuilder):
     """
 
     bins = Int(default=None, help="""
-    Number of bins to use for the histogram. (default: None
-    (use Freedman-Diaconis rule)
+    Number of bins to use for the histogram. (default: None,
+    use Freedman-Diaconis rule)
     """)
 
     density = Bool(True, help="""
diff --git a/bokeh/charts/stats.py b/bokeh/charts/stats.py
--- a/bokeh/charts/stats.py
+++ b/bokeh/charts/stats.py
@@ -334,7 +334,18 @@ def calculate(self):
         self.bin_column = self.column + bin_str
         bin_models = []
 
-        binned, bin_bounds = pd.cut(self.bin_stat.get_data(), self.bin_stat.bin_count,
+        data = self.bin_stat.get_data()
+        bins = self.bin_stat.bin_count
+
+        # Choose bin bounds when data range is ill-defined; pd.cut()
+        # does not handle this well for values that are <= 0
+        if data.size < 2:
+            raise ValueError('Histogram data must have at least two elements.')
+        if data.ndim == 1 and data.std() == 0:
+            margin = 0.01 * abs(float(data[0])) or 0.01
+            bins = np.linspace(data[0] - margin, data[0] + margin, bins+1)
+
+        binned, bin_bounds = pd.cut(data, bins,
                                     retbins=True, include_lowest=True, precision=0)
 
         self.bin_width = np.round(bin_bounds[2] - bin_bounds[1], 1)


Test patch:
Repository: bokeh/bokeh

Issue:
Make reset tool configurable as to what is reset
Request for client work that reset tool not also reset the plot canvas dimensions.  Having it reset the canvas dimensions was added as a request to numerous user requests. Propose to make a configurable property to control whether canvas dimensions are also reset. 



Discussion:
ping @dwillmer 


Resolving patch:
diff --git a/bokeh/models/tools.py b/bokeh/models/tools.py
--- a/bokeh/models/tools.py
+++ b/bokeh/models/tools.py
@@ -128,14 +128,16 @@ class ResetTool(Tool):
     resets the data bounds of the plot to their values when the plot was
     initially created.
 
-    .. note::
-        This tool does not also reset the plot canvas size, if the plot
-        has been resized using the ``ResizeTool``. That feature may be
-        added in a future release.
+    Optionally, the reset tool also resets the plat canvas dimensions to
+    their original size
 
     .. |reset_icon| image:: /_images/icons/Reset.png
         :height: 18pt
     """
+    reset_size = Bool(default=True, help="""
+    Whether activating the Reset tool should also reset the plot's canvas
+    dimensions to their original size.
+    """)
 
 
 class ResizeTool(Tool):
@@ -291,7 +293,7 @@ class BoxZoomTool(Tool):
 
     .. note::
         If the tool is restricted to one dimension, this value has
-        no effect. 
+        no effect.
 
     """)
 


Test patch:
Repository: bokeh/bokeh

Issue:
Add paragraph and pretext widgets to user guide
Similar to issue #4122 



Discussion:

Resolving patch:
diff --git a/sphinx/source/docs/user_guide/source_examples/interaction_paragraph.py b/sphinx/source/docs/user_guide/source_examples/interaction_paragraph.py
new file mode 100644
--- /dev/null
+++ b/sphinx/source/docs/user_guide/source_examples/interaction_paragraph.py
@@ -0,0 +1,11 @@
+from bokeh.models.widgets import Paragraph
+from bokeh.io import output_file, show, vform
+
+output_file("div.html")
+
+p = Paragraph(text="""Your text is initialized with the 'text' argument.  The
+remaining Paragraph arguments are 'width' and 'height'. For this example, those values
+are 200 and 100 respectively.""",
+width=200, height=100)
+
+show(vform(p))
diff --git a/sphinx/source/docs/user_guide/source_examples/interaction_pretext.py b/sphinx/source/docs/user_guide/source_examples/interaction_pretext.py
new file mode 100644
--- /dev/null
+++ b/sphinx/source/docs/user_guide/source_examples/interaction_pretext.py
@@ -0,0 +1,12 @@
+from bokeh.models.widgets import PreText
+from bokeh.io import output_file, show, vform
+
+output_file("div.html")
+
+pre = PreText(text="""Your text is initialized with the 'text' argument.
+
+The remaining Paragraph arguments are 'width' and 'height'. For this example,
+those values are 500 and 100 respectively.""",
+width=500, height=100)
+
+show(vform(pre))


Test patch:
Repository: bokeh/bokeh

Issue:
New strict JS property updates broke DatetimeTickFormatter
The `formats` property is actually a bit problematic. The values sent from python are actually diffs applied on top of a standard base set of formats stored in BokehJS. The "final computed" formats were stored in `@formats` but recent properties changes made `@formats` equivalent to `@get('formats')` however the "final computed" formats actually contain other information and fail validation with errors like: 

```
2016-04-22 15:41:45,748 error handling message Message 'PATCH-DOC' (revision 1): DeserializationError('String expected str, got [6]',)
2016-04-22 15:41:45,749   message header {'msgtype': 'PATCH-DOC', 'msgid': '2DCC546DE9464C298093EC714AF6DE29'} content {'references': [], 'events': [{'attr': 'formats', 'new': {'minsec': [[6], [':%M:%S']], 'microseconds': [[8], ['%fus']], 'milliseconds': [[5, 7], ['%3Nms', '%S.%3Ns']], 'months': [[5, 7], ['%b%y', '%m/%Y']], 'days': [[5, 5], ['%m/%d', '%a%d']], 'years': [[3, 4, 4], [{}, '%Y', {}]], 'seconds': [[3], ['%Ss']], 'hourmin': [[5], ['%H:%M']], 'hours': [[3, 5], ['%Hh', '%H:%M']], 'minutes': [[3, 3], [':%M', '%Mm']]}, 'kind': 'ModelChanged', 'model': {'type': 'DatetimeTickFormatter', 'id': 'e492fb4b-edef-48b9-8846-abd1960e6b1a'}}, {'attr': 'formats', 'new': {'minsec': [[6], [':%M:%S']], 'microseconds': [[8], ['%fus']], 'milliseconds': [[5, 7], ['%3Nms', '%S.%3Ns']], 'months': [[5, 7], ['%b%y', '%m/%Y']], 'days': [[5, 5], ['%m/%d', '%a%d']], 'years': [[3, 4, 4], [{}, '%Y', {}]], 'seconds': [[3], ['%Ss']], 'hourmin': [[5], ['%H:%M']], 'hours': [[3, 5], ['%Hh', '%H:%M']], 'minutes': [[3, 3], [':%M', '%Mm']]}, 'kind': 'ModelChanged', 'model': {'type': 'DatetimeTickFormatter', 'id': '02ed10d1-f233-43d5-bc22-0585f1249521'}}]}
```



Discussion:

Resolving patch:
diff --git a/bokeh/models/formatters.py b/bokeh/models/formatters.py
--- a/bokeh/models/formatters.py
+++ b/bokeh/models/formatters.py
@@ -200,13 +200,26 @@ class CategoricalTickFormatter(TickFormatter):
     """
     pass
 
+DEFAULT_DATETIME_FORMATS = lambda : {
+    'microseconds': ['%fus'],
+    'milliseconds': ['%3Nms', '%S.%3Ns'],
+    'seconds':      ['%Ss'],
+    'minsec':       [':%M:%S'],
+    'minutes':      [':%M', '%Mm'],
+    'hourmin':      ['%H:%M'],
+    'hours':        ['%Hh', '%H:%M'],
+    'days':         ['%m/%d', '%a%d'],
+    'months':       ['%m/%Y', '%b%y'],
+    'years':        ['%Y'],
+}
+
 class DatetimeTickFormatter(TickFormatter):
     """ Display tick values from a continuous range as formatted
     datetimes.
 
     """
 
-    formats = Dict(Enum(DatetimeUnits), List(String), help="""
+    formats = Dict(Enum(DatetimeUnits), List(String), default=DEFAULT_DATETIME_FORMATS, help="""
     User defined formats for displaying datetime values.
 
     The enum values correspond roughly to different "time scales". The


Test patch: