rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
sibling = model.get_value(model.iter_next(iter), 2)
if not model.iter_next(iter) == None: sibling = model.get_value(model.iter_next(iter), 2) else: sibling = None
def drag_data_received_data(treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = selection.data global src_iter temp_dict = {} if data[:4]=="http": data = string.split(data, "?") data[1] = string.split(data[1], "&") for row in data[1]: key, content = string.split(row, "=") content = str...
id = libDenu.moveEntry(data[1], parent, sibling, data[0], dest) entry = libDenu.viewEntry(id, dest) if entry[entry.keys()[0]]['name'].has_key(config.get('DEFAULT', 'locale')): name = entry[entry.keys()[0]]['name'][config.get('DEFAULT', 'locale')] else: name = entry[entry.keys()[0]]['name']["en"] if position == gtk.TREE...
if not int(data[1]) == sibling and int(data[1]) != parent: id = libDenu.moveEntry(data[1], parent, sibling, data[0], dest) entry = libDenu.viewEntry(id, dest) if entry[entry.keys()[0]]['name'].has_key(config.get('DEFAULT', 'locale')): name = entry[entry.keys()[0]]['name'][config.get('DEFAULT', 'locale')] else: name = e...
def drag_data_received_data(treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = selection.data global src_iter temp_dict = {} if data[:4]=="http": data = string.split(data, "?") data[1] = string.split(data[1], "&") for row in data[1]: key, content = string.split(row, "=") content = str...
elif position == gtk.TREE_VIEW_DROP_AFTER:
elif position == gtk.TREE_VIEW_DROP_AFTER and int(data[1]) != parent and int(data[1]) != sibling:
def drag_data_received_data(treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = selection.data global src_iter temp_dict = {} if data[:4]=="http": data = string.split(data, "?") data[1] = string.split(data[1], "&") for row in data[1]: key, content = string.split(row, "=") content = str...
elif position == gtk.TREE_VIEW_DROP_INTO_OR_AFTER or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE:
elif (position == gtk.TREE_VIEW_DROP_INTO_OR_AFTER or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE) and int(data[1]) != parent and int(data[1]) != sibling:
def drag_data_received_data(treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = selection.data global src_iter temp_dict = {} if data[:4]=="http": data = string.split(data, "?") data[1] = string.split(data[1], "&") for row in data[1]: key, content = string.split(row, "=") content = str...
if data[0] == "menu": if menustore.iter_has_child(src_iter): copy_rows(new_iter, src_iter, menustore, model) elif data[0] == "installed": if installedstore.iter_has_child(src_iter): copy_rows(new_iter, src_iter, installedstore, model) if data[0] == "menu": menustore.remove(src_iter)
if int(data[1]) != sibling and int(data[1]) != parent: if data[0] == "menu": if menustore.iter_has_child(src_iter): copy_rows(new_iter, src_iter, menustore, model) elif data[0] == "installed": if installedstore.iter_has_child(src_iter): copy_rows(new_iter, src_iter, installedstore, model) if data[0] == "menu": menustor...
def drag_data_received_data(treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = selection.data global src_iter temp_dict = {} if data[:4]=="http": data = string.split(data, "?") data[1] = string.split(data[1], "&") for row in data[1]: key, content = string.split(row, "=") content = str...
if config.getboolean('DEFAULT', 'debug'): print "Connecting to gui."
debugPrint("Connecting to gui.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Detecting WM(s)."
debugPrint("Detecting WM(s).")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print wm + " is installed."
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Opening installed."
debugPrint("Opening installed.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Opening running menu."
debugPrint("Opening running menu.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Opening " + running[0] + " menu."
debugPrint("Opening " + running[0] + " menu.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Generating installed tree."
debugPrint("Generating installed tree.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
if config.getboolean('DEFAULT', 'debug'): print "Done."
debugPrint("Done.")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
print "Config is:" config.write(sys.stdout)
debugPrint("Config is:") debugPrint("---BEGIN---") config.write(sys.stderr) debugPrint("--- END ---")
def copy_rows(parent_iter, src_iter, srcmodel, destmodel): iter = srcmodel.iter_children(src_iter) while iter != None: icon, name, id = srcmodel.get(iter, 0, 1, 2) parent = destmodel.append(parent_iter, [icon, name, id]) if srcmodel.iter_has_child(iter): copy_rows(parent, iter, srcmodel, destmodel) iter = srcmodel.iter...
print xml.get_widget("add_command").flags() xml.get_widget("add_command").hide() print xml.get_widget("add_command").flags()
if xml.get_widget("add_command_cont").get_property('visible'): xml.get_widget("add_command_cont").hide() elif new_type == 1: if not xml.get_widget("add_command_cont").get_property('visible'): xml.get_widget("add_command_cont").show() elif new_type == 2: if not xml.get_widget("add_command_cont").get_property('visible'):...
def change_add_state(widget): new_type = widget.get_active() if new_type == 0: print xml.get_widget("add_command").flags() xml.get_widget("add_command").hide() print xml.get_widget("add_command").flags()
viewxml = gtk.glade.XML('denu/denu.glade', 'view_window')
viewxml = gtk.glade.XML(config['default'] + 'denu/denu.glade', 'view_window')
def view_entry(widget): viewxml = gtk.glade.XML('denu/denu.glade', 'view_window') menu_iterList = [] def createMenuList(model, path, iter): menu_iterList.append(iter) treeselection = menuview.get_selection() treeselection.selected_foreach(createMenuList) installed_iterList = [] def createInstalledList(model, path, iter...
v=defineArray(2, [(0, 0), (0, 0), (0, 0)]))
v=defineArray(Array_f, 2))
def Zeroes(): return buildGeometry( GL_TRIANGLES, v=defineArray(2, [(0, 0), (0, 0), (0, 0)]))
resultSet = ResultSet()
resultSet = ResultValues()
def makeResultSet(resultSet): results = [Result(d.name, value, d.units) for value, d in zip(resultSet, test.getResultDescs())] return ResultSet(resultName, results)
print >> plot, 'set ylabel "Normalized to %s"' % normalizeBy.title
print >> plot, 'set ylabel "Normalized to %s"' % normalizeTitle
def _generateActualGraph(filename, graphLineList, measured, xunits=None, graphType=GraphType.BAR, normalizeBy=None): ### Make several checks that the data is combined the right way. # Empty lists aren't allowed. assert len(graphLineList) >= 1 assert len(graphLineList[0].resultSetList) >= 1 lineCount = len(graphLineLi...
graph.reset()
graph("e\n") raw_input("press return to continue...\n")
def GraphData(self, path, graph): file = eval(open(path).read()) choice = self.choice1.GetSelection() if choice == -1: choice = 0 size = len(file['Test']['GraphLines'][0]['ResultSet']) count = 0 while count < size: name = file['Test']['GraphLines'][0]['ResultSet'][count]['Name'] result = file['Test']['GraphLines'][0]['...
runTests(filename, testList, 5, "VertexRate")
results = runTests(testList, 5) generateBarGraph(filename, results, 'VertexRate', xlabel='Indices Used')
def run(filename, testtype): testList = [] for i in theRange: repeat = range(i) indices = defineArray(Array_ui, 1, repeat) geo = buildGeometry(GL_TRIANGLE_STRIP, v=v, i=indices) test = testtype(str(i), geo) testList.append(test) runTests(filename, testList, 5, "VertexRate")
TestType = VertexArrayTest finishAction = FinishAction() v = defineArray(Array_f, 2, (5, 5) + (5, 6) + (6, 6)) geo = buildGeometry((GL_TRIANGLES, 1024), v=defineArray(Array_f, 2))
def runStateChange(suffix, state1, state2): TestType = VertexArrayTest finishAction = FinishAction() v = defineArray(Array_f, 2, (5, 5) + (5, 6) + (6, 6)) geo = buildGeometry((GL_TRIANGLES, 1024), v=defineArray(Array_f, 2)) testNoChange = TestType("No Change", geo) testChange = TestType("Change"...
results = runTestsRange(testList, runFor, 'batchSize', range)
def setBatchSize(test, size): test.geometry.batches[0].batchSize = size results = runTestsRange(testList, runFor, setBatchSize, range)
def runStateChange(suffix, state1, state2): TestType = VertexArrayTest finishAction = FinishAction() v = defineArray(Array_f, 2, (5, 5) + (5, 6) + (6, 6)) geo = buildGeometry((GL_TRIANGLES, 1024), v=defineArray(Array_f, 2)) testNoChange = TestType("No Change", geo) testChange = TestType("Change"...
GLError = Exception
GLError = RuntimeError
def makeResultSet(resultSet): results = [Result(d.name, value, d.units) for value, d in zip(resultSet, test.getResultDescs())] return ResultSet(resultName, results)
print e.value()
print e
def makeResultSet(resultSet): results = [Result(d.name, value, d.units) for value, d in zip(resultSet, test.getResultDescs())] return ResultSet(resultName, results)
results = runTestsRange(testList, 1, 'batchSize', range)
results = runTestsRange(testList, runFor, 'batchSize', range)
def runStateChange(suffix, state1, state2): TestType = VertexArrayTest finishAction = FinishAction() v = defineArray(Array_f, 2, (5, 5) + (5, 6) + (6, 6)) geo = buildGeometry(GL_TRIANGLES, v=defineArray(Array_f, 2)) testNoChange = TestType("No Change", geo) testChange = TestType("Change", ...
'''
def buildFragmentShaderSS(source): shaders = ShaderList() shaders[:] = [FragmentShader(source)] program = Program(shaders) state = ShaderState(program) return StateSet(state)
buildFragmentShaderSS('void main() { gl_FragColor = vec3(1, 1, 1); }'), buildFragmentShaderSS('void main() { gl_FragColor = vec3(0, 0, 0); )'))
buildFragmentShaderSS('void main() { gl_FragColor = vec4(1, 1, 1, 1); }'), buildFragmentShaderSS('void main() { gl_FragColor = vec4(0, 0, 0, 1); }'))
def buildFragmentShaderSS(source): shaders = ShaderList() shaders[:] = [FragmentShader(source)] program = Program(shaders) state = ShaderState(program) return StateSet(state)
def buildGeometry(type, v=None, c=None, n=None, t=None, i=None): geo = Geometry(type)
def buildGeometry(primtype, v=None, c=None, n=None, t=None, i=None): geo = Geometry(primtype) if i: geo.indices = i
def buildGeometry(type, v=None, c=None, n=None, t=None, i=None): geo = Geometry(type) if v: geo.vertices = v if c: geo.colors = c if n: geo.normals = n if t: geo.texcoords = t if i: geo.indices = i return geo
if t: geo.texcoords = t if i: geo.indices = i
if t: if type(t) is not list: t = [t] geo.texcoords[:] = t
def buildGeometry(type, v=None, c=None, n=None, t=None, i=None): geo = Geometry(type) if v: geo.vertices = v if c: geo.colors = c if n: geo.normals = n if t: geo.texcoords = t if i: geo.indices = i return geo
sys.exit(run())
sys.exit(run()[0])
def run(args = None): if args is not None: import sys sys.argv = args import doctest, test_cross_module return doctest.testmod(test_cross_module)
};
}
typedef base_class_info derived_class_info;
// Extract from obj a constant reference to the PtrType object which is holding a T. // If obj is None, the reference denotes a default-constructed PtrType
// Extract from obj a reference to the PtrType object which is holding a // T. If it weren't for auto_ptr, it would be a constant reference. Do not // modify the referent except by copying an auto_ptr! If obj is None, the // reference denotes a default-constructed PtrType
typedef std::vector<boost::python::detail::instance_holder_base*>::const_iterator iterator;
static const PtrType& smart_ptr_value(PyObject* obj, boost::python::type<PtrType>)
static PtrType& smart_ptr_value(PyObject* obj, boost::python::type<PtrType>)
typedef std::vector<boost::python::detail::instance_holder_base*>::const_iterator iterator;
friend const std::auto_ptr<T>& from_python(PyObject* p, boost::python::type<std::auto_ptr<T> >)
friend std::auto_ptr<T> from_python(PyObject* p, boost::python::type<std::auto_ptr<T> >)
typedef std::vector<boost::python::detail::instance_holder_base*>::const_iterator iterator;
>>> df = DerivedFromFoo() >>> dir(df) []
... def fred(self):
>>> dir(db) [] >>> dir(DerivedFromBase) ['__doc__', '__module__', 'fred', 'i_am_derived_from_base']
... def fred(self):
... unicode ... catch:
... if unicode: pass ... except:
... def rewrap_const_reference_unsigned_long_long(x): return long(x)
... '__del__', '__doc__', '__init__', '__module__', 'add_len',
... 'Foo_A', 'Foo_B', '__del__', '__doc__', '__init__', '__module__', 'add_len',
... def fred(self):
TYPE_COUNT = 0
def SetDeclarations(self, declarations): Exporter.SetDeclarations(self, declarations) if self.declarations: self.enum = self.GetDeclaration(self.info.name) else: self.enum = None
full_name = namespaces.pyste + 'UniqueInt<%d>' % EnumExporter.TYPE_COUNT EnumExporter.TYPE_COUNT += 1
full_name = namespaces.pyste + 'UniqueInt<%d>' % unique_number
def Export(self, codeunit, exported_names): if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unnamed_enum = True self.ExportUniqueInt(codeunit)...
>>> print_xvec(v) [ yaba c d foo ]
>>> print_xvec(sl) [ yaba c ]
>>> def print_xvec(xvec):
//
#ifndef RETURNING_DWA20011201_HPP
member_function = ''' template <class A0%(, class A%+%)> static PyObject* call(R (A0::*pmf)(%(A%+%:, %))%1, PyObject* args, PyObject* /* keywords */ )
member_function = ''' template <class P, class A0%(, class A%+%)> static PyObject* call(R (A0::*pmf)(%(A%+%:, %))%1, PyObject* args_, PyObject*, P const& policies)
typedef void R;
unwrap<A0%1&> c0(PyTuple_GET_ITEM(args, 0)); %( unwrap_more<A%+> c%+(PyTuple_GET_ITEM(args, %+), c%n);
from_python<A0%1*> c0(PyTuple_GET_ITEM(args_, 0)); if (!c0.convertible()) return 0; %( from_python<A%+> c%+(PyTuple_GET_ITEM(args_, %+)); if (!c%+.convertible()) return 0;
typedef void R;
wrap_more<R> r(c%n); %] if (!c0) return 0; %[r%:return r( %]((*c0).*pmf)(%(*c%+%:, %))%[r%: )%];%[v%: return detail::none();%]
typedef typename P::result_converter result_converter; typename eval<result_converter,R>::type cr; if (!cr.convertible()) return 0; %] if (!policies.precall(args_)) return 0; %[r%:PyObject* result = cr( %]((c0(PyTuple_GET_ITEM(args_, 0)))->*pmf)( %(c%+(PyTuple_GET_ITEM(args_, %+))%: , %))%[r%: )%]; return pol...
typedef void R;
free_function = '''%{ template <%(class A%n%:, %)> %} static PyObject* call(R (*pf)(%(A%n%:, %)), PyObject*%{ args%}, PyObject* /* keywords */ )
free_function = ''' template <class P%(, class A%n%%)> static PyObject* call(R (*pf)(%(A%n%:, %)), PyObject* args_, PyObject*, P const& policies)
typedef void R;
%}%( unwrap%{_more%}<A%n> c%n(PyTuple_GET_ITEM(args, %n)%{, c%-%}); %)%[r%: // find the result converter wrap%{_more%}<R> c%n%{(c%-)%};%]%[not-void-and-0-arg%: if (!c0) return 0;%] %[r%:return c%n( %](*pf)(%(*c%n%:, %))%[r%: )%];%[v%: return detail::none();%]
%}%( from_python<A%n> c%n(PyTuple_GET_ITEM(args_, %n)); if (!c%n.convertible()) return 0; %) %[r%: // find the result converter typedef typename P::result_converter result_converter; typename eval<result_converter,R>::type cr; if (!cr.convertible()) return 0; %]%[not-void-and-0-arg%: if (!policies...
typedef void R;
'test'
'boost_python_test'
... def new_method(self):
>>> c.testCallback('foo') Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: illegal argument type for built-in operation
>>> try: c.testCallback('foo') ... except TypeError, err: assert_integer_expected(err) ... else: print 'no exception'
... def __setattr__(self, name, value):
>>> r.testCallback('foo') Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: illegal argument type for built-in operation
>>> try: r.testCallback('foo') ... except TypeError, err: assert_integer_expected(err) ... else: print 'no exception'
... def callback(self, x):
from test import *
def assert_integer_expected(err): """Handle a common error report which appears differently in Python 1.5.x and 2.0""" assert isinstance(err, TypeError) message = str(err) assert (message == "illegal argument type for built-in operation" or message == "an integer is required")
... def __str__(self):
if not method.abstract:
if not method.abstract and method.visibility == Scope.public:
def Declaration(self, method, indent): '''Returns a string with the declarations of the virtual wrapper and its default implementations. This string must be put inside the Wrapper body. ''' pyste = namespaces.pyste python = namespaces.python rename = self.info[method.name].rename or method.name result = method.result.F...
if method.abstract: return []
def MethodDefinition(self, method): '''Returns a list of lines, which should be put inside the class_ statement to export this method.''' # dont define abstract methods if method.abstract: return [] pyste = namespaces.pyste rename = self.info[method.name].rename or method.name default_names = self.DefaultImplementation...
if method.visibility == Scope.public: if not self.info[method.name].exclude: defs.extend(self.MethodDefinition(method))
exclude = self.info[method.name].exclude if method.visibility == Scope.public and not method.abstract and not exclude: defs.extend(self.MethodDefinition(method))
def GenerateDefinitions(self): defs = [] for method in self.VirtualMethods(): if method.visibility == Scope.public: if not self.info[method.name].exclude: defs.extend(self.MethodDefinition(method)) return defs
del __test__
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: pass has_numarray = 0 try: import numarray m = numarray has_numarray = 1 except ImportError: pass ...
>>> check(y.astype());
>>> check(str(y))
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
>>> check(y.diagonal(0, 1));
>>> check(y.diagonal(0, 0));
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
>>> check(y.isbyteswapped());
>>> check( bool(y.isbyteswapped()) );
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
>>> check(y.trace(0, 1));
>>> check(y.trace(0, 0));
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
>>> check(y.new('D'));
>>> check(y.new('D').getshape()); >>> check(y.new('D').type());
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
>>> check(y.factory((1.2, 3.4), "Double")); >>> check(y.factory((1.2, 3.4), "Double", (1,2,1))); >>> check(y.factory((1.2, 3.4), "Double", (2,1,1), false)); >>> check(y.factory((1.2, 3.4), "Double", (2,), true, true));
>>> check(y.factory((1.2, 3.4), "f8")) >>> check(y.factory((1.2, 3.4), "f8", true)) >>> check(y.factory((1.2, 3.4), "f8", true, false)) >>> check(y.factory((1.2, 3.4), "f8", true, false, None)) >>> check(y.factory((1.2, 3.4), "f8", true, false, None, (1,2,1)))
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args...
self.results += [ str(x) for x in stuff ]
for x in stuff: self.results.append(str(x))
def __call__(self, *stuff): self.results += [ str(x) for x in stuff ]
if self.results[0] == str(x): del self.results[0] else: print ' Expected:\n %s\n but got:\n %s' % (x, self.results[0])
if self.results[0] != str(x): print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) del self.results[0]
def check(self, x): if self.results[0] == str(x): del self.results[0] else: print ' Expected:\n %s\n but got:\n %s' % (x, self.results[0])
print 'testing default extension module' failures += doctest.testmod(sys.modules.get(__name__))[0]
print 'testing default extension module:', \ numpy_ext.get_module_name() or '[numeric support not installed]' for test in find(numeric_tests): failures += run(test)[0]
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_n...
failures += doctest.testmod(sys.modules.get(__name__))[0]
for test in find(numeric_tests): failures += run(test)[0]
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_n...
failures += doctest.testmod(sys.modules.get(__name__))[0]
for test in find(numeric_tests) + find(_numarray_tests): failures += run(test)[0]
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_n...
print 'testing default module again'
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_n...
failures += doctest.testmod(sys.modules.get(__name__))[0]
print 'testing default module again:', \ numpy_ext.get_module_name() or '[numeric support not installed]' for test in find(numeric_tests): failures += run(test)[0]
def _run(args = None): import sys import doctest if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_n...
return doctest.testmod(sys.modules.get(__name__))
self = sys.modules.get(__name__) if (hasattr(pickle, "HIGHEST_PROTOCOL")): self.__doc__ += exercise_pickling return doctest.testmod(self)
def run(args = None): import sys import doctest if args is not None: sys.argv = args return doctest.testmod(sys.modules.get(__name__))
detail::parameter_traits<A%n>::const_reference%)>;
typename detail::parameter_traits<A%n>::const_reference%)>;
typedef typename unwrap_parameter_helper< is_wrapped
... except: pass
... except ReferenceError: pass
>>> def identity(x):
decl += indent*2 + '%s%s::%s(%s);\n' % \ (return_str, self.class_.FullName(), method.name, ', '.join(param_names))
decl += indent*2 + DefaultImpl(method, param_names)
def Declaration(self, method, indent): '''Returns a string with the declarations of the virtual wrapper and its default implementations. This string must be put inside the Wrapper body. ''' pyste = namespaces.pyste python = namespaces.python rename = self.info[method.name].rename or method.name result = method.result.F...
>>> try: return_null_handle() ... except: pass ... else: print 'expectd an exception'
>>> return_null_handle() is None 1
... def __str__(self):
try: import Numeric
try: import Numeric except ImportError: pass else: has_numeric = 1
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_numarray = 1 exc...
has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_numarray = 1 exc...
try: import numarray
try: import numarray except ImportError: pass else: has_numarray = 1
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_numarray = 1 exc...
has_numarray = 1 except ImportError: global _numarray_tests _numarray_tests = None
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric m = Numeric has_numeric = 1 except ImportError: global numeric_tests numeric_tests = None has_numarray = 0 try: import numarray m = numarray has_numarray = 1 exc...
class _printer(object): def __init__(self): self.results = []; def __call__(self, *stuff): for x in stuff: self.results.append(str(x)) def check(self, x): if self.results[0] != str(x): print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) del self.results[0]
def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(str(y)) >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.argsort(1...
def _count_failures(test_names = ('numeric_tests',)): '''Given a sequence of test function names, run all the doctests associated with each function and return the total number of failures. Works portably across versions of doctest.''' import doctest if hasattr(doctest, 'DocTestFinder'): failures = 0 for n in test_...
import doctest, numeric_tests def _count_failures(test_modules = (numeric_tests,)): failures = 0 for m in test_modules: failures += doctest.testmod(m)[0] return failures
def _count_failures(test_names = ('numeric_tests',)): '''Given a sequence of test function names, run all the doctests associated with each function and return the total number of failures. Works portably across versions of doctest.''' import doctest if hasattr(doctest, 'DocTestFinder'): # Newer doctest fails to work...
import sys
import sys, numarray_tests, numeric_tests
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric except ImportError: pass else: has_numeric = 1 m = Numeric has_numarray = 0 try: import numarray except ImportError: pass else: has_numarray = 1 m = numarray # ...
global __test__
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric except ImportError: pass else: has_numeric = 1 m = Numeric has_numarray = 0 try: import numarray except ImportError: pass else: has_numarray = 1 m = numarray # ...
failures += _count_failures(('_numarray_tests', 'numeric_tests'))
failures += _count_failures((numarray_tests, numeric_tests))
def _run(args = None): import sys if args is not None: sys.argv = args # See which of the numeric modules are installed has_numeric = 0 try: import Numeric except ImportError: pass else: has_numeric = 1 m = Numeric has_numarray = 0 try: import numarray except ImportError: pass else: has_numarray = 1 m = numarray # ...
temp = tempfile.mktemp('.h') shutil.copyfile(filename, temp) f = file(temp, 'a') f.write('\n\n'+tail)
if hasattr(tempfile, 'mkstemp'): f_no, temp = tempfile.mkstemp('.h') f = file(temp, 'a') os.close(f_no) else: temp = tempfile.mktemp('.h') f = file(temp, 'a') f.write(' f.write(tail) f.write('\n')
def AppendTail(self, filename, tail): '''Creates a temporary file, appends the text tail to it, and returns the filename of the file. ''' temp = tempfile.mktemp('.h') shutil.copyfile(filename, temp) f = file(temp, 'a') f.write('\n\n'+tail) f.close() return temp
tail.strip()
tail = tail.strip()
def Parse(self, header, interface, tail=None): '''Parses the given filename related to the given interface and returns the (declarations, headerfile). The header returned is normally the same as the given to this method (except that it is the full path), except if tail is not None: in this case, the header is copied to...
warning = '---> Error: Method "%s" needs a policy.' % m.FullName()
warning = '---> Error: Method "%s" needs a policy.' % function.FullName()
def IsString(type): 'Return True if the Type instance can be considered a string' return type.const and type.name == 'char' and isinstance(type, PointerType)
for member in self.class_.members:
for member in self.public_members:
def ExportVirtualMethods(self): # check if this class has any virtual methods has_virtual_methods = False for member in self.class_.members: if type(member) == Method and member.virtual: has_virtual_methods = True break
return [m for m in self.class_.members if type(m) == Method and m.virtual]
def IsVirtual(m): return type(m) == Method and m.virtual and m.visibility == Scope.public return [m for m in self.class_.members if IsVirtual(m)]
def VirtualMethods(self): return [m for m in self.class_.members if type(m) == Method and m.virtual]
return [m for m in self.class_.members if isinstance(m, Constructor)]
def IsValid(m): return isinstance(m, Constructor) and m.visibility == Scope.public return [m for m in self.class_.members if IsValid(m)]
def Constructors(self): return [m for m in self.class_.members if isinstance(m, Constructor)]
>>> g = graph() >>> for el in g.domains:
>>> tm = TestMap() >>> tm["joel"] = X("aaa") >>> tm["kimpo"] = X("bbb") >>> print_xmap(tm) [ (joel, aaa) (kimpo, bbb) ] >>> for el in tm:
>>> def print_xmap(xmap):
return '(%s (*)(%s))%s' % (result, params, self.FullName())
return '(%s (*)(%s))&%s' % (result, params, self.FullName())
def PointerDeclaration(self): 'returns a declaration of a pointer to this function' result = self.result.FullName() params = ', '.join([x.FullName() for x in self.parameters]) return '(%s (*)(%s))%s' % (result, params, self.FullName())
return '(%s (%s::*)(%s) %s)%s' %\
return '(%s (%s::*)(%s) %s)&%s' %\
def PointerDeclaration(self): 'returns a declaration of a pointer to this function' result = self.result.FullName() params = ', '.join([x.FullName() for x in self.parameters]) const = '' if self.const: const = 'const' return '(%s (%s::*)(%s) %s)%s' %\ (result, self.class_, params, const, self.FullName())
wrap%{_more%}<R> r%{(c%-)%};%]%{ if (!c0) return 0;%} %[r%:return r( %](*pf)(%(*c%n%:, %))%[r%: )%];%[v%:
wrap%{_more%}<R> c%n%{(c%-)%};%]%[not-void-and-0-arg%: if (!c0) return 0;%] %[r%:return c%n( %](*pf)(%(*c%n%:, %))%[r%: )%];%[v%:
typedef void R;
if key == 'r':
if key != 'v':
def _returns_value(key, n, args, value): if key == 'r': return value # pass the value through gen_function again for recursive expansion
assert key == 'v'
def _returns_value(key, n, args, value): if key == 'r': return value # pass the value through gen_function again for recursive expansion
if key == 'v':
if key == 'v' or key == 'not-void-and-0-arg' and n != 0:
def _returns_void(key, n, args, value): if key == 'v': return value else: assert key == 'r' # return the empty string, ignoring the value return ''
assert key == 'r'
def _returns_void(key, n, args, value): if key == 'v': return value else: assert key == 'r' # return the empty string, ignoring the value return ''
>>> if sys.version_info[0] < 2 or ( sys.version_info[0] == 2 and
>>> if not sys.__dict__.has_key('version_info') or \ ... sys.version_info[0] < 2 or ( sys.version_info[0] == 2 and
... def fred(self):
>>> ii = Int(1) >>> ii += Int(2) >>> ii.i() 3 >>> ii -= Int(1) >>> ii.i() 2 >>> ii *= Int(3) >>> ii.i() 6 >>> ii /= Int(2) >>> ii.i() 3 >>> ii <<= Int(2) >>> ii.i() 12 >>> ii >>= Int(1) >>> ii.i() 6 >>> ii &= Int(5) >>> ii.i() 4 >>> ii |= Int(9) >>> ii.i() 13 >>> ii ^= Int(7) >>> ii.i() 10 >>> ii %= Int(4) >>> ii.i() 2...
... def overrideB1(self):
if not exporters.importing:
def AddExporter(self, exporter): if not exporters.importing: if exporter not in exporters.exporters: exporters.exporters.append(exporter) exporter.interface_file = exporters.current_interface