-
Notifications
You must be signed in to change notification settings - Fork 120
Implement all ufuncs in TypeTracerArray (was: ak.num(array, axis=1)) #1997
Copy link
Copy link
Closed
Labels
bugThe problem described is something that must be fixedThe problem described is something that must be fixed
Description
Version of Awkward Array
2.0.0
Description and code to reproduce
In [38]: a = ak.from_iter([[1, 2, 3], [4], [5, 6]])
In [39]: tt = ak.Array(a.layout.to_typetracer(forget_length=True))
In [40]: ak.num(tt, axis=1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[40], line 1
----> 1 ak.num(tt, axis=1)
File ~/.pyenv/versions/3.11.1/envs/dev/lib/python3.11/site-packages/awkward/operations/ak_num.py:71, in num(array, axis, highlevel, behavior)
9 """
10 Args:
11 array: Array-like data (anything #ak.to_layout recognizes).
(...)
65 <Array [[1.1, 2.2, 3.3], None, [7.7]] type='3 * option[var * float64]'>
66 """
67 with ak._errors.OperationErrorContext(
68 "ak.num",
69 dict(array=array, axis=axis, highlevel=highlevel, behavior=behavior),
70 ):
---> 71 return _impl(array, axis, highlevel, behavior)
File ~/.pyenv/versions/3.11.1/envs/dev/lib/python3.11/site-packages/awkward/operations/ak_num.py:100, in _impl(array, axis, highlevel, behavior)
95 elif layout.is_leaf:
96 raise ak._errors.wrap_error(
97 np.AxisError(f"axis={axis} exceeds the depth of this array ({depth})")
98 )
--> 100 out = ak._do.recursively_apply(layout, action, behavior, numpy_to_regular=True)
102 return ak._util.wrap(out, behavior, highlevel)
File ~/.pyenv/versions/3.11.1/envs/dev/lib/python3.11/site-packages/awkward/_do.py:33, in recursively_apply(layout, action, behavior, depth_context, lateral_context, allow_records, keep_parameters, numpy_to_regular, return_simplified, return_array, function_name)
18 def recursively_apply(
19 layout: Content | Record,
20 action: ActionType,
(...)
29 function_name: str | None = None,
30 ) -> Content | Record | None:
32 if isinstance(layout, Content):
---> 33 return layout._recursively_apply(
34 action,
35 behavior,
36 1,
37 copy.copy(depth_context),
38 lateral_context,
39 {
40 "allow_records": allow_records,
41 "keep_parameters": keep_parameters,
42 "numpy_to_regular": numpy_to_regular,
43 "return_simplified": return_simplified,
44 "return_array": return_array,
45 "function_name": function_name,
46 },
47 )
49 elif isinstance(layout, Record):
50 out = recursively_apply(
51 layout._array,
52 action,
(...)
61 function_name,
62 )
File ~/.pyenv/versions/3.11.1/envs/dev/lib/python3.11/site-packages/awkward/contents/listoffsetarray.py:1996, in ListOffsetArray._recursively_apply(self, action, behavior, depth, depth_context, lateral_context, options)
1986 def continuation():
1987 content._recursively_apply(
1988 action,
1989 behavior,
(...)
1993 options,
1994 )
-> 1996 result = action(
1997 self,
1998 depth=depth,
1999 depth_context=depth_context,
2000 lateral_context=lateral_context,
2001 continuation=continuation,
2002 behavior=behavior,
2003 backend=self._backend,
2004 options=options,
2005 )
2007 if isinstance(result, Content):
2008 return result
File ~/.pyenv/versions/3.11.1/envs/dev/lib/python3.11/site-packages/awkward/operations/ak_num.py:93, in _impl.<locals>.action(layout, depth, **kwargs)
90 posaxis = ak._util.maybe_posaxis(layout, axis, depth)
92 if posaxis == depth and layout.is_list:
---> 93 return ak.contents.NumpyArray(layout.stops.data - layout.starts.data)
95 elif layout.is_leaf:
96 raise ak._errors.wrap_error(
97 np.AxisError(f"axis={axis} exceeds the depth of this array ({depth})")
98 )
TypeError: unsupported operand type(s) for -: 'TypeTracerArray' and 'TypeTracerArray'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThe problem described is something that must be fixedThe problem described is something that must be fixed