python - Fill an existing numpy array with a scalar function -


i have 1 dimensional numpy array needs refilled data. data @ given index computed function foo

what have like

for in in range(n):     arr[i] = foo(i, state) 

this performance bottleneck of code. considered numpy.fromiter returns new array everytime. rather reuse array save space , time.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -