benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 76befb7a-5a96-57ce-96f2-c1394a23dfea

Problem

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

complete prompt

import matplotlib.pyplot as plt
import numpy as np


def task_func(ax, radius):
    '''
    Draw a circle with a given radius on the polar chart 'ax' and set radial ticks.
    This function manipulates plot data using matplotlib.

    Parameters:
    ax (matplotlib.axes._axes.Axes): The ax to plot on. Must be a polar plot.
    radius (float): The radius of the circle. Must be non-negative.

    Returns:
    matplotlib.axes._axes.Axes: The modified Axes object with the circle plotted.

    Note:
    - If the radius is negative this function will raise ValueError.
    - If 'ax' is not a polar plot this function will raise TypeError.

    Requirements:
    - matplotlib.pyplot
    - numpy

    Example:
    >>> import matplotlib.pyplot as plt
    >>> fig = plt.figure()
    >>> ax = fig.add_subplot(111, polar=True)
    >>> result_ax = task_func(ax, 1.5)
    >>> np.allclose(result_ax.get_lines()[0].get_ydata(), 1.5)
    True
    >>> plt.close()
    '''

instruct prompt

Draw a circle with a given radius on the polar chart 'ax' and set radial ticks. This function manipulates plot data using matplotlib.
Note that: If the radius is negative this function will raise ValueError. If 'ax' is not a polar plot this function will raise TypeError.
The function should output with:
    matplotlib.axes._axes.Axes: The modified Axes object with the circle plotted.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
import numpy as np
def task_func(ax, radius):

code prompt

Code

import matplotlib.pyplot as plt
import numpy as np
def task_func(ax, radius):

entry point

task_func

libs

  • 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