rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
timeouts = (0, 0, timeout*1000, 0, timeout*1000)
timeouts = (0, 0, int(timeout*1000), 0, int(timeout*1000))
def __init__(self, port, #number of device, numbering starts at #zero. if everything fails, the user #can specify a device string, note #that this isn't portable anymore baudrate=9600, #baudrate bytesize=EIGHTBITS, #number of databits parity=PARITY_NONE, #enable parity checking stopbits=S...
if self._writeTimeout is not None and self._writeTimeout > 0: _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) if not ready: raise writeTimeoutError n = os.write(self.fd, d) if self._writeTimeout is not None and self._writeTimeout > 0: _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) if not ...
try: if self._writeTimeout is not None and self._writeTimeout > 0: _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) if not ready: raise writeTimeoutError n = os.write(self.fd, d) if self._writeTimeout is not None and self._writeTimeout > 0: _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) if...
def write(self, data): """Output the given string over the serial port.""" if self.fd is None: raise portNotOpenError t = len(data) d = data while t > 0: if self._writeTimeout is not None and self._writeTimeout > 0: _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) if not ready: raise writeTimeoutError n =...
self.logger.debug('Connection starting up (%s:%d)', self._addr[0], self._addr[1])
if len(self._addr) == 2: self.logger.debug('Connection starting up (%s:%d)', self._addr[0], self._addr[1])
def run(self): self.logger.debug('Connection starting up (%s:%d)', self._addr[0], self._addr[1])
self.logger.debug('Connection shutting down (%s:%d)', self._addr[0], self._addr[1])
if len(self._addr) == 2: self.logger.debug('Connection shutting down (%s:%d)', self._addr[0], self._addr[1])
def run(self): self.logger.debug('Connection starting up (%s:%d)', self._addr[0], self._addr[1])
assert not self._closed
if __debug__: assert not self._closed
def _get_session(self): assert not self._closed if self._session is None: self._session = self._store.createSession() self._newSession = True
assert not self._closed
if __debug__: assert not self._closed
def _get_hasSession(self): assert not self._closed return self._session is not None
assert not self._closed
if __debug__: assert not self._closed
def _get_isSessionNew(self): assert not self._closed return self._newSession
assert not self._closed
if __debug__: assert not self._closed
def _get_hasSessionExpired(self): assert not self._closed return self._expired
assert not self._closed
if __debug__: assert not self._closed
def encodeURL(self, url): """Encodes session ID in URL, if necessary.""" assert not self._closed if not self.encodesSessionInURL or self._session is None: return url u = list(urlparse.urlsplit(url)) q = '%s=%s' % (self._fieldName, self._sessionIdentifier()) if u[3]: u[3] = q + '&' + u[3] else: u[3] = q return urlparse....
_maxWrite = 8192 - 4 - 3
_maxWrite = 8192 - 4 - 3 - 1
def addData(self, data): """ Adds data from the server to this InputStream. Note that we never ask the server for data beyond the Content-Length, so the server should never send us an EOF (empty string argument). """ if not data: raise ProtocolError, 'short data' self._bufList.append(data) length = len(data) self._avai...
data[:toWrite]
data[:toWrite] + '\x00'
def write(self, data): """ Write data (which comprises the response body). Note that due to restrictions on AJP packet size, we limit our writes to 8185 bytes each packet. """ assert self._headersSent, 'Headers must be sent first!'
self.writeRecord(rec)
self.writeRecord(outrec)
def _do_get_values(self, inrec): """Handle an FCGI_GET_VALUES request from the web server.""" outrec = Record(FCGI_GET_VALUES_RESULT)
return (socket.fromfd(s1, socket.AF_UNIX, socket.SOCK_STREAM),
p, c = (socket.fromfd(s1, socket.AF_UNIX, socket.SOCK_STREAM),
def socketpair(): s1, s2 = eunuchs.socketpair.socketpair() return (socket.fromfd(s1, socket.AF_UNIX, socket.SOCK_STREAM), socket.fromfd(s2, socket.AF_UNIX, socket.SOCK_STREAM))
("a", "char")
("a", "char"), (u"\N{LATIN SMALL LETTER E WITH CIRCUMFLEX}\N{LATIN SMALL LETTER A WITH TILDE}", u"\N{LATIN SMALL LETTER O WITH DIAERESIS}\N{LATIN SMALL LETTER U WITH CIRCUMFLEX}"),
def testCursor(self): "Check functionality of the cursor" c=self.db.cursor() c.execute("create table foo(x,y,z)") # table should be empty entry=-1 for entry,values in enumerate(c.execute("select * from foo")): pass self.failUnlessEqual(entry,-1, "No rows should have been returned") # add ten rows for i in range(10): c....
is_sync = kwargs.get(kwarg, default_value)
try: is_sync = kwargs[kwarg] del kwargs[kwarg] except KeyError: is_sync = default_value
def wrapper(*args, **kwargs): is_sync = kwargs.get(kwarg, default_value) if is_sync: del kwargs[kwarg] return syncOperation(func(*args, **kwargs)) else: return func(*args, **kwargs)
del kwargs[kwarg]
def wrapper(*args, **kwargs): is_sync = kwargs.get(kwarg, default_value) if is_sync: del kwargs[kwarg] return syncOperation(func(*args, **kwargs)) else: return func(*args, **kwargs)
all_files.add_pattern ("*.*")
all_files.add_pattern ("*")
def __init__ (self, parent): super (SavePlaylistRegistry, self).__init__ (parent) # all files filter all_files = gtk.FileFilter () all_files.set_name (_("All files")) all_files.add_pattern ("*.*") self.__global_filter = gtk.FileFilter() self.__global_filter.set_name (_("Supported playlists")) self.__file_filters = [s...
def start (self): self.__oper.start () def stop (self): self._check_duration () self.__oper.stop () def on_eos (self, event): self._check_duration () def on_error (self, event, message):
def start(self): self.duration_counter = 3 self.fuzzy_duration = True self.__oper.start() def stop(self): self.__oper.stop() def on_eos(self, event): pass def on_error(self, event, message):
def start (self): self.__oper.start ()
self._check_duration () def on_handoff (self, *ignored): self._fakesink.set_property ("signal-handoffs", False) self.stop () def on_tag (self, event, taglist): self.__metadata.update (taglist) def on_finished (self, event):
pass def on_handoff(self, *ignored): self._check_duration() def on_tag(self, event, taglist): self.__metadata.update(taglist) def on_finished(self, event): self.duration_counter = 0
def on_error (self, event, message): # try to get the size even when there is an error self._check_duration ()
try: duration = int (self.__metadata["duration"]) / gst.SECOND except KeyError: duration = 0 if duration == -1 or duration == 0:
duration = int(self.__metadata.get("duration", 0)) / gst.SECOND if duration == 0:
def on_finished (self, event): if event.id == operations.ERROR: self._propagate(event) return try: duration = int (self.__metadata["duration"]) / gst.SECOND except KeyError: duration = 0 if duration == -1 or duration == 0: self._send_finished_event(operations.ERROR) return self.__metadata["duration"] = duration evt...
self._send_finished_event (operations.SUCCESSFUL) def _check_duration (self): if not self.__metadata.has_key ("duration"): self.__metadata["duration"] = \ self.__oper.query_duration (gst.FORMAT_TIME)
self._send_finished_event(operations.SUCCESSFUL) def _check_duration(self): dur = self.__oper.query_duration(gst.FORMAT_TIME) try: if self.duration_counter > 0: old_dur = self.__metadata["duration"] self.fuzzy_duration = old_dur != dur if self.fuzzy_duration: self.duration_counter = 0 if self.duration_counter > 0...
def on_finished (self, event): if event.id == operations.ERROR: self._propagate(event) return try: duration = int (self.__metadata["duration"]) / gst.SECOND except KeyError: duration = 0 if duration == -1 or duration == 0: self._send_finished_event(operations.ERROR) return self.__metadata["duration"] = duration evt...
self.dialog.connect ("destroy-event", self.__on_destroy) self.dialog.set_title ("")
self.dialog.connect("destroy-event", self.__on_destroy) self.dialog.set_title(_("Serpentine Preferences"))
def __init__ (self, locations): # By default use burnproof self.__write_flags = nautilusburn.RECORDER_WRITE_BURNPROOF # Sets up data dir and version self.version = release.version
if self.__eject.data:
if self.__use_gap.data: ret |= nautilusburn.RECORDER_WRITE_DISC_AT_ONCE if not self.__eject.data:
def __get_write_flags (self): ret = self.__write_flags if self.__eject.data: ret |= nautilusburn.RECORDER_WRITE_EJECT return ret
if handler:
if handler is not None:
def _dispatch_bus_message(self, bus, message): handler = getattr(self, "_on_" + message.type.first_value_nick, None) if handler: handler(bus, message)
source ! decodebin ! audioconvert ! audioresample ! $_WAV_PCM_PARSE ! wavenc
source ! decodebin ! audioconvert ! wavenc
def source_to_wav(source, sink): """ Converts a given source element to wav format and sends it to sink element. To convert a media file to a wav using gst-launch: source ! decodebin ! audioconvert ! audioresample ! $_WAV_PCM_PARSE ! wavenc """ bin = gst.parse_launch( "decodebin name=stw_decodebin !" "audioconvert ! ...
"audioconvert ! audioresample ! " + _WAV_PCM_PARSE + " ! wavenc name=stw_wavenc"
"audioconvert ! wavenc name=stw_wavenc"
def source_to_wav(source, sink): """ Converts a given source element to wav format and sends it to sink element. To convert a media file to a wav using gst-launch: source ! decodebin ! audioconvert ! audioresample ! $_WAV_PCM_PARSE ! wavenc """ bin = gst.parse_launch( "decodebin name=stw_decodebin !" "audioconvert ! ...
self.preferences.dialog.set_parent (self.window_widget)
def __init__ (self): operations.Operation.__init__ (self) self.__preferences = RecordingPreferences () self.__window = SerpentineWindow (self) self.preferences.dialog.set_transient_for (self.window_widget) self.preferences.dialog.set_parent (self.window_widget) self.__window.listeners.append (self) # Load Plugins self....
self.file_dlg.set_title ("") self.file_dlg.set_transient_for (self.parent) self.file_dlg.set_current_folder (os.path.expanduser("~"))
self.file_dlg.set_title("") self.file_dlg.set_transient_for(self.parent) self.file_dlg.set_current_folder(os.path.expanduser("~")) self.file_dlg.set_property("local-only", False)
def __init__ (self, parent): super (FileDialogComponent, self).__init__ (parent) # Open playlist file dialog self.file_dlg = gtk.FileChooserDialog ( parent = self.parent, buttons = ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK ) ) self.file_dlg.set_title ("") self.file_dlg.set_transient_for ...
if self.file_dlg.run () == gtk.RESPONSE_OK:
while self.file_dlg.run () == gtk.RESPONSE_OK:
def run_dialog (self, *args): app = self.parent.application win = self.parent self.__sync_file_filters () if self.file_dlg.run () == gtk.RESPONSE_OK: filename = self.file_dlg.get_filename () basename = os.path.basename (filename) if os.path.exists (filename) and gtkutil.dialog_ok_cancel ( _("Replace existing file"), ...
self.total = float(self.total)
def draw(self, evt): rect = self.allocation radius = min(rect.width / 2.0, rect.height / 2.0) - 5 if radius <= 0: return x = rect.width / 2.0 y = rect.height / 2.0 center = (x, y) small_radius = radius * 0.20 self.total = float(self.total) ctx = self.window.cairo_create() ctx.set_line_width(0.75)
apperture = self.getter(val) / self.total
apperture = self.getter(val) / total
def draw(self, evt): rect = self.allocation radius = min(rect.width / 2.0, rect.height / 2.0) - 5 if radius <= 0: return x = rect.width / 2.0 y = rect.height / 2.0 center = (x, y) small_radius = radius * 0.20 self.total = float(self.total) ctx = self.window.cairo_create() ctx.set_line_width(0.75)
assert offset + apperture <= 1
def draw(self, evt): rect = self.allocation radius = min(rect.width / 2.0, rect.height / 2.0) - 5 if radius <= 0: return x = rect.width / 2.0 y = rect.height / 2.0 center = (x, y) small_radius = radius * 0.20 self.total = float(self.total) ctx = self.window.cairo_create() ctx.set_line_width(0.75)
esc = 0x1b up = 0x41 down = 0x42 right = 0x43 left = 0x44 enter = 0x0a backspace = 0x08
q = ord("q") esc = (27, None) up = (27, 79, 65) down = (27, 79, 66) right = (27, 79, 67) left = (27, 79, 68) enter = 10 backspace = 127
def key_strokes(): # This Corresponds to each Key Stroke's ASCII Value x = ord("x") c = ord("c") v = ord("v") z = ord("z") b = ord("b") j = ord("j") s = ord("s") esc = 0x1b up = 0x41 down = 0x42 right = 0x43 left = 0x44 enter = 0x0a backspace = 0x08 return locals()
def get_key(self):
def get_key(self, timeout = 1):
def get_key(self): # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) # if any key pressed if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) return key return None
(read, write, err) = select.select([0], [], [], 1)
(read, write, err) = select.select([0], [], [], timeout)
def get_key(self): # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) # if any key pressed if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) return key return None
log("key pressed 0x%02x\n" % key) return key
if key == 0x1b: next = self.get_key(0) if next == 79 or next == 91: next = self.get_key(0) return (27, 79, next) return(key,next) return int(key)
def get_key(self): # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) # if any key pressed if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) return key return None
for j in songs[:3]: if i == 2:
for song in slice: if self.highlight + 2 == i:
def draw_jump(self,string): '''This Draws Jump.... But also returns next Songs Matching Query''' self.jump.clear() self.jump.insstr(1,2,"Search: %s" % string) songs = self.songs_that_match(string) i = 2 for j in songs[:3]: if i == 2: style = curses.A_STANDOUT else: style = curses.A_NORMAL self.jump.insstr(i,2,xmms.get_...
self.jump.insstr(i,2,xmms.get_playlist_title(j)[:42],style)
self.jump.insstr(i,2,xmms.get_playlist_title(song)[:42],style)
def draw_jump(self,string): '''This Draws Jump.... But also returns next Songs Matching Query''' self.jump.clear() self.jump.insstr(1,2,"Search: %s" % string) songs = self.songs_that_match(string) i = 2 for j in songs[:3]: if i == 2: style = curses.A_STANDOUT else: style = curses.A_NORMAL self.jump.insstr(i,2,xmms.get_...
return songs[0]
return slice[self.highlight]
def draw_jump(self,string): '''This Draws Jump.... But also returns next Songs Matching Query''' self.jump.clear() self.jump.insstr(1,2,"Search: %s" % string) songs = self.songs_that_match(string) i = 2 for j in songs[:3]: if i == 2: style = curses.A_STANDOUT else: style = curses.A_NORMAL self.jump.insstr(i,2,xmms.get_...
(read, write, err) = select.select([0], [], [], 1) if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key)
key = self.get_key() if key: log("key pressed %s\n" % str(key))
def search(self): self.jump.clear() string = "" # if any key pressed while True: song = self.draw_jump(string) self.update() # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) if key == self.keys["esc"]: self.jump....
if key == self.keys["enter"]:
elif key == self.keys["enter"]:
def search(self): self.jump.clear() string = "" # if any key pressed while True: song = self.draw_jump(string) self.update() # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) if key == self.keys["esc"]: self.jump....
if key == self.keys["backspace"]:
elif key == self.keys["backspace"]:
def search(self): self.jump.clear() string = "" # if any key pressed while True: song = self.draw_jump(string) self.update() # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) if key == self.keys["esc"]: self.jump....
string = string + chr(key)
try: string = string + chr(key) self.base = 0 self.highlight = 0 except: pass
def search(self): self.jump.clear() string = "" # if any key pressed while True: song = self.draw_jump(string) self.update() # select() rocks, timeout == 1 sec (read, write, err) = select.select([0], [], [], 1) if 0 in read: key = self.win.getch() log("key pressed 0x%02x\n" % key) if key == self.keys["esc"]: self.jump....
quit = 0 log("%s\n" % dir(self.timers)) while not quit:
while True:
def main_keyloop(self): quit = 0 log("%s\n" % dir(self.timers)) while not quit: self.update() key = self.get_key() if key == ord('q'): quit = 1 if self.keymaps.has_key(key): self.keymaps[key]()
if key == ord('q'): quit = 1
if key: log("key pressed %s\n" % str(key))
def main_keyloop(self): quit = 0 log("%s\n" % dir(self.timers)) while not quit: self.update() key = self.get_key() if key == ord('q'): quit = 1 if self.keymaps.has_key(key): self.keymaps[key]()
graph.setData(self.data, str(self.attributesLB.text(i)))
graph.setData(self.data, selected[i])
def createGraphs(self): for graph in self.graphs: graph.hide() self.graphs = []
self.startButton=OWGUI.button(opt, self, "Start", self.start)
def __init__(self, parent=None, signalManager=None, name="Multi Dimensional Scaling"): OWWidget.__init__(self, parent, signalManager, name)
self.shapes=[[QwtSymbol.Ellipse]*(len(attributes)+1) for i in range(len(data))] self.sizes=[[5]*(len(attributes)+1) for i in range(len(data))]
self.shapes=[[QwtSymbol.Ellipse]*(len(discAttributes)+1) for i in range(len(data))] self.sizes=[[5]*(len(contAttributes)+1) for i in range(len(data))]
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...
contI=discI=attrI=1
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...
self.colors[i][j+1]=c[int(data[i][attr])] self.shapes[i][j+1]=self.graph.shapeList[int(data[i][attr])%len(self.graph.shapeList)] self.names[i][j+1]=str(data[i][attr]) self.sizes[i][j+1]=5
self.colors[i][attrI]=c[int(data[i][attr])] self.shapes[i][discI]=self.graph.shapeList[int(data[i][attr])%len(self.graph.shapeList)] self.names[i][attrI]=" "+str(data[i][attr]) attrI+=1 discI+=1
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...
self.colors[i][j+1]=c.getColor((data[i][attr]-minVal)/abs(maxVal-minVal)) self.shapes[i][j+1]=self.graph.shapeList[0] self.names[i][j+1]=str(data[i][attr]) self.sizes[i][j+1]=int(self.data[i][attr]/maxVal*9)+1
self.colors[i][attrI]=c.getColor((data[i][attr]-minVal)/abs(maxVal-minVal)) self.names[i][attrI]=" "+str(data[i][attr]) self.sizes[i][contI]=int(self.data[i][attr]/maxVal*9)+1 contI+=1 attrI+=1
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...
self.colors[i][j+1]=Qt.black self.shapes[i][j+1]=self.graph.shapeList[0] self.names[i][j+1]=str(data[i][attr]) self.sizes[i][j+1]=5
self.colors[i][attrI]=Qt.black self.names[i][attrI]=" "+str(data[i][attr]) attrI+=1
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...
self.names[i][1]=d.name self.names[i][2]=d.strain
self.names[i][1]=" "+d.name self.names[i][2]=" "+d.strain
def setList(self, data): self.colorCombo.clear() self.sizeCombo.clear() self.shapeCombo.clear() self.nameCombo.clear() for name in ["One color", "strain"]: self.colorCombo.insertItem(name) for name in ["No name", "name", "strain"]: self.nameCombo.insertItem(name) self.colors=[[Qt.black]*3 for i in range(len(data))] se...
self.showSubsetDistributions = 0
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Mosaic display", TRUE, TRUE)
self.subsetData = data
try: self.subsetData = data.select(self.data.domain) except: self.subsetData = None
def subsetdataHander(self, data): self.subsetData = data if data and len(data) > 1: self.setStatusBarText("The data set received on the 'Example subset' input contains more than one example. Only the first example will be considered.") else: self.setStatusBarText("")
if data and len(data) > 1: self.setStatusBarText("The data set received on the 'Example subset' input contains more than one example. Only the first example will be considered.") else: self.setStatusBarText("")
def subsetdataHander(self, data): self.subsetData = data if data and len(data) > 1: self.setStatusBarText("The data set received on the 'Example subset' input contains more than one example. Only the first example will be considered.") else: self.setStatusBarText("")
if self.showSubsetDistributions and self.subsetData and len(self.subsetData) > 1:
if self.subsetData and len(self.subsetData) > 1 and self.data.domain == self.subsetData.domain:
def updateData(self, *args): # hide all rectangles self.warning() for item in self.canvas.allItems(): item.setCanvas(None) # remove all canvas items for tip in self.tooltips: QToolTip.remove(self.canvasView, tip) self.names = []; self.tooltips = [] if self.data == None : return
if self.subsetData and self.subsetData.domain == self.data.domain and self.conditionalDict[attrVals] > 0:
if self.subsetData and self.subsetData.domain.attributes == self.data.domain.attributes and self.conditionalDict[attrVals] > 0 and len(self.subsetData) == 1:
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
if len(self.subsetData) > 1 or self.subsetData[0].getclass().isSpecial(): color = QColor(0,0,0) else: values = self.attributeValuesDict.get(self.data.domain.classVar.name, None) or getVariableValuesSorted(self.data, self.data.domain.classVar.name) color = self.colorPalette[values.index(self.subsetData[0].getclass().val...
values = self.attributeValuesDict.get(self.data.domain.classVar.name, None) or getVariableValuesSorted(self.data, self.data.domain.classVar.name) color = self.colorPalette[values.index(self.subsetData[0].getclass().value)]
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
v = ((x1-x0)* val)/self.conditionalDict[attrVals]
if i == len(aprioriDist)-1: v = x1-x0 - total else: v = int(((x1-x0)* val)/self.conditionalDict[attrVals])
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
v = ((y1-y0)* val)/self.conditionalDict[attrVals]
if i == len(aprioriDist)-1: v = y1-y0 - total else: v = int(((y1-y0)* val)/self.conditionalDict[attrVals])
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
val = ((x1-x0)* aprioriDist[values[i]])/len(self.data)
if i == len(aprioriDist)-1: v = x1-x0 - total else: v = int(((x1-x0)* aprioriDist[values[i]])/float(len(self.data)))
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
OWCanvasRectangle(self.canvas, x0+total, y0, val+1, self.boxSize, brushColor = self.colorPalette[i], z = 0) total += val if i < len(aprioriDist)-1 and self.showAprioriDistributionLines: OWCanvasLine(self.canvas, x0+total, y0, x0+total, y1, z = 10)
OWCanvasRectangle(self.canvas, x0+total, y0, v, self.boxSize, brushColor = self.colorPalette[i], z = 0) if i < len(aprioriDist)-1 and self.showAprioriDistributionLines: OWCanvasLine(self.canvas, x0+total+v, y0, x0+total+v, y1, z = 10)
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
val = ((y1-y0)* aprioriDist[values[i]])/len(self.data)
if i== len(aprioriDist)-1: v = y1-y0 - total else: v = int(((y1-y0)* aprioriDist[values[i]])/float(len(self.data)))
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
OWCanvasRectangle(self.canvas, x0, y0+total, self.boxSize, val+1, brushColor = self.colorPalette[i], z = 0) total += val if i < len(aprioriDist)-1 and self.showAprioriDistributionLines: OWCanvasLine(self.canvas, x0, y0+total, x1, y0+total, z = 10)
OWCanvasRectangle(self.canvas, x0, y0+total, self.boxSize, v, brushColor = self.colorPalette[i], z = 0) if i < len(aprioriDist)-1 and self.showAprioriDistributionLines: OWCanvasLine(self.canvas, x0, y0+total+v, x1, y0+total+v, z = 10) total += v
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
if self.showSubsetDistributions and self.conditionalSubsetDict:
if self.conditionalSubsetDict:
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
if not self.conditionalSubsetDict[attrVals]: continue
if not self.conditionalSubsetDict[attrVals] or val == 0: continue
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
v = ((x1-x0)* val)/self.conditionalSubsetDict[attrVals] OWCanvasRectangle(self.canvas, x0+total, y1-self.boxSize, v+(x0+total+v<x1), self.boxSize, brushColor = self.colorPalette[i], z = 15)
if i == len(aprioriDist)-1: v = x1-x0 - total else: v = int(((x1-x0)* val)/float(self.conditionalSubsetDict[attrVals])) OWCanvasRectangle(self.canvas, x0+total, y1-self.boxSize, v, self.boxSize, brushColor = self.colorPalette[i], z = 15)
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
v = ((y1-y0)* val)/self.conditionalSubsetDict[attrVals] OWCanvasRectangle(self.canvas, x1-self.boxSize, y0+total, self.boxSize, v+(y0+total+v<y1), brushColor = self.colorPalette[i], z = 15)
if i == len(aprioriDist)-1: v = y1-y0 - total else: v = int(((y1-y0)* val)/float(self.conditionalSubsetDict[attrVals])) OWCanvasRectangle(self.canvas, x1-self.boxSize, y0+total, self.boxSize, v, brushColor = self.colorPalette[i], z = 15)
def addRect(self, x0, x1, y0, y1, condition = "", usedAttrs = [], attrVals = ""): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
self.tip(self.rect, text)
self.tip(self.rect, self.text)
def maybeTip(self, p): if self.rect and self.text: if self.rect.contains(p): self.tip(self.rect, text)
self.setCaption("Orange Canvas")
self.setCaption("Qt Orange Canvas")
def __init__(self,*args): apply(QMainWindow.__init__,(self,) + args) self.resize(800,700) self.setCaption("Orange Canvas")
def getDescriptors(self, trans, examples, buckets):
def getDescriptors(self, translator, examples, buckets):
def getDescriptors(self, trans, examples, buckets): tcoeff_names = [] descriptors = [] # used for managing continuous atts for i in range(len(trans)): t = trans[i] tc = ["%s"%t.attr.name] d = t.description() #print tc[0],d if d[0]==0: # continuous values = self.bucketize(examples, t.attr, buckets) tc += values descript...
for i in range(len(trans)): t = trans[i]
proto_example = orange.Example(examples[0]) true_values = [] for i in range(len(translator.trans)): t = translator.trans[i]
def getDescriptors(self, trans, examples, buckets): tcoeff_names = [] descriptors = [] # used for managing continuous atts for i in range(len(trans)): t = trans[i] tc = ["%s"%t.attr.name] d = t.description() #print tc[0],d if d[0]==0: # continuous values = self.bucketize(examples, t.attr, buckets) tc += values descript...
return descriptors, tcoeff_names def getNames(self, descriptors, tcoeff_names):
return descriptors, tcoeff_names, true_values def getNames(self, descriptors, tcoeff_names, true_values):
def getDescriptors(self, trans, examples, buckets): tcoeff_names = [] descriptors = [] # used for managing continuous atts for i in range(len(trans)): t = trans[i] tc = ["%s"%t.attr.name] d = t.description() #print tc[0],d if d[0]==0: # continuous values = self.bucketize(examples, t.attr, buckets) tc += values descript...
return coeff_names,total,contins def getBasis(self, total,xcoeffs,contins, coeff_names):
return coeff_names,total,contins,tr_values def getBasis(self, total,xcoeffs,contins, coeff_names, tr_values):
def getNames(self, descriptors, tcoeff_names): # filter the coeff_names using these masked descriptors coeff_names = [] cur_i = -1 contins = [] total = 0 for (a,b) in descriptors: if cur_i == a: coeff_names[-1].append(tcoeff_names[a][b+1]) total += 1 else: if b == -1: # continuous contins.append(len(coeff_names)) coeff...
v = coeff_names[i][k+1]
v = tr_values[i][k]
def getBasis(self, total,xcoeffs,contins, coeff_names): # create the basis vectors for each attribute basis = Numeric.identity((total), Numeric.Float) # fix up the continuous attributes in coeffs (duplicate) and in basis (1.0 -> value[i]) x = Numeric.ones((total,), Numeric.Float) coeffs = [] lookup = [] conti = 0 j = ...
(descriptors,prevnames) = self.getDescriptors(classifier.translator.trans,examples,buckets)
(descriptors,prevnames,trans_values) = self.getDescriptors(classifier.translator,examples,buckets)
def __call__(self,classifier,examples, buckets): # skip domain translation and masking robustc = classifier.classifier primitivec = robustc.classifier beta = -primitivec.beta[0]
(coeff_names, total, contins) = self.getNames(descriptors, prevnames)
(coeff_names, total, contins, tr_values) = self.getNames(descriptors, prevnames, trans_values)
def __call__(self,classifier,examples, buckets): # skip domain translation and masking robustc = classifier.classifier primitivec = robustc.classifier beta = -primitivec.beta[0]
(basis,lookup,nlookup,coeffs) = self.getBasis(total, xcoeffs, contins, coeff_names)
(basis,lookup,nlookup,coeffs) = self.getBasis(total, xcoeffs, contins, coeff_names, tr_values)
def __call__(self,classifier,examples, buckets): # skip domain translation and masking robustc = classifier.classifier primitivec = robustc.classifier beta = -primitivec.beta[0]
(descriptors,prevnames) = self.getDescriptors(classifier.translate.trans,examples,buckets) (coeff_names, total, contins) = self.getNames(descriptors, prevnames)
(descriptors,prevnames,trans_values) = self.getDescriptors(classifier.translate,examples,buckets) (coeff_names, total, contins, tr_values) = self.getNames(descriptors, prevnames, trans_values)
def __call__(self,classifier,examples, buckets): if classifier.model['kernel_type'] != 0: raise "Use SVM with a linear kernel." if classifier.model["svm_type"] != 0: raise "Use ordinary SVM classification." if classifier.model["nr_class"] != 2: raise "This is not SVM with a binary class."
if classifier.model["label"][0] == 0: beta = -beta xcoeffs = [-x for x in xcoeffs] (basis,lookup,nlookup,coeffs) = self.getBasis(total, xcoeffs, contins, coeff_names)
(basis,lookup,nlookup,coeffs) = self.getBasis(total, xcoeffs, contins, coeff_names, tr_values)
def __call__(self,classifier,examples, buckets): if classifier.model['kernel_type'] != 0: raise "Use SVM with a linear kernel." if classifier.model["svm_type"] != 0: raise "Use ordinary SVM classification." if classifier.model["nr_class"] != 2: raise "This is not SVM with a binary class."
length = Numeric.sqrt(Numeric.dot(n,n)) ilength = 1.0/length n *= ilength beta *= ilength self.probfunc = lambda x:probfunc(x*length)
self.probfunc = lambda x:probfunc(x)
def __init__(self, examples, classifier, dimensions = 2, buckets = 3, getpies = 0, getexamples = 1): # error detection if len(examples.domain.classVar.values) != 2: raise "The domain does not have a binary class. Binary class is required."
t = orange.ExampleTable('c:/proj/domains/breast-miss.tab')
t = orange.ExampleTable('c:/proj/domains/d_pima.tab')
def printpie(e,p): x = 0 for i in range(len(m.coeff_names)): for j in m.coeff_names[i][1:]: if e[x] > 0.001: print '\t%2.1f%% : '%(100*e[x]),m.coeff_names[i][0],'=', if type(j)==type(1.0): print t[idx][m.coeff_names[i][0]] # continuous else: print j # discrete x += 1 if e[x] > 0.001: print '\t%2.1f%% : '%(100*e[x]),"BA...
sizeDlg = OWChooseImageSizeDlg(self, "", TRUE) sizeDlg.exec_loop() if sizeDlg.result() != QDialog.Accepted: return if sizeDlg.sizeOriginal.isChecked(): size = self.size() elif sizeDlg.size400.isChecked(): size = QSize(400,400) elif sizeDlg.size600.isChecked(): size = QSize(600,600) elif sizeDlg.size800.isChecked(): si...
self.sizeDlg = OWDlgs.OWChooseImageSizeDlg(self) self.sizeDlg.disconnect(self.sizeDlg.okButton, SIGNAL("clicked()"), self.sizeDlg.accept) self.sizeDlg.connect(self.sizeDlg.okButton, SIGNAL("clicked()"), self.saveToFileAccept) self.sizeDlg.exec_loop() def saveToFileAccept(self):
def saveToFile(self): sizeDlg = OWChooseImageSizeDlg(self, "", TRUE) sizeDlg.exec_loop() if sizeDlg.result() != QDialog.Accepted: return
if not sizeDlg.allSizes.isChecked(): self.saveToFileDirect(fileName, ext, size) else: dirName, shortFileName = os.path.split(fileName) if not os.path.isdir(dirName + "\\400\\"): os.mkdir(dirName + "\\400\\") if not os.path.isdir(dirName + "\\600\\"): os.mkdir(dirName + "\\600\\") if not os.path.isdir(dirName + "\\800\\...
self.saveToFileDirect(fileName, ext, self.sizeDlg.getSize()) QDialog.accept(self.sizeDlg)
def saveToFile(self): sizeDlg = OWChooseImageSizeDlg(self, "", TRUE) sizeDlg.exec_loop() if sizeDlg.result() != QDialog.Accepted: return
def saveToFileDirect(self, fileName, ext, size = QSize()):
def saveToFileDirect(self, fileName, ext, size):
def saveToFileDirect(self, fileName, ext, size = QSize()): if self.graphs == []: return count = self.shownAttrCount attrNameSpace = 30 dist = 4 topOffset = 5 if size.isEmpty(): size = self.graphs[0].size() size = QSize(size.width()*count + attrNameSpace + count*dist + topOffset, size.height()*count + attrNameSpace + co...
b=OWGUI.widgetBox(self.controlArea, self, "Options")
b=OWGUI.widgetBox(self.controlArea,"Options")
def __init__(self, parent=None, signalManager=None, name="SVM"): OWWidget.__init__(self, parent, signalManager, name) self.inputs=[("Example Table", ExampleTable, self.cdata)] self.outputs=[("Learner", orange.Learner),("Classifier", orange.Classifier),("Support Vectors", ExampleTable)]
OWGUI.button(b,self,"&Apply settings", callback=self.applySettings)
self.nomogramBox=OWGUI.checkBox(b, self, "nomogram", "For nomogram if posible") OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings)
def __init__(self, parent=None, signalManager=None, name="SVM"): OWWidget.__init__(self, parent, signalManager, name) self.inputs=[("Example Table", ExampleTable, self.cdata)] self.outputs=[("Learner", orange.Learner),("Classifier", orange.Classifier),("Support Vectors", ExampleTable)]
if self.data:
if self.nomogram and self.data and self.data.domain.classVar.varType==orange.VarTypes.Discrete and \ len(self.data.domain.classVar.values)==2 and self.kernel_type==0: import orngLR_Jakulin self.learner=orngSVM.BasicSVMLearner() for attr in ("name", "shrinking"): setattr(self.learner, attr, getattr(self, attr)) for attr...
def applySettings(self): self.learner=orngSVM.SVMLearner() for attr in ("name", "kernel_type", "degree", "shrinking"): setattr(self.learner, attr, getattr(self, attr))
d=orange.ExampleTable("../../doc/datasets/housing.tab")
d=orange.ExampleTable("../../doc/datasets/tic_tac_toe.tab")
def applySettings(self): self.learner=orngSVM.SVMLearner() for attr in ("name", "kernel_type", "degree", "shrinking"): setattr(self.learner, attr, getattr(self, attr))
master.controledAttributes.append((value, CallFront_comboBox(combo)))
if sendSelectedValue: master.controledAttributes.append((value, CallFront_comboBox(combo, valueType))) else: master.controledAttributes.append((value, CallFront_comboBox(combo)))
def comboBox(widget, master, value, box=None, items=None, tooltip=None, callback=None, sendSelectedValue = 0, valueType = str): if box: hb = QHGroupBox(box, widget) else: hb = widget if tooltip: QToolTip.add(hb, tooltip) combo = QComboBox(hb) if items: for i in items: combo.insertItem(str(i)) if len(items)>0: if sendS...
def __init__(self, control): self.control = control def __call__(self, value): for i in range(self.control.count()): if str(self.control.text(i)) == value: self.control.setCurrentItem(i) return
def __init__(self, control, valType = None): self.control = control self.valType = valType def __call__(self, value): if self.valType: for i in range(self.control.count()): if self.valType(str(self.control.text(i))) == value: self.control.setCurrentItem(i) return print "unable to set ", self.control, " to value ", val...
def __init__(self, control): self.control = control
ContextHandler.settingsToWidget(self, widget, context)
ContextHandler.settingsFromWidget(self, widget, context)
def settingsFromWidget(self, context, widget): ContextHandler.settingsToWidget(self, widget, context) context.values = {} for field in self.fields: if not field.flags & self.List: self.saveLow(context, widget, field.name, mygetattr(widget, field.name)) else: context.values[field.name] = mygetattr(widget, field.name) if...
contextHandlers = {"": DomainContextHandler("", ["methods"], False, False, False, False)}
contextHandlers = {"": DomainContextHandler("", ["methods"], False, False, False, False, matchValues = DomainContextHandler.MatchValuesAttributes)}
def focusOutEvent(self, *e): self.callback()
self.indiType = self.data and self.methods.get(self.data.domain[self.selectedAttr].name, (0, ""))[0] or 0
if self.data: attr = self.data.domain[self.selectedAttr] self.indiType, value = self.methods.get(attr.name, False) or (-1, "") if self.indiType >= 0: if attr.varType == orange.VarTypes.Discrete: self.indiValueCtrl.setCurrentItem(value) else: self.indiValueCtrl.setText(value)
def setIndiType(self): self.indiType = self.data and self.methods.get(self.data.domain[self.selectedAttr].name, (0, ""))[0] or 0
self.data = {} self.showMetas = True
self.data = {} self.showMetas = {}
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table")
self.infoEx = QLabel('No data loaded.', infoBox)
self.infoEx = QLabel('No data on input.', infoBox)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table")
self.btnResetSort = QPushButton("Reset Sorting", boxSettings)
self.btnResetSort = QPushButton("Restore Original Order", boxSettings)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table")
self.connect(self.tabs,SIGNAL("currentChanged(QWidget*)"),self.updateInfo)
self.connect(self.tabs,SIGNAL("currentChanged(QWidget*)"),self.tabClicked)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table")
def updateInfo(self, qTableInstance): """Updates the info box when a tab is clicked. """ self.set_info(self.data.get(self.table2id.get(qTableInstance,None),None))
if len(self.data) == 0: self.cbShowMeta.setEnabled(False) def tabClicked(self, qTableInstance): """Updates the info box and showMetas checkbox when a tab is clicked. """ id = self.table2id.get(qTableInstance,None) self.set_info(self.data.get(id,None)) show_col = self.showMetas.get(id,None) if show_col: self.cbShowMet...
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: if self.data.has_key(id): # remove existing table self.data.pop(id)...