benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 47fad8f5-67ba-530a-9324-9bd439ec7cdf

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import inspect
import pandas as pd

def task_func(f_list, file_path):
    """
    Exports the specifications of functions in 'f_list' to a CSV file at 'file_path'.

    The CSV file columns are as follows:
    - 'Function Name': The name of the function.
    - 'Number of Arguments': The number of arguments the function takes.
    - 'Defaults': Default values for the function's arguments, if any.
    - 'Annotations': Type annotations of the function's arguments and return value, if any.
    - 'Is Lambda': Boolean value indicating whether the function is a lambda function.

    Each row in the CSV file corresponds to a function in 'f_list'.

    Parameters:
    f_list (list): A list of function objects to inspect. Each element should be a callable object.
    file_path (str): The path (including filename) where the CSV file will be saved. Should be a writable path.

    Returns:
    None

    Requirements:
    - inspect
    - pandas

    Raises:
    - ValueError: If 'f_list' is not a list of functions, 'f_list' is empty, or 'file_path' is not a valid path.
    - IOError: If there's an error in writing to the specified file path.

    Example:
    >>> def f(x): return 2 * x
    >>> def g(x, y=2): return x * y
    >>> task_func([f, g], './function_info.csv')
    >>> os.remove('./function_info.csv')
    """

instruct prompt

Exports the specifications of functions in 'f_list' to a CSV file at 'file_path'. The CSV file columns are as follows: - 'Function Name': The name of the function. - 'Number of Arguments': The number of arguments the function takes. - 'Defaults': Default values for the function's arguments, if any. - 'Annotations': Type annotations of the function's arguments and return value, if any. - 'Is Lambda': Boolean value indicating whether the function is a lambda function. Each row in the CSV file corresponds to a function in 'f_list'.
The function should raise the exception for: ValueError: If 'f_list' is not a list of functions, 'f_list' is empty, or 'file_path' is not a valid path. IOError: If there's an error in writing to the specified file path.
The function should output with:
    None
You should write self-contained code starting with:

Code

import inspect
import pandas as pd
def task_func(f_list, file_path):

code prompt

Code

import inspect
import pandas as pd
def task_func(f_list, file_path):

entry point

task_func

libs

  • pandas
  • inspect

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import