Skip to content

Instantly share code, notes, and snippets.

@wilywampa
Last active August 29, 2015 14:07
Show Gist options
  • Save wilywampa/37cbe9051edde8f74e32 to your computer and use it in GitHub Desktop.
Save wilywampa/37cbe9051edde8f74e32 to your computer and use it in GitHub Desktop.
Test file for jedi call signatures/fast_parent_copy
import matplotlib.pyplot as plt
import numpy as np
import scipy.constants as const
from numpy.linalg import norm
from collections import namedtuple
pa2psf = 1 / (const.psi * (const.inch /
const.foot) ** 2)
m2ft = 1 / const.foot
if 'fignum_override' not in globals():
fignum_override = None
fignum = fignum_override if fignum_override is not None else 0
Data = namedtuple('Data', ['Time', 'Blah', 'X', 'Y', 'Z'])
time = np.linspace(0, 100, 100)
data = Data(time,
np.random.normal(size=time.shape),
np.random.normal(size=time.shape),
np.random.normal(size=time.shape),
np.random.normal(size=time.shape))
vel = np.array([data.X, data.Y, data.Z])
vnorm = np.linalg.norm(vel, axis=0)
blah = vnorm / data.Blah
starts = [0]
ends = [len(data.Time)]
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
plt.figure()
plt.title('Blah vs. Time')
for run, (start, end) in enumerate(zip(starts, ends)):
plt.plot(data.Time[start:end], data.Blah[start:end], label=str(run))
plt.grid('on')
plt.xlabel('Time (sec)')
plt.ylabel('Blah')
plt.legend()
plt.show()
diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py
index 409fb0e..da1ef78 100644
--- a/jedi/evaluate/helpers.py
+++ b/jedi/evaluate/helpers.py
@@ -119,7 +119,17 @@ def search_call_signatures(user_stmt, position):
call, index = None, 0
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
# some parts will of the statement will be removed
- user_stmt = fast_parent_copy(user_stmt)
+ from time import time
+ user_stmt_orig = copy.deepcopy(user_stmt)
+ t1 = time()
+ user_stmt = fast_parent_copy(user_stmt_orig)
+ t2 = time()
+ d1 = t2 - t1
+ t1 = time()
+ user_stmt = copy.deepcopy(user_stmt_orig)
+ t2 = time()
+ d2 = t2 - t1
+ print 'fast_parent_copy took %f sec ; deepcopy took %f sec' % (d1, d2)
arr, index = call_signature_array_for_pos(user_stmt, position)
if arr is not None:
call = arr.parent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment