benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b5c462ae-3524-5865-b8d1-ae76fae05703

Problem

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

complete prompt

import inspect
import matplotlib.pyplot as plt
import pandas as pd

def task_func(f_list):
    """
    Analyzes a list of functions and draws a bar chart showing the number of arguments for each function.
    The function names are listed along the x-axis, and the number of arguments are represented as bars.
    This method showcases the integration of function introspection, data frame creation, and data visualization.

    Parameters:
    f_list (list): List of functions to inspect.

    Returns:
    pandas.DataFrame: Returns a DataFrame containing the function names and their respective number of arguments.

    Raises:
    ValueError: if the input contains lambda function

    Requirements:
    - inspect
    - matplotlib.pyplot
    - pandas

    Examples:
    >>> def f(x): x*x
    >>> def g(x, y=2): return x*y
    >>> task_func([f, g])
                   Number of Arguments
    Function Name                     
    f                                1
    g                                2
    >>> lambda_func = lambda x: x * 2
    >>> task_func([f, lambda_func])
    Traceback (most recent call last):
    ...
    ValueError: The function should not be a lambda function.
    """

instruct prompt

Analyzes a list of functions and draws a bar chart showing the number of arguments for each function. The function names are listed along the x-axis, and the number of arguments are represented as bars. This method showcases the integration of function introspection, data frame creation, and data visualization.
The function should raise the exception for: ValueError: if the input contains lambda function
The function should output with:
    pandas.DataFrame: Returns a DataFrame containing the function names and their respective number of arguments.
You should write self-contained code starting with:

Code

import inspect
import matplotlib.pyplot as plt
import pandas as pd
def task_func(f_list):

code prompt

Code

import inspect
import matplotlib.pyplot as plt
import pandas as pd
def task_func(f_list):

entry point

task_func

libs

  • pandas
  • inspect
  • matplotlib

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