Skip to content

Commit

Permalink
Show put/get ndarray in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusuMET committed Dec 3, 2023
1 parent 0a6d9e4 commit 057e97c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion netcdf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
//! let data = var.values_arr::<i32, _>(([40, 0 ,0], [1, 100, 100]))?;
//! # #[cfg(feature = "ndarray")]
//! let data = var.values_arr::<i32, _>((40, ..100, ..100))?;
//!
//! // You can read into an ndarray to reuse an allocation
//! # #[cfg(feature = "ndarray")]
//! let mut data = ndarray::Array::<f32, _>::zeros((100, 100));
//! # #[cfg(feature = "ndarray")]
//! var.values_arr_into((0, .., ..), data.view_mut())?;
//! # Ok(()) }
//! ```
//!
Expand All @@ -69,7 +75,8 @@
//! "crab_coolness_level",
//! &["time", "ncrabs"],
//! )?;
//! // Metadata can be added to the variable
//! // Metadata can be added to the variable, but will not be used when
//! // writing or reading data
//! var.add_attribute("units", "Kelvin")?;
//! var.add_attribute("add_offset", 273.15_f32)?;
//!
Expand All @@ -80,6 +87,12 @@
//! // Values can be added along the unlimited dimension, which
//! // resizes along the `time` axis
//! var.put_values(&data, (11, ..))?;
//!
//! // Using the ndarray feature you can also use
//! # #[cfg(feature = "ndarray")]
//! let values = ndarray::Array::from_shape_fn((5, 10), |(j, i)| (j * 10 + i) as f32);
//! # #[cfg(feature = "ndarray")]
//! var.put_values_arr((11.., ..), values.view())?;
//! # Ok(()) }
//! ```

Expand Down

0 comments on commit 057e97c

Please sign in to comment.