benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2b043591-8666-5ba3-a56d-89be51604124

Problem

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

complete prompt

import pickle
import os
import matplotlib.pyplot as plt


def task_func(numbers, file_path="save.pkl"):
    """
    Save a Matplotlib image generated from the provided "numbers" list in a pickle file.
    The function then reads the image back from the file for validation and deletes the pickle file afterward.

    Parameters:
    - numbers  (list): List of int/float values used to generate the matplotlib figure.
    - file_path (str): Path to temporary pickle file. Defaults to 'save.pkl'.

    Returns:
    - loaded_fig (matplotlib.figure.Figure): The loaded matplotlib figure from file_path.

    Requirements:
    - pickle
    - os
    - matplotlib.pyplot

    Raises:
    - TypeError: If the input is not a list of numbers.
    
    Example:
    >>> numbers = [random.random() for _ in range(100)]
    >>> loaded_fig = task_func(numbers)
    >>> type(loaded_fig)
    <class 'matplotlib.figure.Figure'>
    """

instruct prompt

Save a Matplotlib image generated from the provided "numbers" list in a pickle file. The function then reads the image back from the file for validation and deletes the pickle file afterward.
The function should raise the exception for: TypeError: If the input is not a list of numbers.
The function should output with:
    loaded_fig (matplotlib.figure.Figure): The loaded matplotlib figure from file_path.
You should write self-contained code starting with:

Code

import pickle
import os
import matplotlib.pyplot as plt
def task_func(numbers, file_path="save.pkl"):

code prompt

Code

import pickle
import os
import matplotlib.pyplot as plt
def task_func(numbers, file_path="save.pkl"):

entry point

task_func

libs

  • matplotlib
  • pickle
  • os

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