linspace#

named_arrays.linspace(start, stop, axis, num=50, endpoint=True, dtype=None, centers=False)#

Create an array of evenly-spaced numbers between start and stop.

Parameters:
  • start (StartT) – The starting value of the sequence

  • stop (StopT) – The last value of the sequence, unless endpoint is False

  • axis (AxisT) – The name of the new axis corresponding to the sequence

  • num (NumT) – Number of values in the sequence

  • endpoint (bool) – Flag controlling whether stop should be included in the sequence.

  • dtype (None | type | dtype) – numpy.dtype of the result

  • centers (bool) – Flag controlling whether the returned values should be on cell centers. The default is to return values on cell edges.

Return type:

StartT | StopT | AxisT | NumT

See also

numpy.linspace()

Corresponding numpy function.

named_arrays.ScalarLinearSpace

Corresponding implicit scalar array.

named_arrays.UncertainScalarLinearSpace

Corresponding implicit uncertain scalar array.

Examples

Compare the points returned using centers=False to those returned using centers=True.

import named_arrays as na
import matplotlib.pyplot as plt

# Define an array of cell edges
edges_x = na.linspace(0, 1, axis="x", num=11)
edges_y = na.linspace(0, 1, axis="y", num=11)

# Define an array of cell centers
centers_x = na.linspace(0, 1, axis="x", num=10, centers=True)
centers_y = na.linspace(0, 1, axis="y", num=10, centers=True)

# Plot the results as a scatterplot
fig, ax = plt.subplots()
na.plt.scatter(edges_x, edges_y, ax=ax, label="edges");
na.plt.scatter(centers_x, centers_y, ax=ax, label="centers");
ax.legend();
../_images/named_arrays.linspace_0_0.png