コード例 #1
0
    def test_interface_get_frame_a(self) -> None:

        f1 = InterfaceSummary.to_frame(Series)
        f2 = InterfaceSummary.to_frame(Series, minimized=False, max_args=np.inf)
        self.assertTrue(len(f1) == len(f2))

        self.assertEqual(f1.columns.values.tolist(),
                ['cls_name', 'group', 'doc']
                )
        self.assertEqual(
                f2.columns.values.tolist(),
                ['cls_name', 'group', 'doc', 'reference', 'use_signature', 'is_attr', 'delegate_reference', 'delegate_is_attr', 'signature_no_args']
                )
コード例 #2
0
def get_jinja_contexts() -> tp.Dict[str, tp.Any]:

    post: tp.Dict[str, tp.Any] = {}

    # performance_cls = []
    # for name in dir(core):
    #     obj = getattr(core, name)
    #     if inspect.isclass(obj) and issubclass(obj, PerfTest):
    #         performance_cls.append(obj.__name__)

    # post['performance_cls'] = performance_cls

    # for docs
    post['examples_defined'] = get_defined()
    # post['interface_groups'] = INTERFACE_GROUP_ORDER

    post['interface'] = {}
    for target in DOCUMENTED_COMPONENTS:
        inter = InterfaceSummary.to_frame(
            target,  #type: ignore
            minimized=False,
            max_args=99,  # +inf, but keep as int
        )
        # break into iterable of group, frame
        inter_items = []
        for g in INTERFACE_GROUP_ORDER:
            inter_sub = inter.loc[inter['group'] == g]
            if len(inter_sub):  # some groups are empty
                inter_items.append((g, inter_sub))
        post['interface'][target.__name__] = (
            target.__name__,
            target,
            inter_items,
        )
    return post
コード例 #3
0
    def test_interface_via_re_signature_no_args(self) -> None:
        inter = InterfaceSummary.to_frame(
            Series,
            minimized=False,
            max_args=99,  # +inf, but keep as int
        )
        self.assertEqual(
            inter.loc[inter['group'] == InterfaceGroup.AccessorFillValue,
                      'signature_no_args'].values.tolist(),
            [
                'via_fill_value(fill_value).loc',
                'via_fill_value().__getitem__()',
                'via_fill_value(fill_value).via_T',
                'via_fill_value().__add__()', 'via_fill_value().__sub__()',
                'via_fill_value().__mul__()', 'via_fill_value().__truediv__()',
                'via_fill_value().__floordiv__()',
                'via_fill_value().__mod__()', 'via_fill_value().__pow__()',
                'via_fill_value().__lshift__()',
                'via_fill_value().__rshift__()', 'via_fill_value().__and__()',
                'via_fill_value().__xor__()', 'via_fill_value().__or__()',
                'via_fill_value().__lt__()', 'via_fill_value().__le__()',
                'via_fill_value().__eq__()', 'via_fill_value().__ne__()',
                'via_fill_value().__gt__()', 'via_fill_value().__ge__()',
                'via_fill_value().__radd__()', 'via_fill_value().__rsub__()',
                'via_fill_value().__rmul__()',
                'via_fill_value().__rtruediv__()',
                'via_fill_value().__rfloordiv__()'
            ])

        self.assertEqual(
            inter.loc[inter['group'] == InterfaceGroup.AccessorRe,
                      'signature_no_args'].values.tolist(),
            [
                'via_re().search()', 'via_re().match()',
                'via_re().fullmatch()', 'via_re().split()',
                'via_re().findall()', 'via_re().sub()', 'via_re().subn()'
            ])
コード例 #4
0
    def test_interface_summary_a(self) -> None:

        for target in self.get_containers():
            t = InterfaceSummary.to_frame(target)
            self.assertTrue(len(t) > 30)
コード例 #5
0
ファイル: conf.py プロジェクト: nekobon/static-frame
def get_jinja_contexts() -> tp.Dict[str, tp.Any]:

    post: tp.Dict[str, tp.Any] = {}

    performance_cls = []
    for name in dir(core):
        obj = getattr(core, name)
        if inspect.isclass(obj) and issubclass(obj, PerfTest):
            performance_cls.append(obj.__name__)

    post['performance_cls'] = performance_cls

    # for docs
    post['examples_defined'] = get_defined()
    # post['interface_groups'] = INTERFACE_GROUP_ORDER

    post['interface'] = {}
    for target in (
            sf.Series,
            sf.Frame,
            sf.FrameGO,
            sf.Batch,
            sf.Bus,
            sf.Index,
            sf.IndexGO,
            sf.IndexHierarchy,
            sf.IndexHierarchyGO,
            sf.IndexYear,
            sf.IndexYearGO,
            sf.IndexYearMonth,
            sf.IndexYearMonthGO,
            sf.IndexDate,
            sf.IndexDateGO,
            sf.IndexMinute,
            sf.IndexMinuteGO,
            sf.IndexHour,
            sf.IndexHourGO,
            sf.IndexSecond,
            sf.IndexSecondGO,
            sf.IndexMillisecond,
            sf.IndexMillisecondGO,
            sf.IndexMicrosecond,
            sf.IndexMicrosecondGO,
            sf.IndexNanosecond,
            sf.IndexNanosecondGO,
            sf.DisplayConfig,
            sf.StoreConfig,
            sf.StoreFilter,
            ):

        inter = InterfaceSummary.to_frame(target, #type: ignore
                        minimized=False,
                        max_args=99, # +inf, but keep as int
                        )
        # break into iterable of group, frame
        inter_items = []
        for g in INTERFACE_GROUP_ORDER:
            inter_sub = inter.loc[inter['group'] == g]
            if inter_sub: # some groups are empty
                inter_items.append((g, inter_sub))
        post['interface'][target.__name__] = (
                target.__name__,
                target,
                inter_items,
                )
    return post
コード例 #6
0
 def interface(self) -> 'Frame':
     '''{}'''
     from static_frame.core.interface import InterfaceSummary
     return InterfaceSummary.to_frame(self.__class__)
コード例 #7
0
ファイル: container.py プロジェクト: adamczykm/static-frame
 def interface(cls) -> 'Frame':
     '''{}'''
     from static_frame.core.interface import InterfaceSummary
     return InterfaceSummary.to_frame(cls)
コード例 #8
0
 def interface(cls) -> 'Frame':
     '''A ``Frame`` documenting the interface of this class.
     '''
     from static_frame.core.interface import InterfaceSummary
     return InterfaceSummary.to_frame(cls)
コード例 #9
0
ファイル: conf.py プロジェクト: ForeverWintr/static-frame
def get_jinja_contexts() -> tp.Dict[str, tp.List[tp.Tuple[str, str]]]:

    post = {}

    performance_cls = []
    for name in dir(core):
        obj = getattr(core, name)
        if inspect.isclass(obj) and issubclass(obj, PerfTest):
            performance_cls.append(obj.__name__)

    post['performance_cls'] = performance_cls

    def get_func_doc(
            cls: type,
            func_iter: tp.Iterable[str]) -> tp.List[tp.Tuple[str, str]]:
        return [(f, getattr(cls, f).__doc__) for f in sorted(func_iter)]

    for cls in (sf.Index, sf.Series, sf.Frame):
        label = cls.__name__
        post[label + '_operator_unary'] = get_func_doc(cls,
                                                       _UFUNC_UNARY_OPERATORS)
        post[label + '_operator_binary'] = get_func_doc(
            cls, _UFUNC_BINARY_OPERATORS)

    for cls in (sf.Index, sf.Series, sf.Frame):
        label = cls.__name__
        post[label + '_ufunc_axis'] = sorted(UFUNC_AXIS_SKIPNA.keys())

    post['interface'] = []
    for target in (
            sf.Series,
            sf.Frame,
            sf.FrameGO,
            sf.Bus,
            sf.Index,
            sf.IndexGO,
            sf.IndexHierarchy,
            sf.IndexHierarchyGO,
            sf.IndexYear,
            sf.IndexYearGO,
            sf.IndexYearMonth,
            sf.IndexYearMonthGO,
            sf.IndexDate,
            sf.IndexDateGO,
            sf.IndexMinute,
            sf.IndexMinuteGO,
            sf.IndexHour,
            sf.IndexHourGO,
            sf.IndexSecond,
            sf.IndexSecondGO,
            sf.IndexMillisecond,
            sf.IndexMillisecondGO,
            sf.IndexMicrosecond,
            sf.IndexMicrosecondGO,
            sf.IndexNanosecond,
            sf.IndexNanosecondGO,
    ):
        post['interface'].append((
            target.__name__,
            target,
            InterfaceSummary.to_frame(
                target,  #type: ignore
                minimized=False,
                max_args=99,  # +inf, but keep as int
            )))
    return post