Skip to content

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:

  • INCLUDED gives 0, 0.333, 0.667, 1;
  • LOW_ONLY gives 0, 0.25, 0.5, 0.75;
  • HIGH_ONLY gives 0.25, 0.5, 0.75, 1;
  • EXCLUDED gives 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 start for 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:

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)