benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7b21b351-f2d5-5426-9dad-62aa318d575a

Problem

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

complete prompt

from datetime import datetime, timedelta
import numpy as np
import matplotlib.pyplot as plt

def task_func(days_in_past=7, random_seed=0):
    """
    Draw a graph of temperature trends over the past week using randomly generated data.

    This function generates random integer temperatures in Celcius with a low of 15 and high of 35.
    To show temperature trend, it plots date on the x-axis and temperature on the y-axis.

    Parameters:
    days_in_past (int, optional): The number of days in the past for which to generate the graph.
                                  Defaults to 7 days.
    random_seed (int, optional): Seed for random number generation. Defaults to 0.

    Returns:
    ax (matplotlib.axes._axes.Axes): Generated plot showing 'Temperature Trend'
                                     with 'Date' on the a-xis and 'Temperature (°C)' on the y-axis.


    Raises:
    ValueError: If days_in_past is less than 1.
    
    Requirements:
    - datetime.datetime
    - datetime.timedelta
    - numpy
    - matplotlib.pyplot

    Example:
    >>> ax = task_func(random_seed=42)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> ax.get_xticklabels()
    [Text(19810.0, 0, '2024-03-28'), Text(19811.0, 0, '2024-03-29'), Text(19812.0, 0, '2024-03-30'), Text(19813.0, 0, '2024-03-31'), Text(19814.0, 0, '2024-04-01'), Text(19815.0, 0, '2024-04-02'), Text(19816.0, 0, '2024-04-03')]
    """

instruct prompt

Draw a graph of temperature trends over the past week using randomly generated data. This function generates random integer temperatures in Celcius with a low of 15 and high of 35. To show temperature trend, it plots date on the x-axis and temperature on the y-axis.
The function should raise the exception for: ValueError: If days_in_past is less than 1.
The function should output with:
    ax (matplotlib.axes._axes.Axes): Generated plot showing 'Temperature Trend'
    with 'Date' on the a-xis and 'Temperature (°C)' on the y-axis.
You should write self-contained code starting with:

Code

from datetime import datetime, timedelta
import numpy as np
import matplotlib.pyplot as plt
def task_func(days_in_past=7, random_seed=0):

code prompt

Code

from datetime import datetime, timedelta
import numpy as np
import matplotlib.pyplot as plt
def task_func(days_in_past=7, random_seed=0):

entry point

task_func

libs

  • datetime
  • numpy
  • 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