Created
November 21, 2018 23:00
-
-
Save aronnem/707dfeec07b74888fb7390d828684184 to your computer and use it in GitHub Desktop.
An example loop calling Scipy's LinearNDInterpolator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, psutil | |
from scipy.interpolate import LinearNDInterpolator | |
max_N = 199000 | |
tenth_max_N = int(max_N/10) | |
process = psutil.Process(os.getpid()) | |
interp_pt = [[0.1, 0.1]] | |
#pts_list = [[0,0], [1,0], [0,1], [1,1]] | |
#vals = [0,1,1,4] | |
pts_list = [[0.0,0.0], [1.0,0.0], [0.0,1.0], [1.0,1.0]] | |
vals = [0.0,1.0,1.0,4.0] | |
L1 = LinearNDInterpolator(pts_list, vals) | |
x1 = L1(interp_pt) | |
start_rss = process.memory_info().rss | |
start_vms = process.memory_info().vms | |
for n in range(max_N): | |
x1 = L1(interp_pt) | |
if (n % tenth_max_N) == 0: | |
KB_rss = int((process.memory_info().rss - start_rss) / 1024) | |
KB_vms = int((process.memory_info().vms - start_vms) / 1024) | |
print('rss_used={1:10d} KB vms_used={2:10d} KB'.format(max_N, KB_rss, KB_vms)) | |
KB_rss = int((process.memory_info().rss - start_rss) / 1024) | |
KB_vms = int((process.memory_info().vms - start_vms) / 1024) | |
print('rss_used={1:10d} KB vms_used={2:10d} KB (final)'.format(max_N, KB_rss, KB_vms)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment