Skip to content

concatenate and arange mishandling max_bits #2802

Closed

Description

@stress-tess

This reproducer shows 2 bugs, one with arange correctly identifying bigints and with max_bits not actually getting applied to the resulting array of the concatenation

In [13]: a = ak.arange(2**200 - 1, 2**200+4)

In [14]: b = ak.arange(5, max_bits=3)

In [15]: b
Out[15]: array([0 1 2 3 4])

In [16]: a
Out[16]: array([1606938044258990275541962092341162602522202993782792835301375 1606938044258990275541962092341162602522202993782792835301376 1606938044258990275541962092341162602522202993782792835301377 1606938044258990275541962092341162602522202993782792835301378 1606938044258990275541962092341162602522202993782792835301379])

In [17]: ak.concatenate([b,a ])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[17], line 1
----> 1 ak.concatenate([b,a ])

File /opt/homebrew/Caskroom/miniforge/base/envs/arkouda-dev/lib/python3.10/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 ~/proj/arkouda/arkouda/pdarraysetops.py:331, in concatenate(arrays, ordered)
    329         dtype = a.dtype
    330     elif dtype != a.dtype:
--> 331         raise ValueError("All pdarrays must have same dtype")
    332     names.append(cast(pdarray, a).name)
    333 elif objtype == Strings.objType:

ValueError: All pdarrays must have same dtype

In [18]: b
Out[18]: array([0 1 2 3 4])

In [19]: b.dtype
Out[19]: dtype('int64')

In [20]: b = ak.arange(5, max_bits=3, dtype=ak.bigint)

In [21]: b
Out[21]: array([0 1 2 3 4])

In [22]: b.dtype
Out[22]: dtype(bigint)

In [23]: ak.concatenate([b,a ])
Out[23]: array([0 1 2 3 4 1606938044258990275541962092341162602522202993782792835301375 1606938044258990275541962092341162602522202993782792835301376 1606938044258990275541962092341162602522202993782792835301377 1606938044258990275541962092341162602522202993782792835301378 1606938044258990275541962092341162602522202993782792835301379])

In [24]: ak.concatenate([b,a ]).max_bits
Out[24]: -1

In [25]: b.max_bits = 3

In [26]: b.max_bits
Out[26]: 3

In [27]: ak.concatenate([b,a ]).max_bits
Out[27]: 3

In [28]: ak.concatenate([b,a ])
Out[28]: array([0 1 2 3 4 1606938044258990275541962092341162602522202993782792835301375 1606938044258990275541962092341162602522202993782792835301376 1606938044258990275541962092341162602522202993782792835301377 1606938044258990275541962092341162602522202993782792835301378 1606938044258990275541962092341162602522202993782792835301379])

Activity

  1. added
    bug
    on Oct 3, 2023
  2. self-assigned this
    on Oct 3, 2023
  3. changed the title [-]bigint concatenate mishandling `max_bits`[/-] [+]concatenate and arange mishandling `max_bits`[/+] on Oct 3, 2023
  4. changed the title [-]concatenate and arange mishandling `max_bits`[/-] [+]`concatenate` and `arange` mishandling `max_bits`[/+] on Oct 3, 2023
  5. added a commit that references this issue on Oct 3, 2023
    0cf7bb6
  6. added a commit that references this issue on Oct 4, 2023
    89156ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions