{{ function.name }}
描述
{{ function.parsed_doc.description|safe }}
函数签名
{{ function.name }}(
{%- for param in function.signature.parameters -%}
{{ param.name }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
) -> {{ function.signature.return_annotation }}
参数
{% if function.parsed_doc.parameters %} {% for param in function.parsed_doc.parameters %}
{{ param.name }}
({{ param.type }})
{% endfor %}
{% else %}
{{ param.description|safe }}
此函数没有参数
{% endif %}返回值
{{ function.parsed_doc.returns|safe }}
示例
{% if function.examples %} {% for example in function.examples %}输入:
{{ function.name }}(
{%- if example.formatted_args is defined -%}
{% for arg in example.formatted_args %}
{{ arg }}{% if not loop.last %}, {% endif %}
{% endfor %}
{%- else -%}
{%- for arg in example.args -%}
{{ arg }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
{%- endif -%}
)
错误:
输出:
{{ example.result }}
暂无示例
{% endif %}Python使用示例
import numpy as np
from rust_pyfunc import {{ function.name }}
# 使用示例
{% if function.examples and function.examples[0].formatted_args is defined %}
{% set example = function.examples[0] %}
result = {{ function.name }}(
{%- for arg in example.formatted_args -%}
{{ arg }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
)
print(f"结果: {result}")
{% elif function.examples and function.examples[0].args %}
{% set example = function.examples[0] %}
result = {{ function.name }}(
{%- for arg in example.args -%}
{{ arg }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
)
print(f"结果: {result}")
{% else %}
# 请参考文档中的参数说明使用此函数
{% endif %}