We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Scale/Range incompatibility in examples/models/server/population.py
in master:

Scale/Range incompatibility in examples/models/server/population.py

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/models/server/population.py`
Content:
```
1 from __future__ import print_function
2 
3 from math import pi
4 
5 from bokeh.client import push_session
6 from bokeh.document import Document
7 from bokeh.models.glyphs import Line, HBar
8 from bokeh.models import (Plot, ColumnDataSource, DataRange1d, FactorRange,
9                           LinearAxis, CategoricalAxis, Grid, Legend, CategoricalScale)
10 from bokeh.sampledata.population import load_population
11 from bokeh.models.widgets import Select
12 from bokeh.models.layouts import WidgetBox, Column
13 
14 document = Document()
15 session = push_session(document)
16 
17 df = load_population()
18 revision = 2012
19 
20 year, location = 2010, "World"
21 
22 years = [str(x) for x in sorted(df.Year.unique())]
23 locations = sorted(df.Location.unique())
24 groups =  [str(x) for x in df.AgeGrp.unique()]
25 groups.remove('80+') # remove oddball group
26 
27 source_pyramid_m = ColumnDataSource(data=dict(value=[], group=[]))
28 source_pyramid_f = ColumnDataSource(data=dict(value=[], group=[]))
29 
30 def pyramid():
31     xdr = DataRange1d()
32     ydr = FactorRange(factors=groups)
33     y_scale = CategoricalScale()
34 
35     plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=500, toolbar_location=None)
36 
37     xaxis = LinearAxis()
38     plot.add_layout(xaxis, 'below')
39     plot.add_layout(CategoricalAxis(), 'left')
40 
41     plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
42 
43     m = HBar(left="value", right=0, y="group", height=1, fill_color="#3B8686")
44     mglyph = plot.add_glyph(source_pyramid_m, m)
45 
46     f = HBar(left=0, right="value", y="group", height=1, fill_color="#CFF09E")
47     fglyph = plot.add_glyph(source_pyramid_f, f)
48 
49     plot.add_layout(Legend(items=[("Male" , [mglyph]), ("Female" , [fglyph])]))
50 
51     return plot
52 
53 source_known = ColumnDataSource(data=dict(x=[], y=[]))
54 source_predicted = ColumnDataSource(data=dict(x=[], y=[]))
55 
56 def population():
57     xdr = FactorRange(factors=years)
58     ydr = DataRange1d()
59     y_scale = CategoricalScale()
60 
61     plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=150, toolbar_location=None)
62 
63     plot.add_layout(CategoricalAxis(major_label_orientation=pi / 4), 'below')
64 
65     known = Line(x="x", y="y", line_color="violet", line_width=2)
66     known_glyph = plot.add_glyph(source_known, known)
67 
68     predicted = Line(x="x", y="y", line_color="violet", line_width=2, line_dash="dashed")
69     predicted_glyph = plot.add_glyph(source_predicted, predicted)
70 
71     legend = Legend(location="bottom_right",
72                     items=[("known", [known_glyph]), ("predicted", [predicted_glyph])])
73     plot.add_layout(legend)
74 
75     return plot
76 
77 def update_pyramid():
78     pyramid = df[(df.Location == location) & (df.Year == year)]
79 
80     male = pyramid[pyramid.Sex == "Male"]
81     female = pyramid[pyramid.Sex == "Female"]
82 
83     total = df.Value.sum()
84     male_percent = -male.Value / total
85     female_percent = female.Value / total
86 
87     source_pyramid_m.data = dict(
88         group=[str(x) for x in male.AgeGrp.unique()],
89         value=male_percent,
90     )
91     source_pyramid_f.data = dict(
92         group=[str(x) for x in female.AgeGrp.unique()],
93         value=female_percent,
94     )
95 
96 def update_population():
97     population = df[df.Location == location].groupby(df.Year).Value.sum()
98     aligned_revision = revision // 10 * 10
99 
100     known = population[population.index <= aligned_revision]
101     predicted = population[population.index >= aligned_revision]
102 
103     source_known.data = dict(x=known.index.map(str), y=known.values)
104     source_predicted.data = dict(x=predicted.index.map(str), y=predicted.values)
105 
106 def update_data():
107     update_population()
108     update_pyramid()
109 
110 def on_year_change(attr, old, new):
111     global year
112     year = int(new)
113     update_data()
114 
115 def on_location_change(attr, old, new):
116     global location
117     location = new
118     update_data()
119 
120 def create_layout():
121     year_select = Select(title="Year:", value="2010", options=years)
122     location_select = Select(title="Location:", value="World", options=locations)
123 
124     year_select.on_change('value', on_year_change)
125     location_select.on_change('value', on_location_change)
126 
127     controls = WidgetBox(children=[year_select, location_select], height=150, width=600)
128     layout = Column(children=[controls, pyramid(), population()])
129 
130     return layout
131 
132 layout = create_layout()
133 
134 update_data()
135 
136 document.add_root(layout)
137 session.show(layout)
138 
139 if __name__ == "__main__":
140     document.validate()
141     print("\npress ctrl-C to exit")
142     session.loop_until_closed()
143
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/models/server/population.py b/examples/models/server/population.py
--- a/examples/models/server/population.py
+++ b/examples/models/server/population.py
@@ -56,9 +56,9 @@
 def population():
     xdr = FactorRange(factors=years)
     ydr = DataRange1d()
-    y_scale = CategoricalScale()
+    x_scale = CategoricalScale()
 
-    plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=150, toolbar_location=None)
+    plot = Plot(x_range=xdr, y_range=ydr, x_scale=x_scale, plot_width=600, plot_height=150, toolbar_location=None)
 
     plot.add_layout(CategoricalAxis(major_label_orientation=pi / 4), 'below')

{"golden_diff": "diff --git a/examples/models/server/population.py b/examples/models/server/population.py\n--- a/examples/models/server/population.py\n+++ b/examples/models/server/population.py\n@@ -56,9 +56,9 @@\n def population():\n     xdr = FactorRange(factors=years)\n     ydr = DataRange1d()\n-    y_scale = CategoricalScale()\n+    x_scale = CategoricalScale()\n \n-    plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=150, toolbar_location=None)\n+    plot = Plot(x_range=xdr, y_range=ydr, x_scale=x_scale, plot_width=600, plot_height=150, toolbar_location=None)\n \n     plot.add_layout(CategoricalAxis(major_label_orientation=pi / 4), 'below')\n", "issue": "Scale/Range incompatibility in examples/models/server/population.py\nin master:\r\n\r\nScale/Range incompatibility in examples/models/server/population.py\n", "before_files": [{"content": "from __future__ import print_function\n\nfrom math import pi\n\nfrom bokeh.client import push_session\nfrom bokeh.document import Document\nfrom bokeh.models.glyphs import Line, HBar\nfrom bokeh.models import (Plot, ColumnDataSource, DataRange1d, FactorRange,\n                          LinearAxis, CategoricalAxis, Grid, Legend, CategoricalScale)\nfrom bokeh.sampledata.population import load_population\nfrom bokeh.models.widgets import Select\nfrom bokeh.models.layouts import WidgetBox, Column\n\ndocument = Document()\nsession = push_session(document)\n\ndf = load_population()\nrevision = 2012\n\nyear, location = 2010, \"World\"\n\nyears = [str(x) for x in sorted(df.Year.unique())]\nlocations = sorted(df.Location.unique())\ngroups =  [str(x) for x in df.AgeGrp.unique()]\ngroups.remove('80+') # remove oddball group\n\nsource_pyramid_m = ColumnDataSource(data=dict(value=[], group=[]))\nsource_pyramid_f = ColumnDataSource(data=dict(value=[], group=[]))\n\ndef pyramid():\n    xdr = DataRange1d()\n    ydr = FactorRange(factors=groups)\n    y_scale = CategoricalScale()\n\n    plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=500, toolbar_location=None)\n\n    xaxis = LinearAxis()\n    plot.add_layout(xaxis, 'below')\n    plot.add_layout(CategoricalAxis(), 'left')\n\n    plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))\n\n    m = HBar(left=\"value\", right=0, y=\"group\", height=1, fill_color=\"#3B8686\")\n    mglyph = plot.add_glyph(source_pyramid_m, m)\n\n    f = HBar(left=0, right=\"value\", y=\"group\", height=1, fill_color=\"#CFF09E\")\n    fglyph = plot.add_glyph(source_pyramid_f, f)\n\n    plot.add_layout(Legend(items=[(\"Male\" , [mglyph]), (\"Female\" , [fglyph])]))\n\n    return plot\n\nsource_known = ColumnDataSource(data=dict(x=[], y=[]))\nsource_predicted = ColumnDataSource(data=dict(x=[], y=[]))\n\ndef population():\n    xdr = FactorRange(factors=years)\n    ydr = DataRange1d()\n    y_scale = CategoricalScale()\n\n    plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=150, toolbar_location=None)\n\n    plot.add_layout(CategoricalAxis(major_label_orientation=pi / 4), 'below')\n\n    known = Line(x=\"x\", y=\"y\", line_color=\"violet\", line_width=2)\n    known_glyph = plot.add_glyph(source_known, known)\n\n    predicted = Line(x=\"x\", y=\"y\", line_color=\"violet\", line_width=2, line_dash=\"dashed\")\n    predicted_glyph = plot.add_glyph(source_predicted, predicted)\n\n    legend = Legend(location=\"bottom_right\",\n                    items=[(\"known\", [known_glyph]), (\"predicted\", [predicted_glyph])])\n    plot.add_layout(legend)\n\n    return plot\n\ndef update_pyramid():\n    pyramid = df[(df.Location == location) & (df.Year == year)]\n\n    male = pyramid[pyramid.Sex == \"Male\"]\n    female = pyramid[pyramid.Sex == \"Female\"]\n\n    total = df.Value.sum()\n    male_percent = -male.Value / total\n    female_percent = female.Value / total\n\n    source_pyramid_m.data = dict(\n        group=[str(x) for x in male.AgeGrp.unique()],\n        value=male_percent,\n    )\n    source_pyramid_f.data = dict(\n        group=[str(x) for x in female.AgeGrp.unique()],\n        value=female_percent,\n    )\n\ndef update_population():\n    population = df[df.Location == location].groupby(df.Year).Value.sum()\n    aligned_revision = revision // 10 * 10\n\n    known = population[population.index <= aligned_revision]\n    predicted = population[population.index >= aligned_revision]\n\n    source_known.data = dict(x=known.index.map(str), y=known.values)\n    source_predicted.data = dict(x=predicted.index.map(str), y=predicted.values)\n\ndef update_data():\n    update_population()\n    update_pyramid()\n\ndef on_year_change(attr, old, new):\n    global year\n    year = int(new)\n    update_data()\n\ndef on_location_change(attr, old, new):\n    global location\n    location = new\n    update_data()\n\ndef create_layout():\n    year_select = Select(title=\"Year:\", value=\"2010\", options=years)\n    location_select = Select(title=\"Location:\", value=\"World\", options=locations)\n\n    year_select.on_change('value', on_year_change)\n    location_select.on_change('value', on_location_change)\n\n    controls = WidgetBox(children=[year_select, location_select], height=150, width=600)\n    layout = Column(children=[controls, pyramid(), population()])\n\n    return layout\n\nlayout = create_layout()\n\nupdate_data()\n\ndocument.add_root(layout)\nsession.show(layout)\n\nif __name__ == \"__main__\":\n    document.validate()\n    print(\"\\npress ctrl-C to exit\")\n    session.loop_until_closed()\n", "path": "examples/models/server/population.py"}], "after_files": [{"content": "from __future__ import print_function\n\nfrom math import pi\n\nfrom bokeh.client import push_session\nfrom bokeh.document import Document\nfrom bokeh.models.glyphs import Line, HBar\nfrom bokeh.models import (Plot, ColumnDataSource, DataRange1d, FactorRange,\n                          LinearAxis, CategoricalAxis, Grid, Legend, CategoricalScale)\nfrom bokeh.sampledata.population import load_population\nfrom bokeh.models.widgets import Select\nfrom bokeh.models.layouts import WidgetBox, Column\n\ndocument = Document()\nsession = push_session(document)\n\ndf = load_population()\nrevision = 2012\n\nyear, location = 2010, \"World\"\n\nyears = [str(x) for x in sorted(df.Year.unique())]\nlocations = sorted(df.Location.unique())\ngroups =  [str(x) for x in df.AgeGrp.unique()]\ngroups.remove('80+') # remove oddball group\n\nsource_pyramid_m = ColumnDataSource(data=dict(value=[], group=[]))\nsource_pyramid_f = ColumnDataSource(data=dict(value=[], group=[]))\n\ndef pyramid():\n    xdr = DataRange1d()\n    ydr = FactorRange(factors=groups)\n    y_scale = CategoricalScale()\n\n    plot = Plot(x_range=xdr, y_range=ydr, y_scale=y_scale, plot_width=600, plot_height=500, toolbar_location=None)\n\n    xaxis = LinearAxis()\n    plot.add_layout(xaxis, 'below')\n    plot.add_layout(CategoricalAxis(), 'left')\n\n    plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))\n\n    m = HBar(left=\"value\", right=0, y=\"group\", height=1, fill_color=\"#3B8686\")\n    mglyph = plot.add_glyph(source_pyramid_m, m)\n\n    f = HBar(left=0, right=\"value\", y=\"group\", height=1, fill_color=\"#CFF09E\")\n    fglyph = plot.add_glyph(source_pyramid_f, f)\n\n    plot.add_layout(Legend(items=[(\"Male\" , [mglyph]), (\"Female\" , [fglyph])]))\n\n    return plot\n\nsource_known = ColumnDataSource(data=dict(x=[], y=[]))\nsource_predicted = ColumnDataSource(data=dict(x=[], y=[]))\n\ndef population():\n    xdr = FactorRange(factors=years)\n    ydr = DataRange1d()\n    x_scale = CategoricalScale()\n\n    plot = Plot(x_range=xdr, y_range=ydr, x_scale=x_scale, plot_width=600, plot_height=150, toolbar_location=None)\n\n    plot.add_layout(CategoricalAxis(major_label_orientation=pi / 4), 'below')\n\n    known = Line(x=\"x\", y=\"y\", line_color=\"violet\", line_width=2)\n    known_glyph = plot.add_glyph(source_known, known)\n\n    predicted = Line(x=\"x\", y=\"y\", line_color=\"violet\", line_width=2, line_dash=\"dashed\")\n    predicted_glyph = plot.add_glyph(source_predicted, predicted)\n\n    legend = Legend(location=\"bottom_right\",\n                    items=[(\"known\", [known_glyph]), (\"predicted\", [predicted_glyph])])\n    plot.add_layout(legend)\n\n    return plot\n\ndef update_pyramid():\n    pyramid = df[(df.Location == location) & (df.Year == year)]\n\n    male = pyramid[pyramid.Sex == \"Male\"]\n    female = pyramid[pyramid.Sex == \"Female\"]\n\n    total = df.Value.sum()\n    male_percent = -male.Value / total\n    female_percent = female.Value / total\n\n    source_pyramid_m.data = dict(\n        group=[str(x) for x in male.AgeGrp.unique()],\n        value=male_percent,\n    )\n    source_pyramid_f.data = dict(\n        group=[str(x) for x in female.AgeGrp.unique()],\n        value=female_percent,\n    )\n\ndef update_population():\n    population = df[df.Location == location].groupby(df.Year).Value.sum()\n    aligned_revision = revision // 10 * 10\n\n    known = population[population.index <= aligned_revision]\n    predicted = population[population.index >= aligned_revision]\n\n    source_known.data = dict(x=known.index.map(str), y=known.values)\n    source_predicted.data = dict(x=predicted.index.map(str), y=predicted.values)\n\ndef update_data():\n    update_population()\n    update_pyramid()\n\ndef on_year_change(attr, old, new):\n    global year\n    year = int(new)\n    update_data()\n\ndef on_location_change(attr, old, new):\n    global location\n    location = new\n    update_data()\n\ndef create_layout():\n    year_select = Select(title=\"Year:\", value=\"2010\", options=years)\n    location_select = Select(title=\"Location:\", value=\"World\", options=locations)\n\n    year_select.on_change('value', on_year_change)\n    location_select.on_change('value', on_location_change)\n\n    controls = WidgetBox(children=[year_select, location_select], height=150, width=600)\n    layout = Column(children=[controls, pyramid(), population()])\n\n    return layout\n\nlayout = create_layout()\n\nupdate_data()\n\ndocument.add_root(layout)\nsession.show(layout)\n\nif __name__ == \"__main__\":\n    document.validate()\n    print(\"\\npress ctrl-C to exit\")\n    session.loop_until_closed()\n", "path": "examples/models/server/population.py"}]}