function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def url_unescape(value, encoding='utf-8', plus=True): """Decodes the given value from a URL. The argument may be either a byte or unicode string. If encoding is None, the result will be a byte string. Otherwise, the result is a unicode string in the specified encoding. If ``p...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def utf8(value): # type: (typing.Union[bytes,unicode_type,None])->typing.Union[bytes,None] """Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8. """ if isinstance(...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def to_unicode(value): """Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8. """ if isinstance(value, _TO_UNICODE_TYPES): return value if not isinstanc...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user su...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def linkify(text, shorten=False, extra_params="", require_protocol=False, permitted_protocols=["http", "https"]): """Converts plain text into HTML with links. For example: ``linkify("Hello http://tornadoweb.org!")`` would return ``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _build_unicode_map(): unicode_map = {} for name, value in htmlentitydefs.name2codepoint.items(): unicode_map[name] = unichr(value) return unicode_map
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _cls(self): return ds.TransformedDistribution
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def testCachedSamplesWithoutInverse(self): with self.test_session() as sess: mu = 3.0 sigma = 0.02 log_normal = self._cls()( distribution=ds.Normal(loc=mu, scale=sigma), bijector=bs.Exp(event_ndims=0)) sample = log_normal.sample(1) sample_val, log_pdf_val = sess.ru...
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def testEntropy(self): with self.test_session(): shift = np.array([[-1, 0, 1], [-1, -2, -3]], dtype=np.float32) diag = np.array([[1, 2, 3], [2, 3, 2]], dtype=np.float32) actual_mvn_entropy = np.concatenate([ [stats.multivariate_normal(shift[i], np.diag(diag[i]**2)).entropy()] f...
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def _cls(self): return ds.TransformedDistribution
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def _testMVN(self, base_distribution_class, base_distribution_kwargs, batch_shape=(), event_shape=(), not_implemented_message=None): with self.test_session() as sess: # Overriding shapes must be compatible w/bijector; most bijectors ar...
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def testScalarBatchNonScalarEvent(self): self._testMVN( base_distribution_class=ds.MultivariateNormalDiag, base_distribution_kwargs={"loc": [0., 0., 0.], "scale_diag": [1., 1, 1]}, batch_shape=[2], not_implemented_message="not implemented") with...
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def testNonScalarBatchNonScalarEvent(self): with self.test_session(): # Can't override event_shape and/or batch_shape for non_scalar batch, # non-scalar event. with self.assertRaisesRegexp(ValueError, "base distribution not scalar"): self._cls()( distribution=ds.MultivariateNor...
npuichigo/ttsflow
[ 16, 6, 16, 1, 1500635633 ]
def __init__(self,params,parent): self.params=params self.parent=parent
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def run(self):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def subplot(*args): import pylab
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def __init__(self,parent=None,title='',direction='H', size=(750,750),lfname=None,params=None): self.fig=None
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Body(self):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Stopping(self): return self.stopping
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Yield(self): wx.Yield()
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def ResetTitle(self):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Plot(self,sim):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Run_Pause(self,event): if not self.running:
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def __load_sim__(self,lfname):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Reset_Simulation(self,event=None): if not os.path.exists(self.tmpfile): return
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Restart(self,event=None):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Load_Simulation(self,event=None): self.canvas.Show(False) if self.modified: (root,sfname)=os.path.split(self.params['save_sim_file']) dlg=MessageDialog(self, text="Do you want to save the changes you made to %s?" % sfname, ...
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Save_Simulation(self,event=None):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Save_Simulation_As(self,event=None):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Set_Simulation_Parameters(self,event): self.canvas.Show(False) set_simulation_parameters(self.params,self) self.canvas.Show(True)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Set_Input_Parameters(self,event): self.canvas.Show(False) set_input_parameters(self.params,self) self.canvas.Show(True)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Set_Output_Parameters(self,event): self.canvas.Show(False) set_output_parameters(self.params,self) self.canvas.Show(True)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Set_Weight_Parameters(self,event): self.canvas.Show(False) set_weight_parameters(self.params,self) self.canvas.Show(True)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Set_Parameter_Structure(self,event): set_parameter_structure(self.params,self)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def CreateMenu(self):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Display(self,event=None): self.canvas.Show(False) dlg = FileDialog(self, "Choose Display Module",default_dir=os.getcwd()+"/", wildcard='Python Plot Files|plot*.py|All Files|*.*') result = dlg.ShowModal() dlg.Destroy() if result == 'ok': l...
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def About(self,event): win=AboutWindow() win.Show()
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Nop(self,event): self.canvas.Show(False) dlg = MessageDialog(self, "Error","Function Not Implemented",icon='error') dlg.ShowModal() dlg.Destroy() self.canvas.Show(True)
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def Quit(self,event=None):
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def run(lfname=None,params=None,use_splash=True): if use_splash: app1=Application(splash.SplashFrame) app1.Run() app = Application(MainFrame, title="Plasticity",lfname=lfname, params=params) app.Run()
bblais/plasticity
[ 5, 3, 5, 1, 1430486979 ]
def test_api_endpoint_existence(todolist_app): with todolist_app.test_client() as client: resp = client.get('/tasks') assert resp.status_code == 200
inkmonk/flask-sqlalchemy-booster
[ 8, 3, 8, 8, 1430659799 ]
def __init__(self, upload): self.upload = upload
dirkmoors/drf-tus
[ 21, 20, 21, 2, 1488992116 ]
def handle_save(self): pass
dirkmoors/drf-tus
[ 21, 20, 21, 2, 1488992116 ]
def finish(self): # Trigger signal signals.saved.send(sender=self.__class__, instance=self) # Finish self.upload.finish() self.upload.save()
dirkmoors/drf-tus
[ 21, 20, 21, 2, 1488992116 ]
def handle_save(self): # Save temporary field to file field file_field = getattr(self.upload, self.destination_file_field) file_field.save(self.upload.filename, File(open(self.upload.temporary_file_path))) # Finish upload self.finish()
dirkmoors/drf-tus
[ 21, 20, 21, 2, 1488992116 ]
def __getattr__(cls, name): return MagicMock()
ageitgey/face_recognition
[ 47526, 12782, 47526, 704, 1488577959 ]
def combinationSum(self, candidates, target): candidates.sort() self.result = [] self.dfs(candidates,target,0,[]) return self.result
UmassJin/Leetcode
[ 85, 40, 85, 57, 1426803902 ]
def dfs(self,candidates,target,start,reslist): length = len(candidates) if target == 0: return self.result.append(reslist)
UmassJin/Leetcode
[ 85, 40, 85, 57, 1426803902 ]
def combinationSum(self, candidates, target): self.result = [] self.dfs(candidates,0,target,[]) return self.result
UmassJin/Leetcode
[ 85, 40, 85, 57, 1426803902 ]
def dfs(self,can,cursum,target,res): if cursum > target: return if cursum == target: self.result.append(res) return for i in xrange(len(can)): if not res or res[len(res)-1] <= can[i]: self.dfs(can,cursum+can[i],target,res+[can[i]])
UmassJin/Leetcode
[ 85, 40, 85, 57, 1426803902 ]
def __init__(self, **kwargs): """Initialization method. Args: **kwargs: Keyword arguments. Kwargs: hash_table (str): The hash table package id. remote (str): The remote ckan url. api_key (str): The ckan api key. ua (str): The user age...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def delete_table(self, resource_id, **kwargs): """Deletes a datastore table. Args: resource_id (str): The datastore resource id. **kwargs: Keyword arguments that are passed to datastore_create. Kwargs: force (bool): Delete resource even if read-only. ...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def get_hash(self, resource_id): """Gets the hash of a datastore table. Args: resource_id (str): The datastore resource id. Returns: str: The datastore resource hash. Raises: NotFound: If `hash_table_id` isn't set or not in datastore. No...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def fetch_resource(self, resource_id, user_agent=None, stream=True): """Fetches a single resource from filestore. Args: resource_id (str): The filestore resource id. Kwargs: user_agent (str): The user agent. stream (bool): Stream content (default: True). ...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def _update_filestore(self, func, *args, **kwargs): """Helps create or update a single resource on filestore. To create a resource, you must supply either `url`, `filepath`, or `fileobj`. Args: func (func): The resource passed to resource_create. *args: Postional...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def update_filestore(self, resource_id, **kwargs): """Updates a single resource on filestore. Args: resource_id (str): The filestore resource id. **kwargs: Keyword arguments that are passed to resource_create. Kwargs: url (str): New file url (for file link)....
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def find_ids(self, packages, **kwargs): default = {'rid': '', 'pname': ''} kwargs.update({'method': self.query, 'default': default}) return pr.find(packages, **kwargs)
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def create_hash_table(self, verbose=False): kwargs = { 'resource_id': self.hash_table_id, 'fields': [ {'id': 'datastore_id', 'type': 'text'}, {'id': 'hash', 'type': 'text'}], 'primary_key': 'datastore_id' } if verbose: ...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def get_update_date(self, item): timestamps = { 'revision_timestamp': 'revision', 'last_modified': 'resource', 'metadata_modified': 'package' } for key, value in timestamps.items(): if key in item: timestamp = item[key] ...
reubano/ckanutils
[ 3, 3, 3, 3, 1434441316 ]
def register(self, tag): return functools.partial(self._register, tag)
afg984/pyardrone
[ 27, 4, 27, 4, 1439552654 ]
def build_dataset(reader, phi_list, class_func, vectorizer=None, verbose=False): """Core general function for building experimental hand-generated feature datasets.
ptoman/icgauge
[ 9, 2, 9, 1, 1460743801 ]
def experiment_features( train_reader=data_readers.toy, assess_reader=None, train_size=0.7, phi_list=[fe.manual_content_flags], class_func=lt.identity_class_func, train_func=training.fit_logistic_at_with_crossvalidation, score_func=scipy.stats.stats.pearsonr, ...
ptoman/icgauge
[ 9, 2, 9, 1, 1460743801 ]
def get_score_example_pairs(y, y_hat, examples): """ Return a list of dicts: {truth score, predicted score, example} """ paired_results = sorted(zip(y, y_hat), key=lambda x: x[0]-x[1]) performance = [] for i, (truth, prediction) in enumerate(paired_results): performance.append({"truth": truth, ...
ptoman/icgauge
[ 9, 2, 9, 1, 1460743801 ]
def experiment_features_iterated( train_reader=data_readers.toy, assess_reader=None, train_size=0.7, phi_list=[fe.manual_content_flags], class_func=lt.identity_class_func, train_func=training.fit_logistic_at_with_crossvalidation, score_func=utils.safe_weighted_...
ptoman/icgauge
[ 9, 2, 9, 1, 1460743801 ]
def try_pull_image(self, name, tag="latest"): ''' Pull an image ''' self.log("(Try) Pulling image %s:%s" % (name, tag))
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def log(self, msg, pretty_print=False): qb_log(msg)
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def __init__(self, client, results): super(ImageManager, self).__init__() self.client = client self.results = results parameters = self.client.module.params self.check_mode = self.client.check_mode self.archive_path = parameters.get('archive_path') self.contain...
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def fail(self, msg): self.client.fail(msg)
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def absent(self): ''' Handles state = 'absent', which removes an image. :return None ''' image = self.client.find_image(self.name, self.tag) if image: name = self.name if self.tag: name = "%s:%s" % (self.name, self.tag) ...
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def push_image(self, name, tag=None): ''' If the name of the image contains a repository path, then push the image. :param name Name of the image to push. :param tag Use a specific tag. :return: None ''' repository = name if not tag: reposito...
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def build_image(self): ''' Build an image :return: image dict ''' params = dict( path=self.path, tag=self.name, rm=self.rm, nocache=self.nocache, stream=True, timeout=self.http_timeout, pull=self...
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def log(self, msg, pretty_print=False): return qb_log(msg)
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def warn( self, warning ): self.results['warnings'].append( str(warning) )
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def qb_debug(name, message, **payload): if not qb.ipc.stdio.client.log.connected: return False
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def main(): argument_spec = dict( archive_path=dict(type='path'), container_limits=dict(type='dict'), dockerfile=dict(type='str'), force=dict(type='bool', default=False), http_timeout=dict(type='int'), load_path=dict(type='path'), name=dict(type='str', require...
nrser/qb
[ 1, 1, 1, 8, 1448301308 ]
def setUp(self): entry_Li = ComputedEntry("Li", -1.90753119) with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "LiTiO2_batt.json")) as f: entries_LTO = json.load(f, cls=MontyDecoder) self.ie_LTO = InsertionElectrode.from_entries(entries_LTO, entry_Li) with open(os.pat...
materialsproject/pymatgen
[ 1063, 732, 1063, 235, 1319343039 ]
def testPlotly(self): plotter = VoltageProfilePlotter(xaxis="frac_x") plotter.add_electrode(self.ie_LTO, "LTO insertion") plotter.add_electrode(self.ce_FF, "FeF3 conversion") fig = plotter.get_plotly_figure() self.assertEqual(fig.layout.xaxis.title.text, "Atomic Fraction of Li") ...
materialsproject/pymatgen
[ 1063, 732, 1063, 235, 1319343039 ]
def __init__(self, songs_data=None): if songs_data is None: self.songs_data = [] else: self.songs_data = songs_data
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def songs(self): for s in self.songs_data: yield s
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def num_features(self): if len(self.songs_data): return self.songs_data[0].X.shape[1]
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def size(self): return len(self.songs_data)
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def __init__(self, audio_path, label_path): if not os.path.isfile(audio_path): raise IOError("Audio file at %s does not exist" % audio_path) if label_path and not os.path.isfile(label_path): raise IOError("MIDI file at %s does not exist" % label_path) self.audio_path = a...
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def x(self): return self.__x
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def x(self, x): self.__x = x
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def X(self): return self.__X
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def X(self, X): if hasattr(self, 'Y') and self.Y.shape[0] != X.shape[0]: raise ValueError("Number of feature frames must equal number of label frames") self.__X = X
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def Y(self): return self.__Y
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def Y(self, Y): if hasattr(self, 'X') and self.X.shape[0] != Y.shape[0]: raise ValueError("Number of label frames must equal number of feature frames") self.__Y = Y
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def num_pitches(self): if hasattr(self, 'Y'): return np.shape(self.Y)[1] return 0
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def num_features(self): if hasattr(self, 'X'): return self.X.shape[1]
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def num_frames(self): if hasattr(self, 'X'): return self.X.shape[0]
Guitar-Machine-Learning-Group/guitar-transcriber
[ 1, 2, 1, 1, 1476390274 ]
def setHome(home): global __home __home = home
ManiacalLabs/PixelWeb
[ 18, 6, 18, 10, 1445800144 ]
def initConfig(): try: if not os.path.exists(__home): print "Creating {}".format(__home) os.makedirs(__home) except: print "Failed to initialize PixelWeb config!"
ManiacalLabs/PixelWeb
[ 18, 6, 18, 10, 1445800144 ]
def writeConfig(file, data, key = None, path=None): if not path: path = __home base = data if key: base = readConfig(file, path=path) base[key] = data with open(path + "/" + file + ".json", "w") as fp: json.dump(base, fp, indent=4, sort_keys=True)
ManiacalLabs/PixelWeb
[ 18, 6, 18, 10, 1445800144 ]
def readServerConfig(): data = readConfig("config", path=__home) base = paramsToDict(BASE_SERVER_CONFIG.params) if len(data.keys()) == 0: data = paramsToDict(BASE_SERVER_CONFIG.params) elif len(data.keys()) != len(base.keys()): data.upgrade(base) return d(data)
ManiacalLabs/PixelWeb
[ 18, 6, 18, 10, 1445800144 ]
def test_segment_pools(): ### Test Segment ID Pool Operations # Get all configured Segment Pools get_segment_resp = client_session.read('vdnSegmentPools') client_session.view_response(get_segment_resp) # Add a Segment Pool segments_create_body = client_session.extract_resource_body_example('vd...
vmware/nsxramlclient
[ 41, 33, 41, 9, 1440806810 ]
def has_ext_modules(self): return True
ryfeus/lambda-packs
[ 1086, 234, 1086, 13, 1476901359 ]
def finalize_options(self): ret = InstallCommandBase.finalize_options(self) self.install_headers = os.path.join(self.install_purelib, 'tensorflow', 'include') return ret
ryfeus/lambda-packs
[ 1086, 234, 1086, 13, 1476901359 ]
def initialize_options(self): self.install_dir = None self.force = 0 self.outfiles = []
ryfeus/lambda-packs
[ 1086, 234, 1086, 13, 1476901359 ]
def mkdir_and_copy_file(self, header): install_dir = os.path.join(self.install_dir, os.path.dirname(header)) # Get rid of some extra intervening directories so we can have fewer # directories for -I install_dir = re.sub('/google/protobuf_archive/src', '', install_dir) # Copy eigen code into tensorf...
ryfeus/lambda-packs
[ 1086, 234, 1086, 13, 1476901359 ]