pyyeti.writer.getith

pyyeti.writer.getith(i, args, fncs)[source]

Return list with i’th value from each input, typically called by vecwrite().

Parameters:
  • i (integer) – Specifies which value to extract from each input; starts at 0.

  • args (list of variables) – Variable to extract the i’th value from. Must be compatibly sized (scalars or vectors of equal length). Strings are considered scalars.

  • fncs (list of functions) – Same length as args; the function is used to extract the i’th item. Call signature: ith_element_of_a = func(a, i). The function must return an iterable of items (eg, list).

Returns:

lst (list) – List of the i’th items extracted from each variable in args.

Examples

>>> from pyyeti import writer
>>> import numpy as np
>>> r = np.array([1.2, 45.])
>>> s = 'test string'
>>> i = 5
>>> v = ['One', 'Two']
>>> def f(a, i): return [a]
>>> def f2(a, i): return [a[i]]
>>> args = [r, s, i, v]
>>> fncs = [f2, f, f, f2]
>>> writer.getith(0, args, fncs)
[1.2, 'test string', 5, 'One']
>>> writer.getith(1, args, fncs)
[45.0, 'test string', 5, 'Two']