Convert a 1D array between numeric types. Type-safe conversion for 1D arrays, useful for converting vectors of statistics, scores, or other single-dimensional data between numeric types. ## Parameters `array1` - Source 1D array to convert ## Type Parameters `M` - Source numeric type `T` - Target numeric type ## Returns New 1D array with same length but converted element type ## Usage ```rust,
(array1: Array1<M>)
| 697 | /// - Type compatibility between library interfaces |
| 698 | /// - Converting scores or weights for storage |
| 699 | pub fn arr1_conversion<M, T>(array1: Array1<M>) -> anyhow::Result<Array1<T>> |
| 700 | where |
| 701 | M: Num + Copy + num_traits::ToPrimitive, |
| 702 | T: Num + NumCast + Clone, |
| 703 | { |
| 704 | let mut result = Array1::zeros(array1.dim()); |
| 705 | |
| 706 | for (target, &source) in result.iter_mut().zip(array1.iter()) { |
| 707 | *target = T::from(source).ok_or_else(|| anyhow!("Failed to convert value"))?; |
| 708 | } |
| 709 | |
| 710 | Ok(result) |
| 711 | } |
no outgoing calls
no test coverage detected