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.
People also ask

Can linspace return integers?
Not by inference. Pass an integer dtype to get integers; values are rounded towards negative infinity since NumPy 1.20.0.
🌐
casrai.org
casrai.org › guides › research tools & software › statistical software for research › numpy linspace: syntax, parameters and examples
NumPy linspace: Syntax, Parameters, Examples — CASRAI
Does linspace include the stop value?
Yes by default, because endpoint=True . Set endpoint=False to exclude it; the step then changes, as shown above.
🌐
casrai.org
casrai.org › guides › research tools & software › statistical software for research › numpy linspace: syntax, parameters and examples
NumPy linspace: Syntax, Parameters, Examples — CASRAI
🌐
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.
🌐
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.
🌐
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.
🌐
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))
🌐
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 ...
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.
🌐
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, ...
🌐
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).
🌐
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.
🌐
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....
🌐
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.
🌐
Zubairkhalid
zubairkhalid.com › blog › data-analysis › numpy-linspace-syntax-examples
NumPy linspace: Syntax and Examples | Dr. Zubair Khalid
October 3, 2026 - numpy linspace returns a fixed number of evenly spaced values over a closed interval. You give it a start, a stop and how many points you want, and it computes the spacing for you.
🌐
GeeksforGeeks
geeksforgeeks.org › numpy-linspace-python
numpy.linspace() in Python - GeeksforGeeks
May 19, 2022 - numpy.linspace(start, stop, num = 50, endpoint = True, retstep = False, dtype = None) Parameters : -> start : [optional] start of interval range. By default start = 0 -> stop : end of interval range -> restep : If True, return (samples, step). By default restep = False -> num : [int, optional] No. of samples to generate -> dtype : type of output array · Return : -> ndarray -> step : [float, optional], if restep = True ·
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-linspace
NumPy linspace() Method | Create Evenly Spaced Array - GeeksforGeeks
February 14, 2026 - The numpy.linspace() function is used to generate an array of evenly spaced values between two specified numbers.
🌐
Fritz ai
fritz.ai › home › blog › exploring numpy’s linspace() function
Exploring NumPy’s linspace() function - Fritz ai
September 15, 2023 - Note that except for the first 2 arguments, all other arguments are optional. ... A couple of notes here. The start and stop arguments both accept a single value that could be an integer or a float, which can be positive or negative.