What you are trying to do actually corresponds to np.arange.

time = np.arange(dt, T, dt)

To include the T time you will need to change the stop boundary to T + dt.

Answer from Guimoute on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.5 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
NumPy
numpy.org › devdocs › › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.6.dev0 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
Python Guides
pythonguides.com › python-numpy-linspace
NumPy linspace: Formula, Endpoint, vs arange
May 7, 2025 - (1.3 - 1) / 0.1 does not come out as exactly 3 in binary floating point, so the rounding lands the wrong side of the boundary. linspace cannot make this mistake. You state the count, so the count is what you get. Both ends are exact, which matters when the result feeds an interpolation or an axis limit: import numpy as np # linspace hits both ends exactly, which matters for plotting and for interpolation grid = np.linspace(0, 1, 11) print("first:", repr(grid[0])) print("last :", repr(grid[-1])) print("last is exactly 1.0?", grid[-1] == 1.0) print() # edge cases worth knowing print("num=1 ->", np.linspace(0, 10, 1), "(just the start)") print("num=0 ->", np.linspace(0, 10, 0), "(empty)") print("backwards ->", np.linspace(10, 0, 5))
🌐
Real Python
realpython.com › np-linspace-numpy
np.linspace(): Create Evenly or Non-Evenly Spaced Arrays – Real Python
July 3, 2026 - The elements of a NumPy array all belong to the same data type. np.linspace() typically returns arrays of floats.
🌐
PYnative
pynative.com › home › python › python range of float numbers
Python range of float numbers
April 13, 2021 - The numpy.linspace function will return a sequence of evenly spaced values on that interval ... num: The number of samples to generate, default is 50. It cannot be negative, i.e., The Total numbers you want in the output range. endpoint: Set ...
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.3 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: arange() and linspace() to generate evenly spaced values | note.nkmk.me
February 2, 2024 - source: numpy_linspace.py · The data type (dtype) of the generated array can be specified with the dtype argument. Note that by default, even if an array of integers is generated, it becomes floating-point numbers (float). a = np.linspace(0, ...
Find elsewhere
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.25 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.1 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
NumPy
numpy.org › doc › 1.23 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.23 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
NumPy
numpy.org › doc › 1.26 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.26 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
CASRAI
casrai.org › guides › research tools & software › statistical software for research › numpy linspace: syntax, parameters and examples
NumPy linspace: Syntax, Parameters, Examples — CASRAI
2 weeks ago - In research code it is the usual way to build the grid of x-values for a density curve, a model prediction line or a parameter sweep, because you choose how many points you get rather than how far apart they are. Its signature in the current NumPy documentation is numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None).
🌐
AskPython
askpython.com › python-modules › numpy › numpy-linspace-python
NumPy linspace(): Create Arrays Fast - AskPython
January 24, 2026 - import numpy as np import ... specifies the data type for array elements. NumPy infers float64 by default when you provide floating-point start or stop values....
🌐
TechBeamers
techbeamers.com › python-float-range
Generate Floating Point Range in Python - TechBeamers
November 30, 2025 - NumPy has another method (linspace()) to let you produce the specified no. of float numbers.
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.0 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
🌐
Learn By Example
learnbyexample.org › how-to-generate-a-range-of-floating-point-numbers-in-python
How to Generate a Range of Floating-point Numbers in Python - Learn By Example
April 18, 2024 - Another approach with NumPy is using the linspace() function. While similar to arange(), it offers a slightly different way to control the range of numbers generated. Both functions take the sequence’s start and stop values as their first two arguments.
🌐
NumPy
numpy.org › doc › 1.21 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.21 Manual
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.