code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def listProcessesInGuest(self, quiet=False): <NEW_LINE> <INDENT> return self.vmrun('listProcessesInGuest', self.vmx_file, quiet=quiet) | List running processes in Guest OS | 625941c867a9b606de4a7f14 |
def delete_sample(id): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> sample = Sample.query .filter_by(id=id) .delete() <NEW_LINE> db_util.db_commit() <NEW_LINE> if sample: <NEW_LINE> <INDENT> return {"status": "Deleted sample for id [{}]".format(id)} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> re... | delete sample | 625941c826068e7796caed37 |
def mutation(self, selected): <NEW_LINE> <INDENT> selected_for_mutation = [ specimen for specimen in self.population if specimen in selected and self.should_mutate()] <NEW_LINE> for specimen in selected_for_mutation: <NEW_LINE> <INDENT> specimen.mutate() | Mutates every unselected specimen based on a probability. | 625941c8099cdd3c635f0cb5 |
def fahrenheit_to_kelvin(degrees): <NEW_LINE> <INDENT> kelvin_degrees = (decimal.Decimal(degrees) - 32) * 5 / 9 + ABSOLUTE <NEW_LINE> return decimal.Decimal(kelvin_degrees) | Converting fahrenheit to kelvin.
Args:
fahrenheit_degrees(mix): to convert fahrenheit to kelvin
Returns:
a number in decimal
Examples:
>>>fahrenheit_to_kelvin(212)
Decimal('373.15') | 625941c856ac1b37e626422a |
def lastRemaining(self, n): <NEW_LINE> <INDENT> is_left = True <NEW_LINE> head = 1 <NEW_LINE> step = 1 <NEW_LINE> remain = n <NEW_LINE> while remain > 1: <NEW_LINE> <INDENT> if is_left or remain % 2 == 1: <NEW_LINE> <INDENT> head += step <NEW_LINE> <DEDENT> print(head) <NEW_LINE> step *= 2 <NEW_LINE> remain /= 2 <NEW_L... | :type n: int
:rtype: int | 625941c8090684286d50ed3e |
def dict_contains_path(dct, keys): <NEW_LINE> <INDENT> if keys: <NEW_LINE> <INDENT> if not isinstance(dct, dict): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> key = keys.pop(0) <NEW_LINE> if key in dct: <NEW_LINE> <INDENT> dct = dct[key] <NEW_LINE> return dict_contains_path(dct, keys) <NEW_LINE> <DEDENT> return... | Tests whether the keys exist recursively in `dictionary`.
:type dct: dict
:type keys: list
:rtype: bool | 625941c85510c4643540f440 |
def __init__(self, obj): <NEW_LINE> <INDENT> if not obj.type == 'block_record': <NEW_LINE> <INDENT> raise TypeError("Wrong type %s for block_record object!" %obj.type) <NEW_LINE> <DEDENT> self.type = obj.type <NEW_LINE> self.data = obj.data[:] <NEW_LINE> self.name = obj.get_type(2)[0] <NEW_LINE> self.insertion_units = ... | Expects an entity object of type block_record as input. | 625941c8c432627299f04c9f |
def __init__(self, iri=None, original_iri=None, name=None, org_name=None, visibility=None, status=None, user_name=None, uploaded_filename=None, uploaded_format=None, contents=None, format=None): <NEW_LINE> <INDENT> self._iri = None <NEW_LINE> self._original_iri = None <NEW_LINE> self._name = None <NEW_LINE> self._org_n... | PostOnt - a model defined in Swagger | 625941c83c8af77a43ae37f9 |
def delete_num(self, table, data_type, context): <NEW_LINE> <INDENT> sql = "DELETE FROM" + str(table) + "\' WHERE " + str(data_type) + " = " + str(context) <NEW_LINE> return self.run(sql) | Descrption: Delete the specified data of number type.
:param table: the table which the data belongs.
:param data_type: data's type.
:param context: data's context.
:return: None | 625941c8a4f1c619b28b0095 |
def dt(self): <NEW_LINE> <INDENT> return list(map(lambda x: 0.0 if not "dt" in x else x["dt"], self.raw())) | Returns a list of just the durations of all datapoints::
DatapointArray([
{"t": 12345, "d": "hi", "dt": 10},
{"t": 12346, "d": "hi"},
]).dt() # [10,0] | 625941c873bcbd0ca4b2c0d0 |
def SetInsideValue(self, *args): <NEW_LINE> <INDENT> return _itkRobustAutomaticThresholdImageFilterPython.itkRobustAutomaticThresholdImageFilterIUC2IUC2IUL2_SetInsideValue(self, *args) | SetInsideValue(self, unsigned long _arg) | 625941c80a50d4780f666eeb |
def test_wait_for_vm_ip_address_xenapi_failure(mock_xenapi_failure, xenserver, fake_ansible_module): <NEW_LINE> <INDENT> with pytest.raises(FailJsonException) as exc_info: <NEW_LINE> <INDENT> xenserver.wait_for_vm_ip_address(fake_ansible_module, fake_xenapi_ref('VM')) <NEW_LINE> <DEDENT> assert exc_info.value.kwargs['m... | Tests catching of XenAPI failures. | 625941c863f4b57ef0001175 |
def write_points(self, p, points, attrs=None, epsg=None): <NEW_LINE> <INDENT> writer = shapefile.Writer(shapefile.POINT) <NEW_LINE> if attrs: <NEW_LINE> <INDENT> for ai in attrs: <NEW_LINE> <INDENT> writer.field(*ai) <NEW_LINE> <DEDENT> <DEDENT> for pp in points: <NEW_LINE> <INDENT> writer.point(pp.x, pp.y) <NEW_LINE> ... | points: list of SamplePoint objects
if epsg is not None write a .prj file | 625941c8167d2b6e31218bf0 |
def test_match_template_with_alignment(self): <NEW_LINE> <INDENT> self.assertTrue(match_template_with_alignment(self.t, self.a)) <NEW_LINE> t = load_template(CLASHING_STRUCTURE) <NEW_LINE> self.assertFalse(match_template_with_alignment(t, self.a)) | Check if template sequence and alignment match. | 625941c89b70327d1c4e0e2e |
def get_errordefspath(self): <NEW_LINE> <INDENT> if self._errordefspath is None: <NEW_LINE> <INDENT> raise AttributeError("No error definitions file given in this accelerator instance.") <NEW_LINE> <DEDENT> return self._errordefspath | Returns the path to the uncertainty definitions file (formerly called error definitions
file. | 625941c83346ee7daa2b2dc4 |
def addOutParameter(self, name, type, namespace=None, element_type=0): <NEW_LINE> <INDENT> parameter = ParameterInfo(name, type, namespace, element_type) <NEW_LINE> self.outparams.append(parameter) <NEW_LINE> return parameter | Add an output parameter description to the call info. | 625941c84428ac0f6e5ba84c |
def deletePlayers(): <NEW_LINE> <INDENT> db, cursor = connect() <NEW_LINE> players = cursor.execute("DELETE FROM players;") <NEW_LINE> disconnect(db) | Remove all the player records from the database. | 625941c8f8510a7c17cf9755 |
def append(self, val): <NEW_LINE> <INDENT> new_node = self.init_node(val) <NEW_LINE> if self.first_node is None and self.last_node is None: <NEW_LINE> <INDENT> self._init_first_node(new_node) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_node.prev = self.last_node <NEW_LINE> self.last_node.next = new_node <NEW_LINE... | Add node with value to end of the list | 625941c88a43f66fc4b540c0 |
def _chain_foraging(self, agents, best_position, i): <NEW_LINE> <INDENT> r1 = r.generate_uniform_random_number() <NEW_LINE> r2 = r.generate_uniform_random_number() <NEW_LINE> alpha = 2 * r1 * np.sqrt(np.abs(np.log(r1))) <NEW_LINE> if i == 0: <NEW_LINE> <INDENT> chain_foraging = agents[i].position + r2 * (best_position ... | Performs the chain foraging procedure (eq. 1-2).
Args:
agents (list): List of agents.
best_position (np.array): Global best position.
i (int): Index of current manta ray.
Returns:
A new chain foraging. | 625941c8a8ecb033257d3127 |
def _GenerateLog(self, method, message, log): <NEW_LINE> <INDENT> log_message = [] <NEW_LINE> log_message.append('MailService.%s' % method) <NEW_LINE> log_message.append(' From: %s' % message.sender()) <NEW_LINE> for address in message.to_list(): <NEW_LINE> <INDENT> log_message.append(' To: %s' % address) <NEW_LINE> ... | Generate a list of log messages representing sent mail.
Args:
message: Message to write to log.
log: Log function of type string -> None | 625941c816aa5153ce3624d2 |
def read_geograph(filename, *args, **kwargs): <NEW_LINE> <INDENT> read_map = { '.json': lambda filename: read_json_geograph(filename), '.geojson': lambda filename: read_geojson_geograph(filename), '.shp': lambda filename: read_shp_geograph(filename, *args, **kwargs), '.csv': lambda filename: read_csv_geograph(filename,... | Read a geograph from a file whose format is defined by its extension
args, kwargs are used to pass params along to the format
specific read function | 625941c892d797404e3041e3 |
def get_base_margin(self): <NEW_LINE> <INDENT> return self.get_float_info('base_margin') | Get the base margin of the DMatrix.
Returns
-------
base_margin : float | 625941c8a219f33f346289c5 |
def draw(self, title=None, method='linear', number_of_contours=None): <NEW_LINE> <INDENT> self.draw_head() <NEW_LINE> self.draw_inner_head() <NEW_LINE> self.draw_electrodes() <NEW_LINE> self.draw_nose() <NEW_LINE> self.draw_data(method=method, number_of_contours=number_of_contours) <NEW_LINE> self.axes.axis((-1.2, 1.2,... | Draw all components in topoplot including the data.
Parameters
----------
title : str, optional
Title to put on the plot
methods : str, optional
Interpolation method
number_of_contours : int
Number of contours in the colored plot.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> data = {'O1': 1, ... | 625941c8dd821e528d63b203 |
def test_product_installed(self): <NEW_LINE> <INDENT> self.assertTrue(self.installer.isProductInstalled('braives.urban.dataimport')) | Test if braives.urban.dataimport is installed with portal_quickinstaller. | 625941c86e29344779a6266c |
def parse_value(named_reg_value): <NEW_LINE> <INDENT> name, value, value_type = named_reg_value <NEW_LINE> value_class = REG_VALUE_TYPE_MAP[value_type] <NEW_LINE> return name, value_class(value) | Convert the value returned from EnumValue to a (name, value) tuple using the value classes. | 625941c832920d7e50b28229 |
def delete_volume(self, volume): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> vol = self._get_volume(volume['name_id']) <NEW_LINE> self._client.delete_volume(vol['volumeRef']) <NEW_LINE> <DEDENT> except (exception.NetAppDriverException, KeyError): <NEW_LINE> <INDENT> LOG.warning(_LI("Volume %s already deleted."), volum... | Deletes a volume. | 625941c896565a6dacc8f725 |
def checklist(self, message, tags, default=None, cli_flag=None, force_interactive=False, **unused_kwargs): <NEW_LINE> <INDENT> if self._return_default(message, default, cli_flag, force_interactive): <NEW_LINE> <INDENT> return OK, default <NEW_LINE> <DEDENT> while True: <NEW_LINE> <INDENT> self._print_menu(message, tags... | Display a checklist.
:param str message: Message to display to user
:param list tags: `str` tags to select, len(tags) > 0
:param default: default value to return (if one exists)
:param str cli_flag: option used to set this value with the CLI
:param bool force_interactive: True if it's safe to prompt the user
becau... | 625941c8f8510a7c17cf9756 |
def wiggleSort(self, nums): <NEW_LINE> <INDENT> nLen = len(nums) - 1 <NEW_LINE> nums.sort() <NEW_LINE> fidx = nLen // 2 <NEW_LINE> sidx = nLen // 2 + 1 <NEW_LINE> swapIdx = 0 <NEW_LINE> while swapIdx < nLen - 1: <NEW_LINE> <INDENT> nums[swapIdx], nums[fidx] = nums[fidx], nums[swapIdx] <NEW_LINE> swapIdx += 1 <NEW_LINE>... | :type nums: List[int]
:rtype: None Do not return anything, modify nums in-place instead. | 625941c83d592f4c4ed1d0ca |
def enrollment(request,enrollment_id): <NEW_LINE> <INDENT> enrollment_obj = models.StudentEnrollment.objects.get(id=enrollment_id) <NEW_LINE> if enrollment_obj.contract_agreed: <NEW_LINE> <INDENT> return HttpResponse("报名合同正在审核中....") <NEW_LINE> <DEDENT> if request.method == "POST": <NEW_LINE> <INDENT> print("enrollment... | 学员在线报名表地址 | 625941c8be8e80087fb20c9e |
def onRspQuoteAction(self, InputQuoteActionField, RspInfoField, requestId, final): <NEW_LINE> <INDENT> pass | 报价操作请求响应 | 625941c8b830903b967e9966 |
def increase_speed(self): <NEW_LINE> <INDENT> self.ship_speed *= self.speedup_scale <NEW_LINE> self.bullet_speed *= self.speedup_scale <NEW_LINE> self.alien_speed *= self.speedup_scale <NEW_LINE> self.alien_points = int(self.alien_points * self.score_scale) | 提高速度的设置 | 625941c8eab8aa0e5d26dbb2 |
def parse(self, inventory, loader, path, cache=True): <NEW_LINE> <INDENT> super(InventoryModule, self).parse( inventory, loader, path, cache=cache) <NEW_LINE> self._read_config_data(path) <NEW_LINE> inventory = {} <NEW_LINE> cache_key = self.get_cache_key('%s@%s' % ( self.get_option('username'), self.get_option('hostna... | Populate inventory with hosts and groups | 625941c85fcc89381b1e1718 |
def node_exists(self, graph, node, branch, rev): <NEW_LINE> <INDENT> (graph, node) = map(self.json_dump, (graph, node)) <NEW_LINE> for (b, r) in self.active_branches(branch, rev): <NEW_LINE> <INDENT> for x in self.sql( 'node_exists', graph, node, b, r ): <NEW_LINE> <INDENT> return bool(x[0]) <NEW_LINE> <DEDENT> <DEDENT... | Return whether there's a node by this name in this graph at this
revision. | 625941c8796e427e537b061f |
def get_file_hash(self, ext, idr): <NEW_LINE> <INDENT> md=hashlib.md5() <NEW_LINE> t='attachment.'+str(idr) <NEW_LINE> md.update(t.encode('utf-8')) <NEW_LINE> return md.hexdigest()+ext | @
given - | 625941c829b78933be1e5707 |
def delete(self, *args, **kwargs): <NEW_LINE> <INDENT> super(Use, self).delete(*args, **kwargs) | delete -- Remove to leave usage. | 625941c83317a56b86939cb5 |
@cocotb.test(expect_fail=True, skip=True) <NEW_LINE> def test_callable_fail(dut): <NEW_LINE> <INDENT> global g_dut <NEW_LINE> global test_count <NEW_LINE> g_dut = dut <NEW_LINE> create_thread(test_read) <NEW_LINE> dut.log.info("Test thread created") <NEW_LINE> clk_gen = cocotb.fork(Clock(dut.clk, 100).start()) <NEW_LIN... | Test ability to call a function that will block but allow other
coroutines to continue
Test creates a thread to simulate another context. This thread will then
"block" for 5 clock cycles but not using the function decorator.
No cycls should be seen. | 625941c8f9cc0f698b140656 |
def test_retrieving_all_users(self): <NEW_LINE> <INDENT> self.register_user(self.user_details1) <NEW_LINE> self.register_user(self.user_details2) <NEW_LINE> login_token = self.get_token_from_response( self.login_user(self.login_details1)) <NEW_LINE> response = self.test_client().get( "/yummy/api/v1.0/users/", headers={... | tests retrieving all user data | 625941c8566aa707497f45c4 |
def addAfter(self, new_element, node): <NEW_LINE> <INDENT> new_element.next = node.next <NEW_LINE> new_element.previous = node <NEW_LINE> node.next = new_element <NEW_LINE> if new_element.next: <NEW_LINE> <INDENT> new_element.next.previous = new_element <NEW_LINE> <DEDENT> if self.tail == node: <NEW_LINE> <INDENT> self... | add new element/item after a node/element/item in the Linked List
Arguments:
- new_element: an object that reference to a new element to be added
- node: an object that is part of the Linked List elements | 625941c86aa9bd52df036dfe |
def put_user_file(self, user, filename, data): <NEW_LINE> <INDENT> if user in self.user_files: <NEW_LINE> <INDENT> self.user_files[user][filename] = io.BytesIO(data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.user_files[user] = {filename: io.BytesIO(data)} | stores file data for user/file assumes unique fn | 625941c85e10d32532c5ef81 |
def x86_jnp(ctx, i): <NEW_LINE> <INDENT> conditional_jump(ctx, i, conditional.NP) | jump if not parity | 625941c8f7d966606f6aa05d |
def deepestLeavesSum(self, root: TreeNode) -> int: <NEW_LINE> <INDENT> pass | put solution here | 625941c8d58c6744b4257cba |
def _eatOffOneEnd( sText, sEatThese = '', fEatThese = None, bEatOffFront = True, bEatOffBoth = False ): <NEW_LINE> <INDENT> from String.Get import getTheseCharsOffOneEnd <NEW_LINE> iEat = len( getTheseCharsOffOneEnd( sText, sEatThese, fEatThese, bEatOffFront ) ) <NEW_LINE> if bEatOffFront or bEatOffBoth: <NEW_LINE> <IN... | This is the generic program,
it is normally only called by specific implementations below. | 625941c891af0d3eaac9ba72 |
@patch('uqcsbot.scripts.yt.execute_search', new=mocked_search_execute) <NEW_LINE> def test_yt_normal(uqcsbot: MockUQCSBot): <NEW_LINE> <INDENT> uqcsbot.post_message(TEST_CHANNEL_ID, "!yt dog") <NEW_LINE> messages = uqcsbot.test_messages.get(TEST_CHANNEL_ID, []) <NEW_LINE> assert len(messages) == 2 <NEW_LINE> assert mes... | This test aims to test the basic functionality of the yt script.
The mocked function replaces the googleapiclient functionality. | 625941c823e79379d52ee5bf |
@route('/update/:no', method='GET') <NEW_LINE> def edit_item(no): <NEW_LINE> <INDENT> if request.GET.get('save','').strip(): <NEW_LINE> <INDENT> Description = request.GET.get('Description','').strip() <NEW_LINE> status = request.GET.get('status','').strip() <NEW_LINE> Due_date = request.GET.get('Due_date','').strip() <... | update a TODO item | 625941c816aa5153ce3624d3 |
def test_prototype(self): <NEW_LINE> <INDENT> provider_bnd = self.context.install_bundle( "tests.framework.prototype_service_bundle") <NEW_LINE> provider_bnd.start() <NEW_LINE> svc_ref = self.context.get_service_reference("test.prototype.internal") <NEW_LINE> factory = self.context.get_service(svc_ref) <NEW_LINE> consu... | Tests the basic behaviour of prototype service factory handling | 625941c8cdde0d52a9e5308d |
def generate_device_name(prefix, index): <NEW_LINE> <INDENT> return prefix + generate_device_letter(index) | Returns device unit name by index (starts by zero)
i.e.
prefix = vd
index = 0, 1,..., 18277
results = vda, vdb,..., vdzzz | 625941c84f88993c3716c0c2 |
def cancel_completed_task(self, project_id: str, task_id: str, operator_account_id: Optional[str] = None) -> Task: <NEW_LINE> <INDENT> task, _ = self.api.get_task(project_id, task_id) <NEW_LINE> request_body = { "status": TaskStatus.NOT_STARTED.value, "account_id": operator_account_id, "last_updated_datetime": task["up... | タスクの受入完了状態を取り消す。
Args:
project_id: プロジェクトID
task_id: タスクID
operator_account_id: 受入完了状態を取り消した後の担当者のaccount_id
Returns:
変更後のタスク | 625941c80383005118ecf63d |
@ops.RegisterGradient("Acos") <NEW_LINE> def _AcosGrad(op, grad): <NEW_LINE> <INDENT> x = op.inputs[0] <NEW_LINE> with ops.control_dependencies([grad]): <NEW_LINE> <INDENT> x = math_ops.conj(x) <NEW_LINE> x2 = math_ops.square(x) <NEW_LINE> one = constant_op.constant(1, dtype=grad.dtype) <NEW_LINE> den = math_ops.sqrt(m... | Returns grad * -1/sqrt(1-x^2). | 625941c87047854f462a1465 |
def execute_command(self, cmd): <NEW_LINE> <INDENT> LOG.info("VPE command: %s", cmd) <NEW_LINE> output = [] <NEW_LINE> if self.q_in: <NEW_LINE> <INDENT> self.q_in.put(cmd + "\r\n") <NEW_LINE> time.sleep(3) <NEW_LINE> while self.q_out.qsize() > 0: <NEW_LINE> <INDENT> output.append(self.q_out.get()) <NEW_LINE> <DEDENT> <... | send cmd to vnf process | 625941c8d268445f265b4ec8 |
def getDefinitions(self): <NEW_LINE> <INDENT> defs = self.getElemFromXpath('/svg:svg//svg:defs') <NEW_LINE> if defs is None: <NEW_LINE> <INDENT> defs = inkex.etree.SubElement(self.document.getroot(), inkex.addNS('defs', 'svg')) <NEW_LINE> <DEDENT> return defs | retrieves the Defs element of the svg file.
This function returns the element Defs of the current svg file. This elements stores the definition (e.g. marker definition)
if no Defs can be found, a new empty Defs is created
:returns: the defs element
:rtype: etree element | 625941c8a17c0f6771cbe0ac |
def update_repo(repo_path): <NEW_LINE> <INDENT> repo = create_repo(repo_path) <NEW_LINE> if repo.initialized is False: <NEW_LINE> <INDENT> print("\nSTATUS: Repository has not been set up with multipackage.\n") <NEW_LINE> print("Set it up with:\n\n\tmultipackage init {}\n".format(repo_path)) <NEW_LINE> return 1 <NEW_LIN... | Update the installed files in a repository. | 625941c84c3428357757c383 |
def divide(self, dividend: int, divisor: int) -> int: <NEW_LINE> <INDENT> if dividend == 0: <NEW_LINE> <INDENT> result = 0 <NEW_LINE> <DEDENT> elif divisor == 1: <NEW_LINE> <INDENT> result = dividend <NEW_LINE> <DEDENT> elif divisor == -1: <NEW_LINE> <INDENT> result = -dividend <NEW_LINE> <DEDENT> elif divisor == 2: <N... | 在不使用乘法、除法和mod运算符的情况下,给定除数和被除数,返回商
:param dividend:被除数
:param divisor:除数
:return:商 | 625941c8090684286d50ed3f |
def list_cover(list1, list2): <NEW_LINE> <INDENT> set2 = set(list2) <NEW_LINE> incover_list = [item1 in set2 for item1 in list1] <NEW_LINE> return incover_list | returns boolean for each position in list1 if it is in list2
Args:
list1 (list):
list2 (list):
Returns:
list: incover_list - true where list1 intersects list2
CommandLine:
python -m utool.util_list --test-list_cover
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_list import * # NOQA
... | 625941c857b8e32f524834f5 |
def add_widget(self, widget, position=None): <NEW_LINE> <INDENT> if position is not None: <NEW_LINE> <INDENT> self.widgets_list.insert(position, widget) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.widgets_list.append(widget) <NEW_LINE> <DEDENT> self._refresh() | Method adding a widget to the vertical scroll area | 625941c855399d3f0558870e |
def insert(self, k): <NEW_LINE> <INDENT> node = AVLNode(None, k) <NEW_LINE> if self.root is None: <NEW_LINE> <INDENT> self.root = node <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.root.insert(node) <NEW_LINE> <DEDENT> self.rebalance(node) | Inserts a node with key k into the subtree rooted at this node.
This AVL version guarantees the balance property: h = O(lg n).
Args:
k: The key of the node to be inserted. | 625941c8f9cc0f698b140657 |
def copy(self): <NEW_LINE> <INDENT> return Vector(self.x,self.y) | Returns a copy of this | 625941c81b99ca400220ab0c |
def load_label_dict(label_file): <NEW_LINE> <INDENT> tfile = open(label_file, 'r') <NEW_LINE> content = tfile.read() <NEW_LINE> label_dict = eval(content) <NEW_LINE> label_dict = dict(sorted(label_dict.items())) <NEW_LINE> del label_dict['0000'] <NEW_LINE> return label_dict | Load dictionary of labels from a label file | 625941c8aad79263cf390a9a |
def test_writeSolutionFile(self): <NEW_LINE> <INDENT> solutionFilename = '../../files/bestSolution_test.txt' <NEW_LINE> bestSolution = SolutionModel() <NEW_LINE> bestSolution.solutionArray = [4,5,6,-1,3] <NEW_LINE> instance = InstanceModel() <NEW_LINE> population = [9, 5, 16, 27, 30] <NEW_LINE> i = 0 <NEW_LINE> while i... | Description:
Cette méthode est pour tester la méthode "writeSolutionFile()",
pour vérifier si la méthode peut bien écrire la solution dans le fichier
:return: rien | 625941c8d7e4931a7ee9df78 |
def __init__(self, root): <NEW_LINE> <INDENT> self.list = [] <NEW_LINE> self.addlist(root) <NEW_LINE> self.len = len(self.list) | :type root: TreeNode | 625941c8f7d966606f6aa05e |
def read_class_list(self, class_list): <NEW_LINE> <INDENT> with open(class_list) as f: <NEW_LINE> <INDENT> lines = f.readlines() <NEW_LINE> self.images = [] <NEW_LINE> self.labels = [] <NEW_LINE> for l in lines: <NEW_LINE> <INDENT> items = l.split() <NEW_LINE> self.images.append(items[0]) <NEW_LINE> self.labels.append(... | Scan the image file and get the image paths and labels | 625941c81d351010ab855b76 |
def swipe_element(self, locator, direction, offset=3, duration=150): <NEW_LINE> <INDENT> element_attributes = self.get_element_attributes(locator) <NEW_LINE> window_size = self.driver.get_window_size() <NEW_LINE> screen_bottom = window_size['height'] - offset <NEW_LINE> screen_top = offset <NEW_LINE> screen_left = offs... | Swipe an element up, down, left, or right
:param locator:
:param direction:
:param offset:
:param duration:
:return: | 625941c863d6d428bbe4454a |
def update_editor ( self ): <NEW_LINE> <INDENT> panel = self.control <NEW_LINE> panel.SetSizer( None ) <NEW_LINE> panel.DestroyChildren() <NEW_LINE> sizer = wx.BoxSizer( wx.VERTICAL ) <NEW_LINE> value = self.value <NEW_LINE> if not isinstance( value, HasTraits ): <NEW_LINE> <INDENT> control = wx.StaticText( panel, -1, ... | Updates the editor when the object trait changes external to the
editor. | 625941c8e5267d203edcdcf9 |
def __kill_process(self): <NEW_LINE> <INDENT> shell_comm = "kill -kill `lsof -t -i tcp:" + self.__port + "`" <NEW_LINE> process = subprocess.Popen(shell_comm, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) <NEW_LINE> _, __ = process.communicate() <NEW_LINE> time.sleep(5) | Kill the Appium server. | 625941c83c8af77a43ae37fa |
def draw_bar(t, height): <NEW_LINE> <INDENT> t.begin_fill() <NEW_LINE> t.left(90) <NEW_LINE> t.forward(height) <NEW_LINE> t.write(" "+ str(height)) <NEW_LINE> t.right(90) <NEW_LINE> t.forward(size_bin) <NEW_LINE> t.right(90) <NEW_LINE> t.forward(height) <NEW_LINE> t.left(90) <NEW_LINE> t.end_fill() | Get turtle t to draw one bar, of height. | 625941c85fdd1c0f98dc028e |
def load(self, deferData = False): <NEW_LINE> <INDENT> self.loadMetaPkl() <NEW_LINE> """Use the paths res columns to load the results into the df""" <NEW_LINE> for ind in self.metaDf.index: <NEW_LINE> <INDENT> self._loadOne(ind, deferData = deferData) | Load pickled simulation meta object and then the sieveData and sieveResults objects from the paths in resDf.sim and resDf.res
If deferData or deferResults then only load the meta object as self.metaDf but leave paths for data/results | 625941c8596a897236089b1c |
def make_workers(self, count=1): <NEW_LINE> <INDENT> for i in range(count): <NEW_LINE> <INDENT> worker = Worker(self.config['rpc']['worker_bind']) <NEW_LINE> worker.config = self.config <NEW_LINE> self.workers.append(worker) | Create workers
:param count: Number of workers to create | 625941c89f2886367277a8e9 |
def cim_scs_of_sys_id(self, sys_id, raise_error=True): <NEW_LINE> <INDENT> return self._cim_srv_of_sys_id( 'CIM_StorageConfigurationService', sys_id, raise_error) | Return a CIMInstance of CIM_StorageConfigurationService for given
system id.
Using 'SystemName' property as system id of a service which is defined
by DMTF CIM_Service. | 625941c8a219f33f346289c6 |
@app.route('/', methods=['GET', 'POST']) <NEW_LINE> def index(): <NEW_LINE> <INDENT> print("index") <NEW_LINE> return jsonify('Hello AERGO World!') | root path | 625941c8d10714528d5ffd3d |
def test_agg_vs_historical(pudl_out_orig, pudl_out_eia, live_dbs): <NEW_LINE> <INDENT> if not live_dbs: <NEW_LINE> <INDENT> pytest.skip("Data validation only works with a live PUDL DB.") <NEW_LINE> <DEDENT> if pudl_out_eia.freq is None: <NEW_LINE> <INDENT> pytest.skip("Only run if pudl_out_eia != pudl_out_orig.") <NEW_... | Validate whole dataset against aggregated historical values. | 625941c850485f2cf553cdf4 |
def test_object_get_by_tags(self): <NEW_LINE> <INDENT> o4 = self.test_model.objects.create(name="Test 4", tags="red, green, yellow") <NEW_LINE> t1 = self.test_model.objects.get(tags="red, yellow") <NEW_LINE> self.assertEqual(t1.pk, o4.pk) | Check that object.get tags loads the item correctly | 625941c84f88993c3716c0c3 |
def activate(self): <NEW_LINE> <INDENT> api_args = {'activate': 'Y'} <NEW_LINE> response = DynectSession.get_session().execute(self.uri, 'PUT', api_args) <NEW_LINE> self._build(response['data']) | Activate this :class:`DNSSEC` service | 625941c89c8ee82313fbb7d0 |
def list_issue_statuses(self): <NEW_LINE> <INDENT> return IssueStatuses(self.requester).list(project=self.id) | Get the list of :class:`IssueStatus` resources for the project. | 625941c867a9b606de4a7f15 |
@staff_member_required <NEW_LINE> def report_renewal_period_members(request, template_name='reports/renewal_period_members.html'): <NEW_LINE> <INDENT> members = [] <NEW_LINE> for member in MembershipDefault.objects.all(): <NEW_LINE> <INDENT> if member.can_renew(): <NEW_LINE> <INDENT> member_dict = { 'member_number': me... | Table of memberships ordered by join dt, filterable by time period between join date and now.
| 625941c807f4c71912b114dc |
def save_current_buffers(self, filename='', log_type='raw', log_format='both'): <NEW_LINE> <INDENT> filenames = [] <NEW_LINE> if log_format.startswith('both') or log_format.startswith('sid'): <NEW_LINE> <INDENT> fnames = self.logger.log_sid_format( self.config.stations, '', log_type=log_type, extended=log_format.endswi... | Save buffer data from logger.sid_file.
log_type = raw or filtered
log_format = sid_format
| sid_extended
| supersid_format
| supersid_extended
| both
| both_extended | 625941c8656771135c3eb8c8 |
@pytest.mark.uncollectif(lambda appliance: appliance.is_pod) <NEW_LINE> def test_firewalld_running(appliance): <NEW_LINE> <INDENT> result = appliance.ssh_client.run_command('systemctl status firewalld').output <NEW_LINE> assert 'active (running)' in result | Verifies iptables service is running on the appliance | 625941c845492302aab5e31d |
def get_call_to_action(self, id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.get_call_to_action_with_http_info(id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.get_call_to_action_with_http_info(id, ... | Get Call to Action
Get information about a call-to-action.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.get_... | 625941c84d74a7450ccd421f |
def t_STAR(t): <NEW_LINE> <INDENT> t.value = t.value, kwds(t.lexer, len(t.value)) <NEW_LINE> return t | \* | 625941c876e4537e8c3516cd |
def test_help_EOF(self): <NEW_LINE> <INDENT> msg = "EOF command to exit the program\n" <NEW_LINE> with patch('sys.stdout', new=io.StringIO()) as f: <NEW_LINE> <INDENT> HBNBCommand().onecmd("help EOF") <NEW_LINE> st = f.getvalue() <NEW_LINE> self.assertEqual(msg, st) | Test for help of EOF command | 625941c866656f66f7cbc205 |
def __init__(self, parent=None): <NEW_LINE> <INDENT> super(OptionsDialog, self).__init__(parent) <NEW_LINE> QtGui.QDialog.__init__(self, parent) <NEW_LINE> self.setupUi(self) <NEW_LINE> settings = QSettings() <NEW_LINE> self.distance.setValue( settings.value( 'stream-feature-extractor/search-distance', 0, type=float) )... | Constructor. | 625941c8796e427e537b0620 |
def activate(self, _oWidget): <NEW_LINE> <INDENT> oDlg = SutekhDialog("Choose Card Set to Compare with", self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) <NEW_LINE> oCSView = CardSetsListView(None, oDlg) <NEW_LINE> oCSView.set_select... | Create the dialog for choosing the second card set. | 625941c807d97122c41788e4 |
def partial_fit(self, X): <NEW_LINE> <INDENT> opt, cost, rec_loss, l_loss = sess.run((self.optimizer, self.cost, self.reconstr_loss, self.latent_loss), feed_dict={self.x: X}) <NEW_LINE> return cost, rec_loss, l_loss | Train model based on mini-batch of input data.
Return cost of mini-batch. | 625941c8507cdc57c6306d34 |
def attempt_connection(self): <NEW_LINE> <INDENT> self.connection_error = False <NEW_LINE> sleep_exp = 1 <NEW_LINE> connect_count = 0 <NEW_LINE> while self.running and self.socket is None and connect_count < self.__reconnect_attempts_max: <NEW_LINE> <INDENT> for host_and_port in self.__host_and_ports: <NEW_LINE> <INDEN... | Try connecting to the (host, port) tuples specified at construction time. | 625941c8cc40096d615959ac |
def display(self): <NEW_LINE> <INDENT> for i in range(self.n): <NEW_LINE> <INDENT> line = [] <NEW_LINE> offset = i * self.n <NEW_LINE> for j in range(self.n): <NEW_LINE> <INDENT> line.append(self.config[offset + j]) | Style the display of the puzzle state | 625941c897e22403b379cff5 |
def tensor3(name=None, dtype=None): <NEW_LINE> <INDENT> if dtype is None: <NEW_LINE> <INDENT> dtype = config.floatX <NEW_LINE> <DEDENT> type = TensorType(dtype, (False, False, False)) <NEW_LINE> return type(name) | Return a symbolic 3-D variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable | 625941c844b2445a339320f1 |
def _synchronous_wait(self, target, timeout=3.0): <NEW_LINE> <INDENT> wait_until = time.time() + timeout <NEW_LINE> while time.time() < wait_until: <NEW_LINE> <INDENT> if CountingOplogReplayer.count == target: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> time.sleep(0.05) <NEW_LINE> <DEDENT> raise Exception('retry_cou... | Synchronously wait for the oplogreplay to finish.
Waits until the oplog's retry_count hits target, but at most
timeout seconds. | 625941c897e22403b379cff4 |
def getSuggestion(self, municipalityQuery : str) -> MunicipalityModel: <NEW_LINE> <INDENT> municipalityQuery = curateMunicipality(municipalityQuery) <NEW_LINE> bestMunicipality : MunicipalityModel = municipalities[0] <NEW_LINE> bestDistance : int = distance(municipalityQuery, bestMunicipality.nameCured) <NEW_LINE> for ... | Method that returns the best match of the given municipality with the
cuban municipalities. The best match is calculated using the
Damerau-Levenshtein distance. | 625941c8435de62698dfdca7 |
def attract_z(shape, locus, radius, exaggerate=1): <NEW_LINE> <INDENT> args = [Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate)] <NEW_LINE> return Shape(stdlib.attract_z( args[0].ptr, tvec3(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr)) | Attracts the shape away from a XY plane based upon a radius r,
with optional exaggeration | 625941c801c39578d7e74e96 |
def get_consensus(fasta_seqs, min_consensus): <NEW_LINE> <INDENT> seqs = list() <NEW_LINE> counts = list() <NEW_LINE> temp_dir = get_qiime_temp_dir() <NEW_LINE> fd_fas, fasta_tempfile_name = mkstemp(dir=temp_dir, suffix='.fas') <NEW_LINE> close(fd_fas) <NEW_LINE> with open(fasta_tempfile_name, 'w') as fasta_tempfile: <... | Returns consensus sequence from a set of sequences
input: fasta file, min_consensus
fasta_file should be in the following format:
>random_bc|number
seq
>random_bc|number
seq
....
number = number of times this seq has appeared with this random_barcode
Parameters
----------
fasta_seqs: list
min_consensus: float
Returns
... | 625941c821bff66bcd6849af |
def num_messages(self) -> int: <NEW_LINE> <INDENT> return sum(len(x) for x in self.error_info_map.values()) | Return the number of generated messages. | 625941c86fb2d068a760f0f7 |
def range2nets(rng): <NEW_LINE> <INDENT> start, stop = rng <NEW_LINE> if isinstance(start, basestring): <NEW_LINE> <INDENT> start = ip2int(start) <NEW_LINE> <DEDENT> if isinstance(stop, basestring): <NEW_LINE> <INDENT> stop = ip2int(stop) <NEW_LINE> <DEDENT> if stop < start: <NEW_LINE> <INDENT> raise ValueError() <NEW_... | Converts a (start, stop) tuple to a list of networks. | 625941c87b180e01f3dc485a |
def get_data(self, path): <NEW_LINE> <INDENT> assert(os.path.isdir(path)), "Not a valid file path" <NEW_LINE> files = [] <NEW_LINE> for file in glob(path + "/*.csv"): <NEW_LINE> <INDENT> file = pd.read_csv(file) <NEW_LINE> file.columns = ["Timestamp", "Bugs"] <NEW_LINE> files.append(file) <NEW_LINE> <DEDENT> return fil... | Reads csv from the the data folder and converts them to pandas dataframe
:param path: Absolute path of the data
:type path: str
:rtype: List[pd.core.frame.DataFrame] | 625941c8046cf37aa974cda4 |
@pytest.fixture <NEW_LINE> def configuration(request): <NEW_LINE> <INDENT> config = testing.setUp(settings={ 'sqlalchemy.url': 'postgres://localhost:5432/opportune_test' }) <NEW_LINE> config.include('opportune.models') <NEW_LINE> config.include('opportune.routes') <NEW_LINE> def teardown(): <NEW_LINE> <INDENT> testing.... | Setup a database for testing purposes. | 625941c8bf627c535bc1322a |
def __init__(self, app): <NEW_LINE> <INDENT> super(TIDECallback, self).__init__() <NEW_LINE> self._app = app | Constructor parameters:
:param app: The application this handler is associated with | 625941c8aad79263cf390a9b |
def test_repeat_activation(self): <NEW_LINE> <INDENT> user_model = get_user_model() <NEW_LINE> resp = self.client.post( reverse("django_registration_register"), data=self.valid_data ) <NEW_LINE> activation_key = signing.dumps( obj=self.valid_data[user_model.USERNAME_FIELD], salt=REGISTRATION_SALT ) <NEW_LINE> with self... | Once activated, attempting to re-activate an account (even
with a valid key) does nothing. | 625941c86fece00bbac2d799 |
def test_default_redirect(self): <NEW_LINE> <INDENT> app = TestApp(appbottle) <NEW_LINE> response = app.get('/') <NEW_LINE> self.assertEqual('302 Found', response.status) | test_default_redirect | 625941c826068e7796caed39 |
def add_template(self, block): <NEW_LINE> <INDENT> prevhash = block.prevhash_hex <NEW_LINE> previous_hash_keys = list(self.prevhashes) <NEW_LINE> if prevhash in previous_hash_keys: <NEW_LINE> <INDENT> new_block = False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_block = True <NEW_LINE> self.prevhashes[prevhash] =... | Adds new template to the registry.
It also clean up templates which should
not be used anymore. | 625941c8a8370b77170528fb |
def _uncoupled_superradiant(N): <NEW_LINE> <INDENT> N = int(N) <NEW_LINE> jz = jspin(N, "z", basis="uncoupled") <NEW_LINE> en, vn = jz.eigenstates() <NEW_LINE> psi0 = vn[2**N - (N+1)] <NEW_LINE> return ket2dm(psi0) | Generate the density matrix of a superradiant state in the full
:math:`2^N` dimensional Hilbert space.
Parameters
----------
N: int
The number of two-level systems.
Returns
-------
psi0: :class: qutip.Qobj
The density matrix for the superradiant state in the full Hilbert
space. | 625941c8ff9c53063f47c24f |
def p_val_comprehension(p): <NEW_LINE> <INDENT> if DEBUG: <NEW_LINE> <INDENT> print(inspect.stack()[0][3]) <NEW_LINE> <DEDENT> p[0] = ComprehensionNode(p[2], p[4]) | val : LBRACKET val WHERE prop RBRACKET | 625941c867a9b606de4a7f16 |
def sepp(a, b): <NEW_LINE> <INDENT> c_retval = ufunc.sepp(a, b) <NEW_LINE> return c_retval | Wrapper for ERFA function ``eraSepp``.
Parameters
----------
a : double array
b : double array
Returns
-------
c_retval : double array
Notes
-----
The ERFA documentation is below.
- - - - - - - -
e r a S e p p
- - - - - - - -
Angular separation between two p-vectors.
Given:
a double[3] first p-vector ... | 625941c8442bda511e8be475 |
def find_missing_listing_header(): <NEW_LINE> <INDENT> for md in config.markdown_dir.glob("*.md"): <NEW_LINE> <INDENT> lines = md.read_text().splitlines() <NEW_LINE> for n, line in enumerate(lines): <NEW_LINE> <INDENT> if ( line.startswith("//") and line.endswith(".kt") and not lines[n - 1].startswith("```kotlin") ): <... | Look for missing ```kotlin | 625941c8bde94217f3682e4d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.