From 7f3e804e97a6444def4e2f5144752b1bcba45b87 Mon Sep 17 00:00:00 2001 From: Adam Kern Date: Tue, 23 Sep 2025 22:23:48 -0400 Subject: [PATCH] Fills missing documentation and adds warn(missing_docs) --- src/dimension/broadcast.rs | 7 +++++++ src/dimension/conversion.rs | 3 +++ src/dimension/remove_axis.rs | 1 + src/lib.rs | 1 + src/linalg/impl_linalg.rs | 3 +++ src/shape_builder.rs | 13 +++++++++++++ src/zip/ndproducer.rs | 1 + 7 files changed, 29 insertions(+) diff --git a/src/dimension/broadcast.rs b/src/dimension/broadcast.rs index fb9fc1a0c..9e7474388 100644 --- a/src/dimension/broadcast.rs +++ b/src/dimension/broadcast.rs @@ -34,6 +34,13 @@ where Ok(out) } +/// A trait to specify when one dimension is strictly larger than another. +/// +/// Broadcasting two arrays together frequently requires typing the resultant +/// array has having a dimensionality equal to the maximum of the two input arrays. +/// This trait is what determines that typing. +/// +/// For example, `Ix1: DimMax`, but not vice-versa. pub trait DimMax { /// The resulting dimension type after broadcasting. diff --git a/src/dimension/conversion.rs b/src/dimension/conversion.rs index 0cf2e1296..cee8a2eb5 100644 --- a/src/dimension/conversion.rs +++ b/src/dimension/conversion.rs @@ -42,7 +42,10 @@ macro_rules! index_item { /// Argument conversion a dimension. pub trait IntoDimension { + /// The concrete type of the resultant dimension. type Dim: Dimension; + + /// Convert into a type that implements [`Dimension`]. fn into_dimension(self) -> Self::Dim; } diff --git a/src/dimension/remove_axis.rs b/src/dimension/remove_axis.rs index cbb039fc5..7ba3b5330 100644 --- a/src/dimension/remove_axis.rs +++ b/src/dimension/remove_axis.rs @@ -14,6 +14,7 @@ use crate::{Axis, Dim, Dimension, Ix, Ix0, Ix1}; /// removing one axis from *Self* gives smaller dimension *Smaller*. pub trait RemoveAxis: Dimension { + /// Remove the specified axis from a dimension. fn remove_axis(&self, axis: Axis) -> Self::Smaller; } diff --git a/src/lib.rs b/src/lib.rs index 3efb378ce..e11a8a5ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // Enable the doc_cfg nightly feature for including feature gate flags in the documentation #![cfg_attr(docsrs, feature(doc_cfg))] +#![warn(missing_docs)] //! The `ndarray` crate provides an *n*-dimensional container for general elements //! and for numerics. diff --git a/src/linalg/impl_linalg.rs b/src/linalg/impl_linalg.rs index 0bbc0b026..1e4eb80ee 100644 --- a/src/linalg/impl_linalg.rs +++ b/src/linalg/impl_linalg.rs @@ -164,6 +164,9 @@ pub trait Dot /// For two-dimensional arrays: a rectangular array. type Output; + /// Compute the dot product of two arrays. + /// + /// **Panics** if the arrays' shapes are not compatible. fn dot(&self, rhs: &Rhs) -> Self::Output; } diff --git a/src/shape_builder.rs b/src/shape_builder.rs index b9a4b0ab6..50c00b044 100644 --- a/src/shape_builder.rs +++ b/src/shape_builder.rs @@ -96,12 +96,22 @@ impl Strides /// `Array::from_shape_vec`. pub trait ShapeBuilder { + /// The type that captures the built shape's dimensionality. type Dim: Dimension; + + /// The type that captures the built shape's stride pattern. type Strides; + /// Turn into a contiguous-element [`Shape`]. fn into_shape_with_order(self) -> Shape; + + /// Convert into a Fortran-order (a.k.a., column-order) [`Shape`]. fn f(self) -> Shape; + + /// Set the order of the shape to either Fortran or non-Fortran. fn set_f(self, is_f: bool) -> Shape; + + /// Set the strides of the shape. fn strides(self, strides: Self::Strides) -> StrideShape; } @@ -213,7 +223,10 @@ where D: Dimension /// See for example [`.to_shape()`](crate::ArrayRef::to_shape). pub trait ShapeArg { + /// The type that captures the shape's dimensionality. type Dim: Dimension; + + /// Convert the argument into a shape and an [`Order`]. fn into_shape_and_order(self) -> (Self::Dim, Option); } diff --git a/src/zip/ndproducer.rs b/src/zip/ndproducer.rs index 82f3f43a7..de9d66979 100644 --- a/src/zip/ndproducer.rs +++ b/src/zip/ndproducer.rs @@ -16,6 +16,7 @@ pub trait IntoNdProducer type Item; /// Dimension type of the producer type Dim: Dimension; + /// The concrete type of the producer type Output: NdProducer; /// Convert the value into an `NdProducer`. fn into_producer(self) -> Self::Output;