Skip to main content

mod_

Function mod_ 

Source
pub fn mod_<D: Dimension>(
    a: &StringArray<D>,
    args: &[&str],
) -> FerrayResult<StringArray<D>>
Expand description

Format each element as a printf-style template, substituting args in.

Equivalent to numpy.strings.mod(arr, args) (the %-style binding). Supports the most common conversions:

  • %s — verbatim insertion of the next argument
  • %% — literal percent sign
  • %d — integer (parses argument as i64)
  • %f — float (parses argument as f64, default 6-decimal precision)
  • %.Nf — float with explicit precision N
  • %e / %g — scientific / shortest-of-fe representation

args is a slice indexed in conversion-order; each %X consumes the next argument in args.

Width/flag specifiers beyond %.Nf are not supported — parsing the full printf grammar inside a ufunc isn’t worth the complexity given most NumPy users reach for f-strings instead.

§Errors

  • FerrayError::InvalidValue if args.len() is fewer than the number of conversions, an unknown specifier appears, or a %d/%f/etc. argument fails to parse.