code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def vcsLog(self, name): <NEW_LINE> <INDENT> isFile = os.path.isfile(name) <NEW_LINE> noEntries, ok = QInputDialog.getInt( None, self.tr("Subversion Log"), self.tr("Select number of entries to show."), self.getPlugin().getPreferences("LogLimit"), 1, 999999, 1) <NEW_LINE> if ok: <NEW_LINE> <INDENT> from .SvnLogDialog imp... | Public method used to view the log of a file/directory from the
Subversion repository.
@param name file/directory name to show the log of (string) | 625941b4a934411ee3751468 |
def rmatmat(self, x): <NEW_LINE> <INDENT> return self.__H.__mul__(x) | Matrix (batch) product with the conjugate transpose. This method is
included for compatibility with Scipy only. Please use the ``H``
attribute instead. | 625941b416aa5153ce362244 |
def redundant_entry(entry): <NEW_LINE> <INDENT> global entry_set, word_set <NEW_LINE> word_lst = list(word_set[entry]) <NEW_LINE> if not word_lst: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> u_set = entry_set[word_lst[0]] <NEW_LINE> for word in word_lst[1:]: <NEW_LINE> <INDENT> e_set = entry_set[word] <NEW_LINE... | Whether some other entry generates all words this one does and more | 625941b4f548e778e58cd348 |
def multiply_sigmoid_06(x1, x2): <NEW_LINE> <INDENT> expo = 0.6 <NEW_LINE> return signed_expo(x1 * x2, expo) | Computes the function y_i <- sign(x1_i * x2_i) * abs(x1_i * x2_i)^0.6 . | 625941b4099cdd3c635f0a29 |
def pure(x): <NEW_LINE> <INDENT> def parser(state): <NEW_LINE> <INDENT> return State(state.value + [x], state.remaining) <NEW_LINE> <DEDENT> return parser | A parser which simply inserts a new value into the parse result, but does not consume any
input. | 625941b430dc7b7665901738 |
def getTotalArea(inputList, getFrom="coords", type="inside", R=1*u.m, units=u.m**2, angleUnits=u.rad): <NEW_LINE> <INDENT> if getFrom == "Phi": <NEW_LINE> <INDENT> Phi23_1, Phi31_2, Phi12_3 = inputList <NEW_LINE> <DEDENT> elif getFrom == "coords": <NEW_LINE> <INDENT> a1, a2, a3, d1, d2, d3 = inputList <NEW_LINE> Phi23_... | Function to find the total area of a spherical triangle
:param inputList: List of possible inputs.
If getFrom is "coords" list is as [a1, a2, a3, d1, d2, d3] where ai and
di are the alpha and delta of point Pi.
If getFrom is "Phi" list is as [Phi23_1, Phi31_2, Phi12_3] where Phiij_k is the rotation angle
:param getFrom... | 625941b45fc7496912cc3752 |
def initGui(self): <NEW_LINE> <INDENT> icon_path = ':/plugins/NetworkProfiler/icon.png' <NEW_LINE> self.add_action( icon_path, text=self.tr(u'Network Profiler'), callback=self.run, parent=self.iface.mainWindow()) | Create the menu entries and toolbar icons inside the QGIS GUI. | 625941b47b25080760e39228 |
def send(self, message): <NEW_LINE> <INDENT> self.data['data']['alert'] = message <NEW_LINE> r = post(self.url, data=dumps(self.data), headers=self.headers) <NEW_LINE> return r.text, r.status_code | :return: Return message, Status code | 625941b4d58c6744b4257a2d |
def _clean_array(self, value): <NEW_LINE> <INDENT> return shlex.split(value.strip('()')) | Pythonize a bash array | 625941b41f037a2d8b945fcc |
@receiver(post_save, sender=User) <NEW_LINE> def create_subscriber_for_user(sender, **kwargs): <NEW_LINE> <INDENT> user = kwargs.get('instance') <NEW_LINE> created = kwargs.get('created') <NEW_LINE> raw = kwargs.get('raw') <NEW_LINE> logging.debug('user is %r' % user) <NEW_LINE> if created and not raw: <NEW_LINE> <INDE... | Create a Subscriber object whenever a user is created. This is useful so
that we don't have to patch whatever different registration processes we
end up using. | 625941b4a4f1c619b28afe10 |
@dbmanager.command <NEW_LINE> def recreate(): <NEW_LINE> <INDENT> drop() <NEW_LINE> create() | Recreates database tables (same as issuing 'drop' and then 'create') | 625941b4ab23a570cc24ff50 |
def __init__(self): <NEW_LINE> <INDENT> self.set = [False] * 1000000 | Initialize your data structure here. | 625941b4e1aae11d1e749a81 |
def get_locales(self, package_name): <NEW_LINE> <INDENT> self._analyse() <NEW_LINE> for locale in self.values[package_name].keys(): <NEW_LINE> <INDENT> yield locale | Retrieve a list of all available locales in a given package_name.
:param package_name: the package name to get locales of | 625941b4e8904600ed9f1cf6 |
def test_save_POST(self): <NEW_LINE> <INDENT> response = self.client.post('/', data={'item_text': 'A new list item'}) <NEW_LINE> self.assertEqual(Item.objects.count(), 1) <NEW_LINE> new_item = Item.objects.first() <NEW_LINE> self.assertEqual(new_item.text, 'A new list item') <NEW_LINE> self.assertEqual(response.status_... | Unit test checking that home page can save a post request. | 625941b48a43f66fc4b53e37 |
def _updateLabel(self, isLeft): <NEW_LINE> <INDENT> lbl = self._label <NEW_LINE> if self._idx != None: <NEW_LINE> <INDENT> if lbl == None: <NEW_LINE> <INDENT> bw = _BASE_WIDTH <NEW_LINE> num = self._partner_virtual_helix.number() <NEW_LINE> tbr = _FM.tightBoundingRect(str(num)) <NEW_LINE> half_label_h = tbr.height()/2.... | Called by updatePositionAndAppearance during init, or later by
updateConnectivity. Updates drawing and position of the label. | 625941b48a349b6b435e7f42 |
def __div__(self, rhs): <NEW_LINE> <INDENT> return Duration(self._frame, self._seconds / rhs) | Divide a Duration by a value.
= INPUT VARIABLES
- rhs The scalar to divide by.
= RETURN VALUE
- Returns the scaled Duration. | 625941b4925a0f43d2549c40 |
def origin_aliases(): <NEW_LINE> <INDENT> warnings.warn( "origin_aliases is deprecated - please use load_data instead", DeprecationWarning, ) <NEW_LINE> return [PathAlias(**elem) for elem in DATA["origin_alias"]] | Returns:
list[:class:`~PathAlias`]
A list of aliases relating to origin paths. | 625941b4cdde0d52a9e52dfb |
def parse_mentoring(xml): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for deal in xml: <NEW_LINE> <INDENT> if xml_text(xml_find("category-id", deal)) == MENTORING_DEAL_ID: <NEW_LINE> <INDENT> result.append((xml_text(xml_find("party-id", deal)), [xml_text(xml_find("id", party)) for party in xml_find("parties", deal)])) <... | Returns a dictionary specifing all mentoring relationships. The key is
the person id of mentor and the value is a list of all person ids which
are the mentees. | 625941b4dc8b845886cb5301 |
def map_values(e): <NEW_LINE> <INDENT> return col(MapValues(ensure_column(e))) | :rtype: Column | 625941b46aa9bd52df036b6f |
def manage_addCdefGraphPoint(context, id, REQUEST = None): <NEW_LINE> <INDENT> gp = CdefGraphPoint(id) <NEW_LINE> context._setObject(gp.id, gp) <NEW_LINE> if REQUEST: <NEW_LINE> <INDENT> return context.callZenScreen(REQUEST) | This is here so than zope will let us copy/paste/rename
graphpoints. | 625941b4566aa707497f4349 |
def _GetHighlighterParams(self, parsed_url): <NEW_LINE> <INDENT> query_dict = urlparse.parse_qs(parsed_url.query) <NEW_LINE> return (query_dict.get('highlighter', ['pygments'])[0], query_dict.get('style', ['colorful'])[0]) | Get the highlighting parameters from a parsed url.
| 625941b4de87d2750b85fb5b |
def _do_partial_hook(self, cr, uid, ids, context, *args, **kwargs): <NEW_LINE> <INDENT> if isinstance(ids, (int, long)): <NEW_LINE> <INDENT> ids = [ids] <NEW_LINE> <DEDENT> move = kwargs.get('move') <NEW_LINE> assert move, 'missing move' <NEW_LINE> partial_datas = kwargs.get('partial_datas') <NEW_LINE> assert partial_d... | hook to update defaults data of the current object, which is stock.picking.
The defaults data are taken from the _do_partial_hook which is on the stock_partial_picking
osv_memory object used for the wizard of deliveries.
For outgoing shipment | 625941b430bbd722463cbb90 |
def __sub__(self, left): <NEW_LINE> <INDENT> return (self.v - left.v*pow(radix,self.n-left.n,Mod))%Mod | difference of prefixes to get rollinghash of an interval | 625941b4be7bc26dc91cd3d4 |
def __getitem__(self, item: Identifier) -> Symbol: <NEW_LINE> <INDENT> return self.lookup[item] | Returns a symbol from this map | 625941b4be383301e01b5263 |
def dump_logs(sess,splash_url,id_param): <NEW_LINE> <INDENT> sep = '-'*60 <NEW_LINE> for ru in sess.query(RedirectURL).all(): <NEW_LINE> <INDENT> if ru.access_logs: <NEW_LINE> <INDENT> tpl = ru.to_urltuple(splash_url,id_param) <NEW_LINE> m = f'- {yellow("Splash Link")}: {tpl.splash_link}\n' f'- {yellow("... | Dump logs in a simple format to stdout. | 625941b43539df3088e2e119 |
def find_elements(self, *locators): <NEW_LINE> <INDENT> logger.debug('find elements %s by %s' % (locators[1], locators[0])) <NEW_LINE> return self.driver.find_elements(*locators) | Find web elements by UI locators
:param locators: a tuple of UI locators
:return: a list of web elements | 625941b46e29344779a623e4 |
def CollapseDictionary(mapping): <NEW_LINE> <INDENT> def originalPrefixes(item): <NEW_LINE> <INDENT> return item.find('_')+1==1 <NEW_LINE> <DEDENT> revDict = {} <NEW_LINE> for k,v in mapping.items(): <NEW_LINE> <INDENT> revDict.setdefault(v,set()).add(k) <NEW_LINE> <DEDENT> prefixes2Collapse = [] <NEW_LINE> for k,v in ... | Takes a dictionary mapping prefixes to URIs
and removes prefix mappings that begin with _ and
there is already a map to their value
>>> a = {'ex': URIRef('http://example.com/')}
>>> a['_1'] = a['ex']
>>> len(a)
2
>>> a.values()
[rdflib.URIRef('http://example.com/'), rdflib.URIRef('http://example.com/')]
>>> CollapseD... | 625941b42eb69b55b151c677 |
def FSpecialGauss(size, sigma): <NEW_LINE> <INDENT> radius = size // 2 <NEW_LINE> offset = 0.0 <NEW_LINE> start, stop = -radius, radius + 1 <NEW_LINE> if size % 2 == 0: <NEW_LINE> <INDENT> offset = 0.5 <NEW_LINE> stop -= 1 <NEW_LINE> <DEDENT> x, y = np.mgrid[offset + start:stop, offset + start:stop] <NEW_LINE> assert l... | Function to mimic the 'fspecial' gaussian MATLAB function. | 625941b4a17c0f6771cbde22 |
def calcKernel(self): <NEW_LINE> <INDENT> k = [[0 for i in range(self.m)] for j in range(self.m)] <NEW_LINE> for i in range(self.m): <NEW_LINE> <INDENT> if i % 100 == 0: <NEW_LINE> <INDENT> print('construct the kernel:', i, self.m) <NEW_LINE> <DEDENT> X = self.trainDataMat[i, :] <NEW_LINE> for j in range(i, self.m): <N... | 计算核函数
使用的是高斯核 详见“7.3.3 常用核函数” 式7.90
:return: 高斯核矩阵 | 625941b40a50d4780f666c5d |
def test_timeout(self): <NEW_LINE> <INDENT> node = self.network.new_node('T') <NEW_LINE> cb = mock.Mock(side_effect=lambda: self.kill(node)) <NEW_LINE> self.network.set_timer(node.address, 0.01, cb) <NEW_LINE> self.network.run() <NEW_LINE> self.failUnless(cb.called) | Node's timeouts trigger at the appropriate time | 625941b423849d37ff7b2e60 |
def modInv (a, n): <NEW_LINE> <INDENT> res = eucl(a, n)[0] <NEW_LINE> if res < 0: <NEW_LINE> <INDENT> res = a * modPow(res, 2, n) <NEW_LINE> <DEDENT> return res | Inverse modulaire (n'existe que si a et n premiers entre eux). | 625941b4656771135c3eb640 |
def polarU(A: tn.Tensor, pivot_axis: int = -1, mode: Text = "svd", Niter: int = 4) -> tn.Tensor: <NEW_LINE> <INDENT> A_mat = tn.pivot(A, pivot_axis=pivot_axis) <NEW_LINE> if mode == "svd": <NEW_LINE> <INDENT> W, _, Vh, _ = A.backend.svd(A_mat.array) <NEW_LINE> Umat_arr = W@Vh <NEW_LINE> <DEDENT> elif mode == "QDWH": <N... | Computes the isometric factor U in the polar decomposition, U = u @ vh
where u and vh are the singular vector matrices in the SVD.
Args:
A: The input tensor.
pivot_axis: Determines where to matricize A.
mode: Algorithm used for the decomposition. See vumps_params.
Niter: Maximum number of iteration allotted the... | 625941b485dfad0860c3ac26 |
def get_edi_version(): <NEW_LINE> <INDENT> project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) <NEW_LINE> git_dir = os.path.join(project_root, ".git") <NEW_LINE> if os.path.isdir(git_dir): <NEW_LINE> <INDENT> from setuptools_scm import get_version <NEW_LINE> return get_version(root=project_... | Get the version of the current edi installation or the version derived from git.
:return: full edi version string | 625941b4be8e80087fb20a1d |
def test_parser_failed_command(self): <NEW_LINE> <INDENT> def parsing_complete(command_failure): <NEW_LINE> <INDENT> response_dict = command_failure.value.results['response'] <NEW_LINE> self.assertEqual(response_dict['status'], 'error', 'The parser did not return an error response.') <NEW_LINE> self.assertTrue('submitt... | This test verifies that the command parser correctly returns an error response when a command fails (i.e. raises
an exception). In addition, it tests that the parser defaults to requiring an active user session if the command
doesn't provide any meta-data.
@note This test checks the "default to requiring an active se... | 625941b4aad79263cf390808 |
def __getitem__(self, k): <NEW_LINE> <INDENT> if self._data is not None: <NEW_LINE> <INDENT> return self._data[k] <NEW_LINE> <DEDENT> if isinstance(k, slice): <NEW_LINE> <INDENT> if k.start is not None: <NEW_LINE> <INDENT> start = int(k.start) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> start = None <NEW_LINE> <DEDEN... | Support list index and slicing, similar to Django QuerySet. | 625941b4d164cc6175782b1b |
def get_widget_label(self, item_id): <NEW_LINE> <INDENT> return self._pattern.format(item_id + self._offset) | Get widget identifier for user input description.
It should be something similar to the pattern.
:param item_id: Position of the widget in the list.
:type item_id: int starts from 0. | 625941b4dd821e528d63af7a |
def _load_items(self, splits): <NEW_LINE> <INDENT> ids = [] <NEW_LINE> for year, name in splits: <NEW_LINE> <INDENT> root = os.path.join(self._root, 'BDD' + str(year)) <NEW_LINE> lf = os.path.join(root, 'ImageSets', 'Main', name + '.txt') <NEW_LINE> with open(lf, 'r') as f: <NEW_LINE> <INDENT> ids += [(root, line.strip... | Load individual image indices from splits. | 625941b46aa9bd52df036b70 |
@responses.activate <NEW_LINE> def test_async_raise_for_status(): <NEW_LINE> <INDENT> responses.add(responses.GET, 'http://baseurl.com/v1/thing/777', body='{"error": "Not found."}', status=404, content_type='application/json') <NEW_LINE> future = DummyService.async_thing_detail(id=777) <NEW_LINE> with pytest.raises(req... | Test that we raise a `requests.HTTPError` for 40x/50x response status | 625941b4f548e778e58cd349 |
def test_letters_undo(self): <NEW_LINE> <INDENT> self.assertEqual(pycg.undo("bob"), "b") <NEW_LINE> self.assertEqual(pycg.undo("Bob"), "B") | Very simple tests | 625941b42eb69b55b151c678 |
def set_value_unit(self, value, original_unit, fmt=None): <NEW_LINE> <INDENT> base_unit = self.postbox.get_value() <NEW_LINE> self.textbox.set_value(value*self.postbox.get_factor(original_unit, base_unit), fmt) | Set the value to the base unit.
:param value:
:param original_unit:
:param fmt:
:return: | 625941b48e7ae83300e4ad9a |
def read_references(audio_path, annotator_id=0): <NEW_LINE> <INDENT> ds_path = os.path.dirname(os.path.dirname(audio_path)) <NEW_LINE> jam_path = os.path.join(ds_path, ds_config.references_dir, os.path.basename(audio_path)[:-4] + ds_config.references_ext) <NEW_LINE> jam = jams.load(jam_path, validate=False) <NEW_LINE> ... | Reads the boundary times and the labels.
Parameters
----------
audio_path : str
Path to the audio file
Returns
-------
ref_times : list
List of boundary times
ref_labels : list
List of labels
Raises
------
IOError: if `audio_path` doesn't exist. | 625941b4aad79263cf390809 |
def cast(*args): <NEW_LINE> <INDENT> return _itkBinaryImageToStatisticsLabelMapFilterPython.itkBinaryImageToStatisticsLabelMapFilterIUL3IUC3LM3_cast(*args) | cast(itkLightObject obj) -> itkBinaryImageToStatisticsLabelMapFilterIUL3IUC3LM3 | 625941b445492302aab5e08e |
def test_similarity_none_attributes(self): <NEW_LINE> <INDENT> self.obj1.item1.similarity.return_value = Similarity(1.0) <NEW_LINE> self.obj1.item2.similarity.return_value = Similarity(1.0) <NEW_LINE> self.obj1.item2 = None <NEW_LINE> self.obj2.item2 = None <NEW_LINE> similarity = (self.obj1 % self.obj2) <NEW_LINE> sel... | Verify two empty attributes are not included in similarity. | 625941b491af0d3eaac9b7e1 |
def loop_params(soup): <NEW_LINE> <INDENT> counter_div = soup.find('div', attrs={'class': 'page-nave__desktop'}) <NEW_LINE> counter_page = int(str(counter_div.find_all('a')[-1]).split('>')[1].split('<')[0]) <NEW_LINE> return counter_page | bepaal het aantal pagina's die doorlopen moeten worden
# zoek de div met de pagina counters
# zoek de laatste waarde hierin (laatste pagina)
# verwijder anchor tekst zodat het getal overblijft
!!! let op: gaat fout bij 1 pagina | 625941b450485f2cf553cb67 |
def get_entities(self, location, position=None): <NEW_LINE> <INDENT> return self._entities_positions[location.level_id][position or location.position] | Get entitities on given Location. | 625941b4b7558d58953c4cea |
def Dec2Angle(Dec): <NEW_LINE> <INDENT> import astropy.units as u <NEW_LINE> if type(Dec) is not list: <NEW_LINE> <INDENT> Dec = [Dec] <NEW_LINE> <DEDENT> if type(Dec[0]) is str: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> DecAngle = Angle(Dec, unit=u.deg) <NEW_LINE> <DEDENT> except KeyboardInterrupt: <NEW_LINE> <INDE... | Returns Angle objects for input Dec values.
Parameters
----------
Dec : str, float or list of str, float
Values of Dec to convert. Can be strings in makesourcedb format or floats
in degrees
Returns
-------
DecAngle : astropy.coordinates.Angle object | 625941b4004d5f362079a106 |
def get_by_itag(self, itag: int) -> Optional[Stream]: <NEW_LINE> <INDENT> return self.itag_index.get(int(itag)) | Get the corresponding :class:`Stream <Stream>` for a given itag.
:param int itag:
YouTube format identifier code.
:rtype: :class:`Stream <Stream>` or None
:returns:
The :class:`Stream <Stream>` matching the given itag or None if
not found. | 625941b4498bea3a759b9880 |
def ban_owner(self, request, queryset): <NEW_LINE> <INDENT> total = 0 <NEW_LINE> for project in queryset: <NEW_LINE> <INDENT> if project.users.count() == 1: <NEW_LINE> <INDENT> count = (UserProfile.objects .filter(user__projects=project) .update(banned=True)) <NEW_LINE> total += count <NEW_LINE> <DEDENT> else: <NEW_LIN... | Ban project owner
This will only ban single owners, because a malicious user could add a
user as a co-owner of the project. We don't want to induce and
collatoral damage when flagging users. | 625941b4e5267d203edcda70 |
@pytest.mark.parametrize('string, expected_membership', [ ('0', True), ('1', True), ('9', True), ('a', False), ('A', False), ('$', False), ]) <NEW_LINE> def test_is_digit(string: str, expected_membership: bool) -> None: <NEW_LINE> <INDENT> membership: bool = is_digit(string) <NEW_LINE> assert membership == expected_mem... | Test seligimus.characters.digits.is_digit. | 625941b42c8b7c6e89b35599 |
def ddpg(n_episodes=1000, print_every=50): <NEW_LINE> <INDENT> scores = [] <NEW_LINE> scores_deque = deque(maxlen=print_every) <NEW_LINE> log = open("log.txt","w+") <NEW_LINE> for i_episode in range(1, n_episodes+1): <NEW_LINE> <INDENT> env_info = env.reset(train_mode=True)[BRAIN_NAME] <NEW_LINE> agent.reset() <NEW_LIN... | DDQN Algorithm.
Params
======
n_episodes (int): maximum number of training episodes
print_every (int): frequency of printing and loging information throughout iteration | 625941b45e10d32532c5ecfe |
def load_observed_ts(self,site,fn=None,location=None): <NEW_LINE> <INDENT> import pandas as pd <NEW_LINE> if fn is None: <NEW_LINE> <INDENT> if location is None: <NEW_LINE> <INDENT> location = OBSERVED_DIRECTORY <NEW_LINE> <DEDENT> import os <NEW_LINE> from glob import glob <NEW_LINE> matching_files = glob(os.path.join... | Load a time series file of observed loads for a given site. | 625941b4f7d966606f6a9dd7 |
def byte_adaptor(fbuffer): <NEW_LINE> <INDENT> if six.PY3: <NEW_LINE> <INDENT> strings = fbuffer.read().decode('utf-8') <NEW_LINE> fbuffer = six.StringIO(strings) <NEW_LINE> return fbuffer <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return fbuffer | provides py3 compatibility by converting byte based
file stream to string based file stream
Arguments:
fbuffer: file like objects containing bytes
Returns:
string buffer | 625941b423849d37ff7b2e61 |
@test_context <NEW_LINE> def test_check_pending_upload_not_expired(app): <NEW_LINE> <INDENT> with app.app_context(), set_time(): <NEW_LINE> <INDENT> expires = time.now() + timedelta(seconds=10) <NEW_LINE> pu_row, file_row = add_pending_upload_and_file_row( len(DATA), DATA_DIGEST, expires, 'us-west-2') <NEW_LINE> sessio... | check_pending_upload doesn't check anything if the URL isn't expired yet | 625941b4f8510a7c17cf94d4 |
def make_tomato(size): <NEW_LINE> <INDENT> np.random.seed(0) <NEW_LINE> x = np.random.normal(size=size) <NEW_LINE> tomato_price = 5 + x <NEW_LINE> ketchup_price = (2 * np.sin(2 * x) + x + np.random.normal(scale=0.5, size=size)) / 2 + 3 <NEW_LINE> return pd.DataFrame({ 'tomato_price': tomato_price, 'ketchup_price': ketc... | Simulated regression example. | 625941b45fdd1c0f98dc0000 |
def test_get_state(self): <NEW_LINE> <INDENT> c = initialise_cell() <NEW_LINE> s = c.get_state() <NEW_LINE> assert s <NEW_LINE> assert isinstance(s, Dead) | This method tests the ability of the GoLCell to retrieve its current state. The expected result of this test
is for the cell's current state to be correctly retrieved. | 625941b466656f66f7cbbf79 |
def _region_to_opj_arg(self, region_param): <NEW_LINE> <INDENT> arg = None <NEW_LINE> if region_param.mode != 'full': <NEW_LINE> <INDENT> x0 = region_param.pixel_x <NEW_LINE> y0 = region_param.pixel_y <NEW_LINE> x1 = region_param.pixel_x + region_param.pixel_w <NEW_LINE> y1 = region_param.pixel_y + region_param.pixel_h... | Args:
region_param (params.RegionParam)
Returns (str): e.g. 'x0,y0,x1,y1' | 625941b421bff66bcd684724 |
@blueprint.route("/post_file", methods=["POST"]) <NEW_LINE> def post_file(): <NEW_LINE> <INDENT> if not api_key_is_correct(): <NEW_LINE> <INDENT> abort(403) <NEW_LINE> <DEDENT> posted_data = request.form["fileinfo"] <NEW_LINE> posted_file = request.files["datafile"].read() <NEW_LINE> file_info = parse_post_data(posted_... | Загрузить файл к бизнес-процессу | 625941b467a9b606de4a7c8c |
def files_exist(path, files): <NEW_LINE> <INDENT> return all(os.path.exists(os.path.join(path, f)) for f in files) | Return True if all files exist in specified path. | 625941b4fff4ab517eb2f207 |
def make_bootstrap_pom(): <NEW_LINE> <INDENT> tf = NamedTemporaryFile(delete=False) <NEW_LINE> pom = BootstrapPOM() <NEW_LINE> pom.write(tf.name) <NEW_LINE> return tf | Creates a Bootstrap POM and returns the temporary
file it has been written to.
:returns: temporary file
:rtype: :class:`NamedTemporaryFile` | 625941b4462c4b4f79d1d49e |
def mkdir_f(path): <NEW_LINE> <INDENT> if (not os.path.isdir(path)): <NEW_LINE> <INDENT> os.mkdir(path) | Ensure that directory path exists. That is, if path already exists and
is a directory, do nothing; otherwise, try to create directory path (and
raise appropriate OSError if that doesn't work.) | 625941b45fc7496912cc3754 |
def p_annotation_type_member_declarations_opt2(self, p): <NEW_LINE> <INDENT> p[0] = [] | annotation_type_member_declarations_opt : empty | 625941b4090684286d50eab6 |
def cleanup_ovs_ports(netdst, ports): <NEW_LINE> <INDENT> host_bridge = utils_net.find_bridge_manager(netdst) <NEW_LINE> if utils_net.ovs_br_exists(netdst) is True: <NEW_LINE> <INDENT> ports = set(host_bridge.list_ports(netdst)) - set(ports) <NEW_LINE> for p in ports: <NEW_LINE> <INDENT> utils_net.find_bridge_manager(n... | Clean up created ovs ports in this case
:param netdst: netdst get from command line
:param ports: existing ports need to be remain before this test | 625941b4d58c6744b4257a30 |
def Mtp(self, *args): <NEW_LINE> <INDENT> return _DataModel.Tensor_Mtp(self, *args) | Mtp(Tensor self) -> RealQuantity
Mtp(Tensor self) -> RealQuantity | 625941b46fb2d068a760ee70 |
def generate_SOM(self,initial_radius,number_of_iterations,initial_learning_rate): <NEW_LINE> <INDENT> k_layer = self.Kohonen_Layer(self.x_size,self.y_size,self.data) <NEW_LINE> data_length = np.arange(0,self.data.shape[0]-1,1) <NEW_LINE> bmu_list = [] <NEW_LINE> cols_list = [] <NEW_LINE> rows_list = [] <NEW_LINE> for i... | A forward process which loops over training data and a specified number
of timesteps, updating weights and training the map.
:param initial_radius:
(int or float) initial radius around the BMU within which, nodes
are updated based on the input vector and proximity to the BMU
:param number_of_iterations:
... | 625941b4004d5f362079a107 |
def set_waveform(self, channel=1, function="SIN"): <NEW_LINE> <INDENT> self.check_ch(channel) <NEW_LINE> if channel == 1: <NEW_LINE> <INDENT> set_waveform = self.__write('FUNC {:s}'.format(function)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> set_waveform = self.__write('FUNC:CH2 {:s}'.format(function)) | set desired waveform (functions available: SINusoid, SQUare, RAMP, PULSe, NOISe, DC, USER) | 625941b496565a6dacc8f4a4 |
def query(sql, *par): <NEW_LINE> <INDENT> conn, cursor = connection() <NEW_LINE> cursor.execute(sql, par) <NEW_LINE> res = cursor.fetchall() <NEW_LINE> close_connection(conn, cursor) <NEW_LINE> return res | :param sql: sql查询语句
:param par: 占位符参数
:return: sql查询结果,tuple | 625941b4c4546d3d9de72807 |
def test_split_children_type(self): <NEW_LINE> <INDENT> response = self.client.post( self.split_endpoint.format(pk=self.signal_no_image.id), [ { 'text': 'Child #1 Request', 'category': {'sub_category': self.link_subcategory}, 'type': {'code': 'REQ'} }, { 'text': 'Child #2 Maintenance', 'category': {'sub_category': self... | When a signal is split its children must inherit certain properties. | 625941b42ae34c7f2600cf01 |
def step(self, session, encoder_inputs, decoder_inputs, target_weights, bucket_id, forward_only): <NEW_LINE> <INDENT> encoder_size, decoder_size = self.buckets[bucket_id] <NEW_LINE> if len(encoder_inputs) != encoder_size: <NEW_LINE> <INDENT> raise ValueError("Encoder length must be equal to the one in bucket," " %d != ... | Run a step of the model feeding the given inputs.
Args:
session: tensorflow session to use.
encoder_inputs: list of numpy int vectors to feed as encoder inputs.
decoder_inputs: list of numpy int vectors to feed as decoder inputs.
target_weights: list of numpy float vectors to feed as target weights.
bucket_i... | 625941b491af0d3eaac9b7e2 |
def reset(self): <NEW_LINE> <INDENT> self.optimized = None <NEW_LINE> self.timestamp = None <NEW_LINE> self.config_dir = None <NEW_LINE> self.output_dir = None <NEW_LINE> self.pipeline_config_path = None <NEW_LINE> self.pipeline_status_path = None <NEW_LINE> self.pipeline_logfile_path = None <NEW_LINE> self.execution_o... | Resets the builder so that another pipeline can be built. | 625941b4e8904600ed9f1cf8 |
def online_frame_generator(): <NEW_LINE> <INDENT> from madmom.audio.signal import Stream <NEW_LINE> hop_size = int(SAMPLE_RATE / FPS) <NEW_LINE> stream = Stream(sample_rate=SAMPLE_RATE, num_channels=1, frame_size=FRAME_SIZE, hop_size=hop_size, queue_size=1) <NEW_LINE> for frame in stream: <NEW_LINE> <INDENT> yield fram... | generate signal frames from mic | 625941b4cad5886f8bd26db1 |
def segment_combined_simple(self): <NEW_LINE> <INDENT> for line in self.corp: <NEW_LINE> <INDENT> if self.debug: <NEW_LINE> <INDENT> print(line) <NEW_LINE> <DEDENT> for word in line: <NEW_LINE> <INDENT> if word[1] == "S": <NEW_LINE> <INDENT> v = Verb(word[0]) <NEW_LINE> print("Word to segment:", word[0]) <NEW_LINE> m =... | Method that use Simple WixNLP | 625941b4099cdd3c635f0a2c |
def enumerate(vendor_id=0, product_id=0): <NEW_LINE> <INDENT> r = _hidapi.hid_enumerate(vendor_id, product_id) <NEW_LINE> if r is None: <NEW_LINE> <INDENT> raise HIDException('Failed to enumerate devices') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> d = r <NEW_LINE> while d: <NEW_LINE> <INDENT> yield DeviceInformation... | Enumerate the HID Devices.
This function returns an iterator that iterates over all the HID devices
attached to the system which match vendor_id and product_id. If vendor_id
and product_id are both set to 0, then all HID devices will be returned. | 625941b45166f23b2e1a4f28 |
def get_next_term(self): <NEW_LINE> <INDENT> self.termpos += 1 <NEW_LINE> while self.termpos >= len(self.document_term): <NEW_LINE> <INDENT> self.next_doc_and_term() <NEW_LINE> self.termpos += 1 <NEW_LINE> if self.document_term is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> return self.document_t... | 用来判断一篇文档的词是否读完 | 625941b4711fe17d8254214b |
def load_widgets(): <NEW_LINE> <INDENT> core_buttons = plugins.load_widgets_from_dir(config.widgets_path, default_section=_('Core widgets')) <NEW_LINE> local_buttons = plugins.load_widgets_from_dir(config.preferences.local_widget_path, default_section=_('Custom widgets')) <NEW_LINE> for path in [config.widgets_path, c... | Load built-in and user widgets.
Scans the built-in and user widget directories to find the installed widgets and loads it.
@rtype: OrderedDict
@see: L{plugins.load_widgets_from_dir()} for more details e.g. the structure of the dictionary. | 625941b47b25080760e3922b |
def mist_update_psk(mist_url,headers,site_id,key_name,password): <NEW_LINE> <INDENT> return_text = '' <NEW_LINE> api_url = '{}sites/{}/psks?name={}'.format(mist_url,site_id,key_name) <NEW_LINE> response = requests.get(api_url, headers=headers) <NEW_LINE> site_name = get_site_name(mist_url,headers,site_id) <NEW_LINE> if... | Function for showing PSK to Mist site | 625941b4baa26c4b54cb0ef3 |
@require_GET <NEW_LINE> @require_certificate_permission <NEW_LINE> def search_certificates(request): <NEW_LINE> <INDENT> user_filter = request.GET.get("user", "") <NEW_LINE> if not user_filter: <NEW_LINE> <INDENT> msg = _("user is not given.") <NEW_LINE> return HttpResponseBadRequest(msg) <NEW_LINE> <DEDENT> try: <NEW_... | Search for certificates for a particular user OR along with the given course.
Supports search by either username or email address along with course id.
First filter the records for the given username/email and then filter against the given course id (if given).
Show the 'Regenerate' button if a record found in 'gener... | 625941b44e4d5625662d41ad |
def _raise_exception(self): <NEW_LINE> <INDENT> exception_class = NSNitroExceptionsMap[self.errorcode] <NEW_LINE> raise exception_class(self.message, self.errorcode) | Raises exceptions, if it has a more specific mapping if not it raises NSNitroError | 625941b4d99f1b3c44c6736f |
def categorical_attribute_equal(attribute_name: str, attribute_value: str) -> typ.Callable[[graph.TemporalNode], bool]: <NEW_LINE> <INDENT> def __pred(n: graph.TemporalNode) -> bool: <NEW_LINE> <INDENT> return n.get_global_attribute(attribute_name) == attribute_value <NEW_LINE> <DEDENT> return __pred | Checks for equality of global attribute named attribute_name of a node with
the provided attribute value. Attribute must be categorical and global. | 625941b4fb3f5b602dac3466 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PostSendFailed): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941b48a43f66fc4b53e3a |
def createEditor(self, parent, option, index): <NEW_LINE> <INDENT> if index.column()==1: <NEW_LINE> <INDENT> dataType = str(index.sibling(index.row(), 2).data()) <NEW_LINE> if dataType=='int': <NEW_LINE> <INDENT> editor = QtGui.QLineEdit(parent) <NEW_LINE> editor.setValidator(QtGui.QIntValidator(parent)) <NEW_LINE> <DE... | createEditor(parent: QWidget,
option: QStyleOptionViewItem,
index: QModelIndex) -> QWidget
Return the editing widget depending on columns | 625941b46aa9bd52df036b71 |
def get_users_online(self, *args): <NEW_LINE> <INDENT> return self.session.query(User).join(UserOnline).all() | Method gets users online from db | 625941b43cc13d1c6d3c7156 |
def BoundlessRaster(row, col, dataset): <NEW_LINE> <INDENT> filename = dataset.tilename(row=row, col=col, **kwargs) <NEW_LINE> if os.path.exists(filename): <NEW_LINE> <INDENT> raster, profile = PadRaster(row, col, dataset, padding=padding, **kwargs) <NEW_LINE> nodata = profile['nodata'] <NEW_LINE> <DEDENT> else: <NEW_L... | Read tile with some padding,
handling the case if the tile does not exist. | 625941b4a05bb46b383ec5fd |
def make_credits(lines: str) -> list: <NEW_LINE> <INDENT> result = [] <NEW_LINE> for line in lines.splitlines(): <NEW_LINE> <INDENT> words = [] <NEW_LINE> username = None <NEW_LINE> for word in line.split(): <NEW_LINE> <INDENT> word = word.strip("()") <NEW_LINE> if word.startswith("@"): <NEW_LINE> <INDENT> username = w... | Convert multiline credits into list
Ex: @acmcgee
MycroftAI (@MycroftAI)
Tom's great songs | 625941b40383005118ecf3b4 |
def login(self, account, pwd): <NEW_LINE> <INDENT> url = 'https://www.ketangpai.com/Home/User/login.html' <NEW_LINE> self.driver.get(url) <NEW_LINE> self.driver.find_element(*self.account_locator).send_keys(account) <NEW_LINE> self.driver.find_element(*self.pwd_locator).send_keys(pwd) <NEW_LINE> self.driver.find_elemen... | 登录 | 625941b4e5267d203edcda71 |
@view_config(route_name='monitoring', request_method='GET', renderer='json') <NEW_LINE> def check_monitoring(request): <NEW_LINE> <INDENT> core_uri = request.registry.settings['core_uri'] <NEW_LINE> email = request.registry.settings.get('email','') <NEW_LINE> password = request.registry.settings.get('password','') <NEW... | Ask the mist.io service if monitoring is enabled for this machine.
| 625941b430bbd722463cbb92 |
def delete(self, post_id): <NEW_LINE> <INDENT> if not is_login(): <NEW_LINE> <INDENT> raise LoginException(message='not logged in') <NEW_LINE> <DEDENT> like = Like.get_by_post_user(long(post_id), current_user_id()) <NEW_LINE> if like: <NEW_LINE> <INDENT> post = Post.get_by_id(long(post_id)) <NEW_LINE> post.likes = post... | REST delete method
Note:
This also updates the corresponding Post by subtracting 1 to its like property
Args:
post_id: The post's id that will be unliked
Returns:
A JSON object with a simple deleted key value true
Raises:
LoginException: if user is not logged in
OwnerException: if like was not f... | 625941b4a79ad161976cbf15 |
def delta_batch(source, window): <NEW_LINE> <INDENT> assert source.ndim == 3 <NEW_LINE> w = windowed_batch(source, window + 1) <NEW_LINE> return w[1:] - w[:-1] | :param theano.TensorVariable source: 3d tensor of shape (n_time, n_batch, n_dim)
:param int|theano.Variable window: window size
:return: tensor of shape (n_time, n_batch, window * n_dim)
Similar as numpy.diff. Also called delta.
TODO with conv op | 625941b4be383301e01b5265 |
def show_slots(self): <NEW_LINE> <INDENT> slot_numbers = dict() <NEW_LINE> num = 1 <NEW_LINE> for i in self.slots: <NEW_LINE> <INDENT> if self.slots[i]: <NEW_LINE> <INDENT> print(num, i, self.slots[i].name, self.slots[i].armor_points) <NEW_LINE> slot_numbers[num] = self.slots[i].type <NEW_LINE> num += 1 <NEW_LINE> <DED... | Посмотреть предметы в слотах.
Выйти (пустой input) либо снять предмет и положить в инвентарь | 625941b476d4e153a657e8ff |
def bitnot(num): <NEW_LINE> <INDENT> numbits = 16 * 4 <NEW_LINE> return (1 << numbits) - 1 - num | unsigned bitwise not | 625941b48da39b475bd64d46 |
def _find_reports(self, start_dir, pattern): <NEW_LINE> <INDENT> paths = os.listdir(start_dir) <NEW_LINE> for path in paths: <NEW_LINE> <INDENT> full_path = os.path.join(start_dir, path) <NEW_LINE> if os.path.isfile(full_path): <NEW_LINE> <INDENT> if not VALID_MODULE_NAME.match(path): <NEW_LINE> <INDENT> continue <NEW_... | Used by discovery. Yields reports it loads. | 625941b426238365f5f0ec39 |
def create_solution(self, dstore=None, verbosity=0): <NEW_LINE> <INDENT> dstore = dstore or self.dstore <NEW_LINE> groups = self.variables['groups'].get_value(dstore=dstore) <NEW_LINE> ginsts = [self.groups[g] for g in groups] <NEW_LINE> s2gnodes = [] <NEW_LINE> for node in self.nodes: <NEW_LINE> <INDENT> gnodes = list... | Assuming essential variables are determined in a domain store, make a Solution object. | 625941b4dd821e528d63af7b |
def test_find_module(self): <NEW_LINE> <INDENT> im = self.importer <NEW_LINE> for i in test_modules: <NEW_LINE> <INDENT> assert(im.find_module(i)[0] == root) | Test find root functionallity. | 625941b4a17c0f6771cbde24 |
def detectCycle(self, head): <NEW_LINE> <INDENT> store = set() <NEW_LINE> while head: <NEW_LINE> <INDENT> if head in store: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> store.add(head) <NEW_LINE> <DEDENT> head = head.next <NEW_LINE> <DEDENT> return None | :type head: ListNode
:rtype: ListNode | 625941b48e7ae83300e4ad9b |
@mips_instruction(r"{instr_gap}({register}){args_gap}({label})", lambda args: (args[2], args[3])) <NEW_LINE> def bnez(program: MipsProgram, rd: str, label: str): <NEW_LINE> <INDENT> if program.registers[rd] != 0: <NEW_LINE> <INDENT> program.registers["pc"] = program.labels[label].value - 1 | Branch to label if Reg[rd] != 0. | 625941b485dfad0860c3ac28 |
def get_input_data(train_file_path='train.json', train=True): <NEW_LINE> <INDENT> with open(train_file_path, 'r') as train_file: <NEW_LINE> <INDENT> json_data = train_file.read() <NEW_LINE> train_data = json.loads(json_data) <NEW_LINE> <DEDENT> band_1 = [instance['band_1'] for instance in train_data] <NEW_LINE> band_2 ... | Retrieves training (X) and label (y) matrices. Note that this can take a few seconds to run.
Args:
train_file_path is the path of the file containing training data.
Returns:
A tuple containing the X training matrix in the first position, and the y label matrix in the second position.
X is of shape (N, 75,... | 625941b46aa9bd52df036b72 |
def __init__(self): <NEW_LINE> <INDENT> self.__x_axis_location = random.randint(-500, 500) <NEW_LINE> self.__y_axis_location = random.randint(-500, 500) <NEW_LINE> self.__x_axis_speed = random.randint(-10, 10) <NEW_LINE> self.__y_axis_speed = random.randint(-10, 10) <NEW_LINE> self.__size = 3 | Initialize a new Game object.
:return: A new Game object. | 625941b4009cb60464c6318e |
def _on_label_right_click(self, evt): <NEW_LINE> <INDENT> row, col = evt.GetRow(), evt.GetCol() <NEW_LINE> menu_manager = None <NEW_LINE> if row == -1: <NEW_LINE> <INDENT> menu_manager = self.model.get_column_context_menu(col) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> menu_manager = self.model.get_row_context_menu(... | Called when a right click occurred on a label. | 625941b4507cdc57c6306aa2 |
def serial_sorting(dataset, buffer_size): <NEW_LINE> <INDENT> if (buffer_size <= 2): <NEW_LINE> <INDENT> print("Error: buffer size should be greater than 2") <NEW_LINE> return <NEW_LINE> <DEDENT> result = [] <NEW_LINE> sorted_set = [] <NEW_LINE> start_pos = 0 <NEW_LINE> N = len(dataset) <NEW_LINE> while True: <NEW_LINE... | Perform a serial external sorting method based on sort-merge
The buffer size determines the size of eac sub-record set
Arguments:
dataset -- the entire record set to be sorted
buffer_size -- the buffer size determining the size of each sub-record set
Return:
result -- the sorted record set | 625941b42eb69b55b151c67a |
def __init__(self, user, switch, passw=None): <NEW_LINE> <INDENT> self.user = user <NEW_LINE> if passw is None: <NEW_LINE> <INDENT> self.passw = getpass('What is your password: ') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.passw = passw <NEW_LINE> <DEDENT> self.switch = switch | This initializes a switch login object.
:param user: The username used to login.
:param passw: The password for the users;
defaults to using getpass for security.
:param switch: The switch to connect to. | 625941b463f4b57ef0000ef3 |
def test_new_block(self): <NEW_LINE> <INDENT> block = self.blockchain.new_block(proof=33, previous_hash="000000") <NEW_LINE> self.assertEqual(type(block), dict, "checking block type") <NEW_LINE> self.assertEqual(block['index'], len(self.blockchain.chain), "checking created block id") <NEW_LINE> self.assertEqual(block['... | Test created block in blockchain | 625941b4187af65679ca4ef4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.