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.
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.
Top answer 1 of 2
3
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.
2 of 2
2
I agree with Dwight in the comments, but I thought I could tell you anyway, just to give you another option, that numpy.arange(start, stop, step) may be also useful to you, and should do the same trick.
What is the default number of samples in numpy linspace?
50. The num parameter defaults to 50 and must be non-negative.
casrai.org
casrai.org › guides › research tools & software › statistical software for research › numpy linspace: syntax, parameters and examples
NumPy linspace: Syntax, Parameters, Examples — CASRAI
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.
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))
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.
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.
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.
Reddit
reddit.com › r/learnpython › how do i make numpy.linspace use a 128 bit float accuracy?
r/learnpython on Reddit: How do I make numpy.linspace use a 128 bit float accuracy?
October 24, 2021 -
I have an array with dtype=numpy.complex128. I want to use numpy.linspace to evenly space out points over this array. But whenever I do that it does it with a 64 bit float accuracy. How do I make it return evenly spaced out points with a 128 bit float accuracy?
Top answer 1 of 2
2
NumPy doesn't really support true 128-bit floats. On some platforms (Windows not among them), there might be a padded 80-bit float type available. But note that complex128 also only uses 64-bit floats, it just uses two of them for the real and the imaginary parts, totalling 128 bits. If you want a linspace with the same float precision as your complex array, you should just use float64 (and complex128 would work, as well).
2 of 2
1
I can't help you with that question, but why do you need 128 bit accuracy?
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 ·