larray.Array.rationot0
- Array.rationot0(*axes) Array [source]
Return an Array with values array / array.sum(axes) where the sum is not 0, 0 otherwise.
- Parameters
- *axes
- Returns
- Array
array / array.sum(axes)
Examples
>>> a = Axis('a=a0,a1') >>> b = Axis('b=b0,b1,b2') >>> arr = Array([[6, 0, 2], ... [4, 0, 8]], [a, b]) >>> arr a\b b0 b1 b2 a0 6 0 2 a1 4 0 8 >>> arr.sum() 20 >>> arr.rationot0() a\b b0 b1 b2 a0 0.3 0.0 0.1 a1 0.2 0.0 0.4 >>> arr.rationot0('a') a\b b0 b1 b2 a0 0.6 0.0 0.2 a1 0.4 0.0 0.8
for reference, the normal ratio method would produce a warning message and return:
>>> arr.ratio('a') a\b b0 b1 b2 a0 0.6 nan 0.2 a1 0.4 nan 0.8