prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Simplify/refactor filters in bokehjs
  ref https://github.com/bokeh/bokeh/pull/10084#discussion_r432112063
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bokeh/models/filters.py`
  Content:
  ```
  1 #-----------------------------------------------------------------------------
  2 # Copyright (c) 2012 - 2020, Anaconda, Inc., and Bokeh Contributors.
  3 # All rights reserved.
  4 #
  5 # The full license is in the file LICENSE.txt, distributed with this software.
  6 #-----------------------------------------------------------------------------
  7 
  8 #-----------------------------------------------------------------------------
  9 # Boilerplate
  10 #-----------------------------------------------------------------------------
  11 import logging # isort:skip
  12 log = logging.getLogger(__name__)
  13 
  14 #-----------------------------------------------------------------------------
  15 # Imports
  16 #-----------------------------------------------------------------------------
  17 
  18 # Bokeh imports
  19 from ..core.properties import AnyRef, Bool, Dict, Either, Int, Seq, String
  20 from ..model import Model
  21 
  22 #-----------------------------------------------------------------------------
  23 # Globals and constants
  24 #-----------------------------------------------------------------------------
  25 
  26 __all__ = (
  27     'BooleanFilter',
  28     'CustomJSFilter',
  29     'Filter',
  30     'GroupFilter',
  31     'IndexFilter',
  32 )
  33 
  34 #-----------------------------------------------------------------------------
  35 # General API
  36 #-----------------------------------------------------------------------------
  37 
  38 class Filter(Model):
  39     ''' A Filter model represents a filtering operation that returns a row-wise subset of
  40     data when applied to a ``ColumnDataSource``.
  41     '''
  42 
  43     filter = Either(Seq(Int), Seq(Bool), help="""
  44     A list that can be either integer indices or booleans representing a row-wise subset of data.
  45     """)
  46 
  47     def __init__(self, *args, **kw):
  48         if len(args) == 1 and "filter" not in kw:
  49             kw["filter"] = args[0]
  50 
  51         super().__init__(**kw)
  52 
  53 class IndexFilter(Filter):
  54     ''' An ``IndexFilter`` filters data by returning the subset of data at a given set of indices.
  55     '''
  56 
  57     indices = Seq(Int, help="""
  58     A list of integer indices representing the subset of data to select.
  59     """)
  60 
  61     def __init__(self, *args, **kw):
  62         if len(args) == 1 and "indices" not in kw:
  63             kw["indices"] = args[0]
  64 
  65         super().__init__(**kw)
  66 
  67 class BooleanFilter(Filter):
  68     ''' A ``BooleanFilter`` filters data by returning the subset of data corresponding to indices
  69     where the values of the booleans array is True.
  70     '''
  71 
  72     booleans = Seq(Bool, help="""
  73     A list of booleans indicating which rows of data to select.
  74     """)
  75 
  76     def __init__(self, *args, **kw):
  77         if len(args) == 1 and "booleans" not in kw:
  78             kw["booleans"] = args[0]
  79 
  80         super().__init__(**kw)
  81 
  82 class GroupFilter(Filter):
  83     ''' A ``GroupFilter`` represents the rows of a ``ColumnDataSource`` where the values of the categorical
  84     column column_name match the group variable.
  85     '''
  86 
  87     column_name = String(help="""
  88     The name of the column to perform the group filtering operation on.
  89     """)
  90 
  91     group = String(help="""
  92     The value of the column indicating the rows of data to keep.
  93     """)
  94 
  95     def __init__(self, *args, **kw):
  96         if len(args) == 2 and "column_name" not in kw and "group" not in kw:
  97             kw["column_name"] = args[0]
  98             kw["group"] = args[1]
  99 
  100         super().__init__(**kw)
  101 
  102 class CustomJSFilter(Filter):
  103     ''' Filter data sources with a custom defined JavaScript function.
  104 
  105     .. warning::
  106         The explicit purpose of this Bokeh Model is to embed *raw JavaScript
  107         code* for a browser to execute. If any part of the code is derived
  108         from untrusted user inputs, then you must take appropriate care to
  109         sanitize the user input prior to passing to Bokeh.
  110 
  111     '''
  112 
  113     args = Dict(String, AnyRef, help="""
  114     A mapping of names to Python objects. In particular those can be bokeh's models.
  115     These objects are made available to the callback's code snippet as the values of
  116     named parameters to the callback.
  117     """)
  118 
  119     code = String(default="", help="""
  120     A snippet of JavaScript code to filter data contained in a columnar data source.
  121     The code is made into the body of a function, and all of of the named objects in
  122     ``args`` are available as parameters that the code can use. The variable
  123     ``source`` will contain the data source that is associated with the ``CDSView`` this
  124     filter is added to.
  125 
  126     The code should either return the indices of the subset or an array of booleans
  127     to use to subset data source rows.
  128 
  129     Example:
  130 
  131         .. code-block
  132 
  133             code = '''
  134             const indices = []
  135             for (var i = 0; i <= source.data['some_column'].length; i++) {
  136                 if (source.data['some_column'][i] == 'some_value') {
  137                     indices.push(i)
  138                 }
  139             }
  140             return indices
  141             '''
  142 
  143     """)
  144 
  145 #-----------------------------------------------------------------------------
  146 # Dev API
  147 #-----------------------------------------------------------------------------
  148 
  149 #-----------------------------------------------------------------------------
  150 # Private API
  151 #-----------------------------------------------------------------------------
  152 
  153 #-----------------------------------------------------------------------------
  154 # Code
  155 #-----------------------------------------------------------------------------
  156
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/bokeh/models/filters.py b/bokeh/models/filters.py
  --- a/bokeh/models/filters.py
  +++ b/bokeh/models/filters.py
  @@ -16,7 +16,8 @@
   #-----------------------------------------------------------------------------
   
   # Bokeh imports
  -from ..core.properties import AnyRef, Bool, Dict, Either, Int, Seq, String
  +from ..core.has_props import abstract
  +from ..core.properties import AnyRef, Bool, Dict, Int, Seq, String
   from ..model import Model
   
   #-----------------------------------------------------------------------------
  @@ -35,21 +36,12 @@
   # General API
   #-----------------------------------------------------------------------------
   
  +@abstract
   class Filter(Model):
       ''' A Filter model represents a filtering operation that returns a row-wise subset of
       data when applied to a ``ColumnDataSource``.
       '''
   
  -    filter = Either(Seq(Int), Seq(Bool), help="""
  -    A list that can be either integer indices or booleans representing a row-wise subset of data.
  -    """)
  -
  -    def __init__(self, *args, **kw):
  -        if len(args) == 1 and "filter" not in kw:
  -            kw["filter"] = args[0]
  -
  -        super().__init__(**kw)
  -
   class IndexFilter(Filter):
       ''' An ``IndexFilter`` filters data by returning the subset of data at a given set of indices.
       '''
  @@ -132,7 +124,7 @@
   
               code = '''
               const indices = []
  -            for (var i = 0; i <= source.data['some_column'].length; i++) {
  +            for (let i = 0; i <= source.data['some_column'].length; i++) {
                   if (source.data['some_column'][i] == 'some_value') {
                       indices.push(i)
                   }
  
verification_info: {"golden_diff": "diff --git a/bokeh/models/filters.py b/bokeh/models/filters.py\n--- a/bokeh/models/filters.py\n+++ b/bokeh/models/filters.py\n@@ -16,7 +16,8 @@\n #-----------------------------------------------------------------------------\n \n # Bokeh imports\n-from ..core.properties import AnyRef, Bool, Dict, Either, Int, Seq, String\n+from ..core.has_props import abstract\n+from ..core.properties import AnyRef, Bool, Dict, Int, Seq, String\n from ..model import Model\n \n #-----------------------------------------------------------------------------\n@@ -35,21 +36,12 @@\n # General API\n #-----------------------------------------------------------------------------\n \n+@abstract\n class Filter(Model):\n     ''' A Filter model represents a filtering operation that returns a row-wise subset of\n     data when applied to a ``ColumnDataSource``.\n     '''\n \n-    filter = Either(Seq(Int), Seq(Bool), help=\"\"\"\n-    A list that can be either integer indices or booleans representing a row-wise subset of data.\n-    \"\"\")\n-\n-    def __init__(self, *args, **kw):\n-        if len(args) == 1 and \"filter\" not in kw:\n-            kw[\"filter\"] = args[0]\n-\n-        super().__init__(**kw)\n-\n class IndexFilter(Filter):\n     ''' An ``IndexFilter`` filters data by returning the subset of data at a given set of indices.\n     '''\n@@ -132,7 +124,7 @@\n \n             code = '''\n             const indices = []\n-            for (var i = 0; i <= source.data['some_column'].length; i++) {\n+            for (let i = 0; i <= source.data['some_column'].length; i++) {\n                 if (source.data['some_column'][i] == 'some_value') {\n                     indices.push(i)\n                 }\n", "issue": "Simplify/refactor filters in bokehjs\nref https://github.com/bokeh/bokeh/pull/10084#discussion_r432112063\n", "before_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2012 - 2020, Anaconda, Inc., and Bokeh Contributors.\n# All rights reserved.\n#\n# The full license is in the file LICENSE.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Boilerplate\n#-----------------------------------------------------------------------------\nimport logging # isort:skip\nlog = logging.getLogger(__name__)\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n# Bokeh imports\nfrom ..core.properties import AnyRef, Bool, Dict, Either, Int, Seq, String\nfrom ..model import Model\n\n#-----------------------------------------------------------------------------\n# Globals and constants\n#-----------------------------------------------------------------------------\n\n__all__ = (\n    'BooleanFilter',\n    'CustomJSFilter',\n    'Filter',\n    'GroupFilter',\n    'IndexFilter',\n)\n\n#-----------------------------------------------------------------------------\n# General API\n#-----------------------------------------------------------------------------\n\nclass Filter(Model):\n    ''' A Filter model represents a filtering operation that returns a row-wise subset of\n    data when applied to a ``ColumnDataSource``.\n    '''\n\n    filter = Either(Seq(Int), Seq(Bool), help=\"\"\"\n    A list that can be either integer indices or booleans representing a row-wise subset of data.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 1 and \"filter\" not in kw:\n            kw[\"filter\"] = args[0]\n\n        super().__init__(**kw)\n\nclass IndexFilter(Filter):\n    ''' An ``IndexFilter`` filters data by returning the subset of data at a given set of indices.\n    '''\n\n    indices = Seq(Int, help=\"\"\"\n    A list of integer indices representing the subset of data to select.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 1 and \"indices\" not in kw:\n            kw[\"indices\"] = args[0]\n\n        super().__init__(**kw)\n\nclass BooleanFilter(Filter):\n    ''' A ``BooleanFilter`` filters data by returning the subset of data corresponding to indices\n    where the values of the booleans array is True.\n    '''\n\n    booleans = Seq(Bool, help=\"\"\"\n    A list of booleans indicating which rows of data to select.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 1 and \"booleans\" not in kw:\n            kw[\"booleans\"] = args[0]\n\n        super().__init__(**kw)\n\nclass GroupFilter(Filter):\n    ''' A ``GroupFilter`` represents the rows of a ``ColumnDataSource`` where the values of the categorical\n    column column_name match the group variable.\n    '''\n\n    column_name = String(help=\"\"\"\n    The name of the column to perform the group filtering operation on.\n    \"\"\")\n\n    group = String(help=\"\"\"\n    The value of the column indicating the rows of data to keep.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 2 and \"column_name\" not in kw and \"group\" not in kw:\n            kw[\"column_name\"] = args[0]\n            kw[\"group\"] = args[1]\n\n        super().__init__(**kw)\n\nclass CustomJSFilter(Filter):\n    ''' Filter data sources with a custom defined JavaScript function.\n\n    .. warning::\n        The explicit purpose of this Bokeh Model is to embed *raw JavaScript\n        code* for a browser to execute. If any part of the code is derived\n        from untrusted user inputs, then you must take appropriate care to\n        sanitize the user input prior to passing to Bokeh.\n\n    '''\n\n    args = Dict(String, AnyRef, help=\"\"\"\n    A mapping of names to Python objects. In particular those can be bokeh's models.\n    These objects are made available to the callback's code snippet as the values of\n    named parameters to the callback.\n    \"\"\")\n\n    code = String(default=\"\", help=\"\"\"\n    A snippet of JavaScript code to filter data contained in a columnar data source.\n    The code is made into the body of a function, and all of of the named objects in\n    ``args`` are available as parameters that the code can use. The variable\n    ``source`` will contain the data source that is associated with the ``CDSView`` this\n    filter is added to.\n\n    The code should either return the indices of the subset or an array of booleans\n    to use to subset data source rows.\n\n    Example:\n\n        .. code-block\n\n            code = '''\n            const indices = []\n            for (var i = 0; i <= source.data['some_column'].length; i++) {\n                if (source.data['some_column'][i] == 'some_value') {\n                    indices.push(i)\n                }\n            }\n            return indices\n            '''\n\n    \"\"\")\n\n#-----------------------------------------------------------------------------\n# Dev API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Private API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n", "path": "bokeh/models/filters.py"}], "after_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2012 - 2020, Anaconda, Inc., and Bokeh Contributors.\n# All rights reserved.\n#\n# The full license is in the file LICENSE.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Boilerplate\n#-----------------------------------------------------------------------------\nimport logging # isort:skip\nlog = logging.getLogger(__name__)\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n# Bokeh imports\nfrom ..core.has_props import abstract\nfrom ..core.properties import AnyRef, Bool, Dict, Int, Seq, String\nfrom ..model import Model\n\n#-----------------------------------------------------------------------------\n# Globals and constants\n#-----------------------------------------------------------------------------\n\n__all__ = (\n    'BooleanFilter',\n    'CustomJSFilter',\n    'Filter',\n    'GroupFilter',\n    'IndexFilter',\n)\n\n#-----------------------------------------------------------------------------\n# General API\n#-----------------------------------------------------------------------------\n\n@abstract\nclass Filter(Model):\n    ''' A Filter model represents a filtering operation that returns a row-wise subset of\n    data when applied to a ``ColumnDataSource``.\n    '''\n\nclass IndexFilter(Filter):\n    ''' An ``IndexFilter`` filters data by returning the subset of data at a given set of indices.\n    '''\n\n    indices = Seq(Int, help=\"\"\"\n    A list of integer indices representing the subset of data to select.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 1 and \"indices\" not in kw:\n            kw[\"indices\"] = args[0]\n\n        super().__init__(**kw)\n\nclass BooleanFilter(Filter):\n    ''' A ``BooleanFilter`` filters data by returning the subset of data corresponding to indices\n    where the values of the booleans array is True.\n    '''\n\n    booleans = Seq(Bool, help=\"\"\"\n    A list of booleans indicating which rows of data to select.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 1 and \"booleans\" not in kw:\n            kw[\"booleans\"] = args[0]\n\n        super().__init__(**kw)\n\nclass GroupFilter(Filter):\n    ''' A ``GroupFilter`` represents the rows of a ``ColumnDataSource`` where the values of the categorical\n    column column_name match the group variable.\n    '''\n\n    column_name = String(help=\"\"\"\n    The name of the column to perform the group filtering operation on.\n    \"\"\")\n\n    group = String(help=\"\"\"\n    The value of the column indicating the rows of data to keep.\n    \"\"\")\n\n    def __init__(self, *args, **kw):\n        if len(args) == 2 and \"column_name\" not in kw and \"group\" not in kw:\n            kw[\"column_name\"] = args[0]\n            kw[\"group\"] = args[1]\n\n        super().__init__(**kw)\n\nclass CustomJSFilter(Filter):\n    ''' Filter data sources with a custom defined JavaScript function.\n\n    .. warning::\n        The explicit purpose of this Bokeh Model is to embed *raw JavaScript\n        code* for a browser to execute. If any part of the code is derived\n        from untrusted user inputs, then you must take appropriate care to\n        sanitize the user input prior to passing to Bokeh.\n\n    '''\n\n    args = Dict(String, AnyRef, help=\"\"\"\n    A mapping of names to Python objects. In particular those can be bokeh's models.\n    These objects are made available to the callback's code snippet as the values of\n    named parameters to the callback.\n    \"\"\")\n\n    code = String(default=\"\", help=\"\"\"\n    A snippet of JavaScript code to filter data contained in a columnar data source.\n    The code is made into the body of a function, and all of of the named objects in\n    ``args`` are available as parameters that the code can use. The variable\n    ``source`` will contain the data source that is associated with the ``CDSView`` this\n    filter is added to.\n\n    The code should either return the indices of the subset or an array of booleans\n    to use to subset data source rows.\n\n    Example:\n\n        .. code-block\n\n            code = '''\n            const indices = []\n            for (let i = 0; i <= source.data['some_column'].length; i++) {\n                if (source.data['some_column'][i] == 'some_value') {\n                    indices.push(i)\n                }\n            }\n            return indices\n            '''\n\n    \"\"\")\n\n#-----------------------------------------------------------------------------\n# Dev API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Private API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n", "path": "bokeh/models/filters.py"}]}