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

fix: widen input support for ak.type() #2009

Merged
merged 2 commits into from
Dec 15, 2022
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
3 changes: 2 additions & 1 deletion src/awkward/operations/ak_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@ def _impl(array):
return array.form.type

else:
raise ak._errors.wrap_error(TypeError(f"unrecognized array type: {array!r}"))
layout = ak.to_layout(array, allow_other=False)
return _impl(ak._util.wrap(layout))
16 changes: 16 additions & 0 deletions tests/test_2008-ak-type-layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

import re

import awkward as ak


def test_simple():
assert re.match(r"3 \* u?int\d+", str(ak.type([1, 2, 3])))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overkill because the int type is not platform specific, as I had feared. (ArrayBuilder always returns int64)

Suggested change
assert re.match(r"3 \* u?int\d+", str(ak.type([1, 2, 3])))
assert re.match(r"3 \* u?int\d+", str(ak.type([1, 2, 3])))



def test_complex():
assert re.match(
r"2 \* \{x: union\[var \* \?u?int\d+, float\d+\]\}",
str(ak.type([{"x": [None, 10]}, {"x": 40.0}])),
)