Base.stretch¶
- property Base.stretch¶
Extend along a one-dimensional axis to fit another object.
This attribute allows arithmetic operations to occur between objects of different shapes (sometimes referred to as broadcasting). The operation will pair the point or feature in this object with each point or feature in the other object. Operations can occur with a nimble Base object or a stretched object which is one-dimensional along the opposite axis. Note the operation will always return a Base object of the same type as the left-hand operand.
Examples
Nimble Base object with a stretched point.
>>> lst3x3 = [[1, 2, 3], [4, 5, 6], [0, -1, -2]] >>> lst1x3 = [1, 2, 3] >>> baseObj = nimble.data(lst3x3) >>> pointObj = nimble.data(lst1x3) >>> baseObj * pointObj.stretch <Matrix 3pt x 3ft 0 1 2 ┌────────── 0 │ 1 4 9 1 │ 4 10 18 2 │ 0 -2 -6 >
Stretched feature with nimble Base object.
>>> lst3x3 = [[1, 2, 3], [4, 5, 6], [0, -1, -2]] >>> lst1x3 = [[1], [2], [3]] >>> baseObj = nimble.data(lst3x3) >>> featObj = nimble.data(lst1x3) >>> featObj.stretch + baseObj <Matrix 3pt x 3ft 0 1 2 ┌──────── 0 │ 2 3 4 1 │ 6 7 8 2 │ 3 2 1 >
Two stretched objects.
>>> lst1x3 = [[1, 2, 3]] >>> lst3x1 = [[1], [2], [3]] >>> pointObj = nimble.data(lst1x3) >>> featObj = nimble.data(lst3x1) >>> pointObj.stretch - featObj.stretch <Matrix 3pt x 3ft 0 1 2 ┌────────── 0 │ 0 1 2 1 │ -1 0 1 2 │ -2 -1 0 > >>> featObj.stretch - pointObj.stretch <Matrix 3pt x 3ft 0 1 2 ┌────────── 0 │ 0 -1 -2 1 │ 1 0 -1 2 │ 2 1 0 >
Keywords: broadcast, broadcasting, expand, match, matching, resize, grow, shape, dimensions, reshape, resize, spread, restructure