benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6fe61e42-d2d8-513f-a3ba-18ba0dc7d9a5

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


def task_func(n_points=100, random_seed=None):
    """
    Generate an array of random 3D dots in the range [0, 1) for each dimension
    and draw them in a 3D scatter plot.

    Parameters:
    n_points (int): The number of points to generate and plot. Default is 100.
    random_seed (int, optional): Seed for the random number generator. Default is None.

    Returns:
    tuple: A tuple containing:
        - points (ndarray): A numpy ndarray of shape (n_points, 3) with the coordinates of the points.
        - plot (Axes3D): A 3D scatter plot of the generated points.

    Requirements:
    - numpy
    - matplotlib.pyplot

    Example:
    >>> points, plot = task_func(200, random_seed=42)
    >>> type(points)
    <class 'numpy.ndarray'>
    >>> type(plot)
    <class 'mpl_toolkits.mplot3d.axes3d.Axes3D'>
    """

instruct prompt

Generate an array of random 3D dots in the range [0, 1) for each dimension and draw them in a 3D scatter plot.
The function should output with:
    tuple: A tuple containing:
    points (ndarray): A numpy ndarray of shape (n_points, 3) with the coordinates of the points.
    plot (Axes3D): A 3D scatter plot of the generated points.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func(n_points=100, random_seed=None):

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func(n_points=100, random_seed=None):

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