Skip to content

Commit 716ff2f

Browse files
committed
Improve documentation of batch parameter for arithmetic fns
1 parent 031c180 commit 716ff2f

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

src/core/arith.rs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ macro_rules! binary_func {
273273
#[doc=$doc_str]
274274
///
275275
/// This is an element wise binary operation.
276+
///
277+
/// # Important Notes
278+
///
279+
/// - If shape/dimensions of `lhs` and `rhs` are same, the value of `batch` parameter
280+
/// has no effect.
281+
///
282+
/// - If shape/dimensions of `lhs` and `rhs` are different, the value of `batch` has
283+
/// to be set to `true`. In this case, the shapes of `lhs` and `rhs` have to satisfy the
284+
/// following criteria:
285+
/// - Same number of elements in `lhs` and `rhs` along a given dimension/axis
286+
/// - Only one element in `lhs` or `rhs` along a given dimension/axis
276287
pub fn $fn_name<A, B>(lhs: &Array<A>, rhs: &Array<B>, batch: bool) -> Array<A::Output>
277288
where
278289
A: HasAfEnum + ImplicitPromote<B>,
@@ -434,9 +445,18 @@ macro_rules! overloaded_binary_func {
434445
///
435446
/// An Array with results of the binary operation.
436447
///
437-
///# Note
448+
///# Important Notes
449+
///
450+
/// - If shape/dimensions of `arg1` and `arg2` are same, the value of `batch` parameter
451+
/// has no effect.
452+
///
453+
/// - If shape/dimensions of `arg1` and `arg2` are different, the value of `batch` has
454+
/// to be set to `true`. In this case, the shapes of `arg1` and `arg2` have to satisfy the
455+
/// following criteria:
456+
/// - Same number of elements in `arg1` and `arg2` along a given dimension/axis
457+
/// - Only one element in `arg1` or `arg2` along a given dimension/axis
438458
///
439-
/// The trait `Convertable` essentially translates to a scalar native type on rust or Array.
459+
/// - The trait `Convertable` essentially translates to a scalar native type on rust or Array.
440460
pub fn $fn_name<T, U>(
441461
arg1: &T,
442462
arg2: &U,
@@ -530,9 +550,19 @@ macro_rules! overloaded_compare_func {
530550
///# Return Values
531551
///
532552
/// An Array with results of the comparison operation a.k.a an Array of boolean values.
533-
///# Note
534553
///
535-
/// The trait `Convertable` essentially translates to a scalar native type on rust or Array.
554+
///# Important Notes
555+
///
556+
/// - If shape/dimensions of `arg1` and `arg2` are same, the value of `batch` parameter
557+
/// has no effect.
558+
///
559+
/// - If shape/dimensions of `arg1` and `arg2` are different, the value of `batch` has
560+
/// to be set to `true`. In this case, the shapes of `arg1` and `arg2` have to satisfy the
561+
/// following criteria:
562+
/// - Same number of elements in `arg1` and `arg2` along a given dimension/axis
563+
/// - Only one element in `arg1` or `arg2` along a given dimension/axis
564+
///
565+
/// - The trait `Convertable` essentially translates to a scalar native type on rust or Array.
536566
pub fn $fn_name<T, U>(
537567
arg1: &T,
538568
arg2: &U,
@@ -632,9 +662,18 @@ where
632662
///
633663
/// An Array with results of the binary operation.
634664
///
635-
/// # Note
665+
/// # Important Notes
666+
///
667+
/// - If shape/dimensions of `arg1` and `arg2` are same, the value of `batch` parameter
668+
/// has no effect.
669+
///
670+
/// - If shape/dimensions of `arg1` and `arg2` are different, the value of `batch` has
671+
/// to be set to `true`. In this case, the shapes of `arg1` and `arg2` have to satisfy the
672+
/// following criteria:
673+
/// - Same number of elements in `arg1` and `arg2` along a given dimension/axis
674+
/// - Only one element in `arg1` or `arg2` along a given dimension/axis
636675
///
637-
/// The trait `Convertable` essentially translates to a scalar native type on rust or Array.
676+
/// - The trait `Convertable` essentially translates to a scalar native type on rust or Array.
638677
pub fn clamp<T, C>(
639678
input: &Array<T>,
640679
arg1: &C,

0 commit comments

Comments
 (0)