rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
libs = list() tests = list() | libs = list(nlibs) tests = list(ntests) apps = list(napps) | def target_list(ctx): """returns a list of all targets""" bld = Build.BuildContext() proj = Environment.Environment(Options.lockfile) bld.load_dirs(proj['srcdir'], proj['blddir']) bld.load_envs() bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]]) names = set([]) for x in bld.all_task_gen: try: names.add(x... |
for n in names: if '.' in n: tests.append(n) else: libs.append(n) | def target_list(ctx): """returns a list of all targets""" bld = Build.BuildContext() proj = Environment.Environment(Options.lockfile) bld.load_dirs(proj['srcdir'], proj['blddir']) bld.load_envs() bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]]) names = set([]) for x in bld.all_task_gen: try: names.add(x... | |
return "vini: string -> %s" % (self.outputs[0].name()) | return "vini: string -> %s" % (self.outputs[0].name) | def __str__(self): return "vini: string -> %s" % (self.outputs[0].name()) |
vsim_before = Task.simple_task_type('vsim_before', '${VSIM} ${_VSIMFLAGS} ${_VSIMBEFORE}', color='RED', after=['vlib'], before=['vcom', 'vlog', 'sccom'], vars=['VSIM', '_VSIMFLAGS', '_VSIMBEFORE']) | vsim_before = Task.simple_task_type('vsim_before', '${VSIM} ${_VSIMFLAGS} ${_VSIMBEFORE}', color='RED', after=['vlib', 'vinit'], before=['vcom', 'vlog', 'sccom'], vars=['VSIM', '_VSIMFLAGS', '_VSIMBEFORE']) | def vlib_task_str(self): return "vlib: create %s ...\n" % self.target |
vcom_task = Task.simple_task_type('vcom', '${VCOM} ${_VCOMFLAGS} ${SRC}', color='GREEN', before='cxx', ext_in=".vhd", vars=['VCOM', '_VCOMFLAGS']) | vcom_task = Task.simple_task_type('vcom', '${VCOM} ${_VCOMFLAGS} ${SRC}', color='GREEN', before='sccom', ext_in=".vhd", vars=['VCOM', '_VCOMFLAGS']) | def vsim_task_str(self): return "vsim: do %s -> %s\n" % (self.dotask, self.target) |
vlog_task = Task.simple_task_type('vlog', '${VLOG} ${_VLOGFLAGS} ${SRC}', color='GREEN', before='cxx', ext_in=".v", vars=['VLOG', '_VLOGFLAGS']) | vlog_task = Task.simple_task_type('vlog', '${VLOG} ${_VLOGFLAGS} ${SRC}', color='GREEN', before='sccom', ext_in=".v", vars=['VLOG', '_VLOGFLAGS']) | def vcom_task_str(self): ins = [] for inf in self.inputs: ins.append(inf.name) return "vcom: %s -> %s\n" % (', '.join(ins), self.target) |
tsk.set_run_after(vlib) | def modelsim(self): """Apply Variables for the Target create vlib task and vini task as well as dobefore and doafter tasks if needed """ # cxx hack replaces the cpp routine setattr(self,modelsim_sccom.__name__,modelsim_sccom) self.mappings['.cpp']=modelsim_sccom if not Options.options.modelsim: return self.env = self.... | |
def __print_header(self, ext, pfi=None): | def __print_header(self, ext, pfi=None, sfi=None): | def __print_header(self, ext, pfi=None): """Print boiler plate.""" if pfi: __pfi = pfi else: __pfi = self._get_pfi(ext) if __pfi: self.comment_block(u""" Refer to this file by the following public identifier or an appropriate system identifier |
Delivered as file "%s.%s" """ % (__pfi, self._file_name, ext), before=0) | Delivered as file "%s.%s" """ % (__pfi, __sfi, ext), before=0) | def __print_header(self, ext, pfi=None): """Print boiler plate.""" if pfi: __pfi = pfi else: __pfi = self._get_pfi(ext) if __pfi: self.comment_block(u""" Refer to this file by the following public identifier or an appropriate system identifier |
Delivered as file "%s.%s" """ % (self._file_name, ext), before=0) | Delivered as file "%s.%s" """ % (__sfi, ext), before=0) | def __print_header(self, ext, pfi=None): """Print boiler plate.""" if pfi: __pfi = pfi else: __pfi = self._get_pfi(ext) if __pfi: self.comment_block(u""" Refer to this file by the following public identifier or an appropriate system identifier |
self._file_name = self.topic_type.id | self._file_name = self.plugin_name | def _preprocess(self): """Preprocess arguments.""" if self._initialized == False: #if self._owner is None: # self._owner = self.owner if self.topic_type: if isinstance(self.topic_type, ditagen.dita.v1_2.MapType) or isinstance(self.topic_type, ditagen.dita.v1_1.MapType): self.__pfi_prefix = u"MAP" else: self.__pfi_pr... |
self.__print_header("ent", self.generate_public_identifier("ent", d[0], self._pfi_version, d[0].capitalize() + " Attribute", self.owner, u"Domain")) | self.__print_header("ent", self.generate_public_identifier("ent", d[0], self._pfi_version, d[0].capitalize() + " Attribute", self.owner, u"Domain"), d[0] + u"AttDomain") | def generate_att_ent(self, d): """generate attribute domain entity file.""" #if self.version == "1.2": self._preprocess() self.__print_header("ent", self.generate_public_identifier("ent", d[0], self._pfi_version, d[0].capitalize() + " Attribute", self.owner, u"Domain")) self.comment_block(u"ATTRIBUTE EXTENSION ENTITY ... |
__description = self.generate_public_identifier("mod", domain.id, self._pfi_version, domain.title, None, u"Constraints") | __description = self.generate_public_identifier("mod", domain.id, self._pfi_version, domain.title, None, u"Constraint") | def __domain_mod(self, domain): """Print domain module declaration.""" if isinstance(domain, ditagen.dita.v1_2.Constraints): __description = self.generate_public_identifier("mod", domain.id, self._pfi_version, domain.title, None, u"Constraints") else: __description = self.generate_public_identifier("mod", domain.id, se... |
return "<%s: %s>" % (self.__class__.__name__, str (self.Path_.Path)) | return "<%s: %s>" % (self.__class__.__name__, self.Path_.Path.encode ("ascii", "backslashreplace")) | def __repr__ (self): """ Indicate both the fact that this is a wrapped WMI object and the WMI object's own identifying class. """ try: return "<%s: %s>" % (self.__class__.__name__, str (self.Path_.Path)) except pywintypes.com_error: handle_com_error () |
return len(self.tabs) > 2 | return len(self.tabs) > 1 | def has_modifications(self): return len(self.tabs) > 2 |
@on_trait_change('xmin.mpldt') | def xlim_callback(self, ax): self.xmin.mpldt, self.xmax.mpldt = ax.get_xlim() | |
@on_trait_change('xmax.mpldt') | def _xmin_mpldt_changed(self): if self.mainwindow.plot.master_axes and self.mainwindow.plot.master_axes.get_xlim()[0] != self.xmin.mpldt: self.mainwindow.plot.master_axes.set_xlim(xmin=self.xmin.mpldt) self.mainwindow.update_canvas() | |
self.redraw() | self.settings_changed() | def load_file(self): if self.filename: try: self.data = self.datafactory(self.filename) except: uiutil.Message.file_open_failed(self.filename) self.filename = '' return self.channels = list(self.data.iterchannelnames()) self.redraw() |
tablabel = 'Reactor Enviroment logger' | tablabel = 'Reactor Environment logger' | def traits_view(self): return View(Group( Group( Item('visible'), Item('filename', editor=FileEditor(filter=list(self.filter) + ['All files', '*'], entries=0)), Item('reload', show_label=False), Item('legend'), show_border=True, label='General', ), Group( Item('ymin'), Item('ymax'), show_border=True, label='Left y-axis... |
f.write( ' > <A HREF="../'+mainPageFile+'">Data 2010</A>'); | pageName = os.path.splitext(os.path.split(mainPageFile)[1])[0] f.write( ' > <A HREF="../'+mainPageFile+'">'+pageName+'</A>'); | def createPage(myDir, histoPrefix = "", mainPageFile = "index"): |
f.write( '<DIV class="global_nav"><A HREF="/index.html">PhysQC</A>') f.write( ' > <A HREF="/'+mainPageFile+'">Data 2010</A>'); | f.write( '<DIV class="global_nav"><A HREF="../index.html">PhysQC</A>') f.write( ' > <A HREF="../'+mainPageFile+'">Data 2010</A>'); | def createPage(myDir, histoPrefix = "", mainPageFile = "index"): |
inputDir.rstrip('/') | if inputDir.endswith('/'): inputDir = inputDir[:-1] | def copyHistos(inputDir,mainPageFile,options): |
_ct.pointer(clone)[0] = self | ctypes.pointer(clone)[0] = self | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
('options', _ct.c_int), ('min_width', _ct.c_int), ('min_height', _ct.c_int), ('max_width', _ct.c_int), ('max_height', _ct.c_int), ('recommended_width', _ct.c_int), ('recommended_height', _ct.c_int), ('physical_width', _ct.c_int), ('physical_height', _ct.c_int), ('width', _ct.c_int), ('height', _ct.c_int), ('dim_value',... | ('options', ctypes.c_int), ('min_width', ctypes.c_int), ('min_height', ctypes.c_int), ('max_width', ctypes.c_int), ('max_height', ctypes.c_int), ('recommended_width', ctypes.c_int), ('recommended_height', ctypes.c_int), ('physical_width', ctypes.c_int), ('physical_height', ctypes.c_int), ('width', ctypes.c_int), ('heig... | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
HardwareSettingsPtr = _ct.POINTER(HardwareSettings) | HardwareSettingsPtr = ctypes.POINTER(HardwareSettings) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
('brightness', _ct.c_int), ('contrast', _ct.c_int), ('gamma', _ct.c_float), ('dithering_mode', _ct.c_int), ('inversion', _ct.c_int), ('random', _ct.c_int), | ('brightness', ctypes.c_int), ('contrast', ctypes.c_int), ('gamma', ctypes.c_float), ('dithering_mode', ctypes.c_int), ('inversion', ctypes.c_int), ('random', ctypes.c_int), | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
RenderSettingsPtr = _ct.POINTER(RenderSettings) | RenderSettingsPtr = ctypes.POINTER(RenderSettings) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
DriverPtr = _ct.POINTER(Driver) | DriverPtr = ctypes.POINTER(Driver) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
ContextPtr = _ct.POINTER(Context) | ContextPtr = ctypes.POINTER(Context) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_init.argtypes = [DriverPtr, HardwareSettingsPtr, _ct.c_void_p] | aa_init.argtypes = [DriverPtr, HardwareSettingsPtr, ctypes.c_void_p] | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_image.restype = _ct.POINTER(_ct.c_ubyte) | aa_image.restype = ctypes.POINTER(ctypes.c_ubyte) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_text.restype = _ct.POINTER(_ct.c_ubyte) | aa_text.restype = ctypes.POINTER(ctypes.c_ubyte) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_attrs.restype = _ct.POINTER(_ct.c_ubyte) | aa_attrs.restype = ctypes.POINTER(ctypes.c_ubyte) | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_imgwidth.restype = _ct.c_int | aa_imgwidth.restype = ctypes.c_int | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_imgheight.restype = _ct.c_int | aa_imgheight.restype = ctypes.c_int | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_scrwidth.restype = _ct.c_int | aa_scrwidth.restype = ctypes.c_int | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_scrheight.restype = _ct.c_int | aa_scrheight.restype = ctypes.c_int | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
aa_render.argtypes = [ContextPtr, RenderSettingsPtr] + 4 * [_ct.c_int] | aa_render.argtypes = [ContextPtr, RenderSettingsPtr] + 4 * [ctypes.c_int] | def clone(self): clone = type(self)() _ct.pointer(clone)[0] = self return clone |
context = self._context = aa_init(_ct.pointer(aa_mem_d), _ct.pointer(settings), None) | context = self._context = aa_init(ctypes.pointer(aa_mem_d), ctypes.pointer(settings), None) | def __init__(self, **kwargs): '''Initialize the virtual screen. |
_ret_lc_concord(), | c_int, | def real_ctypes_type(type): if not isinstance(type, _param): return type return type.real_ctypes_type() |
_ret_lc_concord() | c_int | def real_ctypes_type(type): if not isinstance(type, _param): return type return type.real_ctypes_type() |
if 0 and ctx is ctx._mp and abs(mag) < 900 and abs(k) < 10000: | if ctx is ctx._mp and abs(mag) < 900 and abs(k) < 10000 and \ abs(z+0.36787944117144) > 0.01: | def lambertw(ctx, z, k=0): k = int(k) if ctx.isnan(z): return z ctx.prec += 20 mag = ctx.mag(z) # Start from fp approximation if 0 and ctx is ctx._mp and abs(mag) < 900 and abs(k) < 10000: w = ctx._fp.lambertw(z, k) else: absz = abs(z) # We must be extremely careful near the singularities at -1/e and 0 u = ctx.exp(-1) ... |
F_4(a,b,c1,c2,x,y) = \sum_{m=0}^{\infty} \sum_{n=0}^{\infty} | F_4(a,b,c_1,c_2,x,y) = \sum_{m=0}^{\infty} \sum_{n=0}^{\infty} | >>> def E(z, m): |
s_{\mu,\nu} = \frac{z^{\mu+1}}{(\mu-\nu+1)(\mu+\nu+1)} | s_{\mu,\nu}(z) = \frac{z^{\mu+1}}{(\mu-\nu+1)(\mu+\nu+1)} | >>> def E(z, m): |
S_{\mu,\nu} = s_{\mu,\nu} + 2^{\mu-1} \Gamma(\frac{1}{2}(\mu-\nu+1)) \Gamma(\frac{1}{2}(\mu+\nu+1)) \left[\sin(\frac{1}{2}(\mu-\nu)\pi) J_{\nu}(z) - \cos(\frac{1}{2}(\mu-\nu)\pi) Y_{\nu}(z) - | S_{\mu,\nu}(z) = s_{\mu,\nu}(z) + 2^{\mu-1} \Gamma\left(\tfrac{1}{2}(\mu-\nu+1)\right) \Gamma\left(\tfrac{1}{2}(\mu+\nu+1)\right) \times \left[\sin(\tfrac{1}{2}(\mu-\nu)\pi) J_{\nu}(z) - \cos(\tfrac{1}{2}(\mu-\nu)\pi) Y_{\nu}(z) | >>> def E(z, m): |
which solves the same as differential equation as | which solves the same differential equation as | >>> def E(z, m): |
n, r = divmod(z, 0.5) | n, r = divmod(z.real, 0.5) | def _cospi_complex(z): n, r = divmod(z, 0.5) z = pi*complex(r, z.imag) n %= 4 if n == 0: return cmath.cos(r) if n == 1: return -cmath.sin(r) if n == 2: return -cmath.cos(r) if n == 3: return cmath.sin(r) |
if n == 0: return cmath.cos(r) if n == 1: return -cmath.sin(r) if n == 2: return -cmath.cos(r) if n == 3: return cmath.sin(r) | if n == 0: return cmath.cos(z) if n == 1: return -cmath.sin(z) if n == 2: return -cmath.cos(z) if n == 3: return cmath.sin(z) | def _cospi_complex(z): n, r = divmod(z, 0.5) z = pi*complex(r, z.imag) n %= 4 if n == 0: return cmath.cos(r) if n == 1: return -cmath.sin(r) if n == 2: return -cmath.cos(r) if n == 3: return cmath.sin(r) |
axes.set_xlim(xlim) | axes.set_xlim(map(float, xlim)) | def plot(ctx, f, xlim=[-5,5], ylim=None, points=200, file=None, dpi=None, singularities=[], axes=None): r""" Shows a simple 2D plot of a function `f(x)` or list of functions `[f_0(x), f_1(x), \ldots, f_n(x)]` over a given interval specified by *xlim*. Some examples:: plot(lambda x: exp(x)*li(x), [1, 4]) plot([cos, sin... |
axes.set_ylim(ylim) | axes.set_ylim(map(float, ylim)) | def plot(ctx, f, xlim=[-5,5], ylim=None, points=200, file=None, dpi=None, singularities=[], axes=None): r""" Shows a simple 2D plot of a function `f(x)` or list of functions `[f_0(x), f_1(x), \ldots, f_n(x)]` over a given interval specified by *xlim*. Some examples:: plot(lambda x: exp(x)*li(x), [1, 4]) plot([cos, sin... |
ok = zetazero(8637740722917, verbose=True).ae(complex(0.5,2124447368584.39296466152)) | ok = zetazero(8637740722917).ae(complex(0.5,2124447368584.39296466152)) | def test_zetazero(): cases = [\ (399999999, 156762524.6750591511), (241389216, 97490234.2276711795), (526196239, 202950727.691229534), (542964976, 209039046.578535272), (1048449112, 388858885.231056486), (1048449113, 388858885.384337406), (1048449114, 388858886.002285122), (1048449115, 388858886.00239369), (1048449116,... |
ok = zetazero(8637740722918, verbose=True).ae(complex(0.5,2124447368584.39298170604)) | ok = zetazero(8637740722918).ae(complex(0.5,2124447368584.39298170604)) | def test_zetazero(): cases = [\ (399999999, 156762524.6750591511), (241389216, 97490234.2276711795), (526196239, 202950727.691229534), (542964976, 209039046.578535272), (1048449112, 388858885.231056486), (1048449113, 388858885.384337406), (1048449114, 388858886.002285122), (1048449115, 388858886.00239369), (1048449116,... |
>>> extraprec(15)(nsum)(lambda k: cos(k*z)/k**s, [1,inf]) | >>> extraprec(20)(nsum)(lambda k: cos(k*z)/k**s, [1,inf]) | >>> def tower(z, n): |
return (not sign, man, exp, bc) | return (0, man, exp, bc) | def mpf_abs(s, prec=None, rnd=round_fast): """Return abs(s) of the raw mpf s, rounded to the specified precision. The prec argument can be omitted to generate an exact result.""" sign, man, exp, bc = s if (not man) and exp: if s == fninf: return finf return s if not prec: if sign: return (not sign, man, exp, bc) return... |
not any(type(i) is ctx.mpc for i in A)): | not sum(type(i) is ctx.mpc for i in A)): | def lu_solve(ctx, A, b, **kwargs): """ Ax = b => x |
ctx.prec = wptheta | ctx.prec = wptheta * LOGGAMMA_BROKENNESS_FACTOR | def z_half(ctx,t,der=0): r""" z_half(t,der=0) Computes Z^(der)(t) """ s=ctx.mpf('0.5')+ctx.j*t wpinitial = ctx.prec ctx.prec = 15 tt = t/(2*ctx.pi) wptheta = wpinitial +1 + ctx.mag(3*(tt**1.5)*ctx.ln(tt)) wpz = wpinitial + 1 + ctx.mag(12*tt*ctx.ln(tt)) ctx.prec = wptheta theta = ctx.siegeltheta(t) ctx.prec = wpz rz = R... |
ctx.prec = wptheta+wptheta/2 | ctx.prec = wptheta * LOGGAMMA_BROKENNESS_FACTOR | def zeta_half(ctx, s, k=0): """ zeta_half(s,k=0) Computes zeta^(k)(s) when Re s = 0.5 """ wpinitial = ctx.prec sigma = s.real t = s.imag #--- compute wptheta, wpR, wpbasic --- ctx.prec = 53 # X see II Section 3.21 (109) and (110) if sigma > 0: X = ctx.sqrt(abs(s)) else: X = (2*ctx.pi)**(sigma-1) * abs(1-s)**(0.5-sigma... |
ctx.prec = wptheta+wptheta/2 | ctx.prec = wptheta * LOGGAMMA_BROKENNESS_FACTOR | def zeta_offline(ctx, s, k=0): """ Computes zeta^(k)(s) off the line """ wpinitial = ctx.prec sigma = s.real t = s.imag #--- compute wptheta, wpR, wpbasic --- ctx.prec = 53 # X see II Section 3.21 (109) and (110) if sigma > 0: X = ctx.power(abs(s), 0.5) else: X = ctx.power(2*ctx.pi, sigma-1)*ctx.power(abs(1-s),0.5-sig... |
ctx.prec = wptheta+wptheta/2 | ctx.prec = wptheta * LOGGAMMA_BROKENNESS_FACTOR | def z_offline(ctx, w, k=0): r""" Computes Z(w) and its derivatives off the line """ s = ctx.mpf('0.5')+ctx.j*w s1 = s s2 = ctx.conj(1-s1) wpinitial = ctx.prec ctx.prec = 35 # X see II Section 3.21 (109) and (110) # M1 see II Section 3.21 (111) and (112) if (s1.real >= 0): M1 = 2*ctx.sqrt(s1.imag/(2 * ctx.pi)) X = ctx... |
if rnd is round_nearest: | if rnd == round_nearest: | def round_int(x, n, rnd): if rnd is round_nearest: if x >= 0: t = x >> (n-1) if t & 1 and ((t & 2) or (x & h_mask[n<300][n])): return (t>>1)+1 else: return t>>1 else: return -round_int(-x, n, rnd) if rnd is round_floor: return x >> n if rnd is round_ceiling: return -((-x) >> n) if rnd is round_down: if x >= 0: return x... |
if rnd is round_floor: | if rnd == round_floor: | def round_int(x, n, rnd): if rnd is round_nearest: if x >= 0: t = x >> (n-1) if t & 1 and ((t & 2) or (x & h_mask[n<300][n])): return (t>>1)+1 else: return t>>1 else: return -round_int(-x, n, rnd) if rnd is round_floor: return x >> n if rnd is round_ceiling: return -((-x) >> n) if rnd is round_down: if x >= 0: return x... |
if rnd is round_ceiling: | if rnd == round_ceiling: | def round_int(x, n, rnd): if rnd is round_nearest: if x >= 0: t = x >> (n-1) if t & 1 and ((t & 2) or (x & h_mask[n<300][n])): return (t>>1)+1 else: return t>>1 else: return -round_int(-x, n, rnd) if rnd is round_floor: return x >> n if rnd is round_ceiling: return -((-x) >> n) if rnd is round_down: if x >= 0: return x... |
if rnd is round_down: | if rnd == round_down: | def round_int(x, n, rnd): if rnd is round_nearest: if x >= 0: t = x >> (n-1) if t & 1 and ((t & 2) or (x & h_mask[n<300][n])): return (t>>1)+1 else: return t>>1 else: return -round_int(-x, n, rnd) if rnd is round_floor: return x >> n if rnd is round_ceiling: return -((-x) >> n) if rnd is round_down: if x >= 0: return x... |
if rnd is round_up: | if rnd == round_up: | def round_int(x, n, rnd): if rnd is round_nearest: if x >= 0: t = x >> (n-1) if t & 1 and ((t & 2) or (x & h_mask[n<300][n])): return (t>>1)+1 else: return t>>1 else: return -round_int(-x, n, rnd) if rnd is round_floor: return x >> n if rnd is round_ceiling: return -((-x) >> n) if rnd is round_down: if x >= 0: return x... |
if rnd is round_nearest: | if rnd == round_nearest: | def _normalize(sign, man, exp, bc, prec, rnd): """ Create a raw mpf tuple with value (-1)**sign * man * 2**exp and normalized mantissa. The mantissa is rounded in the specified direction if its size exceeds the precision. Trailing zero bits are also stripped from the mantissa to ensure that the representation is canoni... |
if rnd is round_nearest: | if rnd == round_nearest: | def _normalize1(sign, man, exp, bc, prec, rnd): """same as normalize, but with the added condition that man is odd or zero """ if not man: return fzero if bc <= prec: return sign, man, exp, bc n = bc - prec if rnd is round_nearest: t = man >> (n-1) if t & 1 and ((t & 2) or (man & h_mask[n<300][n])): man = (t>>1)+1 else... |
rounds_down = (rnd is round_nearest) or \ | rounds_down = (rnd == round_nearest) or \ | def mpf_pow_int(s, n, prec, rnd=round_fast): """Compute s**n, where s is a raw mpf and n is a Python integer.""" sign, man, exp, bc = s if (not man) and exp: if s == finf: if n > 0: return s if n == 0: return fnan return fzero if s == fninf: if n > 0: return [finf, fninf][n & 1] if n == 0: return fnan return fzero ret... |
if rnd is round_nearest: | if rnd == round_nearest: | def mpf_perturb(x, eps_sign, prec, rnd): """ For nonzero x, calculate x + eps with directed rounding, where eps < prec relatively and eps has the given sign (0 for positive, 1 for negative). With rounding to nearest, this is taken to simply normalize x to the given precision. """ if rnd is round_nearest: return mpf_po... |
x = float(x) | x = float(z) | def _lambertw_approx_hybrid(z, k): imag_sign = 0 if hasattr(z, "imag"): x = float(z.real) y = z.imag if y: imag_sign = (-1) ** (y < 0) y = float(y) else: x = float(x) y = 0.0 imag_sign = 0 z = complex(x,y) if k == 0: if -4.0 < y < 4.0 and -1.0 < x < 2.5: if imag_sign: # Taylor series in upper/lower half-plane if y > 1.... |
L1 = cmath.log(z) - 6.2831853071795865j | if imag_sign == -1 and (not y) and x < 0.0: L1 = cmath.log(z) - 3.1415926535897932j else: L1 = cmath.log(z) - 6.2831853071795865j | def _lambertw_approx_hybrid(z, k): imag_sign = 0 if hasattr(z, "imag"): x = float(z.real) y = z.imag if y: imag_sign = (-1) ** (y < 0) y = float(y) else: x = float(x) y = 0.0 imag_sign = 0 z = complex(x,y) if k == 0: if -4.0 < y < 4.0 and -1.0 < x < 2.5: if imag_sign: # Taylor series in upper/lower half-plane if y > 1.... |
prec += 10 | ctx.prec += 10 | def qr_solve(ctx, A, b, norm=None, **kwargs): """ Ax = b => x, ||Ax - b|| |
prec += 10 | ctx.prec += 10 | def cholesky_solve(ctx, A, b, **kwargs): """ Ax = b => x |
An integral involving both :func:`~mpmath.whitm` and :func:`~mpmath.whitmw`, | An integral involving both :func:`~mpmath.whitm` and :func:`~mpmath.whitw`, | >>> def tower(z, n): |
print system("svn up") | print system("svn up --non-interactive") | def cmd_up(self): print self.directory os.chdir(self.directory) print system("svn up") |
def __init__(self, flags=0, bufsize=65536): | def __init__(self, flags=0, bufsize=65536, map=None): | def __init__(self, flags=0, bufsize=65536): """ Initialize an inotify event queue and register it with asyncore. flags is passed to inotify.init(). bufsize is used when receiving events.""" |
asyncore.file_dispatcher.__init__(self, fd) | asyncore.file_dispatcher.__init__(self, fd, map) | def __init__(self, flags=0, bufsize=65536): """ Initialize an inotify event queue and register it with asyncore. flags is passed to inotify.init(). bufsize is used when receiving events.""" |
def errcheck(result, func, arguments): if result < 0: errno = ctypes.get_errno() raise OSError(errno, os.strerror(errno)) return result libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) libc.inotify_init.argtypes = [] libc.inotify_init.errcheck = errcheck libc.inotify_init1.argtypes = [ctypes.c_int]... | def errcheck(result, func, arguments): if result < 0: errno = ctypes.get_errno() raise OSError(errno, os.strerror(errno)) return result | |
def init(flags=0): """ See inotify_init(2) man page. """ | def errcheck(result, func, arguments): if result < 0: errno = ctypes.get_errno() raise OSError(errno, os.strerror(errno)) | def init(flags=0): """ See inotify_init(2) man page. """ if flags: return libc.inotify_init1(flags) else: return libc.inotify_init() |
if flags: | return result libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) try: libc.inotify_init1 except AttributeError: libc.inotify_init.argtypes = [] libc.inotify_init.errcheck = errcheck def init(): """ See inotify_init(2) man page. """ return libc.inotify_init() else: libc.inotify_init1.argtypes = [ctype... | def init(flags=0): """ See inotify_init(2) man page. """ if flags: return libc.inotify_init1(flags) else: return libc.inotify_init() |
else: return libc.inotify_init() | libc.inotify_add_watch.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32] libc.inotify_add_watch.errcheck = errcheck | def init(flags=0): """ See inotify_init(2) man page. """ if flags: return libc.inotify_init1(flags) else: return libc.inotify_init() |
spec_names = self._parse_names('spec_names') strip_spec_names = self._parse_names('strip_spec_names') | self._parse_names('spec_names') self._parse_names('strip_spec_names') | def apply(self): settings = self.document.settings if not getattr(settings, 'spec_names'): return |
list[:] = nodelist | if not nodelist: list.parent.remove(list) else: list[:] = nodelist | def apply(self): settings = self.document.settings if not getattr(settings, 'spec_names'): return |
if not getattr(settings, normedid, ''): yield field continue | def extract_spec(self, field_list): "Extract and strip settings from field_list according to settings. " "Return a stripped field_list and a dictionary with settings overrides. " settings = self.document.settings | |
self.msg('NickServ', 'identify %s' % nickserv_pw) | self.msg('NickServ', 'identify %s' % nickserv_pw.encode()) | def signedOn(self): nickserv_pw = conf['irc.nickserv_pw'] if nickserv_pw: self.msg('NickServ', 'identify %s' % nickserv_pw) else: self.autojoinChannels() self.startTimer('serverPing', 60) |
def sanitize_learn_input(self, string, channel): | def sanitize_learn_input(self, string): | def sanitize_learn_input(self, string, channel): """Remove extraneous/irrelevant data from input to markov chain - remove nickname prefixes: "nick: foo bar" -> "foo bar" """ # channel is included for future use, e.g. in checking the channel # username list # doing more is a good idea? # TODO: use real usernames fro... |
st = open('magic8.txt') | st = open(fortunes.encode()) | def infobat_divine(self, target, *seed): self.me(target, 'shakes the psychic black sphere.') r = random.Random(''.join(seed) + datetime.now().isoformat()) st = open('magic8.txt') l = st.readlines() st.close() l = r.choice(l).strip() self.msg(target, 'It says: "%s"' % l) |
amp.InfobatChildBase.connectionLost(self, reason) | ampirc.IrcChildBase.connectionLost(self, reason) | def connectionLost(self, reason): if self.db: self.db.sync() if self.dbpool: self.dbpool.close() amp.InfobatChildBase.connectionLost(self, reason) |
if channel != self.nickname and channel_obj.is_usable('chain_learn'): self.learn(message) | def privmsg(self, user, channel, message): if (not self.identified and user.lower().startswith('nickserv!') and 'identified' in message): self.identified = True self.autojoinChannels() if not user: return user = user.split('!', 1)[0] if user.lower() in ('nickserv', 'chanserv', 'memoserv'): return if channel == self.nic... | |
return s_command = command.split(' ') command_func = getattr(self, 'infobat_' + s_command[0], None) if command_func is not None and channel_obj.is_usable(s_command[0]): command_func(target, *s_command[1:]) elif self.db and channel_obj.is_usable('chain_splice'): action, result = self.db.splice() if action: self.me(targe... | command = None if command: s_command = command.split(' ') command_func = getattr(self, 'infobat_' + s_command[0], None) if command_func is not None and channel_obj.is_usable(s_command[0]): command_func(target, *s_command[1:]) learn_this = False elif self.db and channel_obj.is_usable('chain_splice'): action, result = s... | def privmsg(self, user, channel, message): if (not self.identified and user.lower().startswith('nickserv!') and 'identified' in message): self.identified = True self.autojoinChannels() if not user: return user = user.split('!', 1)[0] if user.lower() in ('nickserv', 'chanserv', 'memoserv'): return if channel == self.nic... |
starting = _MAX_LINES - 4 response[starting:-3] = ['(...%d lines, entire response in ' '%s ...)' % (nlines - (_MAX_LINES - 1), paste_url)] | response[_MAX_LINES:] = ['(...%d lines, entire response in ' '%s ...)' % (nlines, paste_url)] | def infobat_exec(self, target, *text): try: paste_url = yield self._codepad(_EXEC_PRELUDE + ' '.join(text)) page, ign = yield http.get_page(paste_url) except: self.msg(target, 'Error: %r' % sys.exc_info()[1]) raise else: doc = lxml.html.fromstring(page.decode('utf8', 'replace')) response = u''.join(doc.xpath("//a[@name... |
strerr = 0 | stderr = 0 | def run(): # test all OK files found for outfile in glob.glob("ok/*"): strerr = 0 basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) if target == 'out': target = 'txt' stderr = 1 infile = basename + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infil... |
errors = ['includeconf-itself', 'includeconf-not-found', 'includeconf-target', 'includeconf-text'] | errors = ['includeconf-itself', 'includeconf-not-found', 'includeconf-targeted', 'includeconf-text'] | def run(): ### First test the %!includeconf command errors = ['includeconf-itself', 'includeconf-not-found', 'includeconf-target', 'includeconf-text'] unnumbered = ['includeconf-empty'] # test all t2t files found for infile in glob.glob("includeconf-*.t2t"): basename = infile.replace('.t2t', '') outfile = basename +... |
self.assertEqual(self.desc.systemrequirements, [ | requirements = [ | def test_attributes(self): # TODO: split this method to improve the error reporting # TODO: figure out how to test the comments self.assertEqual(self.desc.name, 'package name') self.assertEqual(self.desc.version, '0.0.1') self.assertEqual(self.desc.date, '2009-01-01') self.assertEqual(self.desc.author, 'Author Name: te... |
]) | ] requirements.sort() self.assertEqual(self.desc.systemrequirements, requirements) | def test_attributes(self): # TODO: split this method to improve the error reporting # TODO: figure out how to test the comments self.assertEqual(self.desc.name, 'package name') self.assertEqual(self.desc.version, '0.0.1') self.assertEqual(self.desc.date, '2009-01-01') self.assertEqual(self.desc.author, 'Author Name: te... |
if package_c.startswith(package): | if re.match(r'%s\-[0-9\.]+' % package, package_c) is not None: | def update_revisions(self): updated = [] pkg_cache_dir = self.conf.pkg_cache try: pkg_cache = os.listdir(pkg_cache_dir) except: raise RuntimeError('Failed to list packages from the pkg_cache') for category in self.categories: self.packages[category] = self._list_packages(category) for category in self.packages: for pac... |
os.path.join(self._config.overlay, 'eclass', 'octave-forge.eclass'): '', | def test_overlay(self): overlay.create_overlay(conf = self._config, quiet = True) files = { os.path.join(self._config.overlay, 'eclass', 'octave-forge.eclass'): '', os.path.join(self._config.overlay, 'profiles', 'repo_name'): 'g-octave', os.path.join(self._config.overlay, 'profiles', 'categories'): 'g-octave', } for _f... | |
return tmp[-1] | return (len(tmp) > 0) and tmp[-1] or None | def latest_version(self, pkgname): tmp = self.package_versions(pkgname) return tmp[-1] |
return tmp[-1] | return (len(tmp) > 0) and tmp[-1] or None | def version_compare(self, versions): tmp = list(versions[:]) tmp.sort(key=cmp_to_key(vercmp)) return tmp[-1] |
ebuild += "\nsrc_prepare() {%s\n}\n" % patch_string | ebuild += "\nsrc_prepare() {%s\n\tg-octave_src_prepare\n}\n" % patch_string | def __create(self, accept_keywords=None, manifest=True): ebuild_path = os.path.join(self._config.overlay, 'g-octave', self.pkgname) ebuild_file = os.path.join(ebuild_path, '%s-%s.ebuild' % (self.pkgname, self.version)) if not os.path.exists(ebuild_path): os.makedirs(ebuild_path, 0o755) ebuild = """\ |
'--nodeps', | def build_package(pkgatom): proc = subprocess.call([ 'emerge', '--nodeps', '--nospinner', '--verbose', '--oneshot', pkgatom ]) if proc != os.EX_OK: bug_report(pkgatom) return False return True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.