benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 4dce2748-ee8d-5cb2-a42f-35b2d82e8c71
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
# Constants
PLOT_TITLE = 'Square root plot'
X_LABEL = 'x'
Y_LABEL = 'sqrt(x)'
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
def task_func(result):
"""
Plots the square root function for values associated with the key 'from_user' from the input list of dictionaries. Annotates the graph with the current date and time.
- Round each square root value to 2 decimals.
Parameters:
result (list): A list of dictionaries containing numeric values with the key 'from_user'.
Returns:
- numpy.ndarray: list of square values associated with the key 'from_user' from the input list of dictionaries.
- matplotlib.axes.Axes: plot of square root values.
Requirements:
- numpy
- matplotlib.pyplot
- datetime
Constants:
- PLOT_TITLE: Title of the plot (default is 'Square root plot').
- X_LABEL: Label for the x-axis (default is 'x').
- Y_LABEL: Label for the y-axis (default is 'sqrt(x)').
- TIME_FORMAT: Format for displaying the current date and time (default is '%Y-%m-%d %H:%M:%S').
Example:
>>> result = [{"hi": 7, "bye": 4, "from_user": 16}, {"some_key": 2, "another_key": 4, "from_user": 9}]
>>> square_roots, ax = task_func(result)
>>> print(square_roots)
[4. 3.]
"""
instruct prompt
Plots the square root function for values associated with the key 'from_user' from the input list of dictionaries. Annotates the graph with the current date and time. - Round each square root value to 2 decimals. Constants: - PLOT_TITLE: Title of the plot (default is 'Square root plot'). - X_LABEL: Label for the x-axis (default is 'x'). - Y_LABEL: Label for the y-axis (default is 'sqrt(x)'). - TIME_FORMAT: Format for displaying the current date and time (default is '%Y-%m-%d %H:%M:%S').
The function should output with:
numpy.ndarray: list of square values associated with the key 'from_user' from the input list of dictionaries.
matplotlib.axes.Axes: plot of square root values.
You should write self-contained code starting with:
Code
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
# Constants
PLOT_TITLE = 'Square root plot'
X_LABEL = 'x'
Y_LABEL = 'sqrt(x)'
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
def task_func(result):
code prompt
Code
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
# Constants
PLOT_TITLE = 'Square root plot'
X_LABEL = 'x'
Y_LABEL = 'sqrt(x)'
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
def task_func(result):
entry point
task_func
libs
- datetime
- numpy
- matplotlib
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
initial import