Repository navigation
Closed
Description
We should be able to use ak.array to create an empty string. However, right now it gives an error:
In [5]: s = ak.array([], dtype="str_")
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 s = ak.array([], dtype="str_")
File ~/git/arkouda/arkouda/numpy/pdarraycreation.py:336, in array(a, dtype, copy, max_bits)
326 rep_msg = generic_msg(
327 cmd=f"arraySegString<{encoded_np.dtype.name}>",
328 args={"size": encoded_np.size},
329 payload=_array_memview(encoded_np),
330 send_binary=True,
331 )
332 parts = cast(str, rep_msg).split("+", maxsplit=3)
333 return (
334 Strings.from_parts(parts[0], parts[1])
335 if dtype is None
--> 336 else akcast(Strings.from_parts(parts[0], parts[1]), dtype)
337 )
339 # If not strings, then check that dtype is supported in arkouda
340 if dtype == bigint or a.dtype.name not in DTypes:
341 # 2 situations result in attempting to call `bigint_from_uint_arrays`
342 # 1. user specified i.e. dtype=ak.bigint
343 # 2. too big to fit into other numpy types (dtype = object)
File ~/anaconda3/envs/arkouda-dev/lib/python3.13/site-packages/typeguard/__init__.py:891, in typechecked.<locals>.wrapper(*args, **kwargs)
889 memo = _CallMemo(python_func, _localns, args=args, kwargs=kwargs)
890 check_argument_types(memo)
--> 891 retval = func(*args, **kwargs)
892 check_return_type(retval, memo)
894 # If a generator is returned, wrap it if its yield/send/return types can be checked
File ~/git/arkouda/arkouda/numpy/numeric.py:225, in cast(pda, dt, errors)
223 return Categorical(pda) # type: ignore
224 elif dt is Strings or akdtype(dt) == str_:
--> 225 return pda[:]
226 else:
227 dt = akdtype(dt)
File ~/git/arkouda/arkouda/numpy/strings.py:367, in Strings.__getitem__(self, key)
365 (start, stop, stride) = key.indices(self.size)
366 self.logger.debug(f"start: {start}; stop: {stop}; stride: {stride}")
--> 367 repMsg = generic_msg(
368 cmd="segmentedIndex",
369 args={
370 "subcmd": "sliceIndex",
371 "objType": self.objType,
372 "obj": self.entry,
373 "dtype": self.entry.dtype,
374 "key": [start, stop, stride],
375 },
376 )
377 return Strings.from_return_msg(repMsg)
378 elif isinstance(key, pdarray):
File ~/git/arkouda/arkouda/client.py:995, in generic_msg(cmd, args, payload, send_binary, recv_binary)
993 else:
994 assert payload is None
--> 995 return type_cast(Channel, channel).send_string_message(
996 cmd=cmd, args=msg_args, size=size, recv_binary=recv_binary
997 )
998 except KeyboardInterrupt as e:
999 # if the user interrupts during command execution, the socket gets out
1000 # of sync reset the socket before raising the interrupt exception
1001 type_cast(Channel, channel).connect(timeout=0)
File ~/git/arkouda/arkouda/client.py:513, in ZmqChannel.send_string_message(self, cmd, recv_binary, args, size, request_id)
511 # raise errors or warnings sent back from the server
512 if return_message.msgType == MessageType.ERROR:
--> 513 raise RuntimeError(return_message.msg)
514 elif return_message.msgType == MessageType.WARNING:
515 warnings.warn(return_message.msg)
RuntimeError: index out of bounds
Metadata
Metadata
Assignees
Labels
No labels
Activity
Closes Bears-R-Us#4725: ak.array for empty strings
Closes Bears-R-Us#4725: ak.array for empty strings
Closes Bears-R-Us#4725: ak.array for empty strings
Closes Bears-R-Us#4725: ak.array for empty strings
Closes Bears-R-Us#4725: ak.array for empty strings
Closes Bears-R-Us#4725: ak.array for empty strings
Closes #4725: ak.array for empty strings (#4732)
Closes Bears-R-Us#4725: ak.array for empty strings (Bears-R-Us#4732)