We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
How to call dev/_make_missing_functions.py?
```
rxin @ C02XT0W6JGH5 : ~/workspace/spark-pandas (master) 
> dev/_make_missing_functions.py 
Traceback (most recent call last):
  File "dev/_make_missing_functions.py", line 22, in <module>
    from databricks.koala.frame import PandasLikeDataFrame
ImportError: No module named databricks.koala.frame
```

Do I need to install koala first? We should add documentation to CONTRIBUTING.md. It'd also be best if this runs against the existing code base, rather than a system-wide installed Koala.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dev/_make_missing_functions.py`
Content:
```
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2019 Databricks, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 
18 import inspect
19 
20 import pandas as pd
21 
22 from databricks.koalas.frame import PandasLikeDataFrame
23 from databricks.koalas.missing.frame import _MissingPandasLikeDataFrame
24 from databricks.koalas.missing.series import _MissingPandasLikeSeries
25 from databricks.koalas.series import PandasLikeSeries
26 
27 
28 INDENT_LEN = 4
29 LINE_LEN_LIMIT = 100
30 
31 
32 def inspect_missing_functions(original_type, target_type, missing_type):
33     """
34     Find functions which exist in original_type but not in target_type,
35     or the signature is modified.
36 
37     :return: the tuple of the missing function name and its signature,
38              and the name of the functions the signature of which is different
39              and its original and modified signature.
40     """
41     missing = []
42     modified = []
43 
44     already_in_missing = set([(name, inspect.signature(func)) for name, func
45                               in inspect.getmembers(missing_type, inspect.isfunction)])
46     for name, func in inspect.getmembers(original_type, inspect.isfunction):
47         # Skip the private attributes
48         if name.startswith('_'):
49             continue
50 
51         original_signature = inspect.signature(func, follow_wrapped=True)
52 
53         if hasattr(target_type, name):
54             f = getattr(target_type, name)
55             if inspect.isfunction(f):
56                 target_signature = inspect.signature(f)
57                 if (name, target_signature) in already_in_missing:
58                     missing.append((name, original_signature))
59                 elif str(original_signature) != str(target_signature):
60                     modified.append((name, original_signature, target_signature))
61                 continue
62 
63         missing.append((name, original_signature))
64 
65     return missing, modified
66 
67 
68 def format_arguments(arguments, prefix_len, suffix_len):
69     """Format arguments not to break pydocstyle.
70 
71     :param arguments: the argument list
72     :param prefix_len: the prefix length when the argument string needs line break
73     :param suffix_len: the suffix length to check the line length exceeds the limit
74     :return: the formatted argument string
75     """
76     lines = ['']
77 
78     def append_arg(arg):
79         if prefix_len + len(lines[-1]) + len(', ') + len(arg) + suffix_len > LINE_LEN_LIMIT:
80             lines.append('')
81             append_arg(arg)
82         else:
83             if len(lines[-1]) > 0:
84                 arg = ', {}'.format(arg)
85             lines[-1] += arg
86 
87     for arg in arguments:
88         append_arg(arg)
89 
90     return (',\n' + (' ' * prefix_len)).join(lines)
91 
92 
93 def format_method_arguments(name, signature):
94     """Format the method arguments from its name and signature.
95 
96     :return: the formatted argument string
97     """
98     arguments = []
99 
100     for param in signature.parameters.values():
101         if param.default is not inspect.Signature.empty and isinstance(param.default, type):
102             arguments.append('{}={}'.format(param.name, param.default.__name__))
103         elif param.default is not inspect.Signature.empty and repr(param.default) == 'nan':
104             arguments.append('{}={}'.format(param.name, 'np.nan'))
105         else:
106             arguments.append(str(param))
107 
108     prefix_len = INDENT_LEN + len('def {}('.format(name))
109     suffix_len = len('):')
110     return format_arguments(arguments, prefix_len, suffix_len)
111 
112 
113 def format_derived_from(original_type, unavailable_arguments, signature):
114     """Format `@derived_from` decorator.
115 
116     :param original_type: the original type to be derived
117     :param unavailable_arguments: the arguments Koalas does not support yet
118     :param signature: the method signature
119     :return: the formatted `@derived_from` decorator
120     """
121     if len(unavailable_arguments) == 0:
122         return '@derived_from(pd.{})'.format(original_type.__name__)
123 
124     arguments = []
125 
126     for arg in unavailable_arguments:
127         param = signature.parameters[arg]
128         if param.default == inspect.Parameter.empty or \
129                 param.kind == inspect.Parameter.VAR_POSITIONAL or \
130                 param.kind == inspect.Parameter.VAR_KEYWORD:
131             continue
132         arguments.append(repr(arg))
133 
134     prefix = '@derived_from(pd.{}, ua_args=['.format(original_type.__name__)
135     suffix = '])'
136     prefix_len = INDENT_LEN + len(prefix)
137     suffix_len = len(suffix)
138     return '{}{}{}'.format(prefix, format_arguments(arguments, prefix_len, suffix_len), suffix)
139 
140 
141 def format_raise_errors(original_type, name, unavailable_arguments, signature):
142     """
143     Format raise error statements for unavailable arguments when specified the different value
144     from the default value.
145 
146     :return: the formatted raise error statements
147     """
148     raise_errors = ''
149 
150     for arg in unavailable_arguments:
151         param = signature.parameters[arg]
152         if param.default == inspect.Parameter.empty or \
153                 param.kind == inspect.Parameter.VAR_POSITIONAL or \
154                 param.kind == inspect.Parameter.VAR_KEYWORD:
155             continue
156         if repr(param.default) == 'nan':
157             not_equal = 'not np.isnan({})'.format(arg)
158         elif isinstance(param.default, type):
159             not_equal = '{} is not {}'.format(arg, param.default.__name__)
160         elif param.default is None or \
161                 param.default is True or param.default is False:
162             not_equal = '{} is not {}'.format(arg, repr(param.default))
163         else:
164             not_equal = '{} != {}'.format(arg, repr(param.default))
165 
166         raise_error_prefix = 'raise PandasNotImplementedError('
167         raise_error_suffix = ')'
168         arguments = format_arguments(
169             arguments=["class_name='pd.{}'".format(original_type.__name__),
170                        "method_name='{}'".format(name),
171                        "arg_name='{}'".format(arg)],
172             prefix_len=(INDENT_LEN * 3 + len(raise_error_prefix)),
173             suffix_len=len(raise_error_suffix))
174         raise_errors += ("""
175         if {0}:
176             {1}{2}{3}""".format(not_equal, raise_error_prefix, arguments, raise_error_suffix))
177 
178     return raise_errors
179 
180 
181 def make_misssing_function(original_type, name, signature):
182     """Make a missing functions stub.
183 
184     :return: the stub definition for the missing function
185     """
186     arguments = format_method_arguments(name, signature)
187     error_argument = format_arguments(
188         arguments=["class_name='pd.{}'".format(original_type.__name__),
189                    "method_name='{}'".format(name)],
190         prefix_len=(8 + len('raise PandasNotImplementedError(')),
191         suffix_len=len(')'))
192 
193     return ("""
194     def {0}({1}):
195         \"""A stub for the equivalent method to `pd.{2}.{0}()`.
196 
197         The method `pd.{2}.{0}()` is not implemented yet.
198         \"""
199         raise PandasNotImplementedError({3})"""
200             .format(name, arguments, original_type.__name__, error_argument))
201 
202 
203 def make_modified_function_def(original_type, name, original, target):
204     """Make the modified function definition.
205 
206     :return: the definition for the modified function
207     """
208     arguments = format_method_arguments(name, original)
209     argument_names = set(target.parameters)
210     unavailable_arguments = [p for p in original.parameters if p not in argument_names]
211     derived_from = format_derived_from(original_type, unavailable_arguments, original)
212     raise_error = format_raise_errors(original_type, name, unavailable_arguments, original)
213     return ("""
214     {0}
215     def {1}({2}):{3}""".format(derived_from, name, arguments, raise_error))
216 
217 
218 def _main():
219     for original_type, target_type, missing_type in \
220             [(pd.DataFrame, PandasLikeDataFrame, _MissingPandasLikeDataFrame),
221              (pd.Series, PandasLikeSeries, _MissingPandasLikeSeries)]:
222         missing, modified = inspect_missing_functions(original_type, target_type, missing_type)
223 
224         print('MISSING functions for {}'.format(original_type.__name__))
225         for name, signature in missing:
226             # print(make_misssing_function(original_type, name, signature))
227             print("""    {0} = unsupported_function('{0}')""".format(name))
228 
229         print()
230         print('MODIFIED functions for {}'.format(original_type.__name__))
231         for name, original, target in modified:
232             print(make_modified_function_def(original_type, name, original, target))
233 
234 
235 if __name__ == '__main__':
236     _main()
237
```
--- 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/dev/_make_missing_functions.py b/dev/_make_missing_functions.py
--- a/dev/_make_missing_functions.py
+++ b/dev/_make_missing_functions.py
@@ -15,6 +15,12 @@
 # limitations under the License.
 #
 
+"""
+A script to generate the missing function stubs. Before running this,
+make sure you install koalas from the current checkout by running:
+pip install -e .
+"""
+
 import inspect
 
 import pandas as pd

{"golden_diff": "diff --git a/dev/_make_missing_functions.py b/dev/_make_missing_functions.py\n--- a/dev/_make_missing_functions.py\n+++ b/dev/_make_missing_functions.py\n@@ -15,6 +15,12 @@\n # limitations under the License.\n #\n \n+\"\"\"\n+A script to generate the missing function stubs. Before running this,\n+make sure you install koalas from the current checkout by running:\n+pip install -e .\n+\"\"\"\n+\n import inspect\n \n import pandas as pd\n", "issue": "How to call dev/_make_missing_functions.py?\n```\r\nrxin @ C02XT0W6JGH5 : ~/workspace/spark-pandas (master) \r\n> dev/_make_missing_functions.py \r\nTraceback (most recent call last):\r\n  File \"dev/_make_missing_functions.py\", line 22, in <module>\r\n    from databricks.koala.frame import PandasLikeDataFrame\r\nImportError: No module named databricks.koala.frame\r\n```\r\n\r\nDo I need to install koala first? We should add documentation to CONTRIBUTING.md. It'd also be best if this runs against the existing code base, rather than a system-wide installed Koala.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# Copyright (C) 2019 Databricks, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nimport inspect\n\nimport pandas as pd\n\nfrom databricks.koalas.frame import PandasLikeDataFrame\nfrom databricks.koalas.missing.frame import _MissingPandasLikeDataFrame\nfrom databricks.koalas.missing.series import _MissingPandasLikeSeries\nfrom databricks.koalas.series import PandasLikeSeries\n\n\nINDENT_LEN = 4\nLINE_LEN_LIMIT = 100\n\n\ndef inspect_missing_functions(original_type, target_type, missing_type):\n    \"\"\"\n    Find functions which exist in original_type but not in target_type,\n    or the signature is modified.\n\n    :return: the tuple of the missing function name and its signature,\n             and the name of the functions the signature of which is different\n             and its original and modified signature.\n    \"\"\"\n    missing = []\n    modified = []\n\n    already_in_missing = set([(name, inspect.signature(func)) for name, func\n                              in inspect.getmembers(missing_type, inspect.isfunction)])\n    for name, func in inspect.getmembers(original_type, inspect.isfunction):\n        # Skip the private attributes\n        if name.startswith('_'):\n            continue\n\n        original_signature = inspect.signature(func, follow_wrapped=True)\n\n        if hasattr(target_type, name):\n            f = getattr(target_type, name)\n            if inspect.isfunction(f):\n                target_signature = inspect.signature(f)\n                if (name, target_signature) in already_in_missing:\n                    missing.append((name, original_signature))\n                elif str(original_signature) != str(target_signature):\n                    modified.append((name, original_signature, target_signature))\n                continue\n\n        missing.append((name, original_signature))\n\n    return missing, modified\n\n\ndef format_arguments(arguments, prefix_len, suffix_len):\n    \"\"\"Format arguments not to break pydocstyle.\n\n    :param arguments: the argument list\n    :param prefix_len: the prefix length when the argument string needs line break\n    :param suffix_len: the suffix length to check the line length exceeds the limit\n    :return: the formatted argument string\n    \"\"\"\n    lines = ['']\n\n    def append_arg(arg):\n        if prefix_len + len(lines[-1]) + len(', ') + len(arg) + suffix_len > LINE_LEN_LIMIT:\n            lines.append('')\n            append_arg(arg)\n        else:\n            if len(lines[-1]) > 0:\n                arg = ', {}'.format(arg)\n            lines[-1] += arg\n\n    for arg in arguments:\n        append_arg(arg)\n\n    return (',\\n' + (' ' * prefix_len)).join(lines)\n\n\ndef format_method_arguments(name, signature):\n    \"\"\"Format the method arguments from its name and signature.\n\n    :return: the formatted argument string\n    \"\"\"\n    arguments = []\n\n    for param in signature.parameters.values():\n        if param.default is not inspect.Signature.empty and isinstance(param.default, type):\n            arguments.append('{}={}'.format(param.name, param.default.__name__))\n        elif param.default is not inspect.Signature.empty and repr(param.default) == 'nan':\n            arguments.append('{}={}'.format(param.name, 'np.nan'))\n        else:\n            arguments.append(str(param))\n\n    prefix_len = INDENT_LEN + len('def {}('.format(name))\n    suffix_len = len('):')\n    return format_arguments(arguments, prefix_len, suffix_len)\n\n\ndef format_derived_from(original_type, unavailable_arguments, signature):\n    \"\"\"Format `@derived_from` decorator.\n\n    :param original_type: the original type to be derived\n    :param unavailable_arguments: the arguments Koalas does not support yet\n    :param signature: the method signature\n    :return: the formatted `@derived_from` decorator\n    \"\"\"\n    if len(unavailable_arguments) == 0:\n        return '@derived_from(pd.{})'.format(original_type.__name__)\n\n    arguments = []\n\n    for arg in unavailable_arguments:\n        param = signature.parameters[arg]\n        if param.default == inspect.Parameter.empty or \\\n                param.kind == inspect.Parameter.VAR_POSITIONAL or \\\n                param.kind == inspect.Parameter.VAR_KEYWORD:\n            continue\n        arguments.append(repr(arg))\n\n    prefix = '@derived_from(pd.{}, ua_args=['.format(original_type.__name__)\n    suffix = '])'\n    prefix_len = INDENT_LEN + len(prefix)\n    suffix_len = len(suffix)\n    return '{}{}{}'.format(prefix, format_arguments(arguments, prefix_len, suffix_len), suffix)\n\n\ndef format_raise_errors(original_type, name, unavailable_arguments, signature):\n    \"\"\"\n    Format raise error statements for unavailable arguments when specified the different value\n    from the default value.\n\n    :return: the formatted raise error statements\n    \"\"\"\n    raise_errors = ''\n\n    for arg in unavailable_arguments:\n        param = signature.parameters[arg]\n        if param.default == inspect.Parameter.empty or \\\n                param.kind == inspect.Parameter.VAR_POSITIONAL or \\\n                param.kind == inspect.Parameter.VAR_KEYWORD:\n            continue\n        if repr(param.default) == 'nan':\n            not_equal = 'not np.isnan({})'.format(arg)\n        elif isinstance(param.default, type):\n            not_equal = '{} is not {}'.format(arg, param.default.__name__)\n        elif param.default is None or \\\n                param.default is True or param.default is False:\n            not_equal = '{} is not {}'.format(arg, repr(param.default))\n        else:\n            not_equal = '{} != {}'.format(arg, repr(param.default))\n\n        raise_error_prefix = 'raise PandasNotImplementedError('\n        raise_error_suffix = ')'\n        arguments = format_arguments(\n            arguments=[\"class_name='pd.{}'\".format(original_type.__name__),\n                       \"method_name='{}'\".format(name),\n                       \"arg_name='{}'\".format(arg)],\n            prefix_len=(INDENT_LEN * 3 + len(raise_error_prefix)),\n            suffix_len=len(raise_error_suffix))\n        raise_errors += (\"\"\"\n        if {0}:\n            {1}{2}{3}\"\"\".format(not_equal, raise_error_prefix, arguments, raise_error_suffix))\n\n    return raise_errors\n\n\ndef make_misssing_function(original_type, name, signature):\n    \"\"\"Make a missing functions stub.\n\n    :return: the stub definition for the missing function\n    \"\"\"\n    arguments = format_method_arguments(name, signature)\n    error_argument = format_arguments(\n        arguments=[\"class_name='pd.{}'\".format(original_type.__name__),\n                   \"method_name='{}'\".format(name)],\n        prefix_len=(8 + len('raise PandasNotImplementedError(')),\n        suffix_len=len(')'))\n\n    return (\"\"\"\n    def {0}({1}):\n        \\\"\"\"A stub for the equivalent method to `pd.{2}.{0}()`.\n\n        The method `pd.{2}.{0}()` is not implemented yet.\n        \\\"\"\"\n        raise PandasNotImplementedError({3})\"\"\"\n            .format(name, arguments, original_type.__name__, error_argument))\n\n\ndef make_modified_function_def(original_type, name, original, target):\n    \"\"\"Make the modified function definition.\n\n    :return: the definition for the modified function\n    \"\"\"\n    arguments = format_method_arguments(name, original)\n    argument_names = set(target.parameters)\n    unavailable_arguments = [p for p in original.parameters if p not in argument_names]\n    derived_from = format_derived_from(original_type, unavailable_arguments, original)\n    raise_error = format_raise_errors(original_type, name, unavailable_arguments, original)\n    return (\"\"\"\n    {0}\n    def {1}({2}):{3}\"\"\".format(derived_from, name, arguments, raise_error))\n\n\ndef _main():\n    for original_type, target_type, missing_type in \\\n            [(pd.DataFrame, PandasLikeDataFrame, _MissingPandasLikeDataFrame),\n             (pd.Series, PandasLikeSeries, _MissingPandasLikeSeries)]:\n        missing, modified = inspect_missing_functions(original_type, target_type, missing_type)\n\n        print('MISSING functions for {}'.format(original_type.__name__))\n        for name, signature in missing:\n            # print(make_misssing_function(original_type, name, signature))\n            print(\"\"\"    {0} = unsupported_function('{0}')\"\"\".format(name))\n\n        print()\n        print('MODIFIED functions for {}'.format(original_type.__name__))\n        for name, original, target in modified:\n            print(make_modified_function_def(original_type, name, original, target))\n\n\nif __name__ == '__main__':\n    _main()\n", "path": "dev/_make_missing_functions.py"}], "after_files": [{"content": "#!/usr/bin/env python\n#\n# Copyright (C) 2019 Databricks, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n\"\"\"\nA script to generate the missing function stubs. Before running this,\nmake sure you install koalas from the current checkout by running:\npip install -e .\n\"\"\"\n\nimport inspect\n\nimport pandas as pd\n\nfrom databricks.koalas.frame import PandasLikeDataFrame\nfrom databricks.koalas.missing.frame import _MissingPandasLikeDataFrame\nfrom databricks.koalas.missing.series import _MissingPandasLikeSeries\nfrom databricks.koalas.series import PandasLikeSeries\n\n\nINDENT_LEN = 4\nLINE_LEN_LIMIT = 100\n\n\ndef inspect_missing_functions(original_type, target_type, missing_type):\n    \"\"\"\n    Find functions which exist in original_type but not in target_type,\n    or the signature is modified.\n\n    :return: the tuple of the missing function name and its signature,\n             and the name of the functions the signature of which is different\n             and its original and modified signature.\n    \"\"\"\n    missing = []\n    modified = []\n\n    already_in_missing = set([(name, inspect.signature(func)) for name, func\n                              in inspect.getmembers(missing_type, inspect.isfunction)])\n    for name, func in inspect.getmembers(original_type, inspect.isfunction):\n        # Skip the private attributes\n        if name.startswith('_'):\n            continue\n\n        original_signature = inspect.signature(func, follow_wrapped=True)\n\n        if hasattr(target_type, name):\n            f = getattr(target_type, name)\n            if inspect.isfunction(f):\n                target_signature = inspect.signature(f)\n                if (name, target_signature) in already_in_missing:\n                    missing.append((name, original_signature))\n                elif str(original_signature) != str(target_signature):\n                    modified.append((name, original_signature, target_signature))\n                continue\n\n        missing.append((name, original_signature))\n\n    return missing, modified\n\n\ndef format_arguments(arguments, prefix_len, suffix_len):\n    \"\"\"Format arguments not to break pydocstyle.\n\n    :param arguments: the argument list\n    :param prefix_len: the prefix length when the argument string needs line break\n    :param suffix_len: the suffix length to check the line length exceeds the limit\n    :return: the formatted argument string\n    \"\"\"\n    lines = ['']\n\n    def append_arg(arg):\n        if prefix_len + len(lines[-1]) + len(', ') + len(arg) + suffix_len > LINE_LEN_LIMIT:\n            lines.append('')\n            append_arg(arg)\n        else:\n            if len(lines[-1]) > 0:\n                arg = ', {}'.format(arg)\n            lines[-1] += arg\n\n    for arg in arguments:\n        append_arg(arg)\n\n    return (',\\n' + (' ' * prefix_len)).join(lines)\n\n\ndef format_method_arguments(name, signature):\n    \"\"\"Format the method arguments from its name and signature.\n\n    :return: the formatted argument string\n    \"\"\"\n    arguments = []\n\n    for param in signature.parameters.values():\n        if param.default is not inspect.Signature.empty and isinstance(param.default, type):\n            arguments.append('{}={}'.format(param.name, param.default.__name__))\n        elif param.default is not inspect.Signature.empty and repr(param.default) == 'nan':\n            arguments.append('{}={}'.format(param.name, 'np.nan'))\n        else:\n            arguments.append(str(param))\n\n    prefix_len = INDENT_LEN + len('def {}('.format(name))\n    suffix_len = len('):')\n    return format_arguments(arguments, prefix_len, suffix_len)\n\n\ndef format_derived_from(original_type, unavailable_arguments, signature):\n    \"\"\"Format `@derived_from` decorator.\n\n    :param original_type: the original type to be derived\n    :param unavailable_arguments: the arguments Koalas does not support yet\n    :param signature: the method signature\n    :return: the formatted `@derived_from` decorator\n    \"\"\"\n    if len(unavailable_arguments) == 0:\n        return '@derived_from(pd.{})'.format(original_type.__name__)\n\n    arguments = []\n\n    for arg in unavailable_arguments:\n        param = signature.parameters[arg]\n        if param.default == inspect.Parameter.empty or \\\n                param.kind == inspect.Parameter.VAR_POSITIONAL or \\\n                param.kind == inspect.Parameter.VAR_KEYWORD:\n            continue\n        arguments.append(repr(arg))\n\n    prefix = '@derived_from(pd.{}, ua_args=['.format(original_type.__name__)\n    suffix = '])'\n    prefix_len = INDENT_LEN + len(prefix)\n    suffix_len = len(suffix)\n    return '{}{}{}'.format(prefix, format_arguments(arguments, prefix_len, suffix_len), suffix)\n\n\ndef format_raise_errors(original_type, name, unavailable_arguments, signature):\n    \"\"\"\n    Format raise error statements for unavailable arguments when specified the different value\n    from the default value.\n\n    :return: the formatted raise error statements\n    \"\"\"\n    raise_errors = ''\n\n    for arg in unavailable_arguments:\n        param = signature.parameters[arg]\n        if param.default == inspect.Parameter.empty or \\\n                param.kind == inspect.Parameter.VAR_POSITIONAL or \\\n                param.kind == inspect.Parameter.VAR_KEYWORD:\n            continue\n        if repr(param.default) == 'nan':\n            not_equal = 'not np.isnan({})'.format(arg)\n        elif isinstance(param.default, type):\n            not_equal = '{} is not {}'.format(arg, param.default.__name__)\n        elif param.default is None or \\\n                param.default is True or param.default is False:\n            not_equal = '{} is not {}'.format(arg, repr(param.default))\n        else:\n            not_equal = '{} != {}'.format(arg, repr(param.default))\n\n        raise_error_prefix = 'raise PandasNotImplementedError('\n        raise_error_suffix = ')'\n        arguments = format_arguments(\n            arguments=[\"class_name='pd.{}'\".format(original_type.__name__),\n                       \"method_name='{}'\".format(name),\n                       \"arg_name='{}'\".format(arg)],\n            prefix_len=(INDENT_LEN * 3 + len(raise_error_prefix)),\n            suffix_len=len(raise_error_suffix))\n        raise_errors += (\"\"\"\n        if {0}:\n            {1}{2}{3}\"\"\".format(not_equal, raise_error_prefix, arguments, raise_error_suffix))\n\n    return raise_errors\n\n\ndef make_misssing_function(original_type, name, signature):\n    \"\"\"Make a missing functions stub.\n\n    :return: the stub definition for the missing function\n    \"\"\"\n    arguments = format_method_arguments(name, signature)\n    error_argument = format_arguments(\n        arguments=[\"class_name='pd.{}'\".format(original_type.__name__),\n                   \"method_name='{}'\".format(name)],\n        prefix_len=(8 + len('raise PandasNotImplementedError(')),\n        suffix_len=len(')'))\n\n    return (\"\"\"\n    def {0}({1}):\n        \\\"\"\"A stub for the equivalent method to `pd.{2}.{0}()`.\n\n        The method `pd.{2}.{0}()` is not implemented yet.\n        \\\"\"\"\n        raise PandasNotImplementedError({3})\"\"\"\n            .format(name, arguments, original_type.__name__, error_argument))\n\n\ndef make_modified_function_def(original_type, name, original, target):\n    \"\"\"Make the modified function definition.\n\n    :return: the definition for the modified function\n    \"\"\"\n    arguments = format_method_arguments(name, original)\n    argument_names = set(target.parameters)\n    unavailable_arguments = [p for p in original.parameters if p not in argument_names]\n    derived_from = format_derived_from(original_type, unavailable_arguments, original)\n    raise_error = format_raise_errors(original_type, name, unavailable_arguments, original)\n    return (\"\"\"\n    {0}\n    def {1}({2}):{3}\"\"\".format(derived_from, name, arguments, raise_error))\n\n\ndef _main():\n    for original_type, target_type, missing_type in \\\n            [(pd.DataFrame, PandasLikeDataFrame, _MissingPandasLikeDataFrame),\n             (pd.Series, PandasLikeSeries, _MissingPandasLikeSeries)]:\n        missing, modified = inspect_missing_functions(original_type, target_type, missing_type)\n\n        print('MISSING functions for {}'.format(original_type.__name__))\n        for name, signature in missing:\n            # print(make_misssing_function(original_type, name, signature))\n            print(\"\"\"    {0} = unsupported_function('{0}')\"\"\".format(name))\n\n        print()\n        print('MODIFIED functions for {}'.format(original_type.__name__))\n        for name, original, target in modified:\n            print(make_modified_function_def(original_type, name, original, target))\n\n\nif __name__ == '__main__':\n    _main()\n", "path": "dev/_make_missing_functions.py"}]}