Skip to content

Align handling of lam and size in ak.random.poisson to numpy.random.poisson #5016

Closed

Description

@drculhane

The parameters aren't handled identically in the two versions of poisson.

np.random.poisson (lam=np.array([[1.0,5.0,10.0],[2.0,4.0,6.0]]),size=(2,2,3)) works, producing something like this:

array([[[ 2,  6,  7],
        [ 2,  0,  7]],

       [[ 0,  3, 15],
        [ 3,  5,  4]]])

ak.random.poisson (lam=ak.array([[1.0,5.0,10.0],[2.0,4.0,6.0]]),size=(2,2,3)) doesn't work, giving this:

Traceback (most recent call last):
  File "<python-input-24>", line 1, in <module>
    ak.random.poisson (lam=ak.array([[1.0,5.0,10.0],[2.0,4.0,6.0]]),size=(2,2,3))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/doctorandy/projects/arkouda/arkouda/numpy/random/legacy.py", line 950, in poisson
    return getGlobalGenerator().poisson(lam, size)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/doctorandy/projects/arkouda/arkouda/numpy/random/generator.py", line 948, in poisson
    is_single_lambda, lam = float_array_or_scalar_helper("poisson", "lam", lam, size)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/doctorandy/projects/arkouda/arkouda/numpy/random/generator.py", line 1090, in float_array_or_scalar_helper
    raise TypeError(f"array of {var_name} must have same size as return size")
TypeError: array of lam must have same size as return size

In numpy, the shape of lam must be broadcastable to size. That's not what arkouda is doing.

Activity

  1. self-assigned this
    on Oct 22, 2025
  2. added a commit that references this issue on Nov 12, 2025
    95993ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions