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

Closes #1394: Fancy pdarray type preservation in ak.concatenate #1402

Merged

Conversation

stress-tess
Copy link
Member

This PR (Closes #1394):

  • Moves type preservation code from ak.util.concatenate to ak.concatenate
  • Adds test that both concat functions perserve fancy pdarray types (IPv4, BitVector, Datetime, TimeDelta)

Example:

>>> pda_one = ak.arange(1, 4)
>>> pda_two = ak.arange(4, 7)
>>> ak.concatenate([ak.IPv4(pda_one), ak.IPv4(pda_two)])
IPv4([0.0.0.1,
      0.0.0.2,
      0.0.0.3,
      0.0.0.4,
      0.0.0.5,
      0.0.0.6],
     )

>>> ak.concatenate([ak.Datetime(pda_one), ak.Datetime(pda_two)])
Datetime(['1970-01-01 00:00:00.000000001',
          '1970-01-01 00:00:00.000000002',
          '1970-01-01 00:00:00.000000003',
          '1970-01-01 00:00:00.000000004',
          '1970-01-01 00:00:00.000000005',
          '1970-01-01 00:00:00.000000006'],
         dtype='datetime64[ns]')

>>> ak.concatenate([ak.Timedelta(pda_one), ak.Timedelta(pda_two)])
Timedelta(['0 days 00:00:00.000000001',
           '0 days 00:00:00.000000002',
           '0 days 00:00:00.000000003',
           '0 days 00:00:00.000000004',
           '0 days 00:00:00.000000005',
           '0 days 00:00:00.000000006'],
          dtype='timedelta64[ns]')

>>> ak.concatenate([ak.BitVector(pda_one), ak.BitVector(pda_two)])
BitVector([...............................................................|,
           ..............................................................|.,
           ..............................................................||,
           .............................................................|..,
           .............................................................|.|,
           .............................................................||.],
          width=64, reverse=False)

Copy link
Collaborator

@reuster986 reuster986 left a comment

Choose a reason for hiding this comment

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

looks great! thanks!

This PR (Closes Bears-R-Us#1394):
- Moves type preservation code from `ak.util.concatenate` to `ak.concatenate`
- Adds test that both concat functions perserve fancy pdarray types (`IPv4`, `BitVector`, `Datetime`, `TimeDelta`)
@stress-tess stress-tess force-pushed the 1394_type_preservation_concatenate branch from 9541f94 to 436f07b Compare May 18, 2022 20:38
Copy link
Contributor

@Ethan-DeBandi99 Ethan-DeBandi99 left a comment

Choose a reason for hiding this comment

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

Looks good

@mhmerrill mhmerrill merged commit 23375c8 into Bears-R-Us:master May 19, 2022
@stress-tess stress-tess deleted the 1394_type_preservation_concatenate branch July 7, 2022 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate ak.util.concatenate logic into ak.concatenate
4 participants