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

feat(python): Additional support for loading numpy.float16 values (as Float32) #20769

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Jan 17, 2025

Adds an entry to the numpy kind/size conversion mapping covering np.float16.
(We don't have a native Float16, so it loads as Float32).

Example

import numpy as np
import polars as pl

df = pl.DataFrame({
  "n": [np.float16(123)],
})

Before:

# ValueError:
#   cannot parse numpy data type dtype('float16') into Polars data type

After:

# shape: (1, 1)
# ┌───────┐
# │ n     │
# │ ---   │
# │ f32   │
# ╞═══════╡
# │ 123.0 │
# └───────┘

…es (as Float32)
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jan 17, 2025
@alexander-beedie alexander-beedie changed the title feat(python): Enable additional cases of loading numpy.float16 values (as Float32) feat(python): Enable additional support for loading numpy.float16 values (as Float32) Jan 17, 2025
@alexander-beedie alexander-beedie changed the title feat(python): Enable additional support for loading numpy.float16 values (as Float32) feat(python): Additional support for loading numpy.float16 values (as Float32) Jan 17, 2025
@alexander-beedie alexander-beedie added the A-interop-numpy Area: interoperability with NumPy label Jan 17, 2025
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.74%. Comparing base (725c960) to head (cac44fc).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20769      +/-   ##
==========================================
- Coverage   79.74%   79.74%   -0.01%     
==========================================
  Files        1561     1561              
  Lines      222012   222012              
  Branches     2530     2530              
==========================================
- Hits       177049   177045       -4     
- Misses      44381    44386       +5     
+ Partials      582      581       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 9501f57 into pola-rs:main Jan 18, 2025
26 checks passed
@alexander-beedie alexander-beedie deleted the load-numpy-float16 branch January 20, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interop-numpy Area: interoperability with NumPy enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants