code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__(self, builtins, interpreter_builtins, interpreter): <NEW_LINE> <INDENT> super().__init__(__BUILTIN_POS__) <NEW_LINE> for id, f in builtins.items(): <NEW_LINE> <INDENT> self.create_local(Syn('ID', id, __BUILTIN_POS__), f) <NEW_LINE> <DEDENT> for id, make_func in interpreter_builtins.items(): <NEW_LINE> <IND... | :param builtins:
:type builtins: dict[str,function]
:return:
:rtype: | 625941c26fb2d068a760f03c |
def add_repository(self, repo_source, repo_type, repo_alias, repo_prio): <NEW_LINE> <INDENT> self.xml_data.add_repository( xml_parse.repository( type_=repo_type, alias=repo_alias, priority=repo_prio, source=xml_parse.source(path=repo_source) ) ) | Add a new repository section at the end of the list
:param string repo_source: repository URI
:param string repo_type: type name defined by schema
:param string repo_alias: alias name
:param string repo_prio: priority number, package manager specific | 625941c2c432627299f04be5 |
def _validate_node_links_json(node_type, node_links, errors): <NEW_LINE> <INDENT> assert isinstance(errors, dict), "errors must be a dict." <NEW_LINE> if not isinstance(node_links, list): <NEW_LINE> <INDENT> errors['links'] = _("links must be a list") <NEW_LINE> return False <NEW_LINE> <DEDENT> if node_type == Start.no... | Validate a single node's links.
node_type is the node type of the action information passed.
node_links is list of dictionaries describing the links.
errors is a dictionary that will be populated with any found errors. | 625941c24c3428357757c2ca |
def build(platform="mac", release=False): <NEW_LINE> <INDENT> specs = load_spec() <NEW_LINE> ensure_build() <NEW_LINE> TARGETS = specs['targets'] <NEW_LINE> LIBS = specs["libraries"] <NEW_LINE> MAIN = specs["main"] <NEW_LINE> INCLUDES = [BINARIES_DIR, BUILD_DIR] <NEW_LINE> EXTRA_FLAGS = [] <NEW_LINE> if platform == "ma... | Builds the F# program from the given specification dictionary | 625941c2507cdc57c6306c77 |
def scrape_cv() -> None: <NEW_LINE> <INDENT> files_dict = get_arguments() <NEW_LINE> for ind in range(len(files_dict['input'])): <NEW_LINE> <INDENT> cv_dict = docx_to_dict(files_dict['input'][ind], files_dict['images'][ind]) <NEW_LINE> with open(files_dict['output'][ind], 'w') as f: <NEW_LINE> <INDENT> json.dump(cv_dic... | Convert ordina cv to json | 625941c2de87d2750b85fd31 |
def __init__(self, exe_return_filename, weights_method, prev_node, class_name): <NEW_LINE> <INDENT> super().__init__(prev_node) <NEW_LINE> CFooterNode.__instance = self <NEW_LINE> dim = CHeaderNode.instance().in_dim <NEW_LINE> id = CHeaderNode.instance().id <NEW_LINE> self.in_dim = prev_node.out_dim <NEW_LINE> self.in_... | Initialize the node.
:param exe_return_filename: Name of file to write test results in.
:param weights_method: The method how the weights are stored and initialized.
'direct': The weights are written into the C file.
'stdio': The weights are read using ANSI C stdio.
:param ... | 625941c28a43f66fc4b54008 |
def str2floatlist(str_values, expected_values): <NEW_LINE> <INDENT> import re <NEW_LINE> if str_values is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> values = re.findall("[-+]?\d+[\.]?\d*", str_values) <NEW_LINE> if len(values) < expected_values: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> for i i... | Converts a string to a list of values. It returns None if the array is smaller than the expected size. | 625941c2a17c0f6771cbdff3 |
def SetName(self, name): <NEW_LINE> <INDENT> self.__header.SetName(name) | Set the name of the histogram
:param name: Name of the histogram
:type name: String | 625941c21f5feb6acb0c4af4 |
def move(servo, angle): <NEW_LINE> <INDENT> pulse_width = (MAX_PULSE - MIN_PULSE) * angle + MIN_PULSE <NEW_LINE> dc = pulse_width / (10.0 / PWM_FREQ) <NEW_LINE> servo.ChangeDutyCycle(dc) <NEW_LINE> return | Change servo rotation.
Parameters:
servo: running servo PWM instance
angle: servo rotation. 0 = full CW, 1 = full CCW | 625941c224f1403a92600b09 |
def random_search_log_reg(train, train_Y, test, save_path): <NEW_LINE> <INDENT> model = LogisticRegression() <NEW_LINE> C = uniform(loc=0, scale=4) <NEW_LINE> hyperparameters = dict(C=C) <NEW_LINE> clf = RandomizedSearchCV(model, hyperparameters, random_state=1, n_iter=10, cv=3, verbose=3, n_jobs=-1) <NEW_LINE> best_mo... | Uses random search to tune the C parameter for logistic regression and make a prediction.
:param train: Training data as array
:param train_Y: Training labels
:param test: Test data as array
:param save_path: path to save model to
- If None then model will not be saved
:return: best model from last fold and pre... | 625941c20a50d4780f666e31 |
def basicsetup(testcase): <NEW_LINE> <INDENT> testcase.workbook = AL_Excel.load_workbook(str(TESTFILE), data_only = True) <NEW_LINE> for sheet in DATA['SHEETS']: <NEW_LINE> <INDENT> setattr(testcase,sheet['alias'],testcase.workbook[sheet['name']]) | Does basic workbook setup for the testcase | 625941c25fdd1c0f98dc01d3 |
def get_bulk_works_details_iter(self, putcodes): <NEW_LINE> <INDENT> if not putcodes: <NEW_LINE> <INDENT> raise ValueError('putcodes can not be an empty sequence') <NEW_LINE> <DEDENT> for putcodes_chunk in utils.chunked_sequence_iter(putcodes, MAX_PUTCODES_PER_WORKS_DETAILS_REQUEST): <NEW_LINE> <INDENT> yield self._get... | Yield a summary of the given works for the given orcid.
A number of requests:
GET https://api.orcid.org/v2.0/0000-0002-0942-3697/works/46674246
Args:
putcode (List[string]): putcode.
Yields:
GetWorksDetailsResponse: the response.
Note:
This call can be very expensive for an author with many works (if
... | 625941c2187af65679ca50bf |
def shortest_path_matrix(self): <NEW_LINE> <INDENT> if not self.src_inds: <NEW_LINE> <INDENT> self.src_inds = [self.vertex_count, self.vertex_count] <NEW_LINE> self.dst_inds = [np.random.randint(0, self.vertex_count), np.random.randint(0, self.vertex_count)] <NEW_LINE> self.vertex_count += 1 <NEW_LINE> <DEDENT> dist = ... | Returns the shortest-path matrix. | 625941c201c39578d7e74ddc |
def show_autoeval(self, args): <NEW_LINE> <INDENT> self.msg("autoeval is %s." % self.get_autoeval()) <NEW_LINE> return False | Show if unrecognized command are evaluated | 625941c2a219f33f3462890d |
def clean_concepts(linkbases): <NEW_LINE> <INDENT> concepts_removed = [] <NEW_LINE> xlink = "{http://www.w3.org/1999/xlink}" <NEW_LINE> schema = linkbases["xsd"]["filename"].split("/")[-1] <NEW_LINE> href_xpath = ".//*[@{0}href='{1}#%s']".format(xlink, schema) <NEW_LINE> concepts_xpath = ".//{http://www.w3.org/2001/XML... | Searches through the provided dictionary of linkbases using the xsd to
build a list of extension concepts. Then finds any that aren't referenced
by the presentation, definition, calculation, or label linkbases and
removes them. | 625941c2be7bc26dc91cd5a4 |
def __init__(self): <NEW_LINE> <INDENT> self.interchangeable_qubit_indices = [] | Initialize a basic gate.
Note:
Set interchangeable qubit indices!
(gate.interchangeable_qubit_indices)
As an example, consider
.. code-block:: python
ExampleGate | (a,b,c,d,e)
where a and b are interchangeable. Then, call this function as
follows:
.. code-block:: python
... | 625941c24d74a7450ccd4164 |
def write(self, data, waitForResponse=True, timeout=5, parseError=True, writeTerm='\r', expectedResponseTermSeq=None): <NEW_LINE> <INDENT> self.log.debug('write: %s', data) <NEW_LINE> responseLines = SerialComms.write(self, data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=expe... | Write data to the modem
This method adds the '
' end-of-line sequence to the data parameter, and
writes it to the modem
@param data: Command/data to be written to the modem
@type data: str
@param waitForResponse: Whether this method should block and return the ... | 625941c2ad47b63b2c509f20 |
def setCenter(self, *args, **kwargs): <NEW_LINE> <INDENT> cen = galsim.utilities.parse_pos_args(args, kwargs, 'xcen', 'ycen', integer=True) <NEW_LINE> self._shift(cen - self.image.bounds.center()) | Set the center of the image to the given (integral) (xcen, ycen)
The arguments here may be either (xcen, ycen) or a PositionI instance.
Or you can provide xcen, ycen as named kwargs. | 625941c230bbd722463cbd65 |
def ht_radio_checked(option,select): <NEW_LINE> <INDENT> if option==select: return 'checked="checked"' <NEW_LINE> return '' | The description of ht_radio_checked comes here.
@param option
@param select
@return | 625941c2f9cc0f698b14059e |
def calculate_mean_reversion_level(days_to_maturity, mean_reversion_rate, sigma, reference_curve): <NEW_LINE> <INDENT> year_fraction = days_to_maturity / 365 <NEW_LINE> forward_rate = reference_curve.instantaneous_forward_rate(days_to_maturity) <NEW_LINE> forward_rate_plus = reference_curve.instantaneous_forward_rate(d... | :param days_to_maturity:
:param mean_reversion_rate:
:param sigma:
:param reference_curve:
:return: | 625941c282261d6c526ab43d |
def next_batch(num, data): <NEW_LINE> <INDENT> idx = np.arange(0, len(data)) <NEW_LINE> np.random.shuffle(idx) <NEW_LINE> idx = idx[:num] <NEW_LINE> data_shuffle = [data[i] for i in idx] <NEW_LINE> return np.asarray(data_shuffle) | Return a total of `num` random samples and labels. | 625941c24c3428357757c2cb |
def _group_by_type(documents, models=None): <NEW_LINE> <INDENT> doc_classes = {} <NEW_LINE> if models is not None: <NEW_LINE> <INDENT> doc_classes.update({model.__name__: model for model in models}) <NEW_LINE> <DEDENT> grouped = defaultdict(list) <NEW_LINE> for doc in documents: <NEW_LINE> <INDENT> if doc._type not in ... | Group documents by document class.
:param documents: List of documents to group.
:param models: List models classes of documents.
:returns: Dict of grouped documents of format
{Model: [doc1, doc2, ...]}. | 625941c2d58c6744b4257c01 |
def _get_last_checkpoint_no(self, root_path): <NEW_LINE> <INDENT> a = self.get_checkpoint_no(root_path) <NEW_LINE> if len(a) > 0: <NEW_LINE> <INDENT> return a[-1] <NEW_LINE> <DEDENT> return -1 | only get the first depth | 625941c2b545ff76a8913db7 |
def _feature_correct(self, features): <NEW_LINE> <INDENT> if not 'urn:xmpp:message-correct:0' in features: <NEW_LINE> <INDENT> if 'correct' in self.commands: <NEW_LINE> <INDENT> del self.commands['correct'] <NEW_LINE> <DEDENT> <DEDENT> elif not 'correct' in self.commands: <NEW_LINE> <INDENT> self.register_command('corr... | Check for the 'correction' feature | 625941c299cbb53fe6792b88 |
def plotblossom(self, blossom_i): <NEW_LINE> <INDENT> i_hot = self.findhot(self.u_grid[blossom_i]) <NEW_LINE> u = linspace(self.u_grid[i_hot]*0.95, self.u_grid[i_hot+1]*1.05, 100) <NEW_LINE> d1 = zeros((100, 2)) <NEW_LINE> d2 = zeros((100, 2)) <NEW_LINE> d3 = zeros((100, 2)) <NEW_LINE> for j in range(0, 100): <NEW_LINE... | Plots the blossom curves | 625941c24e4d5625662d437b |
def sort(n, integer=False): <NEW_LINE> <INDENT> x = ''.join(sorted(str(n))) <NEW_LINE> if integer: <NEW_LINE> <INDENT> return(int(x)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return(x) | Takes a string/integer as input and lexicographically sorts it.
If integer is True, it returns it as integer type. | 625941c22ae34c7f2600d0d3 |
def get_device_name(self, device): <NEW_LINE> <INDENT> parts = device.split("_") <NEW_LINE> mac = parts[0] <NEW_LINE> ap_mac = None <NEW_LINE> if len(parts) > 1: <NEW_LINE> <INDENT> ap_mac = parts[1] <NEW_LINE> <DEDENT> name = None <NEW_LINE> for dev in self.last_results: <NEW_LINE> <INDENT> if dev.mac == mac: <NEW_LIN... | Return the name of the given device or the MAC if we don't know. | 625941c21f037a2d8b94619f |
def _add_bond( self, atom1, atom2, bond_order, is_aromatic, stereochemistry=None, fractional_bond_order=None, ): <NEW_LINE> <INDENT> if isinstance(atom1, int) and isinstance(atom2, int): <NEW_LINE> <INDENT> atom1_atom = self.atoms[atom1] <NEW_LINE> atom2_atom = self.atoms[atom2] <NEW_LINE> <DEDENT> elif isinstance(atom... | Add a bond between two specified atom indices
Parameters
----------
atom1 : int or openff.toolkit.topology.molecule.Atom
Index of first atom or first atom
atom2_index : int or openff.toolkit.topology.molecule.Atom
Index of second atom or second atom
bond_order : int
Integral bond order of Kekulized form
is... | 625941c23eb6a72ae02ec479 |
def test_type(self): <NEW_LINE> <INDENT> assert is_consistent_type(X509Req, 'X509Req') | `X509Req` can be used to create instances of that type. | 625941c2287bf620b61d3a06 |
def _cleanup_namespaces(self, router_namespaces, router_ids): <NEW_LINE> <INDENT> ns_to_ignore = set(NS_PREFIX + id for id in router_ids) <NEW_LINE> ns_to_ignore.update(SNAT_NS_PREFIX + id for id in router_ids) <NEW_LINE> ns_to_destroy = router_namespaces - ns_to_ignore <NEW_LINE> self._destroy_stale_router_namespaces(... | Destroy stale router namespaces on host when L3 agent restarts
This routine is called when self._clean_stale_namespaces is True.
The argument router_namespaces is the list of all routers namespaces
The argument router_ids is the list of ids for known routers. | 625941c266656f66f7cbc14b |
def __hash__(self): <NEW_LINE> <INDENT> raise TypeError('%s is unhashable' % self.__class__.__name__) | Disallow hashing StateStats since they are mutable by design. | 625941c2d486a94d0b98e0e6 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 5 <NEW_LINE> (_x.pin, _x.state,) = _struct_Bf.unpack(str[start:end]) <NEW_LINE> return self <NEW_LINE> <DEDENT> except struct.error as e: <NEW_LINE> <INDENT> raise genpy.Deseria... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941c263b5f9789fde7086 |
def test_add_word(self): <NEW_LINE> <INDENT> email = "[email protected]" <NEW_LINE> user = get_user_profile_by_email(email) <NEW_LINE> add_user_alert_words(user, self.interesting_alert_word_list) <NEW_LINE> words = user_alert_words(user) <NEW_LINE> self.assertEqual(words, self.interesting_alert_word_list) | add_user_alert_words can add multiple alert words at once. | 625941c2bf627c535bc13170 |
def warning(x, *args, **kargs): <NEW_LINE> <INDENT> if kargs.pop("onlyOnce", False): <NEW_LINE> <INDENT> from scapy.config import conf <NEW_LINE> conf.warning_next_only_once = True <NEW_LINE> <DEDENT> log_runtime.warning(x, *args, **kargs) | Prints a warning during runtime.
onlyOnce - if True, the warning will never be printed again. | 625941c2bd1bec0571d905d0 |
def Fabber(*search_dirs, **kwargs): <NEW_LINE> <INDENT> corelib, coreexe, libs, exes = find_fabber(*search_dirs, **kwargs) <NEW_LINE> if corelib and kwargs.get("shlib"): <NEW_LINE> <INDENT> return FabberShlib(core_lib=corelib, model_libs=libs, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return FabberCl(core... | Get an API object for Fabber. Uses the shared lib API if available
and requested using `shlib=True`, otherwise use command line wrappers
:param extra_search_dirs: Extra search directories to use to look for Fabber libraries and executables | 625941c257b8e32f5248343b |
def hard_plastic_net(X, y, xi, lambda_total=1.0, alpha=0.75, tol=1e-8, max_iter=1000): <NEW_LINE> <INDENT> N, D = X.shape <NEW_LINE> beta = np.zeros(D, dtype=np.float64) <NEW_LINE> r = y - np.dot(X, beta) <NEW_LINE> hard_plastic_net_( beta, r, X, xi, lambda_total=lambda_total, alpha=alpha, tol=tol, max_iter=max_iter, )... | Hard plastic net regression. This function finds the :math:`\vec{\beta}` that minimizes
.. math::
\tfrac{1}{2N} ||\vec{y}-X\vec{\beta}||_2^2 + \lambda \bigl( \alpha||\vec{\beta}-\vec{\xi}||_1 + (1-\alpha) \tfrac{1}{2} ||\vec{\beta}||_2^2 \bigr)
Args:
X (numpy.ndarray): shape (N,P) data matrix.
y (numpy.... | 625941c2498bea3a759b9a51 |
def generate_record(): <NEW_LINE> <INDENT> json_data = json.loads(pkg_resources.resource_string( __name__, os.path.join( '../fixtures', 'oai_arxiv_core_record.json' ) )) <NEW_LINE> if 'preprint_date' in json_data: <NEW_LINE> <INDENT> json_data['preprint_date'] = datetime.date.today().isoformat() <NEW_LINE> <DEDENT> ret... | Provide record fixtures. | 625941c26aa9bd52df036d44 |
def set_formula(self, formula): <NEW_LINE> <INDENT> self.formula = formula.replace(' ', '').replace('\n', '').replace('\r', '') | Store the input formula as the one to evaluate on. | 625941c2cb5e8a47e48b7a4e |
def get_values(self): <NEW_LINE> <INDENT> return self.as_matrix() | same as values (but handles sparseness conversions) | 625941c210dbd63aa1bd2b45 |
def cancel_train_network(self,event): <NEW_LINE> <INDENT> self.config = [] <NEW_LINE> self.sel_config.SetPath("") <NEW_LINE> self.pose_cfg_text.Hide() <NEW_LINE> self.update_params_text.Hide() <NEW_LINE> self.pose_cfg_choice.SetSelection(1) <NEW_LINE> self.display_iters.SetValue(1000) <NEW_LINE> self.save_iters.SetValu... | Reset to default | 625941c22c8b7c6e89b35763 |
def HasMultilineSelection(self): <NEW_LINE> <INDENT> bMulti = False <NEW_LINE> sel = super().GetSelection() <NEW_LINE> if sel[0] != sel[1]: <NEW_LINE> <INDENT> sline = self.LineFromPosition(sel[0]) <NEW_LINE> eline = self.LineFromPosition(sel[1]) <NEW_LINE> bMulti = sline != eline <NEW_LINE> <DEDENT> return bMulti | Is the selection over multiple lines?
@return: bool | 625941c263f4b57ef00010c0 |
def date_time_input_format(value, tz_str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tz = pytz.timezone(tz_str) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> tz = pytz.utc <NEW_LINE> <DEDENT> value = value.replace(tzinfo=pytz.utc).astimezone(tz) <NEW_LINE> return value.strftime("%m-%d-%Y %I:%M %p") | Take a date time object and convert it into a string that uses the required input box format.
Note, this format MUST match the format used in the get_utc_datetime_from_user_input function. | 625941c2ac7a0e7691ed4072 |
def try_remove(self, key: KeyType, timeout: float = 0) -> Future[bool]: <NEW_LINE> <INDENT> check_not_none(key, "key can't be None") <NEW_LINE> key_data = self._to_data(key) <NEW_LINE> return self._try_remove_internal(key_data, timeout) | Tries to remove the given key from this map and returns immediately
if timeout is not provided.
If timeout is provided, operation waits until it is completed or
timeout is reached.
Args:
key: Key of the entry to be deleted.
timeout (float): Maximum time in seconds to wait.
Returns:
Future[bool]: ``True``... | 625941c2d164cc6175782cef |
def get_dimensions(is_key=True, track_menu=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> dimensions = additional_json['ItemVariations']['itmVarModel']['menuModels'] <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> dimensions = [] <NEW_LINE> <DEDENT> dimensions_dict = {} <NEW_LINE> dimensions_list = [] <... | is_key=False
['Size', 'Color', 'Macam macam']
is_key=True
['size', 'color', 'macam_macam']
track_menu=True
{'size': [1, 2, 3, 4], 'color': [5, 6, 7]} | 625941c2293b9510aa2c3239 |
def test_feedbooks(self): <NEW_LINE> <INDENT> self._login() <NEW_LINE> response = self.client.get('/library/') <NEW_LINE> assert 'feedbooks.com/book' in response.content | Test that we get a list of feedbooks books from the main page | 625941c2a8370b7717052842 |
def create_shell_stream(self, kernel_id): <NEW_LINE> <INDENT> shell_stream = self._create_connected_stream(kernel_id, zmq.DEALER, 'shell') <NEW_LINE> return shell_stream | Return a ZMQStream object connected to the shell channel.
Parameters
==========
kernel_id : uuid
The id of the kernel.
Returns
=======
stream : ZMQStream | 625941c299fddb7c1c9de333 |
def rbridge_id_interface_ve_ip_igmp_last_member_query_interval(**kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> rbridge_id = ET.SubElement(config, "rbridge-id", xmlns="urn:brocade.com:mgmt:brocade-rbridge") <NEW_LINE> if kwargs.pop('delete_rbridge_id', False) is True: <NEW_LINE> <INDENT> delete_r... | Auto Generated Code
| 625941c2009cb60464c63355 |
def test_not_current(self): <NEW_LINE> <INDENT> self.assert_selector( self.MARKUP, "p:not(:current)", ["0"], flags=util.HTML ) | Test not current. | 625941c23d592f4c4ed1d014 |
def create_batch(self, params): <NEW_LINE> <INDENT> return json.loads(self.http_post(params, self.ENDPOINT_BATCHES)) | Returns:
JSON with the formatted response content | 625941c21d351010ab855abe |
def test_webhook_timeout_exception_on_http_response(self): <NEW_LINE> <INDENT> self.conf_override(group='webhook_notifier', timeout=50) <NEW_LINE> self.notify(self._http_post_exception) <NEW_LINE> result = self.trap.get() <NEW_LINE> self.assertEqual(result, "timeout 50") <NEW_LINE> result = self.trap.get() <NEW_LINE> s... | webhook timeout exception
| 625941c2b5575c28eb68dfa0 |
def check_keyup_events(event, paddle_top, paddle_bottom, paddle_left): <NEW_LINE> <INDENT> if event.key == pygame.K_UP: <NEW_LINE> <INDENT> paddle_left.moving_up = False <NEW_LINE> <DEDENT> elif event.key == pygame.K_DOWN: <NEW_LINE> <INDENT> paddle_left.moving_down = False <NEW_LINE> <DEDENT> if event.key == pygame.K_... | Respond to key releases. | 625941c29f2886367277a830 |
def _tabell(self): <NEW_LINE> <INDENT> tabell_root = tk.Toplevel(self) <NEW_LINE> tabell_vindu = Tabell(tabell_root) | Oppretter vindu for tabell. | 625941c2cc40096d615958f3 |
def svm_loss_vectorized(W, X, y, reg): <NEW_LINE> <INDENT> loss = 0.0 <NEW_LINE> dW = np.zeros(W.shape) <NEW_LINE> delta = 1.0 <NEW_LINE> num_train = X.shape[0] <NEW_LINE> scores = X.dot(W) <NEW_LINE> correct_class_score = scores[np.arange(num_train), y] <NEW_LINE> margins = np.maximum(0, scores - correct_class_score[:... | Structured SVM loss function, vectorized implementation.
Inputs and outputs are the same as svm_loss_naive. | 625941c26fb2d068a760f03d |
def creation_date(path_to_file, return_datetime=True): <NEW_LINE> <INDENT> if platform.system() == 'Windows': <NEW_LINE> <INDENT> created_at = os.path.getctime(path_to_file) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> stat = os.stat(path_to_file) <NEW_LINE> try: <NEW_LINE> <INDENT> created_at = stat.st_birthtime <NEW... | Retrieve a file's creation date.
Try to get the date that a file was created, falling back to when it was
last modified if that isn't possible.
See http://stackoverflow.com/a/39501288/1709587 for explanation.
:param path_to_file: File path
:param return_datetime: Bool, returns value in Datetime format
:return: Creat... | 625941c28e7ae83300e4af6e |
def log_sum_exp(x): <NEW_LINE> <INDENT> x_max = x.data.max() <NEW_LINE> return torch.log(torch.sum(torch.exp(x-x_max), -1, keepdim=True)) + x_max | Utility function for computing log_sum_exp while determining
This will be used to determine unaveraged confidence loss across
all examples in a batch.
Args:
x (Variable(tensor)): conf_preds from conf layers | 625941c2377c676e9127214b |
def upload_S3(self, bucket, obj): <NEW_LINE> <INDENT> return self._upload_S3(bucket, obj) | Upload JSON-encoded object to S3. | 625941c2bde94217f3682d95 |
def another_shape(r, m): <NEW_LINE> <INDENT> for k in range (r): <NEW_LINE> <INDENT> for _ in range (k): <NEW_LINE> <INDENT> print(' ', end='') <NEW_LINE> <DEDENT> for _ in range (m - k): <NEW_LINE> <INDENT> print('+', end='') <NEW_LINE> <DEDENT> print('!', end='') <NEW_LINE> if k % 2 == 0: <NEW_LINE> <INDENT> for j in... | Prints a shape with r rows that looks like this example
in which r = 5 and m = 8:
++++++++!12345678
+++++++!7654321
++++++!123456
+++++!54321
++++!1234
Note that the numbers in rows 1, 3, 5, ... always start at 1
and INCREASE, while the numbers in rows 2, 4, 6, ... DECREASE
and always END at 1.
Also, the numb... | 625941c25fc7496912cc3920 |
def color_print(category, level, msg): <NEW_LINE> <INDENT> if level <= PRINT_LEVEL: <NEW_LINE> <INDENT> print(msg) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pass | print colorized console output
| 625941c2097d151d1a222dfd |
def no_hyphen_at_end_of_rand_name(logical_line, filename): <NEW_LINE> <INDENT> if './tempest/api/network/' in filename: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> msg = "T108: hyphen should not be specified at the end of rand_name()" <NEW_LINE> if RAND_NAME_HYPHEN_RE.match(logical_line): <NEW_LINE> <INDENT> return ... | Check no hyphen at the end of rand_name() argument
T108 | 625941c22c8b7c6e89b35764 |
def play_card(self): <NEW_LINE> <INDENT> print('Not implemented!') <NEW_LINE> raise NotImplementedError() | Play one card. | 625941c226238365f5f0ee0e |
def __init__(self, limbSequence, pose_loc, width, height): <NEW_LINE> <INDENT> self.limbSequence = limbSequence <NEW_LINE> self.nlimbSeq = len(limbSequence) <NEW_LINE> self.canvas = np.zeros((self.nlimbSeq * 2, height, width)).astype('float32') <NEW_LINE> self.ncp = np.zeros((self.nlimbSeq, height, width)) <NEW_LINE> s... | :param limbSequence: maybe multi lists, deal with it one by one
:param pose_loc: sepcial for coco 3*19
:param width:
:param height: | 625941c263d6d428bbe44491 |
def __repr__(self): <NEW_LINE> <INDENT> s = 'Words:\n' + str(self.words) + '\n\n' <NEW_LINE> s += 'Word lengths:\n' + str(self.wordlengths) + '\n\n' <NEW_LINE> s += 'Stems:\n' + str(self.stems) + '\n\n' <NEW_LINE> s += 'Sentence lengths:\n' + str(self.sentencelengths) + '\n\n' <NEW_LINE> s += 'Punctuation:\n' + str(sel... | Display the contents of a TextModel. | 625941c230c21e258bdfa43d |
def getInitiative(self): <NEW_LINE> <INDENT> initiative = self.agilityModifier <NEW_LINE> if "Speed of the cobra" in self.luckySign: <NEW_LINE> <INDENT> initiative += self.luckModifier <NEW_LINE> <DEDENT> return initiative | Return the dccZeroLevelChar initiative modifier. | 625941c2e8904600ed9f1ecd |
def test_save_model_network(self): <NEW_LINE> <INDENT> X_train, X_test, y_train, y_test = modelling.transform_data(self.data, 10) <NEW_LINE> results, model = modelling.evaluate_model(X_train, X_test, y_train, y_test, 128, 1) <NEW_LINE> modelling.save_model(model, self.redis) <NEW_LINE> result = sorted(self.redis.keys()... | Test if the architecture is saved. | 625941c23346ee7daa2b2d0c |
def __init__(self, func, func_group, has_asm_impl=False): <NEW_LINE> <INDENT> self.yaml_declaration = func["declaration"] <NEW_LINE> self.java_documentation = func_group["java_documentation"] <NEW_LINE> self.c_documentation = func_group["c_documentation"] <NEW_LINE> self.default_impl_template = func_group["default_impl... | Initialize the function, setting the function name,
its documentation, template for default implementation,
and creating an array of Argument objects for the functions
arguments
:param func A dictionary from the spec file containing the declaration
:param func_group The group the function is in: groups subsets of speci... | 625941c23617ad0b5ed67e9b |
def destroy(self, request, pk=None): <NEW_LINE> <INDENT> instance = Block.objects.get(blocked=pk, blocker=self.request.user) <NEW_LINE> self.perform_destroy(instance) <NEW_LINE> return Response(status=status.HTTP_204_NO_CONTENT) | API endpoint that allows blocks to be deleted. | 625941c266673b3332b92033 |
def createFullCorpus(self, conversations): <NEW_LINE> <INDENT> self.padToken = self.getWordId('<pad>') <NEW_LINE> self.goToken = self.getWordId('<go>') <NEW_LINE> self.eosToken = self.getWordId('<eos>') <NEW_LINE> self.unknownToken = self.getWordId('<unknown>') <NEW_LINE> for conversation in tqdm(conversations, desc='E... | Extract all data from the given vocabulary.
Save the data on disk. Note that the entire corpus is pre-processed
without restriction on the sentence lenght or vocab size. | 625941c2ec188e330fd5a745 |
def mk_diffByIdxtup_keyfunc_closure(sampledata): <NEW_LINE> <INDENT> def diff_keyfunc(idxtup): <NEW_LINE> <INDENT> ri, qi = idxtup <NEW_LINE> cpvalue = sampledata[ri][qi] <NEW_LINE> all_other_points = [cp_other for ri_other, repdata_other in list(sampledata.items()) for qi_other, cp_other in enumerate(repdata_other) if... | Takes a repdata ordereddict: repdata[ri][qi] = ctvalue
where ri = replicate index, qi = qpcr-index, ctvalue = qpcr ct measurement.
Returns a function which for a particular (ri, qi) tuple calculates
how far the corresponding ct value is from the remaining measurements.
Question: What is the criteria for which samplepoi... | 625941c2ec188e330fd5a744 |
def test_simple_project(self): <NEW_LINE> <INDENT> args = ['startproject', 'testproject'] <NEW_LINE> testproject_dir = os.path.join(test_dir, 'testproject') <NEW_LINE> out, err = self.run_django_admin(args) <NEW_LINE> self.addCleanup(shutil.rmtree, testproject_dir) <NEW_LINE> self.assertNoOutput(err) <NEW_LINE> self.as... | Make sure the startproject management command creates a project | 625941c2fb3f5b602dac3633 |
def setStartPoint(self, startPoint): <NEW_LINE> <INDENT> assert ((self.m_endPoint is not None) and (startPoint.getNode().getOwnerDocument() == self.m_document)) <NEW_LINE> self.m_startPoint = startPoint <NEW_LINE> self.m_range = None | Sets just the start point of the range. New startPoint must reside within
the same document as the current endpoint, and must occur before it.
@param startPoint New start point for this range | 625941c23346ee7daa2b2d0d |
def search(searchTerm, artistName=None): <NEW_LINE> <INDENT> searchTerm = urllib.parse.quote(searchTerm) <NEW_LINE> searchTag = "q=track:" + searchTerm <NEW_LINE> if artistName is not None: <NEW_LINE> <INDENT> if "feat." in artistName: <NEW_LINE> <INDENT> artistName = artistName[:artistName.find('feat.')] <NEW_LINE> <D... | ~ Searches for the given search term using the spotify API ~
:param searchTerm: the term to be searched. Ex: Beat it
:param artistName: if given, the artist name to make the search more accurate. Ex: Michael Jackson
:return: A dictionary containing the information and spotify link of the song (if it is found)
Using th... | 625941c230dc7b766590190a |
def intersection(self, nums1, nums2): <NEW_LINE> <INDENT> res = [] <NEW_LINE> if nums1 == [] or nums2 == []: <NEW_LINE> <INDENT> return res <NEW_LINE> <DEDENT> for i in nums1: <NEW_LINE> <INDENT> if i in nums2 and i not in res: <NEW_LINE> <INDENT> res.append(i) <NEW_LINE> <DEDENT> <DEDENT> return res | :type nums1: List[int]
:type nums2: List[int]
:rtype: List[int] | 625941c238b623060ff0ad90 |
def _calculate_md5_handler(data): <NEW_LINE> <INDENT> function_call = utils.generate_md5_hash_from_string <NEW_LINE> try: <NEW_LINE> <INDENT> payload_value = _data_handler(function_call, data, required_keys=(enums.DATA_KEY,)) <NEW_LINE> return {enums.MD5_KEY: payload_value}, enums.HTTP_SUCCESS <NEW_LINE> <DEDENT> excep... | Default handler to calculate md5 requests
Receives JSON data and returns a tuple
If successful, the tuple contains a dict {'md5': hash} and a int 200
Will return a dict {'error': error_message} and a int 500 otherwise | 625941c221bff66bcd6848f7 |
def _update_range(self, data, **kwargs): <NEW_LINE> <INDENT> self._client.update_range(data=data, **kwargs) | Update range with data
Args:
data (bytes): data. | 625941c291f36d47f21ac493 |
def exception(self, msg, *args, **kwargs): <NEW_LINE> <INDENT> if self.isEnabledFor(logging.ERROR): <NEW_LINE> <INDENT> msg, kwargs = self.process(msg, kwargs) <NEW_LINE> kwargs["exc_info"] = 1 <NEW_LINE> self.logger._log(logging.ERROR, _Message(msg, args), (), **kwargs) | Log an ERROR message with exception traceback. | 625941c273bcbd0ca4b2c018 |
def re100_geothermal_both_nopv(context): <NEW_LINE> <INDENT> re100_geothermal_both(context) <NEW_LINE> newlist = [g for g in context.generators if not isinstance(g, generators.PV)] <NEW_LINE> context.generators = newlist | 100% renewables plus geothermal, but no CST.
>>> class C: pass
>>> c = C()
>>> re100_geothermal_both_nopv(c)
>>> for g in c.generators: assert not isinstance(g, generators.PV) | 625941c2d6c5a10208143feb |
def handleStatus(self): <NEW_LINE> <INDENT> isAlive = False <NEW_LINE> if self.restServerProcess: <NEW_LINE> <INDENT> isAlive = self.restServerProcess.is_alive() <NEW_LINE> if not isAlive: <NEW_LINE> <INDENT> isAlive = False <NEW_LINE> <DEDENT> <DEDENT> return RESTServerStatus(self.state, isAlive=isAlive) | The handler for an incoming Status message. | 625941c27b25080760e393fc |
def _del_user(self, command): <NEW_LINE> <INDENT> if len(command) != 2: <NEW_LINE> <INDENT> self._command_not_found() <NEW_LINE> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self._fs.del_user(command[1]) <NEW_LINE> <DEDENT> except (ValueError, PermissionError) as e: <NEW_LINE> <INDENT> print(e) | Удалить пользователя | 625941c26aa9bd52df036d45 |
def list( self, **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 = "2019-12-01" <NEW_LINE> accept = "application/js... | Lists all the VpnServerConfigurations in a subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ListVpnServerConfigurationsResult or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2019_... | 625941c21f5feb6acb0c4af5 |
def test_portlet_login(self): <NEW_LINE> <INDENT> pass | Test that login portlet is patched. | 625941c2956e5f7376d70e10 |
def __call__(self, xpl, rngpl, nnz): <NEW_LINE> <INDENT> tmp = self.sess.run([self.GetPairs], feed_dict = {self.xyzs_pl:xpl,self.rng_pl:rngpl,self.nnz_pl: nnz}) <NEW_LINE> return tmp[0] | Returns the nonzero pairs. | 625941c230dc7b766590190b |
def release(): <NEW_LINE> <INDENT> i18n() <NEW_LINE> templates() <NEW_LINE> if os.path.isdir("out") == False: <NEW_LINE> <INDENT> os.mkdir("out") <NEW_LINE> <DEDENT> shutil.copytree("src", "out/src") <NEW_LINE> with open("src/manifest.json", "r") as manifest: <NEW_LINE> <INDENT> manifestData = json.load(manifest) <NEW_... | Builds release ZIP for Chrome Web Store | 625941c20383005118ecf586 |
def enable_notifications(self, characteristic, enable=True, indication=False): <NEW_LINE> <INDENT> return True | Enable/disable notifications or indications for a given characteristic
:param characteristic: BluetoothGattCharacteristic Java object
:param enable: enable notifications if True, else disable notifications
:param indication: handle indications instead of notifications
:return: True, if the operation was initiated succ... | 625941c23539df3088e2e2ed |
def _get_side_from_slot(player_slot): <NEW_LINE> <INDENT> return "radiant" if player_slot < 128 else "dire" | Get player team based on player slot | 625941c29c8ee82313fbb716 |
def BuildbyPoints(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | index RPC service
| 625941c215baa723493c3f16 |
def testLearnMajority(self): <NEW_LINE> <INDENT> batch_size = 16 <NEW_LINE> sequence_length = 7 <NEW_LINE> train_steps = 200 <NEW_LINE> eval_steps = 20 <NEW_LINE> cell_type = 'lstm' <NEW_LINE> cell_size = 4 <NEW_LINE> optimizer_type = 'Momentum' <NEW_LINE> learning_rate = 2.0 <NEW_LINE> momentum = 0.9 <NEW_LINE> accura... | Test that `_SequenceClassifier` can learn the 'majority' function. | 625941c2462c4b4f79d1d673 |
def ndr_pad(string): <NEW_LINE> <INDENT> return "\x00" * ((4 - (len(string) & 3)) & 3) | Pad an NDR. | 625941c2d18da76e23532476 |
def kneighbors_graph(X, n_neighbors, mode='connectivity', metric='minkowski', p=2, metric_params=None, include_self=False, n_jobs=None): <NEW_LINE> <INDENT> if not isinstance(X, KNeighborsMixin): <NEW_LINE> <INDENT> X = NearestNeighbors(n_neighbors, metric=metric, p=p, metric_params=metric_params, n_jobs=n_jobs).fit(X)... | Computes the (weighted) graph of k-Neighbors for points in X
Read more in the :ref:`User Guide <unsupervised_neighbors>`.
Parameters
----------
X : array-like or BallTree, shape = [n_samples, n_features]
Sample data, in the form of a numpy array or a precomputed
:class:`BallTree`.
n_neighbors : int
Numbe... | 625941c2a934411ee3751636 |
def multiply(self, num1, num2): <NEW_LINE> <INDENT> if num1 == '0' or num2 == '0': <NEW_LINE> <INDENT> return '0' <NEW_LINE> <DEDENT> len1 = len(num1) <NEW_LINE> len2 = len(num2) <NEW_LINE> ret = '' <NEW_LINE> remain = 0 <NEW_LINE> for i in range(len1 + len2 - 1): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> sum += remain <N... | :type num1: str
:type num2: str
:rtype: str | 625941c28a349b6b435e8116 |
def __rsub__(self, an_angle): <NEW_LINE> <INDENT> negated_self = Angle(list(map(lambda x: -x, self.coefficients))) <NEW_LINE> return negated_self + an_angle | Specifications as for __sub__ except self is second term as in
int - Angle or float - Angle | 625941c2a17c0f6771cbdff5 |
def normalize(self,norm,t=0.): <NEW_LINE> <INDENT> self._amp*= norm/nu.fabs(self.Rforce(1.,0.,t=t)) | NAME:
normalize
PURPOSE:
normalize a potential in such a way that vc(R=1,z=0)=1., or a
fraction of this
INPUT:
norm - normalize such that Rforce(R=1,z=0) is such that it is 'norm' of the force necessary to make vc(R=1,z=0)=1 (if True, norm=1)
OUTPUT:
(none)
HISTORY:
2010-07-10 - Written ... | 625941c276e4537e8c351613 |
def parse_topic(address): <NEW_LINE> <INDENT> data = BeautifulSoup(requests.get(address).text, 'lxml') <NEW_LINE> article_list = data.find_all('div', {'class': 'item item_story-single js-story-item'}) <NEW_LINE> result = [] <NEW_LINE> for article in article_list: <NEW_LINE> <INDENT> url = article.find('a', {'class': 'i... | Парсит статьи в теме
:param address: адрес темы
:return: список распарсенных статей | 625941c2dd821e528d63b14d |
def krmtcng_usetable_vacuum(self, logger_body): <NEW_LINE> <INDENT> vacuum_tr_table = "VACUUM ANALYZE " + self.tr_tablename <NEW_LINE> vacuum_krmtcng = "VACUUM ANALYZE tm_005_krmtcng" <NEW_LINE> try: <NEW_LINE> <INDENT> common.database.Database.vacuumDb(self, vacuum_tr_table) <NEW_LINE> common.database.Database.vacuumD... | トランザクションテーブルと倉先変換マスタテーブルをVACUUMする | 625941c2a8370b7717052843 |
def TcToNum(s): <NEW_LINE> <INDENT> if s == "": <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif len(s) > 8: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> elif len(s) < 8: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> elif Binarytonum(s) >= 128: <NEW_LINE> <INDENT> Negnum = (255 - Binarytonum(s) + 1)*-1 <N... | converts 2's complement number to decimal value | 625941c2d268445f265b4e11 |
def set_size(self, size): <NEW_LINE> <INDENT> self.size = size <NEW_LINE> self.set_center(self.center) | Change size. | 625941c2eab8aa0e5d26dafa |
def test_positive_foreman_module(self): <NEW_LINE> <INDENT> rpm_result = ssh.command('rpm -q foreman-selinux') <NEW_LINE> self.assertEqual(rpm_result.return_code, 0) <NEW_LINE> semodule_result = ssh.command('semodule -l | grep foreman') <NEW_LINE> self.assertEqual(semodule_result.return_code, 0) <NEW_LINE> rpm_version ... | Check if SELinux foreman module has the right version
:id: a0736b3a-3d42-4a09-a11a-28c1d58214a5
:expectedresults: Foreman RPM and SELinux module versions match | 625941c2a219f33f3462890f |
def __init__(self, Trange = (0.0, 0.0), coeffs = [], p0 = -1.0): <NEW_LINE> <INDENT> self._t = Trange <NEW_LINE> self._pref = p0 <NEW_LINE> if len(coeffs) != 9: <NEW_LINE> <INDENT> raise CTI_Error('NASA9 coefficient list must have length = 9') <NEW_LINE> <DEDENT> self._coeffs = coeffs | :param Trange:
The temperature range over which the parameterization is valid.
This must be entered as a sequence of two temperature values.
Required.
:param coeffs:
List of nine coefficients :math:`(a_0, \ldots , a_8)`
:param p0:
The reference-state pressure, usually 1 atm or 1 bar. If omitted,
... | 625941c230bbd722463cbd67 |
def Read(self, data, address = None, size = None): <NEW_LINE> <INDENT> if not address: <NEW_LINE> <INDENT> address = self.memAddress <NEW_LINE> <DEDENT> if hasattr(address, 'value'): <NEW_LINE> <INDENT> address = address.value <NEW_LINE> <DEDENT> if size: <NEW_LINE> <INDENT> nSize = win32structures.ULONG_PTR(size) <NEW... | Read data from the memory block | 625941c21d351010ab855abf |
def __init__(self, name: str): <NEW_LINE> <INDENT> self.name = name | :param name: command name | 625941c2f8510a7c17cf969e |
def rotate_coordinates(self, in_x, in_y, in_z ): <NEW_LINE> <INDENT> if self.pargs['rotation']: <NEW_LINE> <INDENT> x = self.rotation_matrix[0][0]*in_x + self.rotation_matrix[0][1]*in_y + self.rotation_matrix[0][2]*in_z <NEW_LINE> y = self.rotation_matrix[1][0]*in_x + self.rotation_matrix[1][1]*in_y + self.rotation_mat... | Transforms from box coordinates into lattice coordinates, based
on the pre-set rotation values. | 625941c2b830903b967e98b0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.