benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 25067ca7-6c85-5fb7-82b0-75e55d060a48

Problem

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

complete prompt

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import cv2
import os

def task_func(file_path, onpick):
    """
    Draw the color histogram of an image in 3D and call a function when a data point is selected.

    Parameters:
    file_path (str): The path to the image file.
    onpick (function): The function to be called when a data point is picked.

    Returns:
    matplotlib.axes.Axes: The Axes object of the 3D plot.

    Raises:
    FileNotFoundError: If the image file does not exist.
    
    Requirements:
    - matplotlib
    - mpl_toolkits.mplot3d
    - numpy
    - cv2
    - os
    - tempfile
    
    Example:
    >>> def onpick(event):
    ...     ind = event.ind
    ...     print(f'You picked data point(s) {ind}')
    >>> np.random.seed(42)
    >>> dummy_img_path = 'image.jpg'
    >>> dummy_img = np.random.randint(0, 255, (20, 20, 3), dtype=np.uint8)
    >>> cv2.imwrite(dummy_img_path, dummy_img)
    True
    >>> ax = task_func('image.jpg', onpick)
    >>> os.remove(dummy_img_path)
    """

instruct prompt

Draw the color histogram of an image in 3D and call a function when a data point is selected.
The function should raise the exception for: FileNotFoundError: If the image file does not exist.
The function should output with:
    matplotlib.axes.Axes: The Axes object of the 3D plot.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import cv2
import os
def task_func(file_path, onpick):

code prompt

Code

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import cv2
import os
def task_func(file_path, onpick):

entry point

task_func

libs

  • matplotlib
  • mpl_toolkits
  • cv2
  • numpy
  • 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