Пример #1
0
    def run(self):
        from docutils.statemachine import ViewList
        from docutils import nodes
        import pyarrow.compute as pc

        result = ViewList()
        function_kind = self.options.get('kind', None)

        result.append(".. csv-table::", "<computefuncs>")
        result.append("   :widths: 20, 60, 20", "<computefuncs>")
        result.append("   ", "<computefuncs>")
        for fname in pc.list_functions():
            func = pc.get_function(fname)
            option_class = ""
            if func._doc.options_class:
                option_class = f":class:`{func._doc.options_class}`"
            if not function_kind or func.kind == function_kind:
                result.append(
                    f'   "{fname}", "{func._doc.summary}", "{option_class}"',
                    "<computefuncs>")

        node = nodes.section()
        node.document = self.state.document
        self.state.nested_parse(result, 0, node)
        return node.children
Пример #2
0
def test_pickle_functions():
    # Pickle registered functions
    for name in pc.list_functions():
        func = pc.get_function(name)
        reconstructed = pickle.loads(pickle.dumps(func))
        assert type(reconstructed) is type(func)
        assert reconstructed.name == func.name
        assert reconstructed.arity == func.arity
        assert reconstructed.num_kernels == func.num_kernels
Пример #3
0
def test_function_attributes():
    # Sanity check attributes of registered functions
    for name in pc.list_functions():
        func = pc.get_function(name)
        assert isinstance(func, pc.Function)
        assert func.name == name
        kernels = func.kernels
        assert func.num_kernels == len(kernels)
        assert all(isinstance(ker, pc.Kernel) for ker in kernels)
        assert func.arity >= 1  # no varargs functions for now
        repr(func)
        for ker in kernels:
            repr(ker)
Пример #4
0
def test_pickle_global_functions():
    # Pickle global wrappers (manual or automatic) of registered functions
    for name in pc.list_functions():
        func = getattr(pc, name)
        reconstructed = pickle.loads(pickle.dumps(func))
        assert reconstructed is func
Пример #5
0
def test_list_functions():
    assert len(pc.list_functions()) > 10
    assert "add" in pc.list_functions()