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

[REVIEW] CSV Reader: Add hex dtype for explicit hexadecimal parsing #2149

Merged
merged 4 commits into from
Jul 3, 2019

Conversation

j-ieong
Copy link
Contributor

@j-ieong j-ieong commented Jun 29, 2019

Fixes #1925.

  • Add hex, hex64, and hex32 dtypes
    • actual dtypes are GDF_INT64, GDF_INT64, and GDF_INT32
    • indicates explicit request to parse with base-16
  • Remove hexadecimal inference from dtype detection
  • Remove determineBase from numeric parsing
  • Combine column enablement, hex, and other flags
  • Add pytests

* Add `hex`, `hex64`, and `hex32` dtypes
    - actual dtypes are `GDF_INT64`, `GDF_INT64`, and `GDF_INT32`
    - indicates explicit request to parse with base-16
* Remove hexadecimal inference from dtype detection
* Combine column enablement, hex, and other flags
* Add pytests
@j-ieong j-ieong added 2 - In Progress Currently a work in progress cuIO cuIO issue labels Jun 29, 2019
@j-ieong j-ieong self-assigned this Jun 29, 2019
@j-ieong j-ieong changed the title [WIP] CSV Reader: Add hex dtype for explicit hexadecimal parsing [REVIEW] CSV Reader: Add hex dtype for explicit hexadecimal parsing Jul 1, 2019
@j-ieong j-ieong marked this pull request as ready for review July 1, 2019 19:06
@j-ieong j-ieong requested review from a team as code owners July 1, 2019 19:06
@j-ieong j-ieong added 3 - Ready for Review Ready for review by team 4 - Needs cuDF (Python) Reviewer and removed 2 - In Progress Currently a work in progress labels Jul 2, 2019
@j-ieong j-ieong added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team 4 - Needs cuDF (Python) Reviewer labels Jul 2, 2019
@mjsamoht mjsamoht merged commit f42e567 into rapidsai:branch-0.9 Jul 3, 2019
rapids-bot bot pushed a commit that referenced this pull request Mar 1, 2022
This PR silences warnings in `test_csv.py`. (I am working through one test file at a time so we can enable `-Werr` in the future.)

The only warning in this file is related to integer overflow in pandas. Currently, the test data is as follows:
https://github.com/rapidsai/cudf/blob/21325e8348f33b28e434d08d687a28f251c38f67/python/cudf/cudf/tests/test_csv.py#L1313-L1319

First, I note that this "hex" dtype is not part of the pandas API. It is a cuDF addition (#1925, #2149).

Note that there are dtypes for `int32` / `hex32`, and the test data contains both a negative value `-0x1000` and a value `9512c20b`. The negative value `-0x1000` has a sensible interpretation if the results are meant to be signed, but then the value `9512c20b` is out of range (the maximum signed 32-bit value would be `0x7FFFFFFF` and the minimum signed 32-bit value would be `0x80000000`, using the big-endian convention of the parser). Recognizing this, pandas throws a `FutureWarning` when parsing the data `9512c20b` as `int32`, and unsafely wraps it to a negative value. This behavior will eventually be replaced by an `OverflowError`.

In the future, we may need to decide if cuDF should raise an `OverflowError` when exceeding `0x7FFFFFFF` for consistency with pandas, or decide to use unsigned integers when parsing "hex" dtypes and compare to pandas' unsigned types in this test.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Vukasin Milovanovic (https://github.com/vuule)
  - https://github.com/brandon-b-miller

URL: #10362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge cuIO cuIO issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] How to read hex as int using cudf
4 participants