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

✨ Support reading uint/int/float dtypes #18

Merged
merged 4 commits into from
Sep 12, 2024
Merged

✨ Support reading uint/int/float dtypes #18

merged 4 commits into from
Sep 12, 2024

Conversation

weiji14
Copy link
Owner

@weiji14 weiji14 commented Sep 9, 2024

Finally figured out how to workaround the strict typing to support different dtypes after looking at georust/geotiff#17! Using a trait bound to handle this, specifically num_traits::FromPrimitive.

Notes:

  • This is only implemented on the Rust side for now, because PyO3 doesn't work with generic parameters (https://pyo3.rs/v0.22.2/class.html#no-generic-parameters) and I haven't figured out macros yet.
  • Longer term, I'd still like to delegate most of this logic to the georust/geotiff crate. Putting it here for now, more as a chance for me to learn about tricky Rust concepts.

TODO:

  • Initial implementation to support u8/u16/u32/u64/i8/i16/i32/i64/f32/f64 dtypes
  • Update roadmap in main README.md
  • Document multi-dtype usage in main README.md and src/lib.rs crate-level docs

Numeric traits for generic mathematics! Repo at https://github.com/rust-num/num-traits
Add support on the Rust side for reading u8/u16/u32/u64/i8/i16/i32/i64/f32/f64 dtypes via a num_traits::FromPrimitive bound. Different dtypes can be selected via the turbofish operator e.g. by calling `.ndarray::<u16>()`. Added a unit test to check that reading a uint16 tif file works.
@weiji14 weiji14 added the enhancement New feature or request label Sep 9, 2024
@weiji14 weiji14 self-assigned this Sep 9, 2024
Took longer than expected, but support for reading multiple dtypes finally landed (albeit only in the Rust bindings). Stretched out the timeline in the roadmap further into the future, and mentioning aiocogeo-rs under related crates.
Show how the turbofish operator (e.g. `::<f32, _>`) can be used to set the output dtype from the `read_geotiff` function. Mention all supported dtypes in crate-level docs at src/lib.rs.
@weiji14 weiji14 marked this pull request as ready for review September 12, 2024 01:02
@weiji14 weiji14 enabled auto-merge (squash) September 12, 2024 01:02
@weiji14 weiji14 added this to the 0.1.0 milestone Sep 12, 2024
@weiji14 weiji14 merged commit 69e460a into main Sep 12, 2024
14 checks passed
@weiji14 weiji14 deleted the multi-dtype branch September 12, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant