code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def page49(self): <NEW_LINE> <INDENT> result = request4901.GET('/images/G/01/x-locale/personalization/shoveler/left-right-arrow-semi-rd._V236573507_.gif') <NEW_LINE> return result | GET left-right-arrow-semi-rd._V236573507_.gif (request 4901). | 625941f63c8af77a43ae3dfd |
def generate_image_files( filenames: List[Path], dimensions: List[Tuple[int, int]], ) -> None: <NEW_LINE> <INDENT> for path, dim in zip(filenames, dimensions): <NEW_LINE> <INDENT> image = Image.new(mode="RGB", size=dim) <NEW_LINE> if not path.parent.exists(): <NEW_LINE> <INDENT> path.parent.mkdir(parents=True) <NEW_LIN... | Create multiple images with given filenames and random sizes. | 625941f60c0af96317bb883c |
def hook_step(A, b, trusted_region, hook_maxiter, hook_tol, nu=0, **opt): <NEW_LINE> <INDENT> logger = Logger(__name__, "Hook step") <NEW_LINE> r = trusted_region <NEW_LINE> logger.debug({"nu0": nu, "trusted_region": r, }) <NEW_LINE> I = np.matrix(np.identity(len(b), dtype=b.dtype)) <NEW_LINE> AA = np.dot(A.T, A) <NEW_... | optimal hook step based on trusted region approach
Return :math:`x` which minimizes :math:`|Ax-b|`
under the constraint :math:`|x| < r`,
where :math:`r` denotes the radius of trusted region.
Parameters
----------
A : numpy.array (2d)
:math:`A`
b : numpy.array (1d)
:math:`b`
nu : float, optional (default=0.0)
... | 625941f6ec188e330fd5ade6 |
def find_definition(view, location, keyword): <NEW_LINE> <INDENT> for selector, above_only, _ in SYMBOLS: <NEW_LINE> <INDENT> region = find_nearest_symbol( view, keyword, selector, location, above_only) <NEW_LINE> if region: <NEW_LINE> <INDENT> return region <NEW_LINE> <DEDENT> <DEDENT> return None | Find the local definition of a keyword in the view.
Uses the tuple of scopes to search for the local definition of keyword.
Arguments:
view (sublime.View):
the view the keyword is defined in
location (int):
the text position to use to decide which find results to include
keyword (string):
... | 625941f6b545ff76a891446a |
def load_callbacks(self): <NEW_LINE> <INDENT> if self._callbacks_loaded: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> stdout_callback_loaded = False <NEW_LINE> if self._stdout_callback is None: <NEW_LINE> <INDENT> self._stdout_callback = C.DEFAULT_STDOUT_CALLBACK <NEW_LINE> <DEDENT> if isinstance(self._stdout_callbac... | Loads all available callbacks, with the exception of those which
utilize the CALLBACK_TYPE option. When CALLBACK_TYPE is set to 'stdout',
only one such callback plugin will be loaded. | 625941f6a8370b7717052ef2 |
def tuple_get(string, count=None): <NEW_LINE> <INDENT> if not string: return None <NEW_LINE> string = string.strip() <NEW_LINE> assert string.startswith("(") and string.endswith(")") <NEW_LINE> string = string[1:-1] <NEW_LINE> res = string.split(";") <NEW_LINE> if count is not None: <NEW_LINE> <INDENT> assert len(res) ... | parse a tuple string like "(1024;768)" and return strings of the elements | 625941f6167d2b6e312191e9 |
def test_get_sample_type(): <NEW_LINE> <INDENT> assert_true(c.sample_type == "random" or c.sample_type == "lhs") | Test getting the sample_type property. | 625941f61b99ca400220b109 |
def get_flow_steps(self, for_docs=False, verbose=False): <NEW_LINE> <INDENT> lines = [] <NEW_LINE> previous_parts = [] <NEW_LINE> previous_source = None <NEW_LINE> for step in self.steps: <NEW_LINE> <INDENT> parts = step.path.split(".") <NEW_LINE> steps = str(step.step_num).split("/") <NEW_LINE> if len(parts) > len(ste... | Returns a list of flow steps (tasks and sub-flows) for the given flow.
For docs, indicates whether or not we want to use the string for use in a code-block
of an rst file. If True, will omit output of source information. | 625941f63d592f4c4ed1d6b0 |
def run(): <NEW_LINE> <INDENT> env = Environment() <NEW_LINE> agent = env.create_agent(LearningAgent) <NEW_LINE> env.set_primary_agent(agent, enforce_deadline=True) <NEW_LINE> sim = Simulator(env, update_delay=0.01, log_metrics=True, display=False) <NEW_LINE> sim.run(n_test=10) | Driving function for running the simulation.
Press ESC to close the simulation, or [SPACE] to pause the simulation. | 625941f6d4950a0f3b08c99b |
def get_services(self): <NEW_LINE> <INDENT> return self._client._invoke('KRPC', 'GetServices', return_type=self._client._types.as_type('KRPC.Services')) | Get available services and procedures | 625941f624f1403a926011b5 |
def connection_is_established(): <NEW_LINE> <INDENT> return (not _remote_client is None) | Function to check if a connection to the remote server has been established | 625941f663f4b57ef000175b |
def __get_hn_status(self): <NEW_LINE> <INDENT> ret = self.show_wifi() <NEW_LINE> ret_lst = [] <NEW_LINE> if ret[0] == 0: <NEW_LINE> <INDENT> for ele in ret[1].replace(" ", "").split("\n"): <NEW_LINE> <INDENT> if 1 == ele.count(":"): <NEW_LINE> <INDENT> ret_lst += [ele.split(":"),] <NEW_LINE> <DEDENT> <DEDENT> self.hn_s... | parse the status information of hostednetwork stored in self.hn_status
:Returns:
return the flag that function is executed successful or not | 625941f62ae34c7f2600d785 |
def getNumberVertices(self): <NEW_LINE> <INDENT> return len(self.vertices) | Get the number of vertices of the Graph | 625941f656b00c62f0f14cb3 |
def search(self): <NEW_LINE> <INDENT> self._nav(self.search_filters_url) <NEW_LINE> time.sleep(2) | Go to the search results page | 625941f601c39578d7e75490 |
def test_recover(self): <NEW_LINE> <INDENT> lr, sp, _ = ialm.recover(self._data, None) <NEW_LINE> baseline = np.genfromtxt("im_baseline.dat") <NEW_LINE> d = np.linalg.norm(np.round(lr)-baseline, ord='fro') <NEW_LINE> self.assertTrue(np.allclose(d,0.0)) | Test recovery from outliers.
| 625941f671ff763f4b549ced |
def __init__(self, text, size_min = None, size_max = None, parent = None): <NEW_LINE> <INDENT> CfgBase.__init__(self, parent) <NEW_LINE> self.label = QLabel(text, parent) <NEW_LINE> self.lineedit = QLineEdit(parent) <NEW_LINE> layout = QVBoxLayout(parent) <NEW_LINE> layout.addWidget(self.label) <NEW_LINE> layout.addWid... | Initialization of the CfgLineEdit class (text edit, one line).
@param text: text string associated with the line edit
@param size_min: min length (int)
@param size_max: max length (int) | 625941f6460517430c3947c8 |
@app.route('/anim/set/custom', methods=['POST']) <NEW_LINE> def animSetCustom(): <NEW_LINE> <INDENT> return "TODO" | Permanently reset the default animation to a custom definition.
API should expect json object of a `desc`. | 625941f632920d7e50b2882b |
def test(hparams, estimator): <NEW_LINE> <INDENT> test_input = lambda: model.make_input_fn( data_file=hparams.test_file, seq_len=hparams.seq_len, batch_size=hparams.eval_batch_size, cols=SELECT_COLUMN, num_epochs=1) <NEW_LINE> if hparams.test_file.startswith("gs"): <NEW_LINE> <INDENT> bucket_name = hparams.test_file.sp... | Run trained estimator on the test set.
Run trained estimator on the testset for debugging.
Args:
hparams: hyper-parameteters
estimator: trained tf estimator | 625941f663d6d428bbe44b47 |
def ToggleAnnotation( arg = None ): <NEW_LINE> <INDENT> nInputs = ctx.field('numberOfInputs').value <NEW_LINE> currentValue = ctx.field('CustomOrthoView2D0.annotationSizeMode').value <NEW_LINE> values = list( ctx.field('CustomOrthoView2D0.annotationSizeMode').items() ) <NEW_LINE> newValue = '' <NEW_LINE> if ( currentVa... | Toggle all annotations on and off | 625941f6e1aae11d1e74a313 |
def ContourIntegralCircular(imagen, y_0, x_0, r, angs): <NEW_LINE> <INDENT> y = np.zeros([len(angs), r.shape[0], r.shape[1], r.shape[2]], dtype=int) <NEW_LINE> x = np.zeros([len(angs), r.shape[0], r.shape[1], r.shape[2]], dtype=int) <NEW_LINE> for i in range(len(angs)): <NEW_LINE> <INDENT> ang = angs[i] <NEW_LINE> y[i,... | Contour/circular integral using discrete rieman | 625941f6627d3e7fe0d694a7 |
def stringeval(text): <NEW_LINE> <INDENT> stringchar = text[0] <NEW_LINE> if text[-1] != stringchar or stringchar not in ("'", '"'): <NEW_LINE> <INDENT> raise ValueError("error parsing escaped string: %r" % text) <NEW_LINE> <DEDENT> return text[1:-1].replace((stringchar + stringchar), stringchar) | takes away repeated quotes (escapes) and returns the string represented
by the text | 625941f6046cf37aa974d396 |
def stop(self): <NEW_LINE> <INDENT> if (self._limb_client.gh is not None and self._limb_client.get_state() == actionlib.GoalStatus.ACTIVE): <NEW_LINE> <INDENT> self._limb_client.cancel_goal() <NEW_LINE> <DEDENT> rospy.sleep(0.1) | Preempts trajectory execution by sending cancel goals | 625941f660cbc95b062c6b99 |
def testGroupDeleteByID(self): <NEW_LINE> <INDENT> self.g_rh.delete(id=self.g1.id, client_key=self.g1.client_key) <NEW_LINE> try: <NEW_LINE> <INDENT> self.assertRaises(self.g_rh.get(id=self.g1.id), RequestedRangeNotSatisfiable) <NEW_LINE> <DEDENT> except RequestedRangeNotSatisfiable: <NEW_LINE> <INDENT> pass | Try to remove a Group by ID. Expect subsequent request for that Group to fail. | 625941f6d53ae8145f87a8b7 |
def save(self): <NEW_LINE> <INDENT> self.profile_to_save = self.get_profile_dict() <NEW_LINE> self.root.destroy() <NEW_LINE> save_profile(self.profile_to_save, self.profile_to_save["user"]) <NEW_LINE> StartMenu().run() | Saves profile, exits app and start load menu again | 625941f6cc40096d61595fa3 |
def patch(self): <NEW_LINE> <INDENT> raise NotImplementedError | Patch the target path to hijack calls. | 625941f6fff4ab517eb2fa96 |
def display_parameters(self): <NEW_LINE> <INDENT> names = [ "Starting probabilities (pi):", "Transition probabilities (A):", "Emission probabilities (B):" ] <NEW_LINE> for i, parameter in enumerate([self._pi, self._A, self._B]): <NEW_LINE> <INDENT> print(names[i]) <NEW_LINE> for element in parameter: <NEW_LINE> <INDENT... | Display the lambda parameters (A,B,pi) on the console. | 625941f66fb2d068a760f6fd |
def publish(self, issue): <NEW_LINE> <INDENT> if self.subscribers: <NEW_LINE> <INDENT> self.issues.append(issue) <NEW_LINE> <DEDENT> return issue | Adds a new issue to the tail of the queue. | 625941f610dbd63aa1bd31f7 |
def get_id(self): <NEW_LINE> <INDENT> return _extract( self._request(self.ws_prefix + ".getInfo", cacheable=True), "id") | Returns the ID on the network. | 625941f6e5267d203edce2ea |
def plot_county_results(): <NEW_LINE> <INDENT> filePathS = os.path.join(config.rawDataPathS, 'election_statistics', '2008', 'elpo08p020') <NEW_LINE> fullShapeFile = shapefile.Reader(filePathS) <NEW_LINE> shapeL = fullShapeFile.shapes() <NEW_LINE> del fullShapeFile <NEW_LINE> numShapes = len(shapeL) <NEW_LINE> fullDF = ... | Reads in the shapefile and plots a full map of all counties, colored red or blue according to vote totals
See http://stackoverflow.com/questions/15968762/shapefile-and-matplotlib-plot-polygon-collection-of-shapefile-coordinates for how to quickly plot shapes from a shapefile | 625941f645492302aab5e920 |
def endpoint(self, opts: VimOptions) -> Tuple[int, int]: <NEW_LINE> <INDENT> line, col = self.endpoints[-1] if self.endpoints != [] else (0, 1) <NEW_LINE> return (line + 1, col - 1 + 1) | Return the end of the Coq checked section. | 625941f6bf627c535bc13825 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.bands = {"2g": 'g', "5g": 'a'} <NEW_LINE> self.config_path = kwargs.get('config_path', '/mm/mynode') <NEW_LINE> self.api_version = kwargs.get('api_version', 1) <NEW_LINE> self.username = kwargs['username'] <NEW_LINE> self.password = kwargs['password'] <NEW_LINE> se... | Args:
:username (str): MobilityController Login username.
:password (str): MobilityController Login password.
:url (str): MobilityController url.
:proxy (str) Proxy to use. (default=None)
:api_version API Version to use (default=1)
Usage: ::
>>> from aruba_os import ArubaOSAPIClient
>>> MobilityController = MobilityCon... | 625941f697e22403b379d5f1 |
def __init__(self, size, position=None, colour=None): <NEW_LINE> <INDENT> if position is None: <NEW_LINE> <INDENT> position = defaults.canvas_position <NEW_LINE> <DEDENT> Visual.__init__(self, position) <NEW_LINE> self._size = size <NEW_LINE> if colour is not None: <NEW_LINE> <INDENT> self._colour = colour <NEW_LINE> <... | Create a canvas.
Parameters
----------
size : (int, int)
size of the canvas (int,int)
position : (int, int), optional
position of the stimulus
colour : (int,int,int), optional
colour of the canvas stimulus | 625941f6283ffb24f3c55f4f |
def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkSqrtImageFilterIUL3IUL3_Superclass.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj | New() -> itkSqrtImageFilterIUL3IUL3_Superclass
Create a new object of the class itkSqrtImageFilterIUL3IUL3_Superclass and set the input and the parameters if some
named or non-named arguments are passed to that method.
New() tries to assign all the non named parameters to the input of the new objects - the
first non ... | 625941f630bbd722463cc420 |
def copy(self, *__args): <NEW_LINE> <INDENT> return QPixmap | QPixmap.copy(QRect rect=QRect()) -> QPixmap
QPixmap.copy(int, int, int, int) -> QPixmap | 625941f6ac7a0e7691ed4715 |
def alienOrder(self, words): <NEW_LINE> <INDENT> def dfs(u): <NEW_LINE> <INDENT> for v in adj[u]: <NEW_LINE> <INDENT> if visited[v]: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> timer[0] += 1 <NEW_LINE> t_in = timer[0] <NEW_LINE> visited[v] = True <NEW_LINE> dfs(v) <NEW_LINE> timer[0] += 1 <NEW_LINE> t_out = timer[... | :type words: List[str]
:rtype: str | 625941f6498bea3a759ba103 |
def get_votes(self): <NEW_LINE> <INDENT> raise NotImplementedError | Optional.
Retrieves the vote matrix saved by ``store_votes``.
You won't usually need to implement this method, because you want to use fresh data.
But it might be useful if you want some kind of heavy caching, maybe for testing purposes. | 625941f6c432627299f052a1 |
def testBody92(self): <NEW_LINE> <INDENT> pass | Test Body92 | 625941f65166f23b2e1a57af |
@app.route('/create_event', methods=['POST']) <NEW_LINE> def create_event(): <NEW_LINE> <INDENT> client_id = crud.get_client_id(session['clientEmail']) <NEW_LINE> goh_name = request.form['goh_name'] <NEW_LINE> partypackage = request.form['partypackage'] <NEW_LINE> purchase_id = crud.get_partypackage(partypackage) <NEW_... | Create an Event | 625941f6ab23a570cc2507de |
def upgrade_test(test): <NEW_LINE> <INDENT> if isinstance(test, basestring): <NEW_LINE> <INDENT> return {'test': test} <NEW_LINE> <DEDENT> assert isinstance(test, dict) <NEW_LINE> return test | Converts from old style string to new style dict. | 625941f6099cdd3c635f12ad |
def setSocketUserID(sock, userID): <NEW_LINE> <INDENT> sock._actor_userID = userID | !Set a user ID on a socket
| 625941f65fdd1c0f98dc088c |
def encode_lat_or_long(self, x, prev_int): <NEW_LINE> <INDENT> int_value = int(x * 1e5) <NEW_LINE> delta = int_value - prev_int <NEW_LINE> return self.encode_signed(delta), int_value | Encode a single latitude or longitude.
``x``
The latitude or longitude to encode
``prev_int``
The integer value of the previous latitude or longitude
Return the encoded value and its int value, which is used
Example::
>>> x = -179.9832104
>>> encoded_x, prev = encode_lat_or_long(x, 0)
>>> encoded... | 625941f64f6381625f115091 |
def git_mv(old,new): <NEW_LINE> <INDENT> import subprocess <NEW_LINE> commands = [ 'git', 'mv', old, new ] <NEW_LINE> process = subprocess.Popen( commands, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) <NEW_LINE> return_code = process.wait() | git mv | 625941f6dd821e528d63b7f9 |
def __init__(__self__, resource_name, opts=None, organization_id=None, zone=None, __props__=None, __name__=None, __opts__=None): <NEW_LINE> <INDENT> if __name__ is not None: <NEW_LINE> <INDENT> warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning) <NEW_LINE> resource_name = __name__ <NEW_LINE> <DE... | Create a InstanceIP resource with the given unique name, props, and options.
:param str resource_name: The name of the resource.
:param pulumi.ResourceOptions opts: Options for the resource.
:param pulumi.Input[str] organization_id: The organization_id you want to attach the resource to
:param pulumi.Input[str] zone: T... | 625941f616aa5153ce362acf |
def __init__(self, directory='', name='', phenotype1='up', phenotype2='down'): <NEW_LINE> <INDENT> self.directory = directory <NEW_LINE> self.phenotype1 = phenotype1 <NEW_LINE> self.phenotype2 = phenotype2 | directory: the directory containing the full GSEA result files
name: name to give the analysis, this will be the name on the
tab in the excel file | 625941f6b545ff76a891446b |
def create_excel(self, path, filename): <NEW_LINE> <INDENT> if not path.endswith('/'): <NEW_LINE> <INDENT> file = path + '/' + filename + '.xls' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> file = path + filename + '.xls' <NEW_LINE> <DEDENT> excel = xlwt.Workbook(encoding='utf-8', style_compression=0) <NEW_LINE> excel... | Create excel | 625941f60383005118ecfc36 |
def request(self, path, payload=None): <NEW_LINE> <INDENT> self.define_method() <NEW_LINE> self.path = path <NEW_LINE> if self.params.get('port') is not None: <NEW_LINE> <INDENT> self.url = '%(protocol)s://%(host)s:%(port)s/' % self.params + path.lstrip('/') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.url = '%(p... | Perform a REST request | 625941f621bff66bcd684fa2 |
def find_pair(self, numbers: list, target: int) -> tuple: <NEW_LINE> <INDENT> if isinstance(numbers, list) and isinstance(target, int): <NEW_LINE> <INDENT> for num in numbers: <NEW_LINE> <INDENT> for i in range(numbers.index(num)+1, len(numbers)): <NEW_LINE> <INDENT> if num + numbers[i] == target: <NEW_LINE> <INDENT> o... | Method: find_pair
Parameters: list of integers, target integer
Outputs: tuple of indeces of list items whose sum is the target | 625941f6b830903b967e9f59 |
def specialExpected(self, char): <NEW_LINE> <INDENT> if self.nextChar() == char: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> syntError() | will exit program with syntax error
if next lexem is not what expected | 625941f630dc7b7665901fb5 |
def upload(self, blueprint_path, blueprint_id): <NEW_LINE> <INDENT> tempdir = tempfile.mkdtemp() <NEW_LINE> try: <NEW_LINE> <INDENT> tar_path = self._tar_blueprint(blueprint_path, tempdir) <NEW_LINE> application_file = os.path.basename(blueprint_path) <NEW_LINE> blueprint = self._upload( tar_path, blueprint_id=blueprin... | Uploads a blueprint to Cloudify's manager.
:param blueprint_path: Main blueprint yaml file path.
:param blueprint_id: Id of the uploaded blueprint.
:return: Created blueprint.
Blueprint path should point to the main yaml file of the blueprint
to be uploaded. Its containing folder will be packed to an archive
and get ... | 625941f631939e2706e4d4b6 |
def _select_action(self): <NEW_LINE> <INDENT> if self.eval_mode: <NEW_LINE> <INDENT> epsilon = self.epsilon_eval <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> epsilon = self.epsilon_fn( self.epsilon_decay_period, self.training_steps, self.min_replay_history, self.epsilon_train) <NEW_LINE> <DEDENT> if random.random() <=... | Select an action from the set of available actions.
Chooses an action randomly with probability self._calculate_epsilon(), and
otherwise acts greedily according to the current Q-value estimates.
Returns:
int, the selected action. | 625941f67d43ff24873a32fc |
def __call__(self, embedding, state): <NEW_LINE> <INDENT> new_output, new_state = self.step(embedding, state) <NEW_LINE> return (new_output, new_state) | Args:
inputs: the embedding of the previous word for training only
state: tuple: (h, o) where h is the hidden state and o is the vector
used to make the prediction of the previous word | 625941f691f36d47f21acb50 |
def _test_header(self, fname, expected_header): <NEW_LINE> <INDENT> success = True <NEW_LINE> with open(fname, "r", newline="") as csvfile: <NEW_LINE> <INDENT> rdr = csv.reader(csvfile, delimiter=RIIS.DELIMITER) <NEW_LINE> header = next(rdr) <NEW_LINE> <DEDENT> fld_count = len(header) <NEW_LINE> if fld_count != len(exp... | Compare the actual header in fname with an expected_header.
Print warnings if actual fieldnames contain non-ascii characters. Print errors
if the actual header does not contain the same fieldnames, in the same order, as
the expected_header.
Args:
fname (str): CSV data file containing header to check
expected... | 625941f6a8370b7717052ef3 |
def test_multi_column_write_table_html_fill_values_masked(): <NEW_LINE> <INDENT> buffer_output = StringIO() <NEW_LINE> t = Table([[1, 2, 3, 4], ['--', 'a', '--', 'b']], names=('a', 'b'), masked=True) <NEW_LINE> t['a'][0:2] = np.ma.masked <NEW_LINE> t['b'][0:2] = np.ma.masked <NEW_LINE> ascii.write(t, buffer_output, fil... | Test that passing masked values in fill_values should only replace
masked columns or values for multidimensional tables | 625941f68a349b6b435e87c9 |
def ext_pillar(self, pillar, pillar_dirs): <NEW_LINE> <INDENT> if 'ext_pillar' not in self.opts: <NEW_LINE> <INDENT> return pillar <NEW_LINE> <DEDENT> if not isinstance(self.opts['ext_pillar'], list): <NEW_LINE> <INDENT> log.critical('The "ext_pillar" option is malformed') <NEW_LINE> return pillar <NEW_LINE> <DEDENT> e... | Render the external pillar data | 625941f6b7558d58953c555c |
def signServerKeyExchange(self, serverKeyExchange, sigHash=None): <NEW_LINE> <INDENT> if self.serverHello.server_version < (3, 3): <NEW_LINE> <INDENT> hashBytes = serverKeyExchange.hash(self.clientHello.random, self.serverHello.random) <NEW_LINE> serverKeyExchange.signature = self.privateKey.sign(hashBytes) <NEW_LINE> ... | Sign a server key exchange using default or specified algorithm
:type sigHash: str
:param sigHash: name of the signature hash to be used for signing | 625941f667a9b606de4a850c |
def __init__(self, cuda=False, model='resnet-18', layer='default', layer_output_size=512): <NEW_LINE> <INDENT> self.device = torch.device("cuda" if cuda else "cpu") <NEW_LINE> self.layer_output_size = layer_output_size <NEW_LINE> self.model_name = model <NEW_LINE> self.model, self.extraction_layer = self._get_model_and... | Img2Vec
:param cuda: If set to True, will run forward pass on GPU
:param model: String name of requested model
:param layer: String or Int depending on model. See more docs: https://github.com/christiansafka/img2vec.git
:param layer_output_size: Int depicting the output size of the requested layer | 625941f6566aa707497f4bb6 |
def recall_score(y_true, y_pred, average='micro', suffix=False): <NEW_LINE> <INDENT> true_entities = set(get_entities(y_true, suffix)) <NEW_LINE> pred_entities = set(get_entities(y_pred, suffix)) <NEW_LINE> nb_correct = len(true_entities & pred_entities) <NEW_LINE> nb_true = len(true_entities) <NEW_LINE> score = nb_cor... | Compute the recall.
The recall is the ratio ``tp / (tp + fn)`` where ``tp`` is the number of
true positives and ``fn`` the number of false negatives. The recall is
intuitively the ability of the classifier to find all the positive samples.
The best value is 1 and the worst value is 0.
Args:
y_true : 2d array. Groun... | 625941f671ff763f4b549cee |
def restartGame(self): <NEW_LINE> <INDENT> from menuWindow import MenuWindow <NEW_LINE> self.menu = MenuWindow() <NEW_LINE> self.menu.show() <NEW_LINE> self.close() | Called when restart button is clicked. Reopens the menu
Imports the MenuWindow class to open, Instantiates it, and tells the application to show it. Closes game window shortly after. | 625941f63eb6a72ae02ecb46 |
def load_test_files(path): <NEW_LINE> <INDENT> modules = load_modules(path) <NEW_LINE> functions = [] <NEW_LINE> for module in modules: <NEW_LINE> <INDENT> functions += _get_setup_functions_from_module(module) <NEW_LINE> <DEDENT> return functions | load_test_files :: String -> [(a -> b)]
Given a filesystem path, import all modules under that path, then import all setup_functions
inside those modules.
See load_modules, _get_setup_functions_from_module | 625941f6d18da76e23532b35 |
def connect_JSON(config): <NEW_LINE> <INDENT> testnet = config.get('testnet', '0') <NEW_LINE> testnet = (int(testnet) > 0) <NEW_LINE> if not 'rpcport' in config: <NEW_LINE> <INDENT> config['rpcport'] = 4445 if testnet else 14445 <NEW_LINE> <DEDENT> connect = "http://%s:%s@127.0.0.1:%s"%(config['rpcuser'], config['rpcpa... | Connect to a mirai JSON-RPC server | 625941f6bd1bec0571d90c85 |
def cancel_hitas_application(application_apartment: ApplicationApartment) -> None: <NEW_LINE> <INDENT> apartment_uuid = application_apartment.apartment_uuid <NEW_LINE> was_reserved = application_apartment.apartment_reservation.state in [ ApartmentReservationState.RESERVED, ApartmentReservationState.OFFERED, ] <NEW_LINE... | Cancel a HITAS application for a specific apartment. If the application has already
won an apartment, then the winner for that apartment must be recalculated. | 625941f6009cb60464c63a02 |
def test_SeleniumStringPatterns(self): <NEW_LINE> <INDENT> self.sd('open', '/static/page1') <NEW_LINE> self.sd('getText', 'css=h1', 'regexp:H1 text') <NEW_LINE> with py.test.raises(AssertionError): <NEW_LINE> <INDENT> self.sd('assertText', 'css=h1', 'regexp:H1 tex') <NEW_LINE> <DEDENT> self.sd('assertText', 'css=h1', '... | testing string match parameters regexp, exact and glob in _match and _isContained methods | 625941f6f7d966606f6aa662 |
def test_no_birth_with_death(self): <NEW_LINE> <INDENT> test = birth_before_death.birth_before_death(self.individuals['I04']) <NEW_LINE> self.assertFalse(test) | Tests birth_before_death when no birth date exists but a death date does exist | 625941f6aad79263cf3910a1 |
def greeter(): <NEW_LINE> <INDENT> name = input("What is your name? ") <NEW_LINE> print("\nMarvin says:\n") <NEW_LINE> print("Hello %s - your awesomeness!" % name) <NEW_LINE> print("What can I do you for?!") | Greets the user with the parameter as the phrase | 625941f6b5575c28eb68e65d |
@pytest.fixture() <NEW_LINE> def si(nch_and_spacing, bw): <NEW_LINE> <INDENT> nb_channel, spacing = nch_and_spacing <NEW_LINE> return create_input_spectral_information(191.3e12, 0.15, bw, 1e-3, spacing, nb_channel) | parametrize a channel comb with nb_channel, spacing and signal bw | 625941f67cff6e4e81117fdc |
def reject_invitation( self, location, invitation, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "2020-09-01" ... | Rejects the invitation identified by invitationId.
Reject an invitation.
:param location: Location of the invitation.
:type location: str
:param invitation: An invitation payload.
:type invitation: ~azure.mgmt.datashare.models.ConsumerInvitation
:keyword callable cls: A custom type or function that will be passed the... | 625941f6187af65679ca5777 |
def problem_57() -> int: <NEW_LINE> <INDENT> counter = 0 <NEW_LINE> recursionlimit = sys.getrecursionlimit() <NEW_LINE> sys.setrecursionlimit(1010) <NEW_LINE> for i in range(1, 1001): <NEW_LINE> <INDENT> fraction_list = get_fraction(1, get_continued_fraction_expansion(i)) <NEW_LINE> if judge_numerator_digit_is_bigger_t... | Square root convergents | 625941f64f88993c3716c6b6 |
def iq_updatexml(self, iq): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> identifier = iq.getTag("query").getTag("archipel").getAttr("identifier") <NEW_LINE> domain = iq.getTag("query").getTag("archipel").getTag("domain") <NEW_LINE> reply = self.updatexml(iq, identifier, domain) <NEW_LINE> <DEDENT> except Exception as e... | Update the XML description of a parked virtual machine
@type iq: xmpp.Protocol.Iq
@param iq: the received IQ
@rtype: xmpp.Protocol.Iq
@return: a ready to send IQ containing the result of the action | 625941f67b25080760e39aab |
def test_is_remote_user_on_current_user(): <NEW_LINE> <INDENT> assert not is_remote_user(None) <NEW_LINE> assert not is_remote_user(os.getenv('USER')) | is_remote_user with current user. | 625941f6f8510a7c17cf9d58 |
def __init__(self): <NEW_LINE> <INDENT> self._capabilities = {'chrome.switches': [], 'chrome.extensions': []} | Initialize ChromeOptions object. | 625941f60a50d4780f6674ee |
def compress_data(data): <NEW_LINE> <INDENT> compressed = {} <NEW_LINE> for k, v in data.items(): <NEW_LINE> <INDENT> if not k == v: <NEW_LINE> <INDENT> compressed[k] = v <NEW_LINE> <DEDENT> <DEDENT> return compressed | Remove all keys from ``data`` that refer to themselves::
>>> data = {'a': 'a', 'b': 'c'}
>>> compress_data(data)
{'b': 'c'} | 625941f68e71fb1e9831ddfc |
def _create_control_area_remove(self): <NEW_LINE> <INDENT> main_box = Gtk.HBox() <NEW_LINE> remove_button = self._set_up_remove_button() <NEW_LINE> main_box.pack_end(remove_button, False, False, 5.0) <NEW_LINE> return main_box | Creates the remove area for the
control area.
@return: Gtk.Box that holds all the
widgets for displaying the remove
area. | 625941f692d797404e3047e3 |
def evaluate_model(self): <NEW_LINE> <INDENT> self.build_network() <NEW_LINE> self.load_model() <NEW_LINE> self.load_data() <NEW_LINE> return self.model.evaluate(self.dataset.test_images, self.dataset.test_labels) | This method evaluates the model on the test set | 625941f6377c676e912727fd |
def set_cte(self, cte_id: str, sql: str): <NEW_LINE> <INDENT> for cte in self.extra_ctes: <NEW_LINE> <INDENT> if cte.id == cte_id: <NEW_LINE> <INDENT> cte.sql = sql <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.extra_ctes.append(InjectedCTE(id=cte_id, sql=sql)) | This is the equivalent of what self.extra_ctes[cte_id] = sql would
do if extra_ctes were an OrderedDict | 625941f610dbd63aa1bd31f8 |
def generate_launch_description(): <NEW_LINE> <INDENT> return launch.LaunchDescription( mock.launch.generate_launch_nodes() + [ launch_ros.actions.Node( package='py_trees_ros_tutorials', executable="tree-data-gathering", output='screen', emulate_tty=True, ) ] ) | Launcher for the tutorial.
Returns:
the launch description | 625941f6009cb60464c63a03 |
def get_baseline_thresholds( scores: np.ndarray, labels: np.ndarray, objective: METRIC_FN ) -> Tuple[float, List[float]]: <NEW_LINE> <INDENT> num_classes = scores.shape[1] <NEW_LINE> thresholds = [0.5] * num_classes <NEW_LINE> predictions = np.greater(scores, thresholds).astype(np.int32) <NEW_LINE> best_metric = object... | Returns baseline thresholds for multiclass/multilabel classification.
Args:
scores: estimated per-class scores/probabilities predicted by the model,
numpy array with shape [num_examples, num_classes]
labels: ground truth labels,
numpy array with shape [num_examples, num_classes]
objective: ... | 625941f6596a89723608a10e |
def page(self, note, id, params={}): <NEW_LINE> <INDENT> params['domain'] = note <NEW_LINE> path = "/pages/%d.json" % id <NEW_LINE> path += "?%s" % urllib.urlencode(params) if params else '' <NEW_LINE> method = "GET" <NEW_LINE> new_page = Page(self.access_token) <NEW_LINE> new_page.request(path, method, params) <NEW_L... | /pages/:page_id.json에 접근하여 page를 가져옵니다. | 625941f64e4d5625662d4a24 |
def d2logpdf_dlink2(self, inv_link_f, y, Y_metadata=None): <NEW_LINE> <INDENT> assert np.atleast_1d(inv_link_f).shape == np.atleast_1d(y).shape <NEW_LINE> e = y - inv_link_f <NEW_LINE> hess = ((self.v + 1)*(e**2 - self.v*self.sigma2)) / ((self.sigma2*self.v + e**2)**2) <NEW_LINE> return hess | Hessian at y, given link(f), w.r.t link(f)
i.e. second derivative logpdf at y given link(f_i) and link(f_j) w.r.t link(f_i) and link(f_j)
The hessian will be 0 unless i == j
.. math::
\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = \frac{(v+1)((y_{i}-\lambda(f_{i}))^{2} - \sigma^{2}v)}{((y_{i}-\lambda... | 625941f62eb69b55b151cf10 |
def get_consensus(self): <NEW_LINE> <INDENT> return self.http.get(consensus_constants.CONSENSUS_URL) | Returns information about the consensus set. | 625941f6925a0f43d254a4d4 |
def run(self, args_list): <NEW_LINE> <INDENT> ifconfig_file = '/usr/sbin/ifconfig' <NEW_LINE> iwconfig_file = '/usr/sbin/iwconfig' <NEW_LINE> try: <NEW_LINE> <INDENT> ifconfig_info = subprocess.check_output('{} -s'.format(ifconfig_file), shell=True).decode() <NEW_LINE> <DEDENT> except Exception as ex: <NEW_LINE> <INDEN... | Create page to summarise WLAN interface info | 625941f6d58c6744b42582b3 |
def full_like(array, fill_value, stream=None): <NEW_LINE> <INDENT> warnings.warn( 'chainer.cuda.full_like is deprecated. Use cupy.full_like instead.', DeprecationWarning) <NEW_LINE> check_cuda_available() <NEW_LINE> assert stream is None <NEW_LINE> if isinstance(array, cupy.ndarray): <NEW_LINE> <INDENT> return cupy.ful... | Creates a constant-filled :class:`cupy.ndarray` object like the given array.
Args:
array (cupy.ndarray or numpy.ndarray): Base array.
fill_value: Constant value to fill the array by.
stream (cupy.cuda.Stream): CUDA stream.
Returns:
cupy.ndarray: Constant-filled array. | 625941f6d6c5a102081446a7 |
def _update_srcmap_file(self, sources, overwrite=True): <NEW_LINE> <INDENT> if not os.path.isfile(self.files['srcmap']): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> hdulist = fits.open(self.files['srcmap']) <NEW_LINE> hdunames = [hdu.name.upper() for hdu in hdulist] <NEW_LINE> srcmaps = {} <NEW_LINE> for src in sour... | Check the contents of the source map file and generate
source maps for any components that are not present. | 625941f68e71fb1e9831ddfd |
def unique2(s): <NEW_LINE> <INDENT> temp = sorted(s) <NEW_LINE> for j in range(1, len(temp)): <NEW_LINE> <INDENT> if temp[j - 1] == temp[j]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Return True if there are no duplicate elements in sequence s. | 625941f6dc8b845886cb5b8e |
def execute_login(self): <NEW_LINE> <INDENT> if self.options.token is None: <NEW_LINE> <INDENT> login = GalaxyLogin(self.galaxy) <NEW_LINE> github_token = login.create_github_token() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> github_token = self.options.token <NEW_LINE> <DEDENT> galaxy_response = self.api.authentica... | Verify user's identify via Github and retreive an auth token from Galaxy. | 625941f607d97122c4178ef2 |
def rewriteURL(url, mode): <NEW_LINE> <INDENT> pass | Rewrite the URL to redirect to the page in a different mobile view mode.
@param mode: One of MobileRequestType pseudo constants
@return: string | 625941f67c178a314d6efac2 |
def merge_bam_files(bam_files, work_dir, config, out_file=None, batch=None): <NEW_LINE> <INDENT> if len(bam_files) == 1: <NEW_LINE> <INDENT> return bam_files[0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if out_file is None: <NEW_LINE> <INDENT> out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0])... | Merge multiple BAM files from a sample into a single BAM for processing.
Checks system open file limit and merges in batches if necessary to avoid
file handle limits. | 625941f69f2886367277aede |
def expand(self, node, open_list): <NEW_LINE> <INDENT> nt = min(node.t + 1, self.max_t) <NEW_LINE> neighbors = [] <NEW_LINE> coords = self.sub_search[self.rob_id].get_neighbors(node.coord) <NEW_LINE> for i in coords: <NEW_LINE> <INDENT> new_node = self.get_node(i, nt) <NEW_LINE> if new_node.closed: <NEW_LINE> <INDENT> ... | Calls get_neighbor from workspace_graph, checks for
collisions and adds all found neighbors to the open_list
used for performing constrained planning | 625941f6adb09d7d5db6cde2 |
def _update_spinner(self): <NEW_LINE> <INDENT> self.ui.thumbnail.setPixmap(self._spin_icons[self._current_spinner_index]) <NEW_LINE> self._current_spinner_index += 1 <NEW_LINE> if self._current_spinner_index == 4: <NEW_LINE> <INDENT> self._current_spinner_index = 0 | Animate spinner icon | 625941f615fb5d323cde1171 |
def run_cmd(cmd, dir=".", show=True, output=False, checkfail=True): <NEW_LINE> <INDENT> shell = False <NEW_LINE> if not isinstance(cmd, list): <NEW_LINE> <INDENT> cmd = [cmd] <NEW_LINE> shell = True <NEW_LINE> <DEDENT> if show: <NEW_LINE> <INDENT> print("Running: (%s) in (%s)" % (cmd_as_shell(cmd), dir,)) <NEW_LINE> <D... | run a shell command | 625941f68e7ae83300e4b626 |
def classifyunit(self, unit): <NEW_LINE> <INDENT> classes = ["total"] <NEW_LINE> if unit.isfuzzy(): <NEW_LINE> <INDENT> classes.append("fuzzy") <NEW_LINE> <DEDENT> if unit.gettargetlen() == 0: <NEW_LINE> <INDENT> classes.append("blank") <NEW_LINE> <DEDENT> if unit.istranslated(): <NEW_LINE> <INDENT> classes.append("tra... | Returns a list of the classes that the unit belongs to.
:param unit: the unit to classify | 625941f6004d5f362079a985 |
def add_view_menu(self, name): <NEW_LINE> <INDENT> view_menu = self.find_view_menu(name) <NEW_LINE> if view_menu is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> view_menu = self.viewmenu_model() <NEW_LINE> view_menu.name = name <NEW_LINE> self.get_session.add(view_menu) <NEW_LINE> self.get_session.commit() <NEW_L... | Adds a view or menu to the backend, model view_menu
param name:
name of the view menu to add | 625941f65166f23b2e1a57b0 |
def extract_chart_data(result: dict) -> dict: <NEW_LINE> <INDENT> data = { "price": {}, "dividend": {}, "stocksplit": {} } <NEW_LINE> check = checkif_skip_extract_chart(result) <NEW_LINE> if check == False: <NEW_LINE> <INDENT> return data <NEW_LINE> <DEDENT> result = result["chart"]["result"][0] <NEW_LINE> data = extra... | Extract historical price, dividends and stock splits from
the Yahoo! Finance raw data. | 625941f61f037a2d8b946853 |
def _streamToPackets(s, trackId=1): <NEW_LINE> <INDENT> packetsByOffset = [] <NEW_LINE> lastInstrument = None <NEW_LINE> for obj in s: <NEW_LINE> <INDENT> classes = obj.classes <NEW_LINE> if 'Note' in classes or 'Rest' in classes: <NEW_LINE> <INDENT> if 'Rest' in classes: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT... | Convert a Stream to packets.
This assumes that the Stream has already been flattened,
ties have been stripped, and instruments,
if necessary, have been added.
In converting from a Stream to MIDI, this is called first,
resulting in a collection of packets by offset.
Then, packets to events is called. | 625941f6d4950a0f3b08c99c |
def PickKeyWith(self, *argv, **kwargs): <NEW_LINE> <INDENT> if self.isParsedBefore is True: <NEW_LINE> <INDENT> print("Alert: You must pick key first before parsing data!"), exit() <NEW_LINE> <DEDENT> self.isParsedBefore = False <NEW_LINE> tCheckArgsExists(kwargs, "clusterByRegion", "clusterBy", "subtfromfirst") <NEW_L... | PickKeyWith treats the data with special keys | 625941f65fcc89381b1e1d1c |
def delete_buckets_id_labels_id(self, bucket_id, label_id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('async_req'): <NEW_LINE> <INDENT> return self.delete_buckets_id_labels_id_with_http_info(bucket_id, label_id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>... | Delete a label from a bucket.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_buckets_id_labels_id(bucket_id, label_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str bucket_id: The bucket ID.... | 625941f67d847024c06be919 |
def post(self, request, *args, **kwargs): <NEW_LINE> <INDENT> wizard_next_step = self.request.POST.get('wizard_next_step') <NEW_LINE> if wizard_next_step: <NEW_LINE> <INDENT> step = self.steps[wizard_next_step] <NEW_LINE> if step: <NEW_LINE> <INDENT> step = self.steps[wizard_next_step] <NEW_LINE> self.storage.current_s... | This method handles POST requests.
The wizard will render either the current step (if form validation
wasn't successful), the next step (if the current step was stored
successful) or the done view (if no more steps are available) | 625941f6b545ff76a891446c |
def _has_handle_reference(self, classname, handle): <NEW_LINE> <INDENT> if classname == 'Note': <NEW_LINE> <INDENT> return handle in [ref.ref for ref in self.note_list] <NEW_LINE> <DEDENT> elif classname == 'Media': <NEW_LINE> <INDENT> return handle in [ref.ref for ref in self.media_list] <NEW_LINE> <DEDENT> elif class... | Return True if the object has reference to a given handle of given
primary object type.
:param classname: The name of the primary object class.
:type classname: str
:param handle: The handle to be checked.
:type handle: str
:returns: Returns whether the object has reference to this handle of
this object ty... | 625941f64428ac0f6e5bae4f |
def gamma_gen(self,alpha,beta): <NEW_LINE> <INDENT> gamma = np.empty_like(alpha) <NEW_LINE> temp = alpha*beta <NEW_LINE> gamma = temp/np.sum(temp,axis=0) <NEW_LINE> return gamma | 利用前向局部概率alpha和后向局部概率beta计算:给定模型lambda和观测序列O,在某时刻处于某状态的概率
return gamma 行索引为状态,列索引为t | 625941f67b25080760e39aac |
def farm_event(request, farm_group_id, farm_event_id=None): <NEW_LINE> <INDENT> farm_group = get_object_or_404(FarmGroup, pk=farm_group_id) <NEW_LINE> if request.method == 'GET': <NEW_LINE> <INDENT> if (farm_event_id): <NEW_LINE> <INDENT> farm_event = get_object_or_404(FarmEvent, pk=farm_event_id) <NEW_LINE> <DEDENT> e... | We are taking the group and option event via the url instead of in the form.
This one endpoint handles the GET, INSERT, and UPDATE for the FarmEvent | 625941f6d164cc61757833a6 |
def sost(x, y): <NEW_LINE> <INDENT> if ch.check_list(x) and ch.check_list(y): <NEW_LINE> <INDENT> if ch.check_equality(x, y): <NEW_LINE> <INDENT> return total_amount(x, y) - sf(x, y) | Find value remains
:param x: list of dependent variable
:param y: list of independent variable
:return: value of remains | 625941f6cc40096d61595fa4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.