LazyArange class
(Shortest import: from brian2.codegen.runtime.numpy_rt.numpy_rt import LazyArange)
- class brian2.codegen.runtime.numpy_rt.numpy_rt.LazyArange(stop, start=0, indices=None)[source]
Bases:
Iterable
A class that can be used as a
arange
replacement (with an implied step size of 1) but does not actually create an array of values until necessary. It is somewhat similar to therange()
function in Python 3, but does not use a generator. It is tailored to a special use case, the_vectorisation_idx
variable in numpy templates, and not meant for general use. The_vectorisation_idx
is used for stateless function calls such asrand()
and for the numpy codegen target determines the number of values produced by such a call. This will often be the number of neurons or synapses, and this class avoids creating a new array of that size at every code object call when all that is needed is the length of the array.