input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_int_range_inclusive(self): int_range = inputs.int_range(1, 5) assert_equal(5, int_range(5))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_int_range_low(self): int_range = inputs.int_range(0, 5) assert_raises(ValueError, lambda: int_range(-1))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_int_range_high(self): int_range = inputs.int_range(0, 5) assert_raises(ValueError, lambda: int_range(6))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_isointerval(): intervals = [ ( # Full precision with explicit UTC. "2013-01-01T12:30:00Z/P1Y2M3DT4H5M6S", ( datetime(2013, 1, 1, 12, 30, 0, tzinfo=pytz.utc), datetime(2014, 3, 5, 16, 35, 6, tzinfo=pytz.utc), ), ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_invalid_isointerval_error(): try: inputs.iso8601interval('2013-01-01/blah') except ValueError as error: assert_equal( str(error), "Invalid argument: 2013-01-01/blah. argument must be a valid ISO8601 " "date/time interval.", ) return ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_bad_isointervals(): bad_intervals = [ '2013-01T14:', '', 'asdf', '01/01/2013', ] for bad_interval in bad_intervals: yield ( assert_raises, Exception, inputs.iso8601interval, bad_interval, )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _create_3d_axis(): """creates a subplot with 3d projection if one does not already exist""" from matplotlib.projections import get_projection_class from matplotlib import _pylab_helpers create_axis = True if _pylab_helpers.Gcf.get_active() is not None: if isinstance(plt.gca(), get_proje...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _plot_surface(ax, x, y, z, labels, azim=None): """helper function for surface plots""" # ax.tick_params(axis='both', which='major', pad=-3) assert np.size(x) > 1 and np.size(y) > 1 and np.size(z) > 1 if azim is not None: ax.azim = azim X, Y = np.meshgrid(x, y) Z = np.ma.masked_invali...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def label_line(ax, X, Y, U, V, label, color='k', size=8): """Add a label to a line, at the proper angle. Arguments --------- line : matplotlib.lines.Line2D object, label : str x : float x-position to place center of text (in data coordinated y : float ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_phasor(up, i1, beta, r1, xd, xq, ax=0): """creates a phasor plot up: internal voltage i1: current beta: angle i1 vs up [deg] r1: resistance xd: reactance in direct axis xq: reactance in quadrature axis""" i1d, i1q = (i1*np.sin(beta/180*np.pi), i1*np.cos(beta/180*np.pi)) u...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def iqd_phasor(up, iqd, uqd, ax=0): """creates a phasor plot up: internal voltage iqd: current uqd: terminal voltage""" uxdq = (uqd[1]/np.sqrt(2), (uqd[0]/np.sqrt(2)-up)) __phasor_plot(ax, up, (iqd[1]/np.sqrt(2), iqd[0]/np.sqrt(2)), uxdq)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def phasor(bch, ax=0): """create phasor plot from bch""" f1 = bch.machine['p']*bch.dqPar['speed'] w1 = 2*np.pi*f1 xd = w1*bch.dqPar['ld'][-1] xq = w1*bch.dqPar['lq'][-1] r1 = bch.machine['r1'] i1beta_phasor(bch.dqPar['up'][-1], bch.dqPar['i1'][-1], bch.dqPar['beta'][-1], ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def airgap(airgap, ax=0): """creates plot of flux density in airgap""" if ax == 0: ax = plt.gca() ax.set_title('Airgap Flux Density [T]') ax.plot(airgap['pos'], airgap['B'], label='Max {:4.2f} T'.format(max(airgap['B']))) ax.plot(airgap['pos'], airgap['B_fft'], label=...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def airgap_fft(airgap, bmin=1e-2, ax=0): """plot airgap harmonics""" unit = 'T' if ax == 0: ax = plt.gca() ax.set_title('Airgap Flux Density Harmonics / {}'.format(unit)) ax.grid(True) order, fluxdens = np.array([(n, b) for n, b in zip(airgap['nue'], ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def torque(pos, torque, ax=0): """creates plot from torque vs position""" k = 20 alpha = np.linspace(pos[0], pos[-1], k*len(torque)) f = ip.interp1d(pos, torque, kind='quadratic') unit = 'Nm' scale = 1 if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3: scal...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def torque_fft(order, torque, ax=0): """plot torque harmonics""" unit = 'Nm' scale = 1 if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3: scale = 1e-3 unit = 'kNm' if ax == 0: ax = plt.gca() ax.set_title('Torque Harmonics / {}'.format(unit)) ax.grid(True) try:...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def force(title, pos, force, xlabel='', ax=0): """plot force vs position""" unit = 'N' scale = 1 if min(force) < -9.9e3 or max(force) > 9.9e3: scale = 1e-3 unit = 'kN' if ax == 0: ax = plt.gca() ax.set_title('{} / {}'.format(title, unit)) ax.grid(True) ax.plot(pos...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def force_fft(order, force, ax=0): """plot force harmonics""" unit = 'N' scale = 1 if min(force) < -9.9e3 or max(force) > 9.9e3: scale = 1e-3 unit = 'kN' if ax == 0: ax = plt.gca() ax.set_title('Force Harmonics / {}'.format(unit)) ax.grid(True) try: bw = 2...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def forcedens(title, pos, fdens, ax=0): """plot force densities""" if ax == 0: ax = plt.gca() ax.set_title(title) ax.grid(True) ax.plot(pos, [1e-3*ft for ft in fdens[0]], label='F tang') ax.plot(pos, [1e-3*fn for fn in fdens[1]], label='F norm') ax.legend() ax.set_xlabel('Pos / ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def forcedens_surface(fdens, ax=0): if ax == 0: _create_3d_axis() ax = plt.gca() xpos = [p for p in fdens.positions[0]['X']] ypos = [p['position'] for p in fdens.positions] z = 1e-3*np.array([p['FN'] for p in fdens.positions]) _plot_surface(ax, xpos, ypos, z, ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def forcedens_fft(title, fdens, ax=0): """plot force densities FFT Args: title: plot title fdens: force density object """ if ax == 0: ax = plt.axes(projection="3d") F = 1e-3*fdens.fft() fmin = 0.2 num_bars = F.shape[0] + 1 _xx, _yy = np.meshgrid(np.arange(1, num_bar...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def winding_flux(pos, flux, ax=0): """plot flux vs position""" if ax == 0: ax = plt.gca() ax.set_title('Winding Flux / Vs') ax.grid(True) for p, f in zip(pos, flux): ax.plot(p, f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def winding_current(pos, current, ax=0): """plot winding currents""" if ax == 0: ax = plt.gca() ax.set_title('Winding Currents / A') ax.grid(True) for p, i in zip(pos, current): ax.plot(p, i)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def voltage(title, pos, voltage, ax=0): """plot voltage vs. position""" if ax == 0: ax = plt.gca() ax.set_title('{} / V'.format(title)) ax.grid(True) ax.plot(pos, voltage)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def voltage_fft(title, order, voltage, ax=0): """plot FFT harmonics of voltage""" if ax == 0: ax = plt.gca() ax.set_title('{} / V'.format(title)) ax.grid(True) if max(order) < 5: order += [5] voltage += [0] try: bw = 2.5E-2*max(order) ax.bar(order, voltage...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mcv_hbj(mcv, log=True, ax=0): """plot H, B, J of mcv dict""" import femagtools.mcv MUE0 = 4e-7*np.pi ji = [] csiz = len(mcv['curve']) if ax == 0: ax = plt.gca() ax.set_title(mcv['name']) for k, c in enumerate(mcv['curve']): bh = [(bi, hi*1e-3) for bi, h...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mcv_muer(mcv, ax=0): """plot rel. permeability vs. B of mcv dict""" MUE0 = 4e-7*np.pi bi, ur = zip(*[(bx, bx/hx/MUE0) for bx, hx in zip(mcv['curve'][0]['bi'], mcv['curve'][0]['hi']) if not hx == 0]) if ax == 0: ax = plt.gca() ax.plo...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mtpa(pmrel, i1max, title='', projection='', ax=0): """create a line or surface plot with torque and mtpa curve""" nsamples = 10 i1 = np.linspace(0, i1max, nsamples) iopt = np.array([pmrel.mtpa(x) for x in i1]).T iqmax, idmax = pmrel.iqdmax(i1max) iqmin, idmin = pmrel.iqdmin(i1max) if p...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mtpv(pmrel, u1max, i1max, title='', projection='', ax=0): """create a line or surface plot with voltage and mtpv curve""" w1 = pmrel.w2_imax_umax(i1max, u1max) nsamples = 20 if projection == '3d': nsamples = 50 iqmax, idmax = pmrel.iqdmax(i1max) iqmin, idmin = pmrel.iqdmin(i1max) ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __get_linearForce_title_keys(lf): if 'force_r' in lf: return ['Force r', 'Force z'], ['force_r', 'force_z'] return ['Force x', 'Force y'], ['force_x', 'force_y']
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def pmrelsim(bch, title=''): """creates a plot of a PM/Rel motor simulation""" cols = 2 rows = 4 if len(bch.flux['1']) > 1: rows += 1 htitle = 1.5 if title else 0 fig, ax = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 3*rows + htitle)) if title: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def multcal(bch, title=''): """creates a plot of a MULT CAL simulation""" cols = 2 rows = 4 htitle = 1.5 if title else 0 fig, ax = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 3*rows + htitle)) if title: fig.suptitle(title, fontsize=16) row = 1 pl...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def fasttorque(bch, title=''): """creates a plot of a Fast Torque simulation""" cols = 2 rows = 4 if len(bch.flux['1']) > 1: rows += 1 htitle = 1.5 if title else 0 fig, ax = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 3*rows + htitle)) if title: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def cogging(bch, title=''): """creates a cogging plot""" cols = 2 rows = 3 htitle = 1.5 if title else 0 fig, ax = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 3*rows + htitle)) if title: fig.suptitle(title, fontsize=16) row = 1 plt.subplot(rows, ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def transientsc(bch, title=''): """creates a transient short circuit plot""" cols = 1 rows = 2 htitle = 1.5 if title else 0 fig, ax = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 3*rows + htitle)) if title: fig.suptitle(title, fontsize=16) row = 1 ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_torque(i1, beta, torque, title='', ax=0): """creates a surface plot of torque vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() azim = 210 if 0 < np.mean(beta) or -90 > np.mean(beta): azim = -60 unit = 'Nm' scale = 1 if np.min(torque) < -9.9e3 or ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_ld(i1, beta, ld, ax=0): """creates a surface plot of ld vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, i1, beta, np.asarray(ld)*1e3, (u'I1/A', u'Beta/°', u'Ld/mH'), azim=60)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_lq(i1, beta, lq, ax=0): """creates a surface plot of ld vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() azim = 60 if 0 < np.mean(beta) or -90 > np.mean(beta): azim = -120 _plot_surface(ax, i1, beta, np.asarray(lq)*1e3, (u'I1/A', u'Beta...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_psim(i1, beta, psim, ax=0): """creates a surface plot of psim vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, i1, beta, psim, (u'I1/A', u'Beta/°', u'Psi m/Vs'), azim=60)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_up(i1, beta, up, ax=0): """creates a surface plot of up vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, i1, beta, up, (u'I1/A', u'Beta/°', u'Up/V'), azim=60)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_psid(i1, beta, psid, ax=0): """creates a surface plot of psid vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() azim = -60 if 0 < np.mean(beta) or -90 > np.mean(beta): azim = 60 _plot_surface(ax, i1, beta, psid, (u'I1/A', u'Beta/°', u'Ps...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def i1beta_psiq(i1, beta, psiq, ax=0): """creates a surface plot of psiq vs i1, beta""" if ax == 0: _create_3d_axis() ax = plt.gca() azim = 210 if 0 < np.mean(beta) or -90 > np.mean(beta): azim = -60 _plot_surface(ax, i1, beta, psiq, (u'I1/A', u'Beta/°', u'P...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_torque(id, iq, torque, ax=0): """creates a surface plot of torque vs id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() unit = 'Nm' scale = 1 if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3: scale = 1e-3 unit = 'kNm' _plot_surface(ax, id, iq, scal...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_psid(id, iq, psid, ax=0): """creates a surface plot of psid vs id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, id, iq, psid, (u'Id/A', u'Iq/A', u'Psi d/Vs'), azim=210)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_psiq(id, iq, psiq, ax=0): """creates a surface plot of psiq vs id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, id, iq, psiq, (u'Id/A', u'Iq/A', u'Psi q/Vs'), azim=210)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_psim(id, iq, psim, ax=0): """creates a surface plot of psim vs. id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, id, iq, psim, (u'Id/A', u'Iq/A', u'Psi m [Vs]'), azim=120)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_ld(id, iq, ld, ax=0): """creates a surface plot of ld vs. id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, id, iq, np.asarray(ld)*1e3, (u'Id/A', u'Iq/A', u'L d/mH'), azim=120)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def idq_lq(id, iq, lq, ax=0): """creates a surface plot of lq vs. id, iq""" if ax == 0: _create_3d_axis() ax = plt.gca() _plot_surface(ax, id, iq, np.asarray(lq)*1e3, (u'Id/A', u'Iq/A', u'L q/mH'), azim=120)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def ldlq(bch): """creates the surface plots of a BCH reader object with a ld-lq identification""" beta = bch.ldq['beta'] i1 = bch.ldq['i1'] torque = bch.ldq['torque'] ld = np.array(bch.ldq['ld']) lq = np.array(bch.ldq['lq']) psid = bch.ldq['psid'] psiq = bch.ldq['psiq'] rows = 3...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def psidq(bch): """creates the surface plots of a BCH reader object with a psid-psiq identification""" id = bch.psidq['id'] iq = bch.psidq['iq'] torque = bch.psidq['torque'] ld = np.array(bch.psidq_ldq['ld']) lq = np.array(bch.psidq_ldq['lq']) psim = bch.psidq_ldq['psim'] psid = bch....
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def felosses(losses, coeffs, title='', log=True, ax=0): """plot iron losses with steinmetz or jordan approximation Args: losses: dict with f, B, pfe values coeffs: list with steinmetz (cw, alpha, beta) or jordan (cw, alpha, ch, beta, gamma) coeffs title: title string log: l...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def spel(isa, with_axis=False, ax=0): """plot super elements of I7/ISA7 model Args: isa: Isa7 object """ from matplotlib.patches import Polygon if ax == 0: ax = plt.gca() ax.set_aspect('equal') for se in isa.superelements: ax.add_patch(Polygon([n.xy ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mesh(isa, with_axis=False, ax=0): """plot mesh of I7/ISA7 model Args: isa: Isa7 object """ from matplotlib.lines import Line2D if ax == 0: ax = plt.gca() ax.set_aspect('equal') for el in isa.elements: pts = [list(i) for i in zip(*[v.xy for v in el.vertices])] ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _contour(ax, title, elements, values, label='', isa=None): from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection if ax == 0: ax = plt.gca() ax.set_aspect('equal') ax.set_title(title, fontsize=18) if isa: for se in isa.superelements: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def demag(isa, ax=0): """plot demag of NC/I7/ISA7 model Args: isa: Isa7/NC object """ emag = [e for e in isa.elements if e.is_magnet()] demag = np.array([e.demagnetization(isa.MAGN_TEMPERATURE) for e in emag]) _contour(ax, f'Demagnetization at {isa.MAGN_TEMPERATURE} °C', emag,...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def demag_pos(isa, pos, icur=-1, ibeta=-1, ax=0): """plot demag of NC/I7/ISA7 model at rotor position Args: isa: Isa7/NC object pos: rotor position in degree icur: cur amplitude index or last index if -1 ibeta: beta angle index or last index if -1 """ emag = [e for e in isa.eleme...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def flux_density(isa, subreg=[], ax=0): """plot flux density of NC/I7/ISA7 model Args: isa: Isa7/NC object """ if subreg: if isinstance(subreg, list): sr = subreg else: sr = [subreg] elements = [e for s in sr for se in isa.get_subregion(s).elements()...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def loss_density(isa, subreg=[], ax=0): """plot loss density of NC/I7/ISA7 model Args: isa: Isa7/NC object """ if subreg: if isinstance(subreg, list): sr = subreg else: sr = [subreg] elements = [e for s in sr for sre in isa.get_subregion(s).elements(...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mmf(f, title='', ax=0): """plot magnetomotive force (mmf) of winding""" if ax == 0: ax = plt.gca() if title: ax.set_title(title) ax.plot(np.array(f['pos'])/np.pi*180, f['mmf']) ax.plot(np.array(f['pos_fft'])/np.pi*180, f['mmf_fft']) ax.set_xlabel('Position / Deg') phi = ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mmf_fft(f, title='', mmfmin=1e-2, ax=0): """plot winding mmf harmonics""" if ax == 0: ax = plt.gca() if title: ax.set_title(title) else: ax.set_title('MMF Harmonics') ax.grid(True) order, mmf = np.array([(n, m) for n, m in zip(f['nue'], ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def zoneplan(wdg, ax=0): """plot zone plan of winding wdg""" from matplotlib.patches import Rectangle upper, lower = wdg.zoneplan() Qb = len([n for l in upper for n in l]) from femagtools.windings import coil_color rh = 0.5 if lower: yl = rh ymax = 2*rh + 0.2 else: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def winding_factors(wdg, n=8, ax=0): """plot winding factors""" ax = plt.gca() ax.set_title(f'Winding factors Q={wdg.Q}, p={wdg.p}, q={round(wdg.q,4)}') ax.grid(True) order, kwp, kwd, kw = np.array([(n, k1, k2, k3) for n, k1, k2, k3 in zip(wdg.kw_order(n), ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def winding(wdg, ax=0): """plot coils of windings wdg""" from matplotlib.patches import Rectangle from matplotlib.lines import Line2D from femagtools.windings import coil_color coil_len = 25 coil_height = 4 dslot = 8 arrow_head_length = 2 arrow_head_width = 2 if ax == 0: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def main(): import io import sys import argparse from .__init__ import __version__ from femagtools.bch import Reader argparser = argparse.ArgumentParser( description='Read BCH/BATCH/PLT file and create a plot') argparser.add_argument('filename', help='name...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def characteristics(char, title=''): fig, axs = plt.subplots(2, 2, figsize=(10, 8), sharex=True) if title: fig.suptitle(title) n = np.array(char['n'])*60 pmech = np.array(char['pmech'])*1e-3 axs[0, 0].plot(n, np.array(char['T']), 'C0-', label='Torque') axs[0, 0].set_ylabel("Torque / Nm...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def runcmd(cmd, **kw): # same code as in getlino.py """Run the cmd similar as os.system(), but stop when Ctrl-C.""" # kw.update(stdout=subprocess.PIPE) # kw.update(stderr=subprocess.STDOUT) kw.update(shell=True) kw.update(universal_newlines=True) kw.update(check=True) # subprocess.check_out...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_arguments(self, parser): parser.add_argument('--noinput', action='store_false', dest='interactive', default=True, help='Do not prompt for input of any kind.') parser.add_argument('-l', '--list', action='store_true', ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_watch_task(client): user = f.UserFactory.create() task = f.create_task(owner=user, milestone=None) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) url = reverse("tasks-watch", args=(task.id,)) client.login(user) response = client.post(url) assert respons...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_unwatch_task(client): user = f.UserFactory.create() task = f.create_task(owner=user, milestone=None) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) url = reverse("tasks-watch", args=(task.id,)) client.login(user) response = client.post(url) assert respo...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_list_task_watchers(client): user = f.UserFactory.create() task = f.TaskFactory(owner=user) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) f.WatchedFactory.create(content_object=task, user=user) url = reverse("task-watchers-list", args=(task.id,)) client.logi...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_get_task_watcher(client): user = f.UserFactory.create() task = f.TaskFactory(owner=user) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) watch = f.WatchedFactory.create(content_object=task, user=user) url = reverse("task-watchers-detail", args=(task.id, watch.user...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_get_task_watchers(client): user = f.UserFactory.create() task = f.TaskFactory(owner=user) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) url = reverse("tasks-detail", args=(task.id,)) f.WatchedFactory.create(content_object=task, user=user) client.login(user...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_get_task_is_watcher(client): user = f.UserFactory.create() task = f.create_task(owner=user, milestone=None) f.MembershipFactory.create(project=task.project, user=user, is_admin=True) url_detail = reverse("tasks-detail", args=(task.id,)) url_watch = reverse("tasks-watch", args=(task.id,)) ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): self.var = 0
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def connect (): ''' Create the connection to the MongoDB and create 3 collections needed ''' try: # Create the connection to the local host conn = pymongo.MongoClient() print 'MongoDB Connection Successful' except pymongo.errors.ConnectionFailure, err: print 'MongoDB...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): self.var = 1 # self.var will be overwritten C.__init__(self)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): self.var = 0 # self.var will be overwritten
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def make_new_rsa_key_weak(bits): return RSA.generate(bits) # NOT OK
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _build_gravatar_url(email, params): """Generate a Gravatar URL.
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def make_new_rsa_key_strong(bits): return RSA.generate(bits) # OK
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, email, params): self.email = email self.params = params
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def render(self, context): try: if self.params: params = template.Variable(self.params).resolve(context) else: params = {} # try matching an address string literal email_literal = self.email.strip().lower() if EMAIL_RE....
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): # pylint: disable=super-init-not-called pass
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_parse_sections(): simple_mariofile_sections = dict(mariofile.parse_sections(SIMPLE_MARIOFILE.splitlines(True))) assert len(simple_mariofile_sections) == 3 complex_mariofile_sections = dict(mariofile.parse_sections(COMPLEX_MARIOFILE.splitlines(True))) assert len(complex_mariofile_sections) == 2 ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def setUp(self): super(BaseSuggestionUnitTests, self).setUp() self.base_suggestion = MockInvalidSuggestion()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_statements(): with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_1.splitlines()) with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_2.splitlines())
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_accept_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement accept.'): self.base_suggestion.accept()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_parse_statements(): parsed_statement = mariofile.parse_statements(STRING_PARSE_STATEMENTS.splitlines()) assert '\n'.join(parsed_statement) == "statement\nstatement con commento"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_get_change_list_for_accepting_suggestion_raises_error( self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement ' 'get_change_list_for_accepting_suggestion.'): self.base_suggestion.get_...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_parse_section_body(): output_section = { 'action_template': ' task', 'sources_repls': 'source', 'variable': '6', 'target_pattern': 'target', } assert mariofile.parse_section_body(SECTION.splitlines(True)) == output_section with pytest.raises(mariofile.Configur...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_pre_accept_validate_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' pre_accept_validate.'): self.base_suggestion.pre_accept_validate()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_parse_include(): filepaths, current_line = mariofile.parse_include(INCLUDE_FILE.splitlines(True)) assert filepaths == ['prova.ini', 'altrofile.ini'] assert current_line == 4 filepaths, current_line = mariofile.parse_include(INCLUDE_UNIQUE_FILE.splitlines(True)) assert filepaths == ['prova.i...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_populate_old_value_of_change_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' populate_old_value_of_change.'): self.base_suggestion.populate_old_value_of_change()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_pre_update_validate_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' pre_update_validate.'): self.base_suggestion.pre_update_validate({})
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_get_all_html_content_strings(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' get_all_html_content_strings.'): self.base_suggestion.get_all_html_content_strings()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_base_class_get_target_entity_html_strings(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' get_target_entity_html_strings.'): self.base_suggestion.get_target_entity_html_strings()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def setUp(self): super(SuggestionEditStateContentUnitTests, self).setUp() self.signup(self.AUTHOR_EMAIL, 'author') self.author_id = self.get_user_id_from_email(self.AUTHOR_EMAIL) self.signup(self.REVIEWER_EMAIL, 'reviewer') self.reviewer_id = self.get_user_id_from_email(self.REV...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_create_suggestion_edit_state_content(self): expected_suggestion_dict = self.suggestion_dict observed_suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_sugge...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_get_score_part_helper_methods(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['targ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_validate_target_version_at_submission(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dic...