How to use the f90wrap.fortran.f2py_type function in f90wrap

To help you get started, we’ve selected a few f90wrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
had_optional = True
            if i != 0:
                sig += ', '
            sig += arg.py_name
        if had_optional:
            sig += ']'
        sig += ')'
        rex = re.compile(r'\s+')  # collapse multiple whitespace
        sig = rex.sub(' ', sig)
        return sig
    elif isinstance(node, ft.Module):
        return 'Module %s' % node.name
    elif isinstance(node, ft.Element):
        return ('Element %s ftype=%s pytype=%s' %
                (node.name, node.type,
                 ft.f2py_type(node.type)))
    elif isinstance(node, ft.Interface):
        if hasattr(node, 'method_name'):
            name = node.method_name
        else:
            name = node.name
        return '%s(*args, **kwargs)' % name
    else:
        return str(node)
github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
"""
        if isinstance(lineno, slice):
            return 'lines %d-%d' % (lineno.start, lineno.stop - 1)
        else:
            return 'line %d' % lineno

    doc = [format_call_signature(node), '']
    doc.append('')
    doc.append('Defined at %s %s' % (node.filename, _format_line_no(node.lineno)))

    if isinstance(node, ft.Procedure):
        # For procedures, write parameters and return values in numpydoc format
        doc.append('')
        # Input parameters
        for i, arg in enumerate(node.arguments):
            pytype = ft.f2py_type(arg.type, arg.attributes)
            if i == 0:
                doc.append("Parameters")
                doc.append("----------")
            doc.append("%s : %s" % (arg.name, pytype))
            if arg.doc:
                for d in arg.doc:
                    doc.append("\t%s" % d)
                doc.append("")

        if isinstance(node, ft.Function):
            for i, arg in enumerate(node.ret_val):
                pytype = ft.f2py_type(arg.type, arg.attributes)
                if i == 0:
                    doc.append("")
                    doc.append("Returns")
                    doc.append("-------")
github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
doc.append('')
        # Input parameters
        for i, arg in enumerate(node.arguments):
            pytype = ft.f2py_type(arg.type, arg.attributes)
            if i == 0:
                doc.append("Parameters")
                doc.append("----------")
            doc.append("%s : %s" % (arg.name, pytype))
            if arg.doc:
                for d in arg.doc:
                    doc.append("\t%s" % d)
                doc.append("")

        if isinstance(node, ft.Function):
            for i, arg in enumerate(node.ret_val):
                pytype = ft.f2py_type(arg.type, arg.attributes)
                if i == 0:
                    doc.append("")
                    doc.append("Returns")
                    doc.append("-------")
                doc.append("%s : %s" % (arg.name, pytype))
                if arg.doc:
                    for d in arg.doc:
                        doc.append("\t%s" % d)
                    doc.append("")
    elif isinstance(node, ft.Interface):
        # for interfaces, list the components
        doc.append('')
        doc.append('Overloaded interface containing the following procedures:')
        for proc in node.procedures:
            doc.append('  %s' % (hasattr(proc, 'method_name')
                                 and proc.method_name or proc.name))