Skip to content

Commit

Permalink
Update _make_missing_functions.py. (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin authored Apr 19, 2019
1 parent 2a3be45 commit 178bc0c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dev/_make_missing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
import pandas as pd

from databricks.koalas.frame import PandasLikeDataFrame
from databricks.koalas.missing.frame import _MissingPandasLikeDataFrame
from databricks.koalas.missing.series import _MissingPandasLikeSeries
from databricks.koalas.series import PandasLikeSeries


INDENT_LEN = 4
LINE_LEN_LIMIT = 100


def inspect_missing_functions(original_type, target_type):
def inspect_missing_functions(original_type, target_type, missing_type):
"""
Find functions which exist in original_type but not in target_type,
or the signature is modified.
Expand All @@ -39,6 +41,8 @@ def inspect_missing_functions(original_type, target_type):
missing = []
modified = []

already_in_missing = set([(name, inspect.signature(func)) for name, func
in inspect.getmembers(missing_type, inspect.isfunction)])
for name, func in inspect.getmembers(original_type, inspect.isfunction):
# Skip the private attributes
if name.startswith('_'):
Expand All @@ -50,7 +54,9 @@ def inspect_missing_functions(original_type, target_type):
f = getattr(target_type, name)
if inspect.isfunction(f):
target_signature = inspect.signature(f)
if str(original_signature) != str(target_signature):
if (name, target_signature) in already_in_missing:
missing.append((name, original_signature))
elif str(original_signature) != str(target_signature):
modified.append((name, original_signature, target_signature))
continue

Expand Down Expand Up @@ -210,9 +216,10 @@ def {1}({2}):{3}""".format(derived_from, name, arguments, raise_error))


def _main():
for original_type, target_type in [(pd.DataFrame, PandasLikeDataFrame),
(pd.Series, PandasLikeSeries)]:
missing, modified = inspect_missing_functions(original_type, target_type)
for original_type, target_type, missing_type in \
[(pd.DataFrame, PandasLikeDataFrame, _MissingPandasLikeDataFrame),
(pd.Series, PandasLikeSeries, _MissingPandasLikeSeries)]:
missing, modified = inspect_missing_functions(original_type, target_type, missing_type)

print('MISSING functions for {}'.format(original_type.__name__))
for name, signature in missing:
Expand Down

0 comments on commit 178bc0c

Please sign in to comment.