rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.assertEqual([98.9], self.hobj.arr1[0]) | self.assertTrue(all(array([98.9]) == self.hobj.arr1)) | def test_set_to_default(self): self.assertEqual(3.1415926, self.hobj.arr1[0]) self.hobj.add_trait('arr4', Array(iotype='in', units='kg')) self.assertTrue(all(array([]) == self.hobj.arr4)) self.hobj.arr4 = [6.5] self.assertEqual(6.5, self.hobj.arr4[0]) self.hobj.revert_to_defaults() self.assertEqual([98.9], self.hobj.... |
self.assertEqual(3.1415926, self.hobj.arr1[0]) | self.assertTrue(all(array([1.,2.,3.]) == self.hobj.arr1)) | def test_assignment(self): # check starting value self.assertEqual(3.1415926, self.hobj.arr1[0]) # check default value self.assertEqual([98.9], self.hobj.trait('arr1').trait_type.default_value) # use unit_convert to perform unit conversion self.hobj.arr1 = [3.] self.hobj.arr2 = convert_units(self.hobj.arr1, self.hobj.... |
self.hobj.arr1 = [3.] | def test_assignment(self): # check starting value self.assertEqual(3.1415926, self.hobj.arr1[0]) # check default value self.assertEqual([98.9], self.hobj.trait('arr1').trait_type.default_value) # use unit_convert to perform unit conversion self.hobj.arr1 = [3.] self.hobj.arr2 = convert_units(self.hobj.arr1, self.hobj.... | |
self.assertAlmostEqual(36., self.hobj.arr2[0], 5) | self.assertAlmostEqual(12., self.hobj.arr2[0], 5) self.assertAlmostEqual(24., self.hobj.arr2[1], 5) self.assertAlmostEqual(36., self.hobj.arr2[2], 5) | def test_assignment(self): # check starting value self.assertEqual(3.1415926, self.hobj.arr1[0]) # check default value self.assertEqual([98.9], self.hobj.trait('arr1').trait_type.default_value) # use unit_convert to perform unit conversion self.hobj.arr1 = [3.] self.hobj.arr2 = convert_units(self.hobj.arr1, self.hobj.... |
self.hobj.arr2 = [12.] self.hobj.arr1 = convert_units(self.hobj.arr2, self.hobj.trait('arr2').units, 'ft') self.assertEqual(self.hobj.arr1[0], 1.) | self.hobj.arr1 = [1.,2.,3.] self.hobj.arr2 = self.hobj.get_wrapped_attr('arr1') self.assertAlmostEqual(12., self.hobj.arr2[0]) self.assertAlmostEqual(24., self.hobj.arr2[1]) self.assertAlmostEqual(36., self.hobj.arr2[2]) | def test_unit_conversion(self): self.hobj.arr2 = [12.] # inches self.hobj.arr1 = convert_units(self.hobj.arr2, self.hobj.trait('arr2').units, 'ft') self.assertEqual(self.hobj.arr1[0], 1.) # 12 inches = 1 ft |
self.assertEqual(self.hobj.arr1, 3.1415926) self.assertEqual(self.hobj.get('arr1'), 3.1415926) | self.assertTrue(all(self.hobj.get('arr1') == array([1.,2.,3.]))) | def test_get(self): self.assertEqual(self.hobj.arr1, 3.1415926) self.assertEqual(self.hobj.get('arr1'), 3.1415926) |
self.invalidate_deps() | self.invalidate_deps(notify_parent=Trues) | def _pre_execute (self): """Prepares for execution by calling *tree_rooted()* and *check_config()* if their "dirty" flags are set, and by requesting that the parent Assembly update this Component's invalid inputs. Overrides of this function must call this version. """ if self._call_tree_rooted: self.tree_rooted() if ... |
self.driver.iprint = 2 | self.driver.iprint = 0 | def __init__(self): """ Creates a new Assembly with this problem Optimal Design at (1.9776, 0, 0) Optimal Objective = 3.18339""" # pylint: disable-msg=E1101 super(SellarIDF, self).__init__() |
base = os.path.join(destdir, os.path.basename(projdir)+'-%s' % version) | base = os.path.basename(projdir)+'-%s' % version | def _build_sdist(projdir, destdir, version): """Build an sdist out of a develop egg.""" startdir = os.getcwd() try: os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if sys.platform == 'win32': # turn .zip file into .tar.gz file so setuptools wi... |
archive.add(os.path.basename(base)) | archive.add(base) | def _build_sdist(projdir, destdir, version): """Build an sdist out of a develop egg.""" startdir = os.getcwd() try: os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if sys.platform == 'win32': # turn .zip file into .tar.gz file so setuptools wi... |
if os.path.exists('build'): shutil.rmtree('build') | def _build_sdist(projdir, destdir, version): """Build an sdist out of a develop egg.""" startdir = os.getcwd() try: os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if sys.platform == 'win32': # turn .zip file into .tar.gz file so setuptools wi... | |
val = self._design_vars[-1].evaluate() if low and high: | val = expreval.evaluate() if low is not None and high is not None: | def add_des_var(self,ref,low=None,high=None): """adds a design variable to the driver. 'ref' is a string refering to the public variable the driver should vary during execution. 'low' and 'high' refer to the minimum and maximum allowed values for the optimizer to use. If neither are specified, the min and max will defa... |
if not(isinstance(val,float) or isinstance(val,int)): | if not(isinstance(val,float) or isinstance(val,int) or isinstance(val,int32) or \ isinstance(val,int64) or isinstance(val,float32) or isinstance(val,float64) ): | def add_des_var(self,ref,low=None,high=None): """adds a design variable to the driver. 'ref' is a string refering to the public variable the driver should vary during execution. 'low' and 'high' refer to the minimum and maximum allowed values for the optimizer to use. If neither are specified, the min and max will defa... |
sphinx.main(argv=['-P', '-b', 'dictest', '-d', | sphinx.main(argv=['-P', '-b', 'doctest', '-d', | def test_docs(): """Tests the openmdao sphinx documentation. A console script (testdocs) calls this. """ branchdir, docdir, bindir =_get_dirnames() sphinx.main(argv=['-P', '-b', 'dictest', '-d', os.path.join(docdir, '_build', 'doctrees'), docdir, os.path.join(docdir, '_build', 'html')]) |
assert_rel_error(self, asm.comp2.d, -2., 0.01) | assert_rel_error(self, asm.comp2.d, -2.12, 0.01) | def test_in_assembly(self): asm = set_as_top(Assembly()) asm.add('metamodel', MetaModel()) asm.add('comp1', Simple()) asm.add('comp2', Simple()) asm.metamodel.surrogate = KrigingSurrogate() asm.metamodel.model = Simple() asm.metamodel.recorder = DumbRecorder() asm.driver.workflow.add([asm.metamodel,asm.comp1,asm.comp2]... |
self.assertEqual(str(err), "driver: number of DOE values (4) != number of parameters (3)") | self.assertEqual(str(err), "driver: Number of DOE values (4) != number of parameters (3).") | def test_DOE_param_mismatch(self): self.model.driver.remove_parameter('driven.x2') results = ListCaseRecorder() self.model.driver.recorder = results try: self.model.run() except ValueError as err: self.assertEqual(str(err), "driver: number of DOE values (4) != number of parameters (3)") else: self.fail("expected ValueE... |
if sys.platform == 'win32': end_dir = end_dir.lower() if end_dir != self.directory: | if end_dir.lower() != self.directory.lower(): | def tearDown(self): self.model.pre_delete() self.model = None |
def _build_dev_egg(projdir, destdir): | def _build_sdist(projdir, destdir): | def _build_dev_egg(projdir, destdir): """Build an sdist out of a develop egg.""" env = Environment() os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if os.path.exists('build'): shutil.rmtree('build') |
env = Environment() | def _build_dev_egg(projdir, destdir): """Build an sdist out of a develop egg.""" env = Environment() os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if os.path.exists('build'): shutil.rmtree('build') | |
reqs = [Requirement.parse(x) for x in openmdao_packages] dists = working_set.resolve(reqs) | def main(): parser = OptionParser() parser.add_option("-d", "--destination", action="store", type="string", dest="destdir", help="directory where distributions will be placed") parser.add_option("","--version", action="store", type="string", dest="version", help="version string applied to all openmdao distributions") (... | |
for d in dists: if d.project_name in openmdao_packages: pdir = os.path.join(topdir, openmdao_packages[d.project_name][0], d.project_name) if 'src' in os.listdir(pdir): os.chdir(os.path.join(pdir, 'src')) else: os.chdir(pdir) create_releaseinfo_file(d.project_name, options.version) _build_dev_egg(pdir, destdir) | for project_name in openmdao_packages: pdir = os.path.join(topdir, openmdao_packages[project_name][0], project_name) if 'src' in os.listdir(pdir): os.chdir(os.path.join(pdir, 'src')) else: os.chdir(pdir) create_releaseinfo_file(project_name, options.version) _build_sdist(pdir, destdir) | def main(): parser = OptionParser() parser.add_option("-d", "--destination", action="store", type="string", dest="destdir", help="directory where distributions will be placed") parser.add_option("","--version", action="store", type="string", dest="version", help="version string applied to all openmdao distributions") (... |
sdists = os.listdir(destdir) for dist in dists: for sdist in sdists: if sdist.startswith(dist.project_name): pdir = os.path.join(topdir, openmdao_packages[dist.project_name][0], dist.project_name) if not dist.location.startswith(pdir): version = get_metadata(os.path.join(destdir, sdist))['version'] if version == dist.v... | def main(): parser = OptionParser() parser.add_option("-d", "--destination", action="store", type="string", dest="destdir", help="directory where distributions will be placed") parser.add_option("","--version", action="store", type="string", dest="version", help="version string applied to all openmdao distributions") (... | |
if not os.path.isfile(projpath): projpath = '' | if sys.platform == 'darwin': modify_wpr_file(projpath) | def run_wing(): """Runs the Wing IDE after first setting up a profile containing the files in the openmdao repository. It also adds all of our unit tests to the testing area. """ wingpath = None projpath = '' for arg in sys.argv[1:]: if arg.startswith('--wingpath='): wingpath = arg.split('=')[1] elif arg.startswith('--... |
if u == varpath2: | if u == varpath: | def disconnect(self, varpath, varpath2=None): """If varpath2 is supplied, remove the connection between varpath and varpath2. Otherwise, if varpath is the name of a trait, remove all connections to/from varpath in the current scope. If varpath is the name of a Component, remove all connections from all of its inputs an... |
if v == varpath2: | if v == varpath: | def disconnect(self, varpath, varpath2=None): """If varpath2 is supplied, remove the connection between varpath and varpath2. Otherwise, if varpath is the name of a trait, remove all connections to/from varpath in the current scope. If varpath is the name of a Component, remove all connections from all of its inputs an... |
self.assertEqual(n_servers, len(self.cluster)) | try: n_cpus = multiprocessing.cpu_count() except AttributeError: n_cpus = 1 self.assertEqual(n_servers, len(self.cluster)*n_cpus) | def test_normal(self): logging.debug('') logging.debug('test_normal') |
`criteria` is the dictionary returned by :method:`rate_resource`. | `criteria` is the dictionary returned by :meth:`rate_resource`. | def deploy(self, resource_desc, criteria): """ Deploy a server suitable for `resource_desc`. `criteria` is the dictionary returned by :method:`rate_resource`. Returns a proxy to the deployed server. """ raise NotImplementedError |
"""Returns the Variable dependency graph, after updating it with child | """Returns the Variable dependency graph, after updating it with child io_graph | def get_var_graph(self): """Returns the Variable dependency graph, after updating it with child info if necessary. """ if self._need_child_io_update: vargraph = self._var_graph childiographs = self._child_io_graphs for childname,val in childiographs.items(): graph = getattr(self, childname).get_io_graph() if graph is n... |
self.assertFalse('added_int' in allnames) self.assertFalse('added_property' in allnames) | allnames = mht.all_trait_names() self.assertTrue('added_int' in allnames) self.assertTrue('added_property' in allnames) | def test_all_trait_names(self): mht = MyHasTraits() # dynamically added traits DO NOT show up in all_trait_names(), # even after being set allnames = mht.all_trait_names() self.assertFalse('added_int' in allnames) self.assertFalse('added_property' in allnames) mht.added_int = 8 mht.added_property = 9 self.assertFalse(... |
setupnames = ['setup_egg.py', 'setupegg.py', 'setup.py'] | setupnames = ['setupegg.py', 'setup_egg.py', 'setup.py'] | def sdist_to_bdist_egg(self, sdist_path, delete=False): """Take an sdist and replace it with a bdist_egg""" self.logger.info("Converting sdist %s to a bdist_egg" % sdist_path) tmpdir = tempfile.mkdtemp() cdir = os.getcwd() try: # unpack the sdist if sdist_path.endswith('.tar.gz') or sdist_path.endswith('.tar'): tarf = ... |
'setup.py', 'bdist_egg', '-d', '%s' % os.path.dirname(sdist_path)], | setup, 'bdist_egg', '-d', '%s' % os.path.dirname(sdist_path)], | def sdist_to_bdist_egg(self, sdist_path, delete=False): """Take an sdist and replace it with a bdist_egg""" self.logger.info("Converting sdist %s to a bdist_egg" % sdist_path) tmpdir = tempfile.mkdtemp() cdir = os.getcwd() try: # unpack the sdist if sdist_path.endswith('.tar.gz') or sdist_path.endswith('.tar'): tarf = ... |
setups = [' setup ',' setup,', ',setup ', ',setup,'] with open(setup, 'r') as fin: with open('___setup.py', 'w') as fout: found = False for line in fin: if not found: if line.startswith('import ') or ' import ' in line: for s in setups: if s in line: found = True indent = line.find('from') if indent < 0: indent = line.... | def sdist_to_bdist_egg(self, sdist_path, delete=False): """Take an sdist and replace it with a bdist_egg""" self.logger.info("Converting sdist %s to a bdist_egg" % sdist_path) tmpdir = tempfile.mkdtemp() cdir = os.getcwd() try: # unpack the sdist if sdist_path.endswith('.tar.gz') or sdist_path.endswith('.tar'): tarf = ... | |
'setup.py', 'bdist', '-d', '%s' % os.path.dirname(sdist_path)], | '___setup.py', 'bdist_egg', '-d', '%s' % os.path.dirname(sdist_path)], | def sdist_to_bdist_egg(self, sdist_path, delete=False): """Take an sdist and replace it with a bdist_egg""" self.logger.info("Converting sdist %s to a bdist_egg" % sdist_path) tmpdir = tempfile.mkdtemp() cdir = os.getcwd() try: # unpack the sdist if sdist_path.endswith('.tar.gz') or sdist_path.endswith('.tar'): tarf = ... |
raise nose.SkipTest("Windows box has permission problems with this test") | raise SkipTest("Windows box has permission problems with this test") | def test_protected_directory(self): if sys.platform == 'win32': raise nose.SkipTest("Windows box has permission problems with this test") logging.debug('') logging.debug('test_protected_directory') |
if not self.is_valid(): | if not self.is_valid() or self._num_input_caseiters > 0: | def _pre_execute (self): """Prepares for execution by calling *tree_rooted()* and *check_config()* if their "dirty" flags are set, and by requesting that the parent Assembly update this Component's invalid inputs. Overrides of this function must call this version. """ if self._call_tree_rooted: self.tree_rooted() if ... |
if self.get_pathname() != 'branin_meta_model': print 'execute %s' % self.get_pathname() else: sys.stdout.write('.') | def run (self, force=False): """Run this object. This should include fetching input variables, executing, and updating output variables. Do not override this function. """ if self.directory: self.push_dir() | |
else: print 'skipping %s' % self.get_pathname() | def run (self, force=False): """Run this object. This should include fetching input variables, executing, and updating output variables. Do not override this function. """ if self.directory: self.push_dir() | |
if False in self._valid_dict.values() or self._num_input_caseiters > 0: | if False in self._valid_dict.values(): | def is_valid(self): """Return False if any of our public variables is invalid.""" if self._call_execute: return False if False in self._valid_dict.values() or self._num_input_caseiters > 0: self.call_execute = True return False if self.parent is not None: srccomps = [n for n,v in self.get_expr_sources()] if len(srccomp... |
print 'creating bootstrapping installer script go-openmdao.py' installer = os.path.join(os.path.dirname(__file__),'mkinstaller.py') check_call([sys.executable, installer, '-d', destdir]) | def main(): """Create an OpenMDAO release, placing the following files in the specified destination directory: - a tar file of the repository - source distribs of all of the openmdao subpackages - an openmdao empty top level distrib that does nothing but depend on all of the openmdao subpackages (so someone can 'openm... | |
join(bin_dir, 'add_reqs'), '-f', url] + options.reqs, | join(bin_dir, reqscript), '-f', url] + options.reqs, | def after_install(options, home_dir): global logger, openmdao_prereqs reqs = %(reqs)s url = '%(url)s' etc = join(home_dir, 'etc') if sys.platform == 'win32': lib_dir = join(home_dir, 'Lib') bin_dir = join(home_dir, 'Scripts') else: lib_dir = join(home_dir, 'lib', py_version) bin_dir = join(home_dir, 'bin') if not os.... |
if dist.project_name == 'openmdao.main': version = dist.version | def after_install(options, home_dir): global logger reqs = %(reqs)s cmds = %(cmds)s url = 'http://openmdao.org/dists' found = [c for c in cmds if url in c] if not found: cmds.extend(['-f',url]) etc = join(home_dir, 'etc') ## TODO: this should all come from distutils ## like distutils.sysconfig.get_python_inc() if sys.p... | |
distname = '%s-%s.tar.gz'%(modname,options.version) | if sys.platform == 'win32': distname = '%s-%s.zip' % (modname, options.version) else: distname = '%s-%s.tar.gz' % (modname,options.version) | def mod2dist(argv=None, groups= { 'openmdao.component': Component, 'openmdao.driver': Driver, #'openmdao.case_iterator': CaseIterator, #'openmdao.resource_allocator': ResourceAllocator, 'openmdao.variable': TraitType }): """Utility to simplify the packaging of a single module containing OpenMDAO plugin classes into a s... |
self.debug("allocator %s is missing 'hostnames'", allocator._name) | self._logger.debug("allocator %s is missing 'hostnames'", allocator._name) | def _get_estimates(self, resource_desc, need_hostnames=False): """ Return best (estimate, criteria, allocator). """ best_estimate = -2 best_criteria = None best_allocator = None |
allocator = manager.openmdao_main_resource_LocalAllocator(name) | allocator = \ manager.openmdao_main_resource_LocalAllocator(name=name, allow_shell=allow_shell) | def __init__(self, name, machines, authkey=None, allow_shell=False): if authkey is None: authkey = multiprocessing.current_process().authkey if authkey is None: authkey = 'PublicKey' multiprocessing.current_process().authkey = authkey |
args = sys.argv[1:] | args = sys.argv[:] | def run_openmdao_suite(*pargs, **kwargs): """This function is exported as a script that is runnable from the buildout as bin/test. Add any directories to search for tests to tlist. """ args = sys.argv[1:] tlist = ['openmdao'] # force the use of our updated coverage plugin, called coverage2 # (allows html and cobert... |
for i,arg in enumerate(args): if arg.startswith('--cover') and not arg.startswith('--cover2'): args[i] = arg.replace('--cover', '--cover2') elif arg == '--with-coverage': args[i] = '--with-coverage2' | def run_openmdao_suite(*pargs, **kwargs): """This function is exported as a script that is runnable from the buildout as bin/test. Add any directories to search for tests to tlist. """ args = sys.argv[1:] tlist = ['openmdao'] # force the use of our updated coverage plugin, called coverage2 # (allows html and cobert... | |
to_remove = [n for n in val if n.startswith(childdot)] | to_remove = [n for n in val if n.startswith(childdot) and n not in graph] | def get_var_graph(self): """Returns the Variable dependency graph, after updating it with child info if necessary. """ if self._need_child_io_update: vargraph = self._var_graph childiographs = self._child_io_graphs for childname,val in childiographs.items(): graph = getattr(self, childname).get_io_graph() if graph is n... |
for i in range(55): | for i in range(1, 55): | def setUp(self): try: self.user = os.environ['USER'] except KeyError: self.user = None # Probably Windows... self.node = platform.node() self.name = self.node.replace('.', '_') self.python = find_python() self.cluster = None |
for path in glob.glob('/tmp/distrib-*'): | tempdir = tempfile.gettempdir() for path in glob.glob(os.path.join(tempdir, 'distrib-*')): | def tearDown(self): |
self.assertAlmostEqual(16.0393816869,pred.sigma,places=5) self.assertAlmostEqual(15.6772857277,pred.mu,places=5) | self.assertAlmostEqual(14.513550,pred.sigma,places=5) self.assertAlmostEqual(18.759264,pred.mu,places=5) | def bran(x): y = (x[1]-(5.1/(4.*pi**2.))*x[0]**2.+5.*x[0]/pi-6.)**2.+10.*(1.-1./(8.*pi))*cos(x[0])+10. return y |
random.seed(10) numpy_random.seed(10) | def setUp(self): random.seed(10) numpy_random.seed(10) # pyevolve does some caching that causes failures during our # complete unit tests due to stale values in the cache attributes # below, so reset them here Selectors.GRankSelector.cachePopID = None Selectors.GRankSelector.cacheCount = None Selectors.GRouletteWheel.... | |
def test_optimizeSphere(self): self.top.add('comp', SphereFunction()) self.top.driver.workflow.add(self.top.comp) self.top.driver.objective = "comp.total" self.top.driver.add_parameter('comp.x') self.top.driver.add_parameter('comp.y') self.top.driver.add_parameter('comp.z') self.top.driver.mutation_rate = .02 self.... | def test_optimizeSphere_set_high_low(self): self.top.add('comp', SphereFunction()) self.top.driver.workflow.add(self.top.comp) self.top.driver.objective = "comp.total" | |
def setUp(self): random.seed(10) numpy_random.seed(10) | def execute(self): self.y = self.w * 1.1 self.z = self.x * 0.9 | |
for i in range(10): asm.comp1.a = random.uniform(1,8) asm.comp1.b = random.uniform(3,10) | data = [1,2,3,4] for a,b in zip(data[:-1],data[1:]): asm.comp1.a = a asm.comp1.b = b | def test_in_assembly(self): asm = set_as_top(Assembly()) asm.add('metamodel', MetaModel()) asm.add('comp1', Simple()) asm.add('comp2', Simple()) asm.metamodel.surrogate = KrigingSurrogate() asm.metamodel.model = Simple() asm.metamodel.recorder = DumbRecorder() asm.driver.workflow.add([asm.metamodel,asm.comp1,asm.comp2]... |
assert_rel_error(self, asm.comp2.c, 6., 0.02) assert_rel_error(self, asm.comp2.d, -2.12, 0.02) | assert_rel_error(self, asm.comp2.c, 6, 0.02) assert_rel_error(self, asm.comp2.d, -2, 0.02) | def test_in_assembly(self): asm = set_as_top(Assembly()) asm.add('metamodel', MetaModel()) asm.add('comp1', Simple()) asm.add('comp2', Simple()) asm.metamodel.surrogate = KrigingSurrogate() asm.metamodel.model = Simple() asm.metamodel.recorder = DumbRecorder() asm.driver.workflow.add([asm.metamodel,asm.comp1,asm.comp2]... |
blah = raw_input("waiting... ") | def _build_sdist(projdir, destdir, version): """Build an sdist out of a develop egg.""" startdir = os.getcwd() try: os.chdir(projdir) # clean up any old builds if os.path.exists('build'): shutil.rmtree('build') _build_dist('sdist', destdir) if sys.platform == 'win32': # turn .zip file into .tar.gz file so setuptools wi... | |
if i>0: sql.append(")") | vars_added = True if vars_added: sql.append(")") | def case_db_to_dict(dbname, varnames, case_sql=None, var_sql=None): """ Retrieve the values of specified variables from a sqlite DB containing Case data. Returns a dict containing a list of values for each entry, keyed on variable name. dbname : str The name of the sqlite DB file varnames : list[str] The list of nam... |
' --version=%s -d %s' % (version, tmpdir), capture=False) | ' -d %s' % tmpdir, capture=False) | def release(version=None): """Creates source distributions of the current openmdao namespace packages, uploads them to openmdao.org/dists, and updates the index.html file there. """ if version is not None: try: version = _check_version(version) except VersionError, err: print str(err),'\n' version = None if version is... |
print 'building openmdao' _create_pseudo_egg(options.version, destdir) | def main(): """Create an OpenMDAO release, placing the following files in the specified destination directory: - a tar file of the repository - source distribs of all of the openmdao subpackages - an openmdao empty top level distrib that does nothing but depend on all of the openmdao subpackages (so someone can 'openm... | |
newtrait = PassthroughTrait(validation_trait=trait,**metadata) | if "validation_trait" in metadata: newtrait = PassthroughTrait(**metadata) else: newtrait = PassthroughTrait(validation_trait=trait,**metadata) | def create_passthrough(self, pathname, alias=None): """Creates a PassthroughTrait that uses the trait indicated by pathname for validation, adds it to self, and creates a connection between the two. If alias is *None,* the name of the alias trait will be the last entry in its pathname. The trait specified by pathname m... |
def modify_wpr_file(fpath): | def _modify_wpr_file(fpath): | def modify_wpr_file(fpath): config = ConfigParser.ConfigParser() config.read(fpath) config.set('user attributes', 'proj.pypath', _wingify(dict({None: ('custom',os.pathsep.join(sys.path))}), left_margin=18)) with open(fpath, 'w') as fp: config.write(fp) |
modify_wpr_file(projpath) | _modify_wpr_file(projpath) | def run_wing(): """Runs the Wing IDE after first setting up a profile containing the files in the openmdao repository. It also adds all of our unit tests to the testing area. """ wingpath = None projpath = '' for arg in sys.argv[1:]: if arg.startswith('--wingpath='): wingpath = arg.split('=')[1] elif arg.startswith('--... |
for i in range(0, len(result),row_width): result = result[:i] + [zip(*result[i:i+row_width])] + result[i+row_width:] | big_result = [] for i in range(0, row_width * int(len(result)/row_width),row_width): big_result.append([]) for j in range(row_width): big_result[-1].append(result[i+j]) return big_result | def get(self, header, subcase, constraints, column_names, row_width=1): # find the grid we're talking about my matching # the header myindex = None maybeindex = None # for partial matches for index, grid in enumerate(self.grids): if self.headers[index]["actual"].strip() == header or \ self.headers[index]["clean"] == he... |
if '-' != line: print referrer(line) | ref = referrer(line) if '-' != ref: print ref | def referrer(logline): ''' Extracts the referrer string from an Apache web server "combined" log file record ''' parts = logline.split('"') return parts[3] |
group_info['title'] = group.getGroupTitleOrName() | def doSearch(self, searchString): """ Search for a group by id or title""" acl = getToolByName(self, 'acl_users') rolemakers = acl.plugins.listPlugins(IRolesPlugin) | |
findAll = form.get('form.button.FindAll', None) is not None and not self.many_users self.searchString = not findAll and form.get('searchstring', '') or '' self.searchResults = self.getPotentialMembers(self.searchString) | def __call__(self): self.groupname = getattr(self.request, 'groupname') self.gtool = getToolByName(self, 'portal_groups') self.mtool = getToolByName(self, 'portal_membership') self.group = self.gtool.getGroupById(self.groupname) self.grouptitle = self.group.getGroupTitleOrName() or self.groupname | |
filter(None, mergedResults) return mergedResults | return filter(None, mergedResults) | def getMembers(self): searchResults = self.gtool.getGroupMembers(self.groupname) |
self.searchResults = self.getPotentialGroups(self.searchString) | if findAll or not self.many_groups or self.searchString != '': self.searchResults = self.getPotentialGroups(self.searchString) if search or findAll: self.newSearch = True | def __call__(self): self.userid = getattr(self.request, 'userid') self.gtool = getToolByName(self, 'portal_groups') self.mtool = getToolByName(self, 'portal_membership') self.member = self.mtool.getMemberById(self.userid) |
filter(None, groupResults) return groupResults | return filter(None, groupResults) | def getGroups(self): groupResults = [self.gtool.getGroupById(m) for m in self.gtool.getGroupsForPrincipal(self.member)] groupResults.sort(key=lambda x: x is not None and x.getGroupTitleOrName().lower()) filter(None, groupResults) return groupResults |
utils.addPortalMessage(_(u'Unable to activate PAS plugin "recursive_groups".')) | utils.addPortalMessage(_(u"Unable to activate PAS plugin 'recursive_groups'.")) | def set_enable_nested_groups(self, value): acl = getToolByName(self.context, 'acl_users') plugins = acl.plugins if value: plugins.activatePlugin(IGroupsPlugin, 'recursive_groups') if 'recursive_groups' not in plugins.getAllPlugins('IGroupsPlugin')['active']: utils = getToolByName(context, 'plone_utils') utils.addPortal... |
groupsTool.addGroup('group1', [], [], title='Group 1') groupsTool.addGroup('group2', [], [], title='Group 2') groupsTool.addGroup('group3', [], [], title='Group 3') | groupsTool.addGroup('group1', [], [], title="Group 1") groupsTool.addGroup('group2', [], [], title="Group 2") groupsTool.addGroup('group3', [], [], title="Group 3 accentué") | def generateGroups(self): groupsTool = getToolByName(self.portal, 'portal_groups') groupsTool.addGroup('group1', [], [], title='Group 1') groupsTool.addGroup('group2', [], [], title='Group 2') groupsTool.addGroup('group3', [], [], title='Group 3') |
from zope.app.keyreference.persistent import KeyReferenceToPersistent | from zope.keyreference.persistent import KeyReferenceToPersistent | def create_subscriptions(): # Register adapters and handlers: from zope.component import provideUtility, provideAdapter, provideHandler for adapter in (subscribe.catalog_data, subscribe.SubscriptionSearchableText): provideAdapter(adapter) from zope.component.event import objectEventNotify for handler in (subscribe.sub... |
if default is None: | if default is not None: | def xml_int(element, attr, default = None): if element.get(attr) is None: if default is None: return default else: raise Exception("Element has no attribute: " + attr) return int(float(element.get(attr))) |
if default is None: | if default is not None: | def xml_bool(element, attr, default = None): if element.get(attr) is None: if default is None: return default else: raise Exception("Element has no attribute: " + attr) return element.get(attr).lower() == "true" |
def right_button(self, event, position): | def right_button_down(self, event, position): | def right_button(self, event, position): self.from_item = None self.action = None NetTool.right_button(self, event, position) self.netview.redraw() |
NetTool.right_button(self, event, position) | NetTool.right_button_down(self, event, position) | def right_button(self, event, position): self.from_item = None self.action = None NetTool.right_button(self, event, position) self.netview.redraw() |
self.window.add_tab("Parameters", w, lambda x: self.close_tab_for_obj(obj)) | self.window.add_tab(name, w, lambda x: self.close_tab_for_obj(obj)) | def add_tab(self, name, w, obj): """ Open new tab labeled with "name" with content "w" and register this tab for "obj" """ self.tabtable[obj] = w self.window.add_tab("Parameters", w, lambda x: self.close_tab_for_obj(obj)) self.switch_to_tab(w) |
vconfig = InstanceVisualConfig(self.simulation, i) | vconfig = InstanceVisualConfig(self.simulation, area, i) | def area_callbacks(area, i): vconfig = InstanceVisualConfig(self.simulation, i) draw_fn = lambda cr,w,h,vx,vy: self._instance_draw(cr, w, h, vx, vy, vconfig, area, i) click_fn = lambda position: self._on_instance_click(position, area, i) return (draw_fn, click_fn) |
def __init__(self, simulation, iid): | def __init__(self, simulation, area, iid): | def __init__(self, simulation, iid): self.simulation = simulation self.iid = iid |
tokens = self.simulation.get_tokens_of_place(place) return tokens[self.iid] | if self.area.is_inside(place): tokens = self.simulation.get_tokens_of_place(place) return tokens[self.iid] else: return [] | def get_token_strings(self, place): tokens = self.simulation.get_tokens_of_place(place) return tokens[self.iid] |
self.project.export(proj.get_exported_filename()) | proj.export(proj.get_exported_filename()) | def export_project(self, proj = None): if proj is None: proj = self.project try: self.project.export(proj.get_exported_filename()) except project.ExportException as e: self.console_write(str(e) + "\n", "error") return False return True |
RunProgram("/bin/sh", [os.path.join(TEST_PROJECTS, "fullclean.sh")]).run() | def build(self, filename, final_output): RunProgram("/bin/sh", [os.path.join(TEST_PROJECTS, "fullclean.sh")]).run() name, ext = os.path.splitext(filename) directory = os.path.dirname(name) RunProgram("python", [ CMDUTILS, "--export", filename ]).run() RunProgram(PTP_BIN, [ name + ".xml", name + ".cpp" ]).run() RunProgr... | |
self.build(os.path.join(TEST_PROJECTS, "helloworld.proj"), "Hello world 12\n") | self.build(os.path.join(TEST_PROJECTS, "helloworlds", "helloworld.proj"), "Hello world 12\n") | def test_helloworld(self): self.build(os.path.join(TEST_PROJECTS, "helloworld.proj"), "Hello world 12\n") |
self.build(os.path.join(TEST_PROJECTS, "helloworld2.proj"), "Hello world 5\n") | self.build(os.path.join(TEST_PROJECTS, "helloworlds", "helloworld2.proj"), "Hello world 5\n") def test_packing(self): output = "0\n1\n2\n3\n4\n0\n1\n2\n3\n4\n5\n5\n6\n7\n8\n9\n100\n100\n" self.build(os.path.join(TEST_PROJECTS, "packing", "packing.proj"), output) | def test_helloworld2(self): self.build(os.path.join(TEST_PROJECTS, "helloworld2.proj"), "Hello world 5\n") |
def build(self, filename, final_output): | def build(self, filename, final_output, params = []): | def build(self, filename, final_output): name, ext = os.path.splitext(filename) directory = os.path.dirname(name) RunProgram("/bin/sh", [os.path.join(TEST_PROJECTS, "fullclean.sh")], cwd = directory).run() RunProgram("python", [ CMDUTILS, "--export", filename ]).run() RunProgram(PTP_BIN, [ name + ".xml", name + ".cpp" ... |
RunProgram(name, []).run(final_output) | RunProgram(name, params).run(final_output) | def build(self, filename, final_output): name, ext = os.path.splitext(filename) directory = os.path.dirname(name) RunProgram("/bin/sh", [os.path.join(TEST_PROJECTS, "fullclean.sh")], cwd = directory).run() RunProgram("python", [ CMDUTILS, "--export", filename ]).run() RunProgram(PTP_BIN, [ name + ".xml", name + ".cpp" ... |
if self.selected_item: self.netview.highlight_off() | def select_item(self, item): if self.selected_item: self.netview.highlight_off() self.selected_item = item if item: self.netview.highlight(item) self.netview.set_entry_types(item.get_text_entries()) | |
menu_actions = [("Delete", lambda w: self.selected_item.delete())] | menu_actions = [("Delete", delete_event)] | def right_button_down(self, event, position): if self.selected_item in self.net.pick_items(position): |
def switch_to_tab(self, widget): self.window.switch_to_tab(widget) | def switch_to_tab(self, tabtag): w, callback = self.tabtable[tabtag] self.window.switch_to_tab(w) | def switch_to_tab(self, widget): self.window.switch_to_tab(widget) |
self.switch_to_tab(self.tabtable[transition]) | self.switch_to_tab(transition) | def transition_edit(self, transition): if transition in self.tabtable: self.switch_to_tab(self.tabtable[transition]) return |
self.switch_to_tab(self.tabtable[place]) | self.switch_to_tab(place) | def place_edit(self, place): if place in self.tabtable: self.switch_to_tab(self.tabtable[place]) return |
self.switch_to_tab(self.tabtable["params"]) | self.switch_to_tab("params") | def parameters_edit(self): if "params" in self.tabtable: self.switch_to_tab(self.tabtable["params"]) return w = ParametersWidget(self.project, self.window) self.add_tab("Parameters", w, "params") |
self.switch_to_tab(self.tabtable[tab_tag]) | self.switch_to_tab(tab_tag) return | def edit_sourcefile(self, filename): tab_tag = "file:" + filename if tab_tag in self.tabtable: self.switch_to_tab(self.tabtable[tab_tag]) w = CodeFileEditor(filename) self.add_tab(os.path.basename(filename), w, tab_tag) |
self.switch_to_tab(w) | self.switch_to_tab(obj) | def add_tab(self, name, w, obj, callback = None): """ Open new tab labeled with "name" with content "w" and register this tab for "obj" """ self.tabtable[obj] = (w, callback) self.window.add_tab(name, w, lambda x: self.close_tab_for_obj(obj)) self.switch_to_tab(w) |
if form.validate_on_POST(): | if form.validate_on_submit(): | def index(): form = MyForm() if form.validate_on_POST(): name = form.name.data flash("You entered %s" % name) return redirect(url_for("index")) return render_template("index.html", form=form) |
csrf_token = self._session.get('_csrf_token') | csrf_token = session.get('_csrf_token') | def __init__(self, formdata=None, *args, **kwargs): |
csrf_token = self._session.pop('_csrf_token', None) | csrf_token = session.pop('_csrf_token', None) | def validate_csrf(self, field): if not self.csrf_enabled or request.is_xhr: return csrf_token = self._session.pop('_csrf_token', None) if not field.data or field.data != csrf_token: raise ValidationError, "Missing or invalid CSRF token" |
is_valid = field.data and field.data == csrf_token | is_valid = field.data and \ field.data == csrf_token and \ self.csrf_is_valid is not False | def validate_csrf(self, field): if not self.csrf_enabled or request.is_xhr: return |
return render_template('show_entries.html', entries=entries) | form = EntryForm() return render_template('show_entries.html', entries=entries, form=form) | def show_entries(): entries = Entry.query.order_by(Entry.id.desc()) return render_template('show_entries.html', entries=entries) |
flash('New entry was successfully posted') | def add_entry(): if not session.get('logged_in'): abort(401) form = EntryForm() if form.validate(): entry = Entry() form.populate_obj(entry) db.session.add(entry) db.session.commit() flash('New entry was successfully posted') return redirect(url_for('show_entries')) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.