rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
dest='find_mode', action='store_Const', const='small') | dest='find_mode', action='store_Const', const='small'), | def redirecting_stdout(self, action, filter_name, filter_args): '''Calls the given _action_ with stdout temporarily redirected to _self.output_file_ or |
print node.kids print node[0].kids | def preprocess(root): # IP < PP PU -> PP < PP PU (20:58(1)) if root.count() == 2 and root[1].tag == 'PU' and root[0].tag.startswith('PP'): root.tag = root[0].tag for node in nodes(root): if node.is_leaf(): continue first_kid, first_kid_index = get_nonpunct_kid(node, get_last=False) last_kid, last_kid_index = get_no... | |
debug('originally: %s', pprint(node)) | def label_root(node): debug('originally: %s', pprint(node)) final_punctuation_stk = [] # These derivations consist of a leaf PU root: 24:73(4), 25:81(4), 28:52(21) if node.is_leaf(): return node # inconsistent top-level taggings (0:21(4)) lead to a CCG-like absorption analysis elif is_right_punct_absorption(node): ret... | |
@echo | def is_topicalisation(cat): # T/(T/X) return (cat.is_complex() and cat.right.is_complex() and cat.left == cat.right.left and cat.direction == FORWARD and cat.right.direction == FORWARD) | |
elif(os.path.isfile(src_file) and syntax(src_file) and needs_update(src_file)): | elif(os.path.isfile(src_file) and syntax(src_file) and needs_update(dir)): | def process(dir, margin = ''): """Recursively calls page() on every file/dir in the given directory""" for file in os.listdir(dir): src_file = os.path.join(dir, file) if(os.path.islink(src_file)): continue elif(os.path.isfile(src_file) and syntax(src_file) and needs_update(src_file)): out_file = src_file.split('.') ou... |
def needs_update(file): | def needs_update(dir): | def needs_update(file): if(template_last_change > minimalsite_last_run or os.path.getmtime(file) > minimalsite_last_run): return True return False |
or os.path.getmtime(file) > minimalsite_last_run): | or os.path.getmtime(dir) > minimalsite_last_run): | def needs_update(file): if(template_last_change > minimalsite_last_run or os.path.getmtime(file) > minimalsite_last_run): return True return False |
return [l+"\n" for l in code.split("\n")] | def fixupcode(code): if sys.version_info<(2,5): if type(code)!=str: code=code.read() return [l+"\n" for l in code.split("\n")] if sys.version_info>=(3,0): if type(code)!=bytes: code=code.read() if type(code)==bytes: code=code.decode("iso8859-1") return [l+"\n" for l in code.split("\n")] return code | |
for line in fixupcode(code).split("\n"): | for line in fixupcode(code): | def fixupasyncvfs(self, fname, code): n=os.path.join(os.path.dirname(__file__), fname) # see http://www.sqlite.org/src/info/084941461f afs=re.compile(r"^(int asyncFileSize\()") proto=re.compile(r"^(\w+\s+sqlite3async_(initialize|shutdown|control|run)\()") o=open(n, "wt") try: for line in fixupcode(code).split("\n"): li... |
o.write(line+"\n") | o.write(line) | def fixupasyncvfs(self, fname, code): n=os.path.join(os.path.dirname(__file__), fname) # see http://www.sqlite.org/src/info/084941461f afs=re.compile(r"^(int asyncFileSize\()") proto=re.compile(r"^(\w+\s+sqlite3async_(initialize|shutdown|control|run)\()") o=open(n, "wt") try: for line in fixupcode(code).split("\n"): li... |
self.assertRaises(apsw.AbortError, blobro.read, 2) | def check_unchanged(): self.assertEqual(_fixup(buf[0]), BYTES(r"\x44")) self.assertEqual(_fixup(buf[1]), BYTES(r"\x55")) self.assertEqual(_fixup(buf[2]), BYTES(r"\x66")) self.assertEqual(_fixup(buf[3]), BYTES(r"\x77")) self.assertEqual(len(buf), 4) | |
for line in fixupcode(code): | for line in fixupcode(code).split("\n"): | def fixupasyncvfs(self, fname, code): n=os.path.join(os.path.dirname(__file__), fname) # see http://www.sqlite.org/src/info/084941461f afs=re.compile(r"^(int asyncFileSize\()") proto=re.compile(r"^(\w+\s+sqlite3async_(initialize|shutdown|control|run)\()") o=open(n, "wt") try: for line in fixupcode(code): line=afs.sub(r... |
o.write(line) | o.write(line+"\n") | def fixupasyncvfs(self, fname, code): n=os.path.join(os.path.dirname(__file__), fname) # see http://www.sqlite.org/src/info/084941461f afs=re.compile(r"^(int asyncFileSize\()") proto=re.compile(r"^(\w+\s+sqlite3async_(initialize|shutdown|control|run)\()") o=open(n, "wt") try: for line in fixupcode(code): line=afs.sub(r... |
header=sys.platform=="win32" and d.underline or d.inverse, header_=sys.platform=="win32" and d.underline_ or d.inverse_, | header=sys.platform=="win32" and d.inverse or d.underline, header_=sys.platform=="win32" and d.inverse_ or d.underline_, | def colour_value(self, val, formatted): c=self.colour if val is None: return self.vnull+formatted+self.vnull_ if isinstance(val, Shell._basestring): return self.vstring+formatted+self.vstring_ if isinstance(val, Shell._binary_type): return self.vblob+formatted+self.vblob_ # must be a number - we don't distinguish betwe... |
fmt=lambda x: self.colour.header+x+self.colour.header_ | fmt=lambda x: self.colour.header+self._fmt_html_col(x)+self.colour.header_ | def output_html(self, header, line): "HTML table style" if header: if not self.header: return fmt=lambda x: self.colour.header+x+self.colour.header_ else: fmt=lambda x: self.colour.colour_value(x, self._fmt_html_col(x)) line=[fmt(l) for l in line] out=["<TR>"] for l in line: out.append(("<TD>","<TH>")[header]) out.appe... |
fmt=lambda x: c.header+x+c.header_ | fmt=lambda x: c.header+self._fmt_python(x)+c.header_ | def output_python(self, header, line): "Tuples in Python source form for each row" if header: if not self.header: return c=self.colour fmt=lambda x: c.header+x+c.header_ else: fmt=lambda x: self.colour.colour_value(x, self._fmt_python(x)) self.write(self.stdout, '('+", ".join([fmt(l) for l in line])+"),\n") |
fmt=lambda x: c.header+x+c.header_ | fmt=lambda x: c.header+self._fmt_c_string(x)+c.header_ | def output_tcl(self, header, line): "Outputs TCL/C style strings using current separator" # In theory you could paste the output into your source ... if header: if not self.header: return c=self.colour fmt=lambda x: c.header+x+c.header_ else: fmt=lambda x: self.colour.colour_value(x, self._fmt_c_string(x)) self.write(s... |
ext.define_macros.append( ('APSW_NO_NDEBUG', '1') ) ext.define_macros.append( ('SQLITE_DEBUG', '1') ) | ext.define_macros.append( ('APSW_NO_NDEBUG', '1') ) ext.define_macros.append( ('APSW_TESTFIXTURES', '1') ) ext.define_macros.append( ('SQLITE_DEBUG', '1') ) | def finalize_options(self): v=beparent.finalize_options(self) |
except IOError: | except: | def cmdloop(self, intro=None): """Runs the main interactive command loop. |
self.value = default | if item is None: self.value = default else: self.value = item.title.lower() | def __init__(self, content, default=None): props = IDCDescriptiveProperties(content, None) if props is None: self.value = default else: self.value = props.title.lower() |
docs.remove(doc_id) | try: docs.remove(doc_id) except AttributeError: docs = True | def value_unindex_doc(self, doc_id): documents_to_values = self.documents_to_values value = documents_to_values.get(doc_id) if value is not None: values_to_documents = self.values_to_documents self.documentCount.change(-1) del documents_to_values[doc_id] docs = values_to_documents.get(value) # Patch begins here try: d... |
ValueIndex.index_doc = value_index_doc | def value_index_doc(self, doc_id, value): if value is None: self.unindex_doc(doc_id) else: values_to_documents = self.values_to_documents documents_to_values = self.documents_to_values old = documents_to_values.get(doc_id) documents_to_values[doc_id] = value if old is None: self.documentCount.change(1) elif old != valu... | |
ValueIndex.unindex_doc = value_unindex_doc | def value_unindex_doc(self, doc_id): documents_to_values = self.documents_to_values value = documents_to_values.get(doc_id) if value is not None: values_to_documents = self.values_to_documents self.documentCount.change(-1) del documents_to_values[doc_id] docs = values_to_documents.get(value) # Patch begins here try: d... | |
del values_to_documents[old] self.wordCount.change(-1) | try: del values_to_documents[old] self.wordCount.change(-1) except KeyError: pass | def value_index_doc(self, doc_id, value): if value is None: self.unindex_doc(doc_id) else: values_to_documents = self.values_to_documents documents_to_values = self.documents_to_values old = documents_to_values.get(doc_id) documents_to_values[doc_id] = value if old is None: self.documentCount.change(1) elif old != valu... |
del values_to_documents[value] self.wordCount.change(-1) | try: del values_to_documents[value] self.wordCount.change(-1) except KeyError: pass | def value_unindex_doc(self, doc_id): documents_to_values = self.documents_to_values value = documents_to_values.get(doc_id) if value is not None: values_to_documents = self.values_to_documents self.documentCount.change(-1) del documents_to_values[doc_id] docs = values_to_documents.get(value) # Patch begins here try: d... |
ValueIndex.index_doc = value_index_doc | def value_index_doc(self, doc_id, value): if value is None: self.unindex_doc(doc_id) else: values_to_documents = self.values_to_documents documents_to_values = self.documents_to_values old = documents_to_values.get(doc_id) documents_to_values[doc_id] = value if old is None: self.documentCount.change(1) elif old != valu... | |
ValueIndex.unindex_doc = value_unindex_doc | def value_unindex_doc(self, doc_id): documents_to_values = self.documents_to_values value = documents_to_values.get(doc_id) if value is not None: values_to_documents = self.values_to_documents self.documentCount.change(-1) del documents_to_values[doc_id] docs = values_to_documents.get(value) # Patch begins here try: d... | |
should be a single type object | should be a single string describing thd desired type | def __instantiator(self, type_blob, relative_to, **kwargs): """ Instantiate a type, which is defined by a type blob in the following format: |
dictionary with only one key that is the desired type object. The value associated with this key should be another dictionary which maps the parameter:value pairs | dictionary with only one key that is a string describing the desired type. The value associated with this key should be dictionary which maps the parameter:value pairs | def __instantiator(self, type_blob, relative_to, **kwargs): """ Instantiate a type, which is defined by a type blob in the following format: |
return render_to_response('vortaro/about.html', {}) | return render_to_response('about.html', {}) | def about(request): return render_to_response('vortaro/about.html', {}) |
return view_word(request.GET[u'vorto']) | return render_word_view(request.GET[u'vorto']) | def index(request): # all requests are dispatched from here, to keep URLs simple if u'vorto' in request.GET: return view_word(request.GET[u'vorto']) elif u'serĉo' in request.GET: return search_word(request.GET[u'serĉo']) else: return render_to_response('index.html', {}) |
return search_word(request.GET[u'serĉo']) | return render_word_search(request.GET[u'serĉo']) | def index(request): # all requests are dispatched from here, to keep URLs simple if u'vorto' in request.GET: return view_word(request.GET[u'vorto']) elif u'serĉo' in request.GET: return search_word(request.GET[u'serĉo']) else: return render_to_response('index.html', {}) |
def search_word(search_term): | def precise_word_search(word): """Find every possible term this word could be. Our variant table holds every possible conjugation and declension, so we just query that and remove duplicates. We return results in alphabetical order. However, the only way to get more than one result is if we have the same string in diff... | def search_word(search_term): # substitute ' if used, since e.g. vort' == vorto if search_term.endswith("'"): word = search_term[:-1] + 'o' else: word = search_term # strip any hyphens used, since we can't guarantee where they # will/will not appear word = word.replace('-', '') # find all words that match this search... |
matching_variants = Variant.objects.filter(variant=word) matching_words = [] for variant in matching_variants: if not variant.word in matching_words: matching_words.append(variant.word) | word = word.lower() | def search_word(search_term): # substitute ' if used, since e.g. vort' == vorto if search_term.endswith("'"): word = search_term[:-1] + 'o' else: word = search_term # strip any hyphens used, since we can't guarantee where they # will/will not appear word = word.replace('-', '') # find all words that match this search... |
compare = lambda word_x, word_y: compare_esperanto_strings(word_x.word, word_y.word) matching_words.sort(cmp=compare) | matching_words = precise_word_search(word) | def search_word(search_term): # substitute ' if used, since e.g. vort' == vorto if search_term.endswith("'"): word = search_term[:-1] + 'o' else: word = search_term # strip any hyphens used, since we can't guarantee where they # will/will not appear word = word.replace('-', '') # find all words that match this search... |
spelling_variations = get_spelling_variations(word) if len(spelling_variations) > 999: spelling_variations = spelling_variations[:999] matching_variants = Variant.objects.filter(variant__in=spelling_variations) similar_words = [] for variant in matching_variants: if (not variant.word in similar_words) and (not variant... | similar_words = [term for term in imprecise_word_search(word) if term not in matching_words] | def search_word(search_term): # substitute ' if used, since e.g. vort' == vorto if search_term.endswith("'"): word = search_term[:-1] + 'o' else: word = search_term # strip any hyphens used, since we can't guarantee where they # will/will not appear word = word.replace('-', '') # find all words that match this search... |
splits.sort(reverse=True) | splits.sort(key=len) | def find_roots(compound): """Given a word that has been put together using Esperanto roots, find those roots. We do this by working left to right and building up a list of all possible radikoj according to the substrings seen so far. Since we assume roots are intact, the suffices -ĉjo and -njo which modify the roots c... |
root + 'us']) | root + 'us', root + 'u']) | def get_variants(word): # every possible legitimate spelling of this word, always lower # case to give a case insensitive sort (see vortaro/models.py) variants = [word.lower()] if is_infinitive(word): root = word[:-1] variants.extend([root + 'is', root + 'as', root + 'os', root + 'us']) elif is_declinable_adjective(wo... |
if l == "quit": exit(0); | if l == "quit\n": exit(0); | def input(): l = sys.stdin.readline(); if l == "quit": exit(0); return l; |
_current_scheme_version = 4 | _current_scheme_version = 5 | def init(self, fname, userDefined, unsaved=0): """ @param fname {str} Either the full path to a scheme file, or a scheme name (see unsaved) @param userDefined {bool} False if it's a Komodo-defined scheme @param unsaved {bool} True: fname is the name of a scheme, False: fname is a full path @returns {bool} True iff the ... |
cmd = ['git-rev-list', revlist] | cmd = ['git', 'rev-list', revlist] | def commits(options, revlist): cmd = ['git-rev-list', revlist] proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = options.repodir) revs = [] for line in proc.stdout.readlines(): revs.append(line.strip()) return revs |
cmd = ['git-diff', '%(rev)s^..%(rev)s' % {'rev': rev}] | cmd = ['git', 'diff', '%(rev)s^..%(rev)s' % {'rev': rev}] | def commit(options, rev): cmd = ['git-diff', '%(rev)s^..%(rev)s' % {'rev': rev}] proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = options.repodir) buf = proc.communicate()[0] return buf |
for line in text.split('\n'): | for line in text.decode('utf-8').split('\n'): | def parse_patch(text): patchbuf = '' commentbuf = '' buf = '' # state specified the line we just saw, and what to expect next state = 0 # 0: text # 1: suspected patch header (diff, ====, Index:) # 2: patch header line 1 (---) # 3: patch header line 2 (+++) # 4: patch hunk header line (@@ line) # 5: patch hunk content ... |
(patch, comment) = parse_patch(sys.stdin.read()) | content = sys.stdin.read().decode('utf-8') (patch, comment) = parse_patch(content) | def main(args): from optparse import OptionParser parser = OptionParser() parser.add_option('-p', '--patch', action = 'store_true', dest = 'print_patch', help = 'print parsed patch') parser.add_option('-c', '--comment', action = 'store_true', dest = 'print_comment', help = 'print parsed comment') parser.add_option('-#... |
for backendlink in backendlinks: if backendlink[backendlink.__len__()-1:]=='/': blink = backendlink[:-1] else: blink = backendlink if remote.startswith(blink): frontendlinks = smartlink_config.frontendlink frontendlink = frontendlinks[backendlinks.index(backendlink)] if frontendlink[frontendlink.__len__()-1:]=='/': fro... | frontend_main_link = getattr(smartlink_config, 'frontend_main_link', '') if frontend_main_link: portal_url = getToolByName(self, 'portal_url')() if remote.startswith(portal_url): remote = remote.replace(portal_url, frontend_main_link) else: for backendlink in backendlinks: if backendlink[-1]=='/': blink = backendlin... | def getRemoteUrl(self): """Return the URL of the link from the appropriate field, internal or external.""" smartlink_config = queryUtility(ISmartlinkConfig, name="smartlink_config") |
roles = ('Member', 'Contributor') | def afterSetUp(self): roles = ('Member', 'Contributor') self.portal.portal_membership.addMember('contributor', 'secret', roles, []) | |
'secret', roles, []) | default_password, ('Member', 'Contributor'), []) | def afterSetUp(self): roles = ('Member', 'Contributor') self.portal.portal_membership.addMember('contributor', 'secret', roles, []) |
version = '0.5.0' | version = '0.5.1' | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
version = '0.6.0' | version = '0.6.1' | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
url='http://svn.plone.org/svn/collective/redturtle.smartlink', | url='http://plone.org/products/smart-link', | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
[distutils.setup_keywords] paster_plugins = setuptools.dist:assert_string_list [egg_info.writers] paster_plugins.txt = setuptools.command.egg_info:write_arg | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() | |
user_fullname = "%s %s"%(user_firstname, user_lastname) | user_fullname = "%s %s"%(user_firstname[0], user_lastname[0]) | def listRecords(self, recordType): records = [] |
firstname = user_firstname, lastname = user_lastname, | firstname = user_firstname[0], lastname = user_lastname[0], | def listRecords(self, recordType): records = [] |
self._proxy.blogger.getUserInfo('', username, password) | self._proxy.wp.getUsersBlogs(username, password) | def authenticate(self, username, password): try: self._proxy.blogger.getUserInfo('', username, password) return True except: return False |
for pkg_download in packs: self._show_package(pkg_download, INFO_DOWNLOADING) try: repo = self.yumbase.repos.getRepo(pkg_download.repoid) except exceptions.IOError, e: self.error(ERROR_NO_SPACE_ON_DEVICE, "Disk error: %s" % _to_unicode(e)) except Exception, e: self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.form... | pkg_download = packs[0] self._show_package(pkg_download, INFO_DOWNLOADING) try: repo = self.yumbase.repos.getRepo(pkg_download.repoid) except exceptions.IOError, e: self.error(ERROR_NO_SPACE_ON_DEVICE, "Disk error: %s" % _to_unicode(e)) except Exception, e: self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_... | def download_packages(self, directory, package_ids): ''' Implement the download-packages functionality ''' try: self._check_init() except PkError, e: self.error(e.code, e.details, exit=False) return self.yumbase.conf.cache = 0 # Allow new files self.allow_cancel(True) self.status(STATUS_DOWNLOAD) percentage = 0 bump = ... |
matches, m_rc = self._entropy.atom_match(keyslot, multiMatch = True, multiRepo = True) | matches, m_rc = self._entropy.atom_match(keyslot, multi_match = True, multi_repo = True) | def get_update_detail(self, package_ids): |
def _media_find_root(self, media_id, disc_number=1): | def _media_find_root(self, media_id, disc_number=-1): | def _media_find_root(self, media_id, disc_number=1): """ returns the root "/media/Fedora Extras" or None """ |
disc_number_tmp = 1 try: disc_number_tmp = int(lines[3].strip()) except ValueError, e: pass if disc_number_tmp != disc_number: continue | if disc_number != -1: disc_number_tmp = 1 try: disc_number_tmp = int(lines[3].strip()) except ValueError, e: pass if disc_number_tmp != disc_number: continue | def _media_find_root(self, media_id, disc_number=1): """ returns the root "/media/Fedora Extras" or None """ |
print "Error opening source file '"+thisfilename+"'" sys.exit(1) | raise Exception("Error opening source file '"+thisfilename+"'") | def processfile(filename): # I'm going to read in all the file contents and put them into a dict keyed # by name filedatadict = {} # start with a "todo" list of just the file mentioned... files_to_read = [filename] while files_to_read != []: # figure out which file to read... thisfilename = files_to_read.pop() if t... |
outfiledata = processfile(sys.argv[1]) outfileobj.writelines(outfiledata) | try: outfileobj.writelines(outfiledata) finally: outfileobj.close() | def main(): if len(sys.argv)!= 3: print "Invalid number of arguments" print usestring sys.exit(1) # we don't support this (yet) if sys.argv[1] == sys.argv[2]: print "The infile and outfile must be different files" sys.exit(1) # get the outgoing file object try: outfileobj = file(sys.argv[2],'w') except: print "Erro... |
Example:: | def constraint(self, n=-1, fid=0): """Obtain the set of orthogonal equations that make the solution of the rank deficient normal equations possible. | |
OWGUI.button(self.controlArea, self, "Navigator", self.toggleNavigator, debuggingEnabled = 0) findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal") self.centerRootButton=OWGUI.button(findbox, self, "Find Root", callback=lambda :self.rootNode and self.sceneView.centerOn(self.rootNode.x(), self.rootNode... | grid = QGridLayout() navButton = OWGUI.button(self.controlArea, self, "Navigator", self.toggleNavigator, debuggingEnabled = 0, addToLayout=False) self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False, callback=lambda :self.rootNode and \ self.sceneView.centerOn(self.rootNode.x(), s... | def __init__(self, parent=None, signalManager = None, name='TreeViewer2D'): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.root = None self.selectedNode = None |
self.sceneView.centerOn(self.selectedNode.scenePos())) | self.sceneView.centerOn(self.selectedNode.scenePos())) grid.addWidget(navButton, 0, 0, 1, 2) grid.addWidget(self.centerRootButton, 1, 0) grid.addWidget(self.centerNodeButton, 1, 1) self.leftWidgetPart.layout().insertLayout(1, grid) | def __init__(self, parent=None, signalManager = None, name='TreeViewer2D'): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.root = None self.selectedNode = None |
if not lowv: | if lowv == None: | def printFigure(fig, *args, **kwargs): canvas = FigureCanvasAgg(fig) canvas.print_figure(*args, **kwargs) |
if not highv: | if highv == None: | def printFigure(fig, *args, **kwargs): canvas = FigureCanvasAgg(fig) canvas.print_figure(*args, **kwargs) |
self.outputLB.addItem(QListWidgetItem(icons[attr.varType], attr.name)) | self.outputLB.addItem(icons[attr.varType], attr.name) | def onDataInput(self, data): self.closeContext() if data and self.isDataWithClass(data, orange.VarTypes.Continuous): orngPade.makeBasicCache(data, self) |
if isinstance(addSpace, int): | if addSpace and isinstance(addSpace, bool): separator(widget) if addSpace and isinstance(addSpace, int): | def indentedBox(widget, sep=20, orientation = True, addSpace=False): r = widgetBox(widget, orientation = "horizontal") separator(r, sep, 0) if isinstance(addSpace, int): separator(widget, 0, addSpace) elif addSpace: separator(widget) return widgetBox(r, orientation = orientation) |
def separator(widget, width=8, height=8): | def separator(widget, width=0, height=0): | def separator(widget, width=8, height=8): sep = QWidget(widget) if widget.layout(): widget.layout().addWidget(sep) sep.setFixedSize(width, height) return sep |
if isinstance(addSpace, int): | if isinstance(addSpace, bool): separator(widget) elif isinstance(addSpace, int): | def comboBox(widget, master, value, box=None, label=None, labelWidth=None, orientation='vertical', items=None, tooltip=None, callback=None, sendSelectedValue = 0, valueType = unicode, control2attributeDict = {}, emptyString = None, editable = 0, searchAttr = False, indent = 0, addToLayout = 1, addSpace = False, debuggi... |
if data.domain.classVar: if data.domain.classVar.varType == orange.VarTypes.Discrete: self.graph.ColorAttr = len(data.domain.variables) elif data.domain.classVar.varType == orange.VarTypes.Continuous: self.graph.SizeAttr = len(data.domain.variables) | def setExampleTable(self, data): self.colorCombo.clear() self.sizeCombo.clear() self.shapeCombo.clear() self.nameCombo.clear() attributes=[attr for attr in data.domain.variables+data.domain.getmetas().values() or [] ] discAttributes=filter(lambda a: a.varType==orange.VarTypes.Discrete, attributes) contAttributes=filter... | |
painter.fillRect(option.rect.adjusted(1, 1, -option.rect.width() * (ratio), -1), self.color) | painter.fillRect(option.rect.adjusted(1, 1, -option.rect.width() * ratio, -1), self.color) | def paint(self, painter, option, index): painter.save() self.drawBackground(painter, option, index) ratio = None ratio, ok = index.data(TableBarItem.BarRole).toDouble() if not ok: ratio = None value, ok = index.data(Qt.DisplayRole).toDouble() if ok and getattr(self.widget, "showBars", False): col = index.column() if co... |
table.horizontalHeader().setSortIndicatorShown(True) | table.horizontalHeader().setSortIndicatorShown(False) | def dataset(self, data, id=None): """Generates a new table and adds it to a new tab when new data arrives; or hides the table and removes a tab when data==None; or replaces the table when new data arrives together with already existing id.""" if data != None: # can be an empty table! if self.data.has_key(id): # remove... |
tot = confm.TP+confm.TN | tot = confm.FN+confm.TN | def NPV(confm): """Return negative predictive value over the given confusion matrix.""" if type(confm) == list: return [NPV(cm) for cm in confm] else: tot = confm.TP+confm.TN if tot < 1e-6: import warnings warnings.warn("Can't compute NPV: one or both classes have no instances") return -1 return confm.TP/tot |
return confm.TP/tot | return confm.TN/tot | def NPV(confm): """Return negative predictive value over the given confusion matrix.""" if type(confm) == list: return [NPV(cm) for cm in confm] else: tot = confm.TP+confm.TN if tot < 1e-6: import warnings warnings.warn("Can't compute NPV: one or both classes have no instances") return -1 return confm.TP/tot |
attrItemsSet = set(context.attributes.items()) metaItemsSet = set(context.metas.items()) | def attrSet(attrs): if isinstance(attrs, dict): return set(attrs.items()) elif isinstance(attrs, bool): return {} else: return set([]) attrItemsSet = attrSet(context.attributes) metaItemsSet = attrSet(context.metas) | def settingsToWidget(self, widget, context): ContextHandler.settingsToWidget(self, widget, context) excluded = {} addOrdinaryTo = [] addMetaTo = [] attrItemsSet = set(context.attributes.items()) metaItemsSet = set(context.metas.items()) for field in self.fields: name, flags = field.name, field.flags |
DomainContextHandler.__init__(self, contextName, fields, False, False, False, syncWithGlobal, **args) | DomainContextHandler.__init__(self, contextName, fields, False, False, syncWithGlobal, **args) | def __init__(self, contextName = "", fields = [], syncWithGlobal = True, **args): DomainContextHandler.__init__(self, contextName, fields, False, False, False, syncWithGlobal, **args) |
self.connect(self.shownAttribsLB, SIGNAL('doubleClicked(QListBoxItem *)'), self.flipAttribute) | self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute) | def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates", TRUE) |
data = orange.ExampleTable(r"e:\Development\Orange Datasets\UCI\wine.tab") | data = orange.ExampleTable("../../doc/datasets/iris.tab") | def loadResults(self): self.clearResults() |
self.warning(0, "Examples with missing values were removed. Keeping %d of %d examples." % (len(data), len(self.originalData))) | self.warning(0, "Examples with missing values were removed. Keeping %d of %d examples." % (len(self.originalData), len(data))) if len(self.originalData) == 0: self.error(0, "All examples from the data set were removed!") return | def setData(self, data): self.warning([0,1]) |
ckey.setRenderHints(QwtPlotItem.RenderAntialiased, self.useAntialiasing) | ckey.setRenderHint(QwtPlotItem.RenderAntialiased, self.useAntialiasing) | def refreshPureVisibleOutcomes(self): if self.dataHasDiscreteClass: return keys=self.hdata.keys() if self.variableContinuous: keys.sort() self.clear() self.tips.removeAll() cn=0 for key in keys: ckey = PolygonCurve(pen=QPen(Qt.black), brush=QBrush(Qt.gray)) ckey.attach(self) ckey.setRenderHints(QwtPlotItem.RenderAntial... |
index = "<br/>".join('<a href="%s">%s</a>' % (self.tree.item(i).elementId, self.re_h1.search(self.tree.item(i).content).group("name")) | index = "<br/>".join('<a href=" | def saveReport(self): filename = QFileDialog.getSaveFileName(self, "Save Report", self.saveDir, "Web page (*.html *.htm)") if not filename: return |
l = l[:-1] | l = l.strip() | def loadARFF(filename): try: f = open(filename,'r') except: f = open(filename+'.arff','r') attributes = [] name = '' state = 0 # header data = [] for l in f.readlines(): l = l[:-1] # strip \n l = string.replace(l,'\t',' ') # get rid of tabs x = string.split(l,sep='%')[0] # strip comments if len(string.strip(x)) == 0: c... |
self.beginInsertRows(QModelIndex(), len(self), len(self) + len(list_)) | self.beginInsertRows(QModelIndex(), len(self), len(self) + len(list_) - 1) | def extend(self, iterable): list_ = list(iterable) self.beginInsertRows(QModelIndex(), len(self), len(self) + len(list_)) self._list.extend(list_) self.endInsertRows() |
self.beginInsertRows(QModelIndex(), i, i + 1) | self.beginInsertRows(QModelIndex(), i, i) | def insert(self, i, val): self.beginInsertRows(QModelIndex(), i, i + 1) self._list.insert(i, val) self.endInsertRows() |
def __delslice(self, i, j): self.beginRemoveRows(QModelIndex(), i, j) del self._list[i:j] self.endRemoveRows() | def __delslice__(self, i, j): if j > i: self.beginRemoveRows(QModelIndex(), i, j - 1) del self._list[i:j] self.endRemoveRows() | def __delslice(self, i, j): self.beginRemoveRows(QModelIndex(), i, j) del self._list[i:j] self.endRemoveRows() |
self._list[i:j] = iterable self.reset() | self.__delslice__(i, j) all = list(iterable) if len(all): self.beginInsertRows(QModelIndex(), i, i + len(all) - 1) self._list[i:i] = all self.endInsertRows() | def __setslice__(self, i, j, iterable): self._list[i:j] = iterable self.reset() |
if parent and parent.layout(): | if parent and parent.layout() is not None: | def __init__(self, parent = None): self.canvas = QGraphicsScene(0, 0, 1000, colorButtonSize) QGraphicsView.__init__(self, self.canvas, parent) self.ensureVisible(0,0,1,1) self.color1 = None self.color2 = None self.rgbColors = [] self.passThroughColors = None |
if self.parent and self.parent.layout(): | if self.parent and self.parent.layout() is not None: | def __init__(self, master = None, parent = None, label = None, color = None): QWidget.__init__(self, master) |
self.distance = self.distance_constructor(self.data) | self.distance = self.distance_constructor(self.data) if self.data else None | def __init__(self, data=None, centroids=3, maxiters=None, minscorechange=None, stopchanges=0, nstart=1, initialization=kmeans_init_random, distance=orange.ExamplesDistanceConstructor_Euclidean, scoring=score_distance_to_centroids, inner_callback = None, outer_callback = None): """ :param data: Instances to be clustered... |
self.redirect.advance() | if not self._delay: try: self._delay = True self.redirect.advance() finally: self._delay = False else: QTimer.singleShot(100, self.advance) | def advance(self): self.redirect.advance() |
import glob | def test_scripts(complete, just_print, module="orange", root_directory=".", test_files=None, directories=None): """Test the scripts in the given directory.""" global error_status if sys.platform == "win32" and sys.executable[-6:].upper() != "_D.EXE": import win32process, win32api win32process.SetPriorityClass(win32api.... | |
os.spawnl(os.P_WAIT, sys.executable, "-c", regtestdir+"/xtest1.py", name, str(titerations), outputsdir) | def test_scripts(complete, just_print, module="orange", root_directory=".", test_files=None, directories=None): """Test the scripts in the given directory.""" global error_status if sys.platform == "win32" and sys.executable[-6:].upper() != "_D.EXE": import win32process, win32api win32process.SetPriorityClass(win32api.... | |
for p in [path, os.path.join(path, "widgets"), os.path.join(path, "widgets", "prototypes"), os.path.join(path, "lib-%s" % "-".join(( sys.platform, platform.machine() if sys.platform!="win32" else "", ".".join(map(str, sys.version_info[:2])) )) )]: | for p in [path, os.path.join(path, "widgets"), os.path.join(path, "widgets", "prototypes"), os.path.join(path, "lib-%s" % "-".join(( sys.platform, "x86" if (platform.machine()=="") else platform.machine(), ".".join(map(str, sys.version_info[:2])) )) )]: | def addAddOnDirectoriesToPath(): import os, sys global addOnDirectories, registeredAddOns sys.path = [dir for dir in sys.path if dir not in addOnDirectories] for addOn in installedAddOns.values() + registeredAddOns: path = addOn.directory for p in [path, os.path.join(path, "widgets"), os.path.join(path, "widgets", "pro... |
if os.path.isfile(path): path = os.path.dirname(path) __writeAddOnLists([a for a in __readAddOnLists(userOnly=not systemWide) if a.name != name and a.directory != path] + (add and [OrangeRegisteredAddOn(name, path, systemWide)] or []), userOnly=not systemWide) global registeredAddOns registeredAddOns.append( OrangeReg... | if not add: unregisredAddOn(name, path, userOnly=not systemWide) else: if os.path.isfile(path): path = os.path.dirname(path) __writeAddOnLists([a for a in __readAddOnLists(userOnly=not systemWide) if a.name != name and a.directory != path] + ([OrangeRegisteredAddOn(name, path, systemWide)] or []), userOnly=not systemWi... | def registerAddOn(name, path, add = True, refresh=True, systemWide=False): if os.path.isfile(path): path = os.path.dirname(path) __writeAddOnLists([a for a in __readAddOnLists(userOnly=not systemWide) if a.name != name and a.directory != path] + (add and [OrangeRegisteredAddOn(name, path, systemWide)] or []), userOnly=... |
maxVal = max(maxVal, max(orange.Distribution(attr, self.rawData))) | maxVal = max(maxVal, max(orange.Distribution(attr, self.rawData) or [1])) | def showDistributionValues(self, validData, indices): # create color table clsCount = len(self.dataDomain.classVar.values) #if clsCount < 1: clsCount = 1.0 |
maxVal = max(maxVal, max([max(val) for val in self.domainContingency[attr].values()])) | maxVal = max(maxVal, max([max(val or [1]) for val in self.domainContingency[attr].values()] or [1])) | def showDistributionValues(self, validData, indices): # create color table clsCount = len(self.dataDomain.classVar.values) #if clsCount < 1: clsCount = 1.0 |
a = OWQCanvasFuncts.OWCanvasLine(canvas, lineWidth = at.lineWidth, show = 0) | a = OWQCanvasFuncts.OWCanvasLine(canvas, penWidth = at.lineWidth, show = 0) | def initializeBeforePaint(self, canvas): [l.scene().removeItem(l) for l in self.contLabel] self.contLabel=[] for val in self.attValues: # draw value a = OWQCanvasFuncts.OWCanvasText(canvas, val.name, alignment = Qt.AlignRight, show = 0) a.marker = OWQCanvasFuncts.OWCanvasLine(canvas, z = 5, show = 0) self.contLabel.app... |
prob = float(val) / sum(self.distribution) | prob = float(val) / (sum(self.distribution) or 1) | def __init__(self, *args, **kwargs): MajorityChart.__init__(self, *args, **kwargs) index = int(numpy.argmax(list(self.distribution))) val = self.distribution[self.majorityValue] prob = float(val) / sum(self.distribution) |
QGraphicsWidget.setGeometry(self, rect) | QGraphicsWidget.setGeometry(self, rect) if getattr(self, "colorSchema", None) is not None: self.setColorSchema(self.colorSchema) | def setGeometry(self, rect): QGraphicsWidget.setGeometry(self, rect) |
settingsList = ["drawMode","objSize","commitOnChange", "backgroundMode", "backgroundCheck", "includeCodebook", "showToolTips"] | settingsList = ["drawMode", "showNodeOutlines", "objSize","commitOnChange", "backgroundMode", "backgroundCheck", "includeCodebook", "showToolTips"] | def updateToolTips(self, *args, **kwargs): for item in self.somWidgets(): item.somItem.updateToolTips(*args, **kwargs) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.