Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow np.arrays in ak.full_like as fill_value #3315

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/awkward/operations/ak_full_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from awkward._layout import HighLevelContext, ensure_same_backend
from awkward._nplikes.numpy_like import NumpyMetadata
from awkward._nplikes.typetracer import is_unknown_scalar
from awkward._regularize import is_integer_like
from awkward._regularize import is_array_like, is_integer_like
from awkward.operations.ak_zeros_like import _ZEROS

__all__ = ("full_like",)
Expand Down Expand Up @@ -222,7 +222,9 @@ def action(layout, backend, **kwargs):
else:
return None

out = ak._do.recursively_apply(layout, action)
out = ak._do.recursively_apply(
layout, action, numpy_to_regular=not is_array_like(fill_value)
)
return ctx.wrap(out, highlevel=highlevel)


Expand Down
12 changes: 12 additions & 0 deletions tests/test_2787_ak_full_like_with_broadcasting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import numpy as np

import awkward as ak


def test_ak_full_like_with_broadcasting():
a = ak.Array(np.ones((2, 2)))
b = ak.full_like(a, fill_value=np.array([2.0, 3.0]))

assert ak.to_list(b) == [[2.0, 3.0], [2.0, 3.0]]
Loading