Skip to content

Commit

Permalink
📝 Document how to set output dtype using turbofish operator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weiji14 committed Sep 12, 2024
1 parent 3e737d0 commit 3cbc6f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() {
};

// Read GeoTIFF into an ndarray::Array
let arr: Array3<f32> = read_geotiff(stream).unwrap();
let arr: Array3<f32> = read_geotiff::<f32, _>(stream).unwrap();
assert_eq!(arr.dim(), (1, 549, 549));
assert_eq!(arr[[0, 500, 500]], 0.13482364);
}
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@
//! Cursor::new(bytes)
//! };
//!
//! let arr: Array3<f32> = read_geotiff(stream).unwrap();
//! let arr: Array3<f32> = read_geotiff::<f32, _>(stream).unwrap();
//! assert_eq!(arr.dim(), (1, 549, 549));
//! assert_eq!(arr[[0, 500, 500]], 0.13482364);
//! }
//! ```
//!
//! Note that the output dtype can be specified either by using a type hint
//! (`let arr: Array3<f32>`) or via the turbofish operator (`read_geotiff::<f32>`).
//! Currently supported dtypes include uint (u8/u16/u32/u64), int (i8/i16/i32/i64) and
//! float (f32/f64).

/// Modules for handling Input/Output of GeoTIFF data
pub mod io;
Expand Down

0 comments on commit 3cbc6f2

Please sign in to comment.