def _Main(): options = _ParseArguments() _ConfigureLogging(options.loglevel) self = ControllerClient(options.url, options.username, options.password) from IPython.terminal import embed ipshell = embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())
def console(): """Starts an interactive IPython console""" import sys import builtins from IPython.terminal.embed import (load_default_config, InteractiveShell, InteractiveShellEmbed) header = 'Django debug console' config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell # save ps1/ps2 if defined ps1 = None ps2 = None try: ps1 = sys.ps1 ps2 = sys.ps2 except AttributeError: pass # save previous instance saved_shell_instance = InteractiveShell._instance if saved_shell_instance is not None: cls = type(saved_shell_instance) cls.clear_instance() # Starts shell retvalue = None def exit(value=None): nonlocal retvalue retvalue = value try: builtins.exit = exit shell = InteractiveShellEmbed.instance(config=config) shell(header=header, stack_depth=2, compile_flags=None) InteractiveShellEmbed.clear_instance() finally: pass # restore previous instance if saved_shell_instance is not None: cls = type(saved_shell_instance) cls.clear_instance() for subclass in cls._walk_mro(): subclass._instance = saved_shell_instance if ps1 is not None: sys.ps1 = ps1 sys.ps2 = ps2 return retvalue
def draw(self): fig, ax = plt.subplots() ax.axis('equal') #ax.set_aspect('equal', adjustable='box') patch = PolygonPatch(self.poly, facecolor='#6699cc', linewidth=2) ax.add_patch(patch) ax.add_collection(mc.LineCollection(self.ridges, linewidths=1)) from IPython.terminal import embed ipshell = embed.InteractiveShellEmbed( config=embed.load_default_config())(local_ns=locals()) #ax.autoscale() ax.margins(0.1) plt.show()
def interact(self, **kwargs): from IPython.terminal.embed import InteractiveShellEmbed, load_default_config import sys config = kwargs.get('config') header = kwargs.pop('header', u'') compile_flags = kwargs.pop('compile_flags', None) if config is None: config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell kwargs['config'] = config frame = sys._getframe(1) shell = InteractiveShellEmbed.instance( _init_location_id='%s:%s' % ( frame.f_code.co_filename, frame.f_lineno), **kwargs) shell(header=header, stack_depth=2, compile_flags=compile_flags, _call_location_id='%s:%s' % (frame.f_code.co_filename, frame.f_lineno)) InteractiveShellEmbed.clear_instance()
def embed(pdb=False): from IPython.terminal.embed import InteractiveShellEmbed, load_default_config from IPython import Application, embed, get_ipython config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell config.InteractiveShellEmbed.pdb = pdb shell = InteractiveShellEmbed.instance(config=config) # my hook shell.set_hook('synchronize_with_editor', synchronize_with_editor) ### di, gu, gv etc... shell.safe_execfile('/home/ppalucki/workspace/djangoshellhelpers.py') ### start shell(stack_depth=2)
def _compute_A(self, ts, knots): n = len(ts) - 1 A = np.zeros([n + 3, n + 3]) for i in range(1, n + 2): for j in range(i - 1, i + 2): try: A[i, j] = self._basis_func(j, ts[i - 1], knots) except Exception as e: from IPython.terminal import embed ipshell = embed.InteractiveShellEmbed( config=embed.load_default_config())(local_ns=locals()) for j in range(0, 3): A[0, j] = self._basis_func_2diff(j, ts[0], knots) for j in range(n, n + 3): A[n + 2, j] = self._basis_func_2diff(j, ts[n], knots) return A
def interact(self, **kwargs): from IPython.terminal.embed import InteractiveShellEmbed, load_default_config import sys config = kwargs.get('config') header = kwargs.pop('header', u'') compile_flags = kwargs.pop('compile_flags', None) if config is None: config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell kwargs['config'] = config frame = sys._getframe(1) shell = InteractiveShellEmbed.instance( _init_location_id='%s:%s' % (frame.f_code.co_filename, frame.f_lineno), **kwargs) shell(header=header, stack_depth=2, compile_flags=compile_flags, _call_location_id='%s:%s' % (frame.f_code.co_filename, frame.f_lineno)) InteractiveShellEmbed.clear_instance()
from IPython.terminal import embed; ipshell=embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())
import sympy u = sympy.symbols('u') u0, u1, u2, u3, u4 = sympy.symbols('u:5') expr0 = (u - u0)**3 / ((u1 - u0) * (u2 - u0) * (u3 - u0)) expr1 = ((u - u0)**2 * (u2 - u)) / ((u2 - u1)*(u3 - u0)*(u2 - u0)) \ + ((u3 - u) * (u - u0) * (u - u1)) / ((u2 - u1)*(u3 - u1)*(u3 - u0)) \ + (u4 - u) * (u - u1)**2 / ((u2 - u1)*(u4 - u1)*(u3 - u1)) expr2 = ((u - u0) * (u3 - u)**2) / ((u3 - u2)*(u3 - u1)*(u3 - u1)) \ + ((u4 - u) * (u3 - u) * (u - u1)) / ((u3 - u2)*(u4 - u1)*(u3 - u1)) \ + (u4 - u)**2 * (u - u2) / ((u3 - u2)*(u4 - u2)*(u4 - u1)) expr3 = (u4 - u)**3 / ((u4 - u3) * (u4 - u2) * (u4 - u1)) print(sympy.simplify(expr0.diff(u).diff(u))) print(sympy.simplify(expr1.diff(u).diff(u))) print(sympy.simplify(expr2.diff(u).diff(u))) print(sympy.simplify(expr3.diff(u).diff(u))) # 6*(-u + u0)/((u0 - u1)*(u0 - u2)*(u0 - u3)) # 2*((u0 - u2)*(u0 - u3)*(3*u - 2*u1 - u4) + (u0 - u2)*(u1 - u4)*(3*u - u0 - u1 - u3) + (u1 - u3)*(u1 - u4)*(3*u - 2*u0 - u2))/((u0 - u2)*(u0 - u3)*(u1 - u2)*(u1 - u3)*(u1 - u4)) # 2*((u1 - u3)**2*(-3*u + u2 + 2*u4) + (u1 - u3)*(u2 - u4)*(-3*u + u1 + u3 + u4) + (u1 - u4)*(u2 - u4)*(-3*u + u0 + 2*u3))/((u1 - u3)**2*(u1 - u4)*(u2 - u3)*(u2 - u4)) # 6*(u - u4)/((u1 - u4)*(u2 - u4)*(u3 - u4)) from IPython.terminal import embed ipshell = embed.InteractiveShellEmbed(config=embed.load_default_config())( local_ns=locals())
"area": torch.tensor(area), "iscrowd": torch.tensor(is_crowd) } # img, target = self.transforms(img, target) return img, target if __name__ == '__main__': #import transforms as T #transforms = [] #transforms.append(T.ToTensor()) #transforms.append(T.RandomHorizontalFlip(0.5)) #transforms = T.Compose(transforms) import albumentations from albumentations.pytorch.transforms import ToTensorV2 data_transforms = albumentations.Compose([ albumentations.Flip(), #albumentations.RandomBrightness(0.2), albumentations.ShiftScaleRotate(rotate_limit=90, scale_limit=0.10), #albumentations.Normalize(), #albumentations.Resize(512, 512), #ToTensorV2() ], bbox_params=albumentations.BboxParams(format='pascal_voc', label_fields=['class_labels'])) # min_visibility=0.2 #self = DSB('/home/leus/3rdparty/github.com/ompugao/dm6190/2_segmentationreview/data-science-bowl-2018/', image_set="stage1_train", transforms=data_transforms) import preprocess preprocessfn = preprocess.ImagePreProcessor1('./kmeans.pkl') self = DSB('/home/leus/3rdparty/github.com/ompugao/dm6190/2_segmentationreview/data-science-bowl-2018/', image_set="stage1_train", transforms=data_transforms, preprocessfn=preprocessfn) from IPython.terminal import embed; ipshell=embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())
# スライディングモード制御のゲイン K = 15.0 # start simulation for k in range(len(t) - 1): # ∂S/∂x # Sx = np.array([1, V * np.cos(x[2, k]) + z]) try: u[k] = -np.dot( 1 / (np.dot(Sx, B)), (np.dot(Sx, f(x[1:3, k])) + [K * sig(S(x[1:3, k]))])) except Exception as e: from IPython.terminal import embed ipshell = embed.InteractiveShellEmbed( config=embed.load_default_config())(local_ns=locals()) raise (e) #u[k] = - np.linalg.inv(np.dot(p.T, B)) - np.dot(K, sig(S(xsmc[:,k].reshape(2,1)))) x[:, k + 1] = rk4(x[:, k].reshape(3, 1), u[k], dt, F).flatten() #plt.clear() plt.subplot(4, 1, 1) plt.plot(t, x[0, :]) plt.ylabel("state x1") plt.grid('on') plt.title("time series") plt.subplot(4, 1, 2) plt.plot(t, x[1, :]) plt.ylabel('state x2') plt.grid('on') plt.subplot(4, 1, 3)