rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
t = time.clock() | def parse_stream(self, stream): t = time.clock() self._setup_handlers() self._parser = expat.ParserCreate() self._parser.StartElementHandler = self._start_element_handler self._parser.EndElementHandler = self._end_element_handler self._stream = stream self._progress = util.ProgressFactory("Loading XML...", self._stream... | |
print "Time:", time.clock() - t | def parse_stream(self, stream): t = time.clock() self._setup_handlers() self._parser = expat.ParserCreate() self._parser.StartElementHandler = self._start_element_handler self._parser.EndElementHandler = self._end_element_handler self._stream = stream self._progress = util.ProgressFactory("Loading XML...", self._stream... | |
Py_DECREF(list); | [[def switch(layer, args)]] switch(get_image_combination([[images[layer].pyname]])) { [[for type in images[layer].pixel_types]] [[exec current = '*((' + type + '*)' + images[layer].name + ')']] case [[type.upper()]]: [[if layer == len(images) - 1]] [[if not function.return_type is None]] return_value = [[end]] [[functi... | |
k.load_settings("c:/Documents and Settings/Karl MacMillan/Desktop/default.xml") generate_features_list(glyphs, k.feature_functions) forest = distance.unique_distances(glyphs) | forest = k.unique_distances(glyphs) | def create_graph(glyphs, ratio): import gamera.knn k = gamera.knn.kNN() k.load_settings("c:/Documents and Settings/Karl MacMillan/Desktop/default.xml") generate_features_list(glyphs, k.feature_functions) forest = distance.unique_distances(glyphs) #forest = create_forest(glyphs) num_nodes = len(glyphs) next = 1 g = Grap... |
import traceback traceback.print_stack() | def _init_gamera(): import traceback traceback.print_stack() global _gamera_initialised if _gamera_initialised: return _gamera_initialised = True import plugin, gamera_xml, sys # Create the default functions for the menupl for method in ( plugin.PluginFactory( "load_image", "File", plugin.ImageType(ALL, "image"), plugi... | |
unions = [] | def _pregroup(self, glyphs, function): from gamera import graph G = graph.Undirected() G.add_nodes(glyphs) progress = util.ProgressFactory("Pre-grouping glyphs...", len(glyphs)) try: equivalencies = {} group_no = 0 for i in range(len(glyphs)): gi = glyphs[i] for j in range(i + 1, len(glyphs)): gj = glyphs[j] if functio... | |
self.unions.append(union) union.properties.root_number = self.root_number | def _evaluate_subgroup(self, subgroup): import image_utilities if len(subgroup) > 1: union = image_utilities.union_images(subgroup) self.unions.append(union) ### union.properties.root_number = self.root_number ### classification = self.guess_glyph_automatic(union) classification_name = classification[0][1] if (classifi... | |
return 0 | return 0.0 | def _evaluate_subgroup(self, subgroup): import image_utilities if len(subgroup) > 1: union = image_utilities.union_images(subgroup) self.unions.append(union) ### union.properties.root_number = self.root_number ### classification = self.guess_glyph_automatic(union) classification_name = classification[0][1] if (classifi... |
self.root_number = 0 | def _find_group_unions(self, G, evaluate_function, max_parts_per_group=5): self.root_number = 0 ### import image_utilities progress = util.ProgressFactory("Grouping glyphs...", G.nsubgraphs) try: found_unions = [] for root in G.get_subgraph_roots(): self.root_number += 1 ### best_grouping = G.optimize_partitions( root,... | |
self.root_number += 1 | def _find_group_unions(self, G, evaluate_function, max_parts_per_group=5): self.root_number = 0 ### import image_utilities progress = util.ProgressFactory("Grouping glyphs...", G.nsubgraphs) try: found_unions = [] for root in G.get_subgraph_roots(): self.root_number += 1 ### best_grouping = G.optimize_partitions( root,... | |
classification_state = image.classification_state | def Draw(self, grid, attr, dc, rect, row, col, isSelected): dc.BeginDrawing() dc.SetOptimization(True) view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], v... | |
version = [int(x) for x in docutils.__version__.split(".")] | version = tuple([int(x) for x in docutils.__version__.split(".")]) | def do_docstring(obj, name): doc_string = inspect.getdoc(obj) if doc_string is None: text = "[Not documented]\n\n" else: text = doc_string + "\n\n" content = docutils.statemachine.string2lines(text, convert_whitespace=1) if not options.has_key('no_title'): title_text = "``%s``" % name textnodes, messages = state.inline... |
return unicodedata.lookup(id_name) | return unicodedata.lookup(name) | def name_lookup_unicode(id_name): name = id_name.replace(".", " ") name = name.upper() try: return unicodedata.lookup(id_name) except KeyError: print "ERROR: Name not found:", id_name return "" |
print "ERROR: Name not found:", id_name | print "ERROR: Name not found:", name | def name_lookup_unicode(id_name): name = id_name.replace(".", " ") name = name.upper() try: return unicodedata.lookup(id_name) except KeyError: print "ERROR: Name not found:", id_name return "" |
if (%(pysymbol)s_seq) | if (%(pysymbol)s_seq == NULL) | def from_python(self): return """ const char* type_error_%(name)s = "Argument '%(name)s' must be an iterable of images."; PyObject* %(pysymbol)s_seq = PySequence_Fast(%(pysymbol)s, type_error_%(name)s); if (%(pysymbol)s_seq) return 0; int %(symbol)s_size = PySequence_Fast_GET_SIZE(%(pysymbol)s_seq); %(symbol)s.resize(%... |
self._classifier.get_feature_functions()[0]] | ImageBase.get_feature_functions()[0]] | def _OnChangeSetOfFeatures(self, event): all_features = [x[0] for x in ImageBase.methods_flat_category("Features", ONEBIT)] all_features.sort() existing_features = [x[0] for x in self._classifier.get_feature_functions()[0]] feature_controls = [] for x in all_features: feature_controls.append( Check('', x, default=(x in... |
return Rect(int(o.ul_y - amount), int(o.ul_x - amount), int(o.nrows + amount * 2), int(o.ncols + amount * 2)) | return Rect(Point(int(o.ul_x-amount), int(o.ul_y - amount)), Dim(int(o.ncols + amount * 2), int(o.nrows + amount * 2))) | def Fudge(o, amount = FUDGE_AMOUNT): # For rectangles, just return a new rectangle that is slightly larger if isinstance(o, Rect): return Rect(int(o.ul_y - amount), int(o.ul_x - amount), int(o.nrows + amount * 2), int(o.ncols + amount * 2)) # For integers, return one of our "fudge number proxies" elif isinstance(o, in... |
font.SetPointSize(14) | pass | def __init__(self, toplevel, parent = None, id = -1, size = wxDefaultSize): self.toplevel = toplevel MultiImageWindow.__init__(self, parent, id, size) |
self.titlebar_button = wxButton(self, -1, "+", size=(16, 16)) | self.titlebar_button = wxButton(self, -1, "+") | def __init__(self, toplevel, parent = None, id = -1, size = wxDefaultSize): self.toplevel = toplevel MultiImageWindow.__init__(self, parent, id, size) |
lc.right.SameAs(self, wxRight, 0) | lc.right.SameAs(self.titlebar_button, wxLeft, 0) | def __init__(self, toplevel, parent = None, id = -1, size = wxDefaultSize): self.toplevel = toplevel MultiImageWindow.__init__(self, parent, id, size) |
lc.height.AsIs() lc.width.AsIs() | lc.height.SameAs(self.titlebar, wxHeight, 0) lc.width.SameAs(self.titlebar, wxHeight, 0) | def __init__(self, toplevel, parent = None, id = -1, size = wxDefaultSize): self.toplevel = toplevel MultiImageWindow.__init__(self, parent, id, size) |
if gui_util.are_you_sure_dialog(self._frame, | if gui_util.are_you_sure_dialog( | def _OnClearClassifierCollection(self, event): if self._classifier.is_dirty: if gui_util.are_you_sure_dialog(self._frame, "Are you sure you want to clear all glyphs in the classifier?"): self._classifier.clear_glyphs() else: self._classifier.clear_glyphs() self._classifier.is_dirty = False |
"Are you sure you want to quit without saving?", self._frame): | "Are you sure you want to quit without saving?"): | def _OnCloseWindow(self, event): if self.is_dirty: if not gui_util.are_you_sure_dialog( "Are you sure you want to quit without saving?", self._frame): event.Veto() return self._classifier.set_display(None) self.multi_iw.Destroy() self.single_iw.Destroy() self.splitterhr1.Destroy() self.splitterhr0.Destroy() self.splitt... |
self.text = wxTextCtrl(self, txID, style=wxTE_PROCESS_ENTER) | self.text = wxTextCtrl(self, txID, style=wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB) | def __init__(self, symbol_table, toplevel, parent = None, id = -1): wxPanel.__init__( self, parent, id, style=wxWANTS_CHARS|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE) self.toplevel = toplevel self._symbol_table = symbol_table self.SetAutoLayout(true) self.box = wxBoxSizer(wxVERTICAL) txID = NewId() self.text = wxText... |
EVT_TEXT_TAB(self, txID, self._OnTab) | def __init__(self, symbol_table, toplevel, parent = None, id = -1): wxPanel.__init__( self, parent, id, style=wxWANTS_CHARS|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE) self.toplevel = toplevel self._symbol_table = symbol_table self.SetAutoLayout(true) self.box = wxBoxSizer(wxVERTICAL) txID = NewId() self.text = wxText... | |
def _OnTab(self, evt): | def _OnKey(self, evt): find = self.text.GetValue() if evt.KeyCode() == WXK_TAB: | def _OnTab(self, evt): find = self._symbol_table.autocomplete(find) self.text.SetValue(find) self.text.SetInsertionPointEnd() |
def _OnKey(self, evt): find = self.text.GetValue() if evt.KeyCode() == WXK_TAB: self._OnTab(evt) | def _OnTab(self, evt): find = self._symbol_table.autocomplete(find) self.text.SetValue(find) self.text.SetInsertionPointEnd() | |
pkg = os.path.join(self.dist_dir, name + ".pkg") if os.path.exists(pkg): remove_tree(pkg) | def run (self): name = self.distribution.metadata.name version = self.distribution.metadata.version description = self.distribution.metadata.description self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.warn_dir = 0 log.info("installi... | |
log.info("Building %s.pkg..." % name) pm = buildpkg.PackageMaker(name, version, description) | log.info("Building %s.pkg..." % fullname) pm = buildpkg.PackageMaker(fullname, version, description) | def run (self): name = self.distribution.metadata.name version = self.distribution.metadata.version description = self.distribution.metadata.description self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.warn_dir = 0 log.info("installi... |
readmes = ['README', 'readme.txt', 'LICENSE', 'ACKNOWLEDGEMENTS'] for readme in readmes: if os.path.exists(readme): copy_file(readme, pkg_dir) | def run (self): name = self.distribution.metadata.name version = self.distribution.metadata.version description = self.distribution.metadata.description self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.warn_dir = 0 log.info("installi... | |
removals = [os.path.join(self.dist_dir, name + ".dmg"), os.path.join(self.dist_dir, "_%s.dmg" % name)] | removals = [os.path.join(self.dist_dir, fullname + ".dmg"), os.path.join(self.dist_dir, "_%s.dmg" % fullname)] | def run (self): name = self.distribution.metadata.name version = self.distribution.metadata.version description = self.distribution.metadata.description self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.warn_dir = 0 log.info("installi... |
log.info("Making %s.dmg..." % name) makedmg.make_dmg(pkg_dir, self.dist_dir, name) | log.info("Making %s.dmg..." % fullname) makedmg.make_dmg(pkg_dir, self.dist_dir, fullname) | def run (self): name = self.distribution.metadata.name version = self.distribution.metadata.version description = self.distribution.metadata.description self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.warn_dir = 0 log.info("installi... |
if wxIsBusy(): | while wxIsBusy(): | def OnBrowse(self, event): parent = self.text.GetParent() filename = gui_util.open_file_dialog(parent, self.extension) if filename: self.text.SetValue(filename) parent.Raise() if wxIsBusy(): wxEndBusyCursor() |
if wxIsBusy(): | while wxIsBusy(): | def OnBrowse(self, event): parent = self.text.GetParent() filename = gui_util.save_file_dialog(parent, self.extension) if filename: self.text.SetValue(filename) parent.Raise() if wxIsBusy(): wxEndBusyCursor() |
if wxIsBusy(): | while wxIsBusy(): | def OnBrowse(self, event): parent = self.text.GetParent() filename = gui_util.directory_dialog(self.text) if filename: self.text.SetValue(filename) parent.Raise() if wxIsBusy(): wxEndBusyCursor() |
for x in self._members_for_menu | for x in _members_for_menu | def members_for_menu(self): return ["%s: %s" % (x, getattr(self, x)) for x in self._members_for_menu if hasattr(self, x)] |
evaluate_function = _Classifier._evaluate_subgroup | evaluate_function = self._evaluate_subgroup | def group_list_automatic(self, glyphs, grouping_function=None, evaluate_function=None): if len(glyphs) == 0: return glyphs = [x for x in glyphs if x.classification_state != 3] splits, removed = self.classify_list_automatic(glyphs) glyphs = [x for x in glyphs if not x.get_main_id().startswith('split')] if grouping_funct... |
def _evaluate_subgroup(subgroup): | def _evaluate_subgroup(self, subgroup): | def _evaluate_subgroup(subgroup): import image_utilities if len(subgroup) > 1: union = image_utilities.union_images(subgroup) classification = self.guess_glyph_automatic(union) if (classification[0][1].startswith("split") or classification[0][1].startswith("skip")): return 0 else: return classification[0][0] return sub... |
_evaulate_subgroup = staticmethod(_evaluate_subgroup) | def _evaluate_subgroup(subgroup): import image_utilities if len(subgroup) > 1: union = image_utilities.union_images(subgroup) classification = self.guess_glyph_automatic(union) if (classification[0][1].startswith("split") or classification[0][1].startswith("skip")): return 0 else: return classification[0][0] return sub... | |
self.GetGridWindow().GetParent().Layout() | def resize_grid(self, do_auto_size=1): if not self.created: return wxBeginBusyCursor() self.BeginBatch() try: orig_rows = self.rows rows = int(max(ceil(float(len(self.list) - 1) / float(GRID_NCOLS)), 1)) cols = GRID_NCOLS self.DeleteRows(0, self.rows) self.AppendRows(rows) self.rows = rows self.cols = cols row_size = 1... | |
to_rle, from_rle] | to_rle, from_rle, iterate_black_horizontal_runs, iterate_black_vertical_runs, iterate_white_horizontal_runs, iterate_white_vertical_runs] | def __call__(self, length): warnings.warn("Use filter_wide_black_runs instead of filter_wide_runs.", DeprecationWarning) return _runlength.filter_wide_black_runs(self, length) |
def add_highlight_cc(self, cc): self._iw.id.add_highlight_cc(cc) | def add_highlight_cc(self, cc, color): self._iw.id.add_highlight_cc(cc, color) | def add_highlight_cc(self, cc): self._iw.id.add_highlight_cc(cc) |
font.SetPointSize(14) | if wxPlatform == '__WXMSW__': font.SetPointSize(10) else: font.SetPointSize(14) | def __init__(self, toplevel, parent = None, id = -1, size = wxDefaultSize): self.toplevel = toplevel MultiImageWindow.__init__(self, parent, id, size) |
def _SaveClassifierCollection(self, filename): try: self._classifier.to_xml_filename(filename) except gamera_xml.XMLError, e: gui_util.message("Saving classifier glyphs: " + str(e)) def _OnClearClassifierCollection(self, event): if self._classifier.is_dirty: if gui_util.are_you_sure_dialog(self._frame, "Are you sure y... | def _OnGenerateClassifierStats(self, event): from gamera import classifier_stats all_stats = [(x.title, x) for x in classifier_stats.all_stat_pages] all_stats.sort() stats_controls = [Check('', x[0], default=True) for x in all_stats] stats_controls.append(Directory('Stats directory')) dialog = Args( stats_controls, nam... | |
else len(args) == 2: | elif len(args) == 2: | def __call__(self, *args): if len(args) == 5: return _draw.draw_hollow_rect(self, *args) elif len(args) == 3: try: a = args[0] b = args[1] value = args[2] return _draw.draw_hollow_rect(self, a.y, a.x, b.y, b.x, value) except KeyError, AttributeError: pass else len(args) == 2: try: a = args[0] value = args[1] return _dr... |
**draw_filled_rect** (Point(*x1*, *y1*), Point(*x2*, *y2)) | **draw_filled_rect** (Point(*x1*, *y1*), Point(*x2*, *y2*)) | def __doc_example1__(images): from random import randint from gamera.core import Image image = Image(0, 0, 100, 100, RGB, DENSE) for i in range(10): image.draw_hollow_rect(randint(0, 100), randint(0, 100), randint(0, 100), randint(0, 100), RGBPixel(randint(0, 255), randint(0,255), randint(0, 255))) return image |
else len(args) == 2: | elif len(args) == 2: | def __call__(self, *args): if len(args) == 5: return _draw.draw_filled_rect(self, *args) elif len(args) == 3: try: a = args[0] b = args[1] value = args[2] return _draw.draw_filled_rect(self, a.y, a.x, b.y, b.x, value) except KeyError, AttributeError: pass else len(args) == 2: try: a = args[0] value = args[1] return _dr... |
*accuracy*: | *accuracy* = ``0.1``: | def __doc_example1__(images): from random import randint from gamera.core import Image image = Image(0, 0, 100, 100, RGB, DENSE) for i in range(10): image.draw_filled_rect(randint(0, 100), randint(0, 100), randint(0, 100), randint(0, 100), RGBPixel(randint(0, 255), randint(0,255), randint(0, 255))) return image |
print self.database | def change_feature_set(self, features): self.is_dirty = True if len(self.database): print self.database self.feature_functions = iter(self.database).next().get_feature_functions(features) self.generate_features(self.database) self.instantiate_from_images(self.database) | |
print name | def magic_import(name, globals_={}, locals_={}, fromlist=[]): if fromlist != None and "core" in fromlist: fromlist = list(fromlist) fromlist.remove("core") if (name[0] == '_' and name[1] != "_" and name != "_winreg") or name == "core" or name == "gamera.core": print name return None else: return std_import(name, glob... | |
printf(\"Could not load gamera.py - falling back to gameracore\n\"); | printf(\"Could not load gamera.py - falling back to gameracore\\n\"); | [[def switch(layer, args)]] switch(get_image_combination([[images[layer].name]], cc_type)) { [[for type in images[layer].pixel_types]] [[exec current = '*((' + type + '*)((RectObject*)' + images[layer].name + ')->m_x)']] case [[type.upper()]]: [[if layer == len(images) - 1]] [[if function.return_type != None]] return_v... |
PyErr_SetString(PyExc_RuntimeError, \"Unable to load gameracore.\"); | PyErr_SetString(PyExc_RuntimeError, \"Unable to load gameracore.\\n\"); | [[def switch(layer, args)]] switch(get_image_combination([[images[layer].name]], cc_type)) { [[for type in images[layer].pixel_types]] [[exec current = '*((' + type + '*)((RectObject*)' + images[layer].name + ')->m_x)']] case [[type.upper()]]: [[if layer == len(images) - 1]] [[if function.return_type != None]] return_v... |
PyErr_SetString(PyExc_RuntimeError, \"Unable to get module dictionary\"); | PyErr_SetString(PyExc_RuntimeError, \"Unable to get module dictionary\\n\"); | [[def switch(layer, args)]] switch(get_image_combination([[images[layer].name]], cc_type)) { [[for type in images[layer].pixel_types]] [[exec current = '*((' + type + '*)((RectObject*)' + images[layer].name + ')->m_x)']] case [[type.upper()]]: [[if layer == len(images) - 1]] [[if function.return_type != None]] return_v... |
output_file.write('\n') output_file.close() | [[def switch(layer, args)]] switch(get_image_combination([[images[layer].name]], cc_type)) { [[for type in images[layer].pixel_types]] [[exec current = '*((' + type + '*)((RectObject*)' + images[layer].name + ')->m_x)']] case [[type.upper()]]: [[if layer == len(images) - 1]] [[if function.return_type != None]] return_v... | |
[[ | def restore_import(): global std_import __builtins__['__import__'] = std_import | |
return 0;\ | return 0; | #ifndef _MSC_VER void init[[module_name]](void); |
return Cc(self, *args, **kwargs) | return Cc(self, self.label, *args, **kwargs) | def subimage(self, *args, **kwargs): """Creates a new view that is part of an existing image. |
self.class_names.sort(lambda x, y: cmp(x.lower(), y.lower())) | self.class_names.sort(lambda x, y: cmp(x[0].lower(), y[0].lower())) | def table_of_contents(self, classes): s = open(os.path.join(self.docgen.src_path, "classes.txt"), "w") s.write("=======\nClasses\n=======\n\n") s.write("Alphabetical\n-------------\n") self.class_names.sort(lambda x, y: cmp(x.lower(), y.lower())) letter = '~' first = True links = [] for name, combined_name in self.clas... |
return 1 return 0 | return True return False | def has_id_name(self, name): for confidence, id_name in self.id_name: if name == id_name: return 1 return 0 |
cls.last_directory, "", extensions, self._flags) | cls.last_directory, "", str(extensions), self._flags) | def __init__(self, parent, extensions="*.*", multiple=0): cls = self.__class__ if cls.last_directory is None: cls.last_directory = config.get("default_dir") self._flags = False if multiple: self._flags |= wxMULTIPLE self._multiple = True else: self._multiple = False wxFileDialog.__init__( self, parent, "Choose a file",... |
tmp_dc = wxMemoryDC() | def Draw(self, grid, attr, dc, rect, row, col, isSelected): view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], view_size[1])): return | |
try: color = self._colors[classification_state] except KeyError: color = wxColor(200, 200, 200) | color = self._colors[classification_state] | def Draw(self, grid, attr, dc, rect, row, col, isSelected): view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], view_size[1])): return |
x = int(rect.x + (rect.width - width) / 2) y = int(rect.y + (rect.height - height) / 2) | x = rect.x + (rect.width - width) / 2 y = rect.y + (rect.height - height) / 2 | def Draw(self, grid, attr, dc, rect, row, col, isSelected): view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], view_size[1])): return |
bmp = wxBitmapFromImage(wx_image) | bmp = wx_image.ConvertToBitmap() | def Draw(self, grid, attr, dc, rect, row, col, isSelected): view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], view_size[1])): return |
tmp_dc = wxMemoryDC() | def Draw(self, grid, attr, dc, rect, row, col, isSelected): view_start = grid.GetViewStart() view_units = grid.GetScrollPixelsPerUnit() view_size = grid.GetClientSize() if not rect.Intersects(wxRect( view_start[0] * view_units[0], view_start[1] * view_units[1], view_size[0], view_size[1])): return | |
self._flags = False | def __init__(self, parent, extensions="*.*", multiple=0): cls = self.__class__ if cls.last_directory is None: cls.last_directory = config.get("default_dir") self._flags = False if multiple: self._flags |= wxMULTIPLE self._multiple = True else: self._multiple = False wxFileDialog.__init__( self, parent, "Choose a file",... | |
subimage = self.image.subimage(y, x, h, w) | subimage = self.image.subimage(int(y), int(x), int(h), int(w)) | def PaintArea(self, x, y, w, h, check=1, dc=None): if not self.image: return if dc == None: dc = wxClientDC(self) self.draw_rubber(dc) redraw_rubber = 1 else: redraw_rubber = 0 # This needs to be created every time we call Paint, since its # address can (but in practice usually doesn't) change. tmpdc = wxMemoryDC() |
node['name'] = name state_machine.document.note_implicit_target(node, node) | version = [int(x) for x in docutils.__version__.split(".")] if version >= (0, 3, 9): node['names'] = [name] else: node['name'] = name state_machine.document.note_implicit_target(node) | def do_docstring(obj, name): doc_string = inspect.getdoc(obj) if doc_string is None: text = "[Not documented]\n\n" else: text = doc_string + "\n\n" content = docutils.statemachine.string2lines(text, convert_whitespace=1) if not options.has_key('no_title'): title_text = "``%s``" % name textnodes, messages = state.inline... |
state.nested_parse(content, 0, node) | state.nested_parse(content, content_offset, node) | def do_docstring(obj, name): doc_string = inspect.getdoc(obj) if doc_string is None: text = "[Not documented]\n\n" else: text = doc_string + "\n\n" content = docutils.statemachine.string2lines(text, convert_whitespace=1) if not options.has_key('no_title'): title_text = "``%s``" % name textnodes, messages = state.inline... |
y1, x1, y2, x1, value = args | y1, x1, y2, x2, value = args | def __call__(self, *args): if len(args) == 3: return _draw.draw_filled_rect(self, *args) elif len(args) == 2: try: a, value = args return _draw.draw_filled_rect(self, a.ul, a.lr, value) except KeyError, AttributeError: pass elif len(args) == 5: try: y1, x1, y2, x1, value = args result = _draw.draw_filled_rect(self, (x1... |
origin = self.GetViewStart() | origin = [x * self.scroll_amount for x in self.GetViewStart()] | def focus(self, subimages): scroll_amount = self.scroll_amount if not util.is_sequence(subimages): subimages = (subimages,) x1 = y1 = maxint x2 = y2 = 0 # Get a combined rectangle of all images in the list for image in subimages: x1 = min(image.page_offset_x(), x1) y1 = min(image.page_offset_y(), y1) x2 = max(image.pag... |
scale = self.scaling | scale = scaling | def scale(self, scale=None): scroll_amount = self.scroll_amount if scale == None: scale = self.scaling w = self.width * scale - 1 h = self.height * scale - 1 x = max(min(self.GetViewStart()[0] * scale / self.scaling + 1, w - self.GetSize().x) - 2, 0) y = max(min(self.GetViewStart()[1] * scale / self.scaling + 1, h - se... |
x = max(min(self.GetViewStart()[0] * scale / self.scaling + 1, | origin = [x * self.scroll_amount for x in self.GetViewStart()] x = max(min(origin[0] * scale / scaling + 1, | def scale(self, scale=None): scroll_amount = self.scroll_amount if scale == None: scale = self.scaling w = self.width * scale - 1 h = self.height * scale - 1 x = max(min(self.GetViewStart()[0] * scale / self.scaling + 1, w - self.GetSize().x) - 2, 0) y = max(min(self.GetViewStart()[1] * scale / self.scaling + 1, h - se... |
y = max(min(self.GetViewStart()[1] * scale / self.scaling + 1, | y = max(min(origin[1] * scale / scaling + 1, | def scale(self, scale=None): scroll_amount = self.scroll_amount if scale == None: scale = self.scaling w = self.width * scale - 1 h = self.height * scale - 1 x = max(min(self.GetViewStart()[0] * scale / self.scaling + 1, w - self.GetSize().x) - 2, 0) y = max(min(self.GetViewStart()[1] * scale / self.scaling + 1, h - se... |
x, y) | floor(x / scroll_amount), floor(y / scroll_amount)) self.Clear() | def scale(self, scale=None): scroll_amount = self.scroll_amount if scale == None: scale = self.scaling w = self.width * scale - 1 h = self.height * scale - 1 x = max(min(self.GetViewStart()[0] * scale / self.scaling + 1, w - self.GetSize().x) - 2, 0) y = max(min(self.GetViewStart()[1] * scale / self.scaling + 1, h - se... |
if hasattr(sys, 'winver'): def OnPaint(self, event): origin = [x * self.scroll_amount for x in self.GetViewStart()] if self.image: self.BeginDrawing() update_regions = self.GetUpdateRegion() rects = wxRegionIterator(update_regions) while rects.HaveRects(): ox = rects.GetX() / self.scaling oy = rects.GetY() / self.scal... | def OnPaint(self, event): if not self.image: return scaling = self.scaling origin = [x * self.scroll_amount for x in self.GetViewStart()] origin_scaled = [x / scaling for x in origin] update_regions = self.GetUpdateRegion() rects = wxRegionIterator(update_regions) while rects.HaveRects(): ox = rects.GetX() / scaling o... | def OnResize(self, event): size = self.GetSize() self.tmpDC.SelectObject(wxEmptyBitmap( size.GetWidth(), size.GetHeight())) self.tmpDC.SetPen(wxTRANSPARENT_PEN) event.Skip() self.scale() |
origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] | origin_scaled = [a / scaling for a in origin] size_scaled = [a / scaling for a in self.GetSizeTuple()] | def PaintArea(self, x, y, w, h, check=1): dc = wxPaintDC(self) dc.SetLogicalFunction(wxCOPY) origin = [a * self.scroll_amount for a in self.GetViewStart()] origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] if check: if ((x + w < origin_scaled[0]) and (y + h... |
self.tmpDC.SetUserScale(self.scaling, self.scaling) if (y + h > self.image.nrows): | self.tmpDC.SetUserScale(scaling, scaling) if (y + h >= self.height): | def PaintArea(self, x, y, w, h, check=1): dc = wxPaintDC(self) dc.SetLogicalFunction(wxCOPY) origin = [a * self.scroll_amount for a in self.GetViewStart()] origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] if check: if ((x + w < origin_scaled[0]) and (y + h... |
if (x + w > self.image.ncols): | if (x + w >= self.width): | def PaintArea(self, x, y, w, h, check=1): dc = wxPaintDC(self) dc.SetLogicalFunction(wxCOPY) origin = [a * self.scroll_amount for a in self.GetViewStart()] origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] if check: if ((x + w < origin_scaled[0]) and (y + h... |
fudge = int(self.scaling / 2.0) if self.scaling == 1: | fudge = int(scaling / 2.0) if scaling == 1: | def PaintArea(self, x, y, w, h, check=1): dc = wxPaintDC(self) dc.SetLogicalFunction(wxCOPY) origin = [a * self.scroll_amount for a in self.GetViewStart()] origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] if check: if ((x + w < origin_scaled[0]) and (y + h... |
dc.Blit(x * self.scaling - origin[0], y * self.scaling - origin[1], w * self.scaling, h * self.scaling, | dc.Blit(x * scaling - origin[0], y * scaling - origin[1], w * scaling, h * scaling, | def PaintArea(self, x, y, w, h, check=1): dc = wxPaintDC(self) dc.SetLogicalFunction(wxCOPY) origin = [a * self.scroll_amount for a in self.GetViewStart()] origin_scaled = [a / self.scaling for a in origin] size_scaled = [a / self.scaling for a in self.GetSizeTuple()] if check: if ((x + w < origin_scaled[0]) and (y + h... |
origin = self.GetViewStart() | origin = [x * self.scroll_amount for x in self.GetViewStart()] | def OnLeftDown(self, event): self.rubber_on = 1 self.draw_rubber() origin = self.GetViewStart() x = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) y = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) if (x > self.rubber_origin_x and x < self.rubber_origin_x + self.block_w): sel... |
self.rubber_origin_x = self.rubber_x2 = x self.rubber_origin_y = self.rubber_y2 = y | self.rubber_origin_x = self.rubber_x2 = int(x) self.rubber_origin_y = self.rubber_y2 = int(y) | def OnLeftDown(self, event): self.rubber_on = 1 self.draw_rubber() origin = self.GetViewStart() x = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) y = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) if (x > self.rubber_origin_x and x < self.rubber_origin_x + self.block_w): sel... |
origin = self.GetViewStart() self.rubber_x2 = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) self.rubber_y2 = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) | origin = [x * self.scroll_amount for x in self.GetViewStart()] self.rubber_x2 = int(min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1)) self.rubber_y2 = int(min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1)) | def OnLeftUp(self, event): if self.rubber_on: self.draw_rubber() origin = self.GetViewStart() self.rubber_x2 = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) self.rubber_y2 = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) self.draw_rubber() for i in self.click_callbacks: try:... |
origin = self.GetViewStart() | scaling = self.scaling origin = [x * self.scroll_amount for x in self.GetViewStart()] | def draw_rubber(self): dc = wxPaintDC(self) origin = self.GetViewStart() x = min(self.rubber_origin_x, self.rubber_x2) y = min(self.rubber_origin_y, self.rubber_y2) x2 = max(self.rubber_origin_x, self.rubber_x2) y2 = max(self.rubber_origin_y, self.rubber_y2) x = x * self.scaling - origin[0] y = y * self.scaling - origi... |
x = x * self.scaling - origin[0] y = y * self.scaling - origin[1] x2 = x2 * self.scaling - origin[0] y2 = y2 * self.scaling - origin[1] | x = x * scaling - origin[0] y = y * scaling - origin[1] x2 = x2 * scaling - origin[0] y2 = y2 * scaling - origin[1] | def draw_rubber(self): dc = wxPaintDC(self) origin = self.GetViewStart() x = min(self.rubber_origin_x, self.rubber_x2) y = min(self.rubber_origin_y, self.rubber_y2) x2 = max(self.rubber_origin_x, self.rubber_x2) y2 = max(self.rubber_origin_y, self.rubber_y2) x = x * self.scaling - origin[0] y = y * self.scaling - origi... |
origin = self.GetViewStart() self.rubber_x2 = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) self.rubber_y2 = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) | origin = [x * self.scroll_amount for x in self.GetViewStart()] self.rubber_x2 = int(min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1)) self.rubber_y2 = int(min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1)) | def OnMotion(self, event): if self.rubber_on: self.draw_rubber() origin = self.GetViewStart() self.rubber_x2 = min((event.GetX() + origin[0]) / self.scaling, self.image.ncols - 1) self.rubber_y2 = min((event.GetY() + origin[1]) / self.scaling, self.image.nrows - 1) self.draw_rubber() if self.dragging: self.Scroll( (sel... |
except IOError, e: print e | except: pass | def load_image(filename, compression = DENSE): """**load_image** (FileOpen *filename*, Choice *storage_format* = ``DENSE``) |
*input_filename*: The input Gamera XML filename *output_filename*: The output Gamera XML filename""" | *input_filename* The input Gamera XML filename *output_filename* The output Gamera XML filename""" | def strip_features(input_filename, output_filename): """**strip_features** (FileOpen *input_filename*, FileSave *output_filename*) |
faces = shell.faces style_face = config.options.shell.face for face in ('times', 'mono', 'helv', 'other'): faces[face] = style_face faces['lnsize'] = int(config.options.shell.size) - 2 faces['size'] = int(config.options.shell.size) self.setStyles(faces) | def __init__(self, main_win, parent, id, message): | |
self._database = util.CallbackList(database) | def __init__(self, database=[], features='all', perform_splits=True): """ | |
if (recursion_level > max_recursion) or len(self.database) == 0: | if (recursion_level > max_recursion): | def _classify_list_automatic(self, glyphs, max_recursion=10, recursion_level=0, progress=None): |
self._classifier.generate_features(glyphs) | for glyph in glyphs: self._classifier.generate_features(glyph) | def _SavePageCollection(self, filename, glyphs=None, with_features=True): if glyphs is None: glyphs = self.multi_iw.id.GetAllItems() self._classifier.generate_features(glyphs) try: gamera_xml.WriteXMLFile( glyphs=glyphs, symbol_table=self._symbol_table, with_features=with_features).write_filename(filename) except gamer... |
self._classifier.generate_features(glyphs) | for glyph in glyphs: self._classifier.generate_features(glyph) | def _OnSaveSelectedGlyphs(self, event): glyphs = self.get_all_selected()[0] if len(glyphs) == 0: gui_util.message("There are no selected glyphs.") return if gui_util.are_you_sure_dialog( ("There are %d selected glyphs.\n" + "Are you sure you want to save?") % len(glyphs)): filename = gui_util.save_file_dialog(self._fra... |
if not gui_util.are_you_sure_dialog("Editing glyphs have not been saved. Are you sure you wish to proceed?"): | if not gui_util.are_you_sure_dialog("Page glyphs have not been saved. Are you sure you wish to proceed?"): | def _OnOpenAndSegmentImage(self, event): if self.multi_iw.id.is_dirty: if not gui_util.are_you_sure_dialog("Editing glyphs have not been saved. Are you sure you wish to proceed?"): return segmenters = [x[0] for x in ImageBase.methods_flat_category("Segmentation", ONEBIT)] if self.default_segmenter == -1: self.default_... |
if not gui_util.are_you_sure_dialog("Editing glyphs have not been saved. Are you sure you wish to proceed?"): | if not gui_util.are_you_sure_dialog("Page glyphs have not been saved. Are you sure you wish to proceed?"): | def _OnSelectAndSegmentImage(self, event): if self.multi_iw.id.is_dirty: if not gui_util.are_you_sure_dialog("Editing glyphs have not been saved. Are you sure you wish to proceed?"): return segmenters = [x[0] for x in ImageBase.methods_flat_category("Segmentation", ONEBIT)] if self.default_segmenter == -1: self.defaul... |
self.progress_box.Update(min(100, int((float(num) / float(den)) * 100.0))) | def update(self, num, den): if not self.done: self.progress_box.Update(min(100, int((float(num) / float(den)) * 100.0))) if num >= den: self.done = 1 wxEndBusyCursor() self.progress_box.Destroy() | |
self.done = 1 | self.done = True | def update(self, num, den): if not self.done: self.progress_box.Update(min(100, int((float(num) / float(den)) * 100.0))) if num >= den: self.done = 1 wxEndBusyCursor() self.progress_box.Destroy() |
for col in xrange(self.cols, -1, -1): for row in xrange(self.rows, -1, -1): | for row in xrange(0, self.cols): for col in xrange(0, self.rows): | def do_auto_move(self, state): # if auto-moving is turned off, just return if state == []: return |
Pixel("value")]) def __call__(self, *args): if len(args) == 9: | Pixel("value"), Float("accuracy", default=0.1)]) def __call__(self, *args): if len(args) == 10: | def __doc_example1__(): from random import randint from gamera.core import Image image = Image(0, 0, 100, 100, RGB, DENSE) for i in range(10): image.draw_filled_rect(randint(0, 100), randint(0, 100), randint(0, 100), randint(0, 100), RGBPixel(randint(0, 255), randint(0,255), randint(0, 255))) return image |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.