Every line of 'np.linspace python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
147 def _linspace(start, stop, num): 148 # produces results identical to: 149 # np.linspace(start, stop, num) 150 start = T.cast(start, 'float32') 151 stop = T.cast(stop, 'float32') 152 num = T.cast(num, 'float32') 153 step = (stop-start)/(num-1) 154 return T.arange(num, dtype='float32')*step+start
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
213 def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): 214 """ 215 Return evenly spaced numbers over a specified interval. 216 217 Returns *num* evenly spaced samples, calculated over the interval [*start, stop*]. 218 219 The endpoint of the interval can optionally be excluded. 220 221 :param start: (*number*) Start of interval. The interval includes this value. 222 :param stop: (*number*) The end value of the sequence, unless endpoint is set to 223 False. In that case, the sequence consists of all but the last of ``num + 1`` 224 evenly spaced samples, so that stop is excluded. Note that the step size changes 225 when endpoint is False. 226 :param num: (*int, optional*) Number of samples to generate. Default is 50. Must 227 be non-negative. 228 :param endpoint: (*boolean, optional*) If true, stop is the last sample. Otherwise, it is not included. 229 Default is True. 230 :param dtype: (*dtype*) The type of output array. If dtype is not given, infer the data 231 type from the other input arguments. 232 233 :returns: (*NDArray*) Array of evenly spaced values. 234 235 Examples:: 236 237 >>> linspace(2.0, 3.0, num=5) 238 array([2.0, 2.25, 2.5, 2.75, 3.0]) 239 >>> linspace(2.0, 3.0, num=5, endpoint=False) 240 array([2.0, 2.25, 2.5, 2.75]) 241 """ 242 return NDArray(ArrayUtil.lineSpace(start, stop, num, endpoint))
71 def linspace(start, stop, num, endpoint=True, unit=None): 72 """ 73 Arguments 74 ------------ 75 * `start` (int or float): the starting point of the sequence. 76 * `stop` (int or float): the ending point of the sequence, unless `endpoint` 77 is set to False. In that case, the sequence consists of all but the 78 last of ``num + 1`` evenly spaced samples, so that `stop` is excluded. 79 Note that the step size changes when `endpoint` is False. 80 * `num` (int): number of samples to generate. 81 * `endpoint` (bool, optional, default=True): If True, `stop` is the last 82 sample. Otherwise, it is not included. 83 * `unit` (astropy unit or string, optional, default=None): unit 84 corresponding to the passed values. 85 86 Returns 87 ----------- 88 * <Linspace> 89 """ 90 return _wrappers.Linspace(start, stop, num, endpoint, unit)
74 def test_linspace_6(): 75 a = nw.linspace(1, PhysicalQuantity(10, 'mm'), 10) 76 b = np.linspace(1, 10, 10) 77 assert_almost_equal(a.value, b)