Spacing(start, stop, count, bounds=Bounds.INCLUDED)
Source¶
A given count of evenly spaced numbers from start to stop, used by Array.from_spacing.
bounds tells whether start and stop are among the values. With start=0,
stop=1 and count=4:
INCLUDEDgives 0, 0.333, 0.667, 1;LOW_ONLYgives 0, 0.25, 0.5, 0.75;HIGH_ONLYgives 0.25, 0.5, 0.75, 1;EXCLUDEDgives 0.2, 0.4, 0.6, 0.8.
Added in version 0.1.0
Parameters:
-
start(float)First bound.
-
stop(float)Second bound, lower than
startfor decreasing values. -
count(int)Number of values, at least 2 when both bounds are included, at least 1 otherwise.
-
bounds(Bounds, default:Bounds.INCLUDED)Which bounds are among the values. Both are included by default.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidCountErrorWhen
countis too low for the bounds.
Examples:
import numdaplot as ndp
ndp.Array.from_spacing(ndp.Spacing(start=0, stop=1, count=5))
# Array([0. , 0.25, 0.5 , 0.75, 1. ], dtype=FLOAT64)
ndp.Array.from_spacing(ndp.Spacing(start=0, stop=1, count=4, bounds=ndp.Bounds.EXCLUDED))
# Array([0.2, 0.4, 0.6, 0.8], dtype=FLOAT64)