code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __isparent(self, ignore_errors=False): <NEW_LINE> <INDENT> return len(self.__list_children( ignore_errors=ignore_errors)) > 0 | Indicates whether the current image is a parent image.
'ignore_plugin_errors' ignore plugin runtime errors when
trying to determine if we're a parent image. | 625941c2e64d504609d747d7 |
def __init__(self, highlim=75, lowlim=25): <NEW_LINE> <INDENT> self.highlim = highlim <NEW_LINE> self.lowlim = lowlim <NEW_LINE> super().__init__() | A Cox model which outputs the class of the sample:
high, mid, or low hazard. Limits are defined as percentiles. | 625941c294891a1f4081ba3f |
def __init__(self, data_array, rows=3000, columns=4000, datatype='uint16',channel_groups=(1,1)): <NEW_LINE> <INDENT> self.Images = [] <NEW_LINE> self.channel_groups = channel_groups <NEW_LINE> self.num_channel_groups = self.channel_groups[0]*self.channel_groups[1] <NEW_LINE> if len(data_array)>0 and type(data_array[0])... | data_array: list of RAW files or list of Image objects | 625941c2f7d966606f6a9f99 |
def withdraw(self, amount): <NEW_LINE> <INDENT> self.wthdrw = amount <NEW_LINE> print("This is your withdrawal:",self.wthdrw) <NEW_LINE> if self.initial_balance < self.wthdrw: <NEW_LINE> <INDENT> self.count_fees += 5 <NEW_LINE> self.initial_balance -= self.wthdrw <NEW_LINE> print("This is new bal after withdrawal:",sel... | Withdraws the amount from the account. Each withdrawal resulting in a
negative balance also deducts a penalty fee of 5 dollars from the balance. | 625941c2a219f33f34628903 |
def get_structure_dataframes(self, abspath=False, filter_abifile=None, **kwargs): <NEW_LINE> <INDENT> from abipy.core.structure import dataframes_from_structures <NEW_LINE> if "index" not in kwargs: <NEW_LINE> <INDENT> index = list(self._abifiles.keys()) <NEW_LINE> if not abspath: index = self._to_relpaths(index) <NEW_... | Wrap dataframes_from_structures function.
Args:
abspath: True if paths in index should be absolute. Default: Relative to getcwd().
filter_abifile: Function that receives an ``abifile`` object and returns
True if the file should be added to the plotter. | 625941c2091ae35668666ef9 |
def _lpad(self, length, pad=' '): <NEW_LINE> <INDENT> return _ops.LPad(self, length, pad).to_expr() | Returns string of given length by truncating (on right)
or padding (on left) original string
Parameters
----------
length : int
pad : string, default is ' '
Examples
--------
table.strings.lpad(5, '-')
'a' becomes '----a'
'abcdefg' becomes 'abcde'
Returns
-------
padded : string | 625941c216aa5153ce362410 |
def read_bitcoin_config(dbdir): <NEW_LINE> <INDENT> from ConfigParser import SafeConfigParser <NEW_LINE> class FakeSecHead(object): <NEW_LINE> <INDENT> def __init__(self, fp): <NEW_LINE> <INDENT> self.fp = fp <NEW_LINE> self.sechead = '[all]\n' <NEW_LINE> <DEDENT> def readline(self): <NEW_LINE> <INDENT> if self.sechead... | Read the alta.conf file from dbdir, returns dictionary of settings | 625941c2442bda511e8be3b2 |
@jsonErrorHandler <NEW_LINE> def createUsers(data): <NEW_LINE> <INDENT> users_list = list(data['users'].value_counts().keys()) <NEW_LINE> for user in users_list: <NEW_LINE> <INDENT> if len(users.distinct('user_id')) == 0: <NEW_LINE> <INDENT> users_id = 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> users_id = len(user... | Creates users in our database in MongoDB from the dataset cleaned | 625941c250485f2cf553cd30 |
def polyFeatures(X, p): <NEW_LINE> <INDENT> X_poly = np.zeros((X.shape[0], p)) <NEW_LINE> for j in range(1, p + 1): <NEW_LINE> <INDENT> X_poly[:, j - 1] = X[:, 0] ** j <NEW_LINE> <DEDENT> return X_poly | Maps X (1D vector) into the p-th power
[X_poly] = POLYFEATURES(X, p) takes a data matrix X (size m x 1) and
maps each example into its polynomial features where
X_poly(i, :) = [X(i) X(i).^2 X(i).^3 ... X(i).^p]; | 625941c21f037a2d8b946195 |
def extract_maas_parameters(config): <NEW_LINE> <INDENT> params = {} <NEW_LINE> for line in config.splitlines(): <NEW_LINE> <INDENT> cloud, key, type, value = line.split()[:4] <NEW_LINE> if key == "cloud-init/maas-metadata-url": <NEW_LINE> <INDENT> params['url'] = value <NEW_LINE> <DEDENT> elif key == "cloud-init/maas-... | Extracts the needed values from the debconf
entry. | 625941c250812a4eaa59c2bb |
def delete(self): <NEW_LINE> <INDENT> self.rdbFile.deleteRouter(self.name) <NEW_LINE> self.crcFile.deleteRouterDetails(self.name) <NEW_LINE> self.djangoDevice.delete() | Remove from routerdb and cloginrc and django database | 625941c2d10714528d5ffc78 |
def addConditionTask(self, parentTask, parentOutputModuleName): <NEW_LINE> <INDENT> mySplitArgs = {} <NEW_LINE> mySplitArgs['algo_package'] = "T0.JobSplitting" <NEW_LINE> mySplitArgs['runNumber'] = self.runNumber <NEW_LINE> mySplitArgs['streamName'] = self.streamName <NEW_LINE> parentTaskCmssw = parentTask.getStep("cms... | _addConditionTask_
Does not actually produce any jobs
The job splitter is custom and just forwards information
into T0AST specific data structures, the actual upload
of the conditions to the DropBox is handled in a separate
Tier0 component. | 625941c207f4c71912b11418 |
def stop(self): <NEW_LINE> <INDENT> _log.info('stopping services: %s', self.service_names) <NEW_LINE> SpawningProxy(self.containers).stop() <NEW_LINE> _log.info('services stopped: %s', self.service_names) | Stop all running containers concurrently.
The method blocks until all containers have stopped. | 625941c267a9b606de4a7e52 |
def needs_commit(self): <NEW_LINE> <INDENT> return self.count_pending_units > 0 | Check whether there are some not committed changes. | 625941c29f2886367277a826 |
def set_high_low_lines(self, color='black', width=0.75, dash_type='solid', transparency=50): <NEW_LINE> <INDENT> self.chart.set_high_low_lines({ 'line': { 'color': color, 'width': width, 'dash_type': dash_type, 'transparency': transparency } }) | Set properties for the chart high-low lines.
:param color: string, default 'black'
:param width: float or int, default 0.75
:param dash_type: string, default 'solid'
:param transparency: int, default 50
:return: | 625941c2d99f1b3c44c6752b |
def _flow_check_handler_internal(self): <NEW_LINE> <INDENT> integ_flow = self.integ_br_obj.dump_flows_for( in_port=self.int_peer_port_num) <NEW_LINE> ext_flow = self.ext_br_obj.dump_flows_for( in_port=self.phy_peer_port_num) <NEW_LINE> for net_uuid, lvm in six.iteritems(self.local_vlan_map): <NEW_LINE> <INDENT> vdp_vla... | Periodic handler to check if installed flows are present.
This handler runs periodically to check if installed flows are present.
This function cannot detect and delete the stale flows, if present.
It requires more complexity to delete stale flows. Generally, stale
flows are not present. So, that logic is not put here... | 625941c2435de62698dfdbe3 |
@click.group() <NEW_LINE> def main(): <NEW_LINE> <INDENT> pass | Simple CLI for ecasb2share | 625941c28e05c05ec3eea30a |
def gratingAnglesFF(phEnergy, lineDensity, cff, nOrderDiff=1): <NEW_LINE> <INDENT> hc = 1.239842e-6 <NEW_LINE> alpha = np.arcsin(-nOrderDiff*lineDensity*1e3*hc/phEnergy/(cff**2-1) + np.sqrt(1+(-nOrderDiff*lineDensity*1e3*hc/phEnergy*cff/(cff**2-1))**2)) <NEW_LINE> return [alpha, gratingAngle(alpha, phEnergy, lineDensit... | Grating angles at Fixed Focus Condition
returns alpha and beta in rad
phEnergy in eV
lineDensity in line/mm | 625941c2ac7a0e7691ed4067 |
def get_W(self, word_vecs, k=300): <NEW_LINE> <INDENT> vocab_size = len(word_vecs) <NEW_LINE> word_idx_map = dict() <NEW_LINE> W = np.zeros(shape=(vocab_size+1, k), dtype="float32") <NEW_LINE> W[0] = np.zeros(k) <NEW_LINE> i = 1 <NEW_LINE> for word in word_vecs: <NEW_LINE> <INDENT> W[i] = word_vecs[word] <NEW_LINE> wor... | Get word matrix. W[i] is the vector for word indexed by i | 625941c2090684286d50ec7b |
def set_api_env(url=None, headers=None): <NEW_LINE> <INDENT> global api_base_url <NEW_LINE> global http_headers <NEW_LINE> api_base_url = url <NEW_LINE> http_headers = headers | Set base URL and http headers
Parameters
----------
url : str
Base URL string
headers : dict
Http headers | 625941c21f037a2d8b946196 |
def test_dataset_is_public_and_has_data(self): <NEW_LINE> <INDENT> department = Department.create(name="IM Police Department", short_name="IMPD", load_defaults=True) <NEW_LINE> assert department.dataset_is_public_and_has_data("complaints") == False <NEW_LINE> assert department.dataset_is_public_and_has_data("uof") == F... | We can accurately tell if a dataset is public and has data.
| 625941c257b8e32f52483431 |
def phaseSelection(k, v, fmt, meta): <NEW_LINE> <INDENT> global inselection <NEW_LINE> if k == 'Para': <NEW_LINE> <INDENT> if isinstance(v[0], dict): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> if v[0] == '%%kaishi%%': <NEW_LINE> <INDENT> if inselection: <NEW_LINE> <INDENT> inselection = False <NEW_LINE> <DEDENT>... | Second Step: Foce on selection | 625941c2b7558d58953c4eaf |
def test_metrics_clear(n_samples=2000, knn=50, uniform_class=0): <NEW_LINE> <INDENT> X, y = generate_sample(n_samples=n_samples, n_features=10) <NEW_LINE> sample_weight = numpy.random.exponential(size=n_samples) <NEW_LINE> predictions = numpy.random.random(size=[n_samples, 2]) <NEW_LINE> predictions /= predictions.sum(... | Testing that after deleting all inappropriate events (events of other class),
metrics stays the same | 625941c271ff763f4b54961f |
def created_as_json( request: Request, start_response: StartResponse, url_part: str, json: str | bytes | Any, *, extra_headers: Sequence[Header] = [], ) -> Iterable[bytes]: <NEW_LINE> <INDENT> all_headers = [_location_header(request, url_part)] + list(extra_headers) <NEW_LINE> return respond_with_json( start_response, ... | Prepare a 201 Created WSGI response with a Location header and JSON body. | 625941c2167d2b6e31218b2d |
def _collapseMsg(self, msg): <NEW_LINE> <INDENT> retval = {} <NEW_LINE> for log in msg: <NEW_LINE> <INDENT> data = "".join(msg[log]) <NEW_LINE> if isinstance(log, tuple) and log[0] == 'log': <NEW_LINE> <INDENT> retval['log'] = (log[1], data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> retval[log] = data <NEW_LINE> <D... | Take msg, which is a dictionary of lists of output chunks, and
concatenate all the chunks into a single string | 625941c2ec188e330fd5a73a |
@api_view(['GET']) <NEW_LINE> def asset_classfilter(request, class_name): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> assets = Asset.objects.filter(asset_class=class_name) <NEW_LINE> if not assets: <NEW_LINE> <INDENT> return Response(status=status.HTTP_404_NOT_FOUND) <NEW_LINE> <DEDENT> else: <N... | List assets filtered by the provided class string
:param request: Django HTTP request
:param class_name: The name of the class to perform filtering
:return: Response with appropriate assets | 625941c2656771135c3eb804 |
def new_column_sugar(needs: tuple, name=None): <NEW_LINE> <INDENT> def real_decorator(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> for need in needs: <NEW_LINE> <INDENT> if need not in self: <NEW_LINE> <INDENT> raise exceptions.RequiredColumnError(need) <NEW... | Decorator for certain methods of ActivityData that create new columns
using the special column types.
Parameters
----------
needs : tuple
A tuple of column names.
name : str, optional
The name for the returned Series object.
Returns
-------
Series
Suitable for joining to the existing data.
Raises
------
... | 625941c2435de62698dfdbe4 |
def arrayPairSum(self, nums): <NEW_LINE> <INDENT> nums.sort() <NEW_LINE> sum = 0 <NEW_LINE> for n in nums[0::2]: <NEW_LINE> <INDENT> sum+= n <NEW_LINE> <DEDENT> return sum | :type nums: List[int]
:rtype: int | 625941c2b57a9660fec3381a |
def list_favorite_kittens(color: KittenColor) -> List[Kitten]: <NEW_LINE> <INDENT> kittens = [ Kitten({'name': 'fluffums', 'color': 'white', 'cuteness': 9.8}), Kitten({'name': 'tabitha', 'color': 'tabby', 'cuteness': 8.7}), Kitten({'name': 'meowster', 'color': 'white', 'cuteness': 7.8}), Kitten({'name': 'fuzzball', 'co... | List your favorite kittens, optionally filtered by color. | 625941c292d797404e304121 |
def main(): <NEW_LINE> <INDENT> url = 'https://www.triip.me/search/' <NEW_LINE> options = webdriver.ChromeOptions() <NEW_LINE> options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary' <NEW_LINE> options.add_argument('window-size=800x841') <NEW_LINE> options.add_argument('he... | crawls over Triip.com for all listings and unique users.
commented out code is no longer needed once the initial scrape is completed.
:return: None | 625941c2507cdc57c6306c6e |
def cublasDger(m, n, alpha, x, incx, y, incy, A, lda): <NEW_LINE> <INDENT> _libcublas.cublasDger(m, n, alpha, int(x), incx, int(y), incy, int(A), lda) <NEW_LINE> status = cublasGetError() <NEW_LINE> cublasCheckStatus(status) | Rank-1 operation on real general matrix. | 625941c28e7ae83300e4af64 |
def rect_circle(rect, circle): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> rect_x, rect_y, rect_width, rect_height = rect <NEW_LINE> circle_x, circle_y, radius = circle <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> rect_x, rect_y, rect_width, rect_height = circle <NEW_LINE> circle_x, circle_y, radius = rec... | Check if rectangle and circle are overlapping
Args:
rect (peachy.geo.Rect, tuple[x, y, w, h]): The rectangle to use in this
collision detection procedure.
circle (peachy.geo.Circle, tuple[x, y, r]): The circle to use in this
collision detection procdure. Represented using a Circle or tuple.
No... | 625941c2e1aae11d1e749c4d |
@image_comparison(['legend_auto1'], remove_text=True) <NEW_LINE> def test_legend_auto1(): <NEW_LINE> <INDENT> fig = plt.figure() <NEW_LINE> ax = fig.add_subplot(111) <NEW_LINE> x = np.arange(100) <NEW_LINE> ax.plot(x, 50 - x, 'o', label='y=1') <NEW_LINE> ax.plot(x, x - 50, 'o', label='y=-1') <NEW_LINE> ax.legend(loc='b... | Test automatic legend placement | 625941c24e696a04525c93e4 |
def get_context_menu(self, pos): <NEW_LINE> <INDENT> menu = Menu() <NEW_LINE> splitter = None <NEW_LINE> splitter = None <NEW_LINE> for tabwidget in self.tabwidgets(): <NEW_LINE> <INDENT> global_rect = QtCore.QRect(tabwidget.mapToGlobal(QtCore.QPoint(0, 0)), tabwidget.size()) <NEW_LINE> if global_rect.contains(pos): <N... | Returns a context menu containing split/collapse actions
pos : position (in global coordinates) where the context menu was
requested | 625941c230c21e258bdfa434 |
def get_ipv4_pattern(): <NEW_LINE> <INDENT> byte = '([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])' <NEW_LINE> regex = '^{0}(\.{0}){{3}}$'.format(byte) <NEW_LINE> pattern = re.compile(regex) <NEW_LINE> return pattern | Compiles a regex pattern that matches IPv4 addresses. | 625941c2c432627299f04bdc |
def _backend(self, settings_override=None): <NEW_LINE> <INDENT> settings = { "auth.ldap.url": "ldap://localhost/", "auth.ldap.service_dn": "cn=service,ou=users,o=test", "auth.ldap.service_password": "snerp", "auth.ldap.base_dn": "ou=users,o=test", "auth.ldap.user_search_filter": "(cn={username})", "auth.ldap.admin_fiel... | Wrapper to instantiate a LDAPAccessBackend | 625941c2ec188e330fd5a73b |
def render(self, **kwargs): <NEW_LINE> <INDENT> if self.points.shape[1] == 2: <NEW_LINE> <INDENT> return PointCloudViewer2d(self.figure_id, self.new_figure, self.points).render(**kwargs) <NEW_LINE> <DEDENT> elif self.points.shape[1] == 3: <NEW_LINE> <INDENT> return PointCloudViewer3d(self.figure_id, self.new_figure, se... | Select the correct type of pointcloud viewer for the given
pointcloud dimensionality.
Parameters
----------
kwargs : dict
Passed through to pointcloud viewer.
Returns
-------
viewer : :class:`Renderer`
The rendering object.
Raises
------
DimensionalityError
Only 2D and 3D viewers are supported. | 625941c256ac1b37e626416b |
def test_serviceassignment_getservice(self): <NEW_LINE> <INDENT> pass | Test case for serviceassignment_getservice
View a list of locations where a service is available # noqa: E501 | 625941c25e10d32532c5eebf |
def haveSomeData(self): <NEW_LINE> <INDENT> if not self.__allSqQueries: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Determine if this binnary flush contain any data
:return: | 625941c263d6d428bbe44487 |
def _check_is_not_deleted(self): <NEW_LINE> <INDENT> if self._is_deleted: <NEW_LINE> <INDENT> raise _error.EntityDeleted(self.ref) | Raise an exception if the entity has 'deleted' state
| 625941c2adb09d7d5db6c729 |
def test_widget_save_copy_1(widget_test): <NEW_LINE> <INDENT> copy_names = ( expand_path('favorite_copy.json'), '', expand_path('read-only_copy.json'), ) <NEW_LINE> widget_test.file_dialog.getSaveFileName.side_effect = [ [name] for name in copy_names ] <NEW_LINE> steno_dict_copies = ( mock.create_autospec(StenoDictiona... | ☑ ★ favorite.json
☑ 🗘 loading.json
☑ ⎕ normal.json
☑ 🛇 read-only.ro
☑ ! invalid.bad | 625941c2baa26c4b54cb10b9 |
def _get_svol_uri(self, part_obj, boot_params): <NEW_LINE> <INDENT> if boot_params['boot_method'] == 'scsi': <NEW_LINE> <INDENT> sg_type = 'fcp' <NEW_LINE> prop_key = 'uuid' <NEW_LINE> prop_value = boot_params['uuid'] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sg_type = 'fc' <NEW_LINE> prop_key = 'device-number' <NE... | Find the uri of a storage volume | 625941c2377c676e91272141 |
def __init__(self, is_direction_incoming): <NEW_LINE> <INDENT> self.__direction_incoming = is_direction_incoming <NEW_LINE> self.__total_bytes = 0 <NEW_LINE> self.__ticks = deque() <NEW_LINE> self.__ticks_lock = Lock() <NEW_LINE> self.__start_time = None <NEW_LINE> self.__timer_service = TimerService( TRAFFIC_NOTIFICAT... | @param is_direction_incoming: whether the measured direction
is incoming (otherwise outgoing).
@type is_direction_incoming: bool | 625941c2c4546d3d9de729ca |
def test_get_flowcell_product_code(self): <NEW_LINE> <INDENT> run_dir = 'data/nanopore_data/run4/done_demuxing/20200104_1412_MN19414_AAU644_68125dc2' <NEW_LINE> run = MinIONqc(run_dir, None, None) <NEW_LINE> got_id = run._get_flowcell_product_code() <NEW_LINE> expected_id = 'FLO-FLG001' <NEW_LINE> self.assertEqual(got_... | Get flowcell product code from report.md. | 625941c2d7e4931a7ee9deb5 |
def prepend(self, *others): <NEW_LINE> <INDENT> p = Path(*others) <NEW_LINE> p = p.append(self) <NEW_LINE> return p | Join another path or relationship to the start of this path to form a new path.
:arg others: Entities to join to the start of this path
:rtype: :class:`.Path` | 625941c285dfad0860c3adf2 |
@login_required <NEW_LINE> def remove_folios(request): <NEW_LINE> <INDENT> page = int(request.GET.get('page')) <NEW_LINE> folio_pgs = get_curr_folio_pgs(request) <NEW_LINE> folio_pgs.clear_page(page) <NEW_LINE> set_curr_folio_pgs(request, folio_pgs) <NEW_LINE> return HttpResponse(dumps(str(None)), mimetype="text/json") | Given a manuscript's id and a page number, removes all folio numbers
for the specified page in the specified manuscript. | 625941c2a4f1c619b28affd6 |
def testConnectionsEstablishedAfterTrust(self): <NEW_LINE> <INDENT> self.servers = ['test_server_1','test_server_2'] <NEW_LINE> self.clientSecurePorts,self.serverSecurePorts = createServers( self.servers) <NEW_LINE> serverAndPort = "%s %s"%("localhost",self.clientSecurePorts[1]) <NEW_LINE> run_client_command("connect-s... | Connections are established after servers has trusted each other | 625941c296565a6dacc8f664 |
def get_current_date(): <NEW_LINE> <INDENT> return date.today().strftime("%d/%m/%Y") | :return: the current date in format %d/%m/%Y | 625941c238b623060ff0ad86 |
def set_confirm_widget(self, widget_name): <NEW_LINE> <INDENT> self.main_dialog.set_confirm_widget(widget_name) | Make a widget confirmable, eg activating that widget would
close the dialog.
:param widget_name: name of the widget to be confirmable | 625941c224f1403a92600b00 |
def cumulative_cases(self): <NEW_LINE> <INDENT> return self.state["cumulative_cases"] | Stock: cumulative_cases =
self.zika_cases()
Initial Value: self.init_cumulative_cases()
Do not overwrite this function | 625941c2956e5f7376d70e06 |
def __getNextState(self, s, a): <NEW_LINE> <INDENT> stateCurRow = s // self.numCols <NEW_LINE> stateCurCol = s % self.numCols <NEW_LINE> actionHorizontal = 0 <NEW_LINE> actionVertical = 0 <NEW_LINE> if a == 0: <NEW_LINE> <INDENT> actionHorizontal = 1 <NEW_LINE> actionVertical = 0 <NEW_LINE> <DEDENT> elif a == 1: <NEW_L... | This function calculates the next state from the given state and action. | 625941c230dc7b7665901901 |
def case_generator(op_type, Xshape, diagonal, expected): <NEW_LINE> <INDENT> cls_name = "{0}_{1}_shape_{2}_diag_{3}".format(expected, op_type, Xshape, diagonal) <NEW_LINE> errmsg = { "diagonal: TypeError": "diagonal in {} must be a python Int".format(op_type), "input: ValueError": "x shape in {} must be at least 2-D".f... | Generate testcases with the params shape of X, diagonal and op_type.
If arg`expercted` is 'success', it will register an Optest case and expect to pass.
Otherwise, it will register an API case and check the expect failure. | 625941c23317a56b86939bf5 |
def construct_tree(edges): <NEW_LINE> <INDENT> parentDB = {} <NEW_LINE> childrenDB = {} <NEW_LINE> for edg in edges: <NEW_LINE> <INDENT> c, p = edg[0], edg[1] <NEW_LINE> parentDB[c] = p <NEW_LINE> if p in childrenDB: <NEW_LINE> <INDENT> childrenDB[p][c] = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> childrenDB[p]... | Given a list of edges [child, parent], return a tree. | 625941c2187af65679ca50b6 |
def get(self, attr): <NEW_LINE> <INDENT> idx = pd.Index(self.fid, name='fid') <NEW_LINE> return pd.Series(getattr(self, attr), index=idx, name=attr) | Returns ``pandas.Series`` of object attribute.
Example:
>>> g.get('ead') | 625941c23539df3088e2e2e4 |
def show_translation(self, dx, dy): <NEW_LINE> <INDENT> ody = dx + self.data.shape[0]/2 <NEW_LINE> odx = self.data.shape[1]/2 - dy <NEW_LINE> plt.scatter(odx, ody, s=40, alpha = .5) <NEW_LINE> return odx, ody | prints on the image where the peak is
usage:
corr = Corr()
best = corr.find_peak()
dx, dy = corr.find_translation(best)
corr.show_image()
corr.show_translation(dx, dy)
plt.show() | 625941c221a7993f00bc7c85 |
def dipole_potential(x, y): <NEW_LINE> <INDENT> r_sq = x**2 + y**2 <NEW_LINE> theta = np.arctan2(y, x) <NEW_LINE> z = np.cos(theta)/r_sq <NEW_LINE> return (np.max(z)-z) / (np.max(z)-np.min(z)) | An electric dipole potential V. | 625941c22eb69b55b151c845 |
def clean(self): <NEW_LINE> <INDENT> if self.email_subject: <NEW_LINE> <INDENT> self.email_subject = self.email_subject. replace('\r\n', ' ').replace('\r', ' ').replace('\n', ' ') <NEW_LINE> <DEDENT> super().clean() | override :meth:`django.db.models.Model.clean` to
clean the instance data before saving it to the database
* remove line breaks from email subject
:raises: :exc:`django.core.exceptions.ValidationError` | 625941c2090684286d50ec7c |
def tmod_Haul(self,index): <NEW_LINE> <INDENT> if index == 0: <NEW_LINE> <INDENT> return "size" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 0 | Hauling is dependent on the direction of the haul. So a vertical
haul can drive a different parameter to a horizontal haul. The
direction of the haul is represented by an index, with 0
representing horizontal and 1 representing vertical. The function
simply returns the name of the attribute to drive, given it's index.
... | 625941c2cdde0d52a9e52fca |
def check(self, raw_metadata): <NEW_LINE> <INDENT> return raw_metadata.get('url', '').startswith( 'ftp://ftp.gportal.jaxa.jp/standard/GCOM-W/GCOM-W.AMSR2/L3.SST') | Checks that the URL starts with the right prefix | 625941c215fb5d323cde0aa5 |
def handle_popup_done(self): <NEW_LINE> <INDENT> pass | popup interaction is done
The popup_done event is sent out when a popup grab is broken,
that is, when the user clicks a surface that doesn't belong
to the client owning the popup surface. | 625941c2566aa707497f4505 |
def get_low_velocity(self, arg0): <NEW_LINE> <INDENT> return self.sampler.execute(self.get_low_velocity_cmd, (arg0, )) | Get Zone Low Velocity
Returns:
BYTE | 625941c28a43f66fc4b54000 |
def train_based_on_states(self, data, max_epochs=1000, learning_rate=0.1): <NEW_LINE> <INDENT> num_examples = data.shape[0] <NEW_LINE> data = np.insert(data, 0, 1, axis=1) <NEW_LINE> errors = [] <NEW_LINE> for epoch in range(max_epochs): <NEW_LINE> <INDENT> pos_hidden_activations = np.dot(data, self.weights) <NEW_LINE>... | Train the machine.
Parameters
----------
data: A matrix where each row is a training example consisting of the states of visible units. | 625941c28c0ade5d55d3e952 |
def coord_num(phi): <NEW_LINE> <INDENT> n = 20.0 - 34.0*phi + 14.0*phi**2.0 <NEW_LINE> return n | Calculates coordination number value as a function of porosity using the
relationship:
n = 20.0 - 34.0*phi + 14.0*phi**2.0
The above expression was copied from Avseth's QSI book, equation 2.7 on
page 55.
Usage:
n = coord_num(phi)
Inputs:
phi = porosity (v/v)
Output:
n = coordination number (n... | 625941c250812a4eaa59c2bc |
def __init__(self, serial_number=None, pixelFormat=None): <NEW_LINE> <INDENT> self.cam = xiapi.Camera() <NEW_LINE> if serial_number is None: <NEW_LINE> <INDENT> self.cam.open_device() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.cam.open_device_by_SN(serial_number) <NEW_LINE> <DEDENT> if pixelFormat is None: <NEW... | Constructor method
| 625941c26e29344779a625ac |
def set_range_direction(self, char): <NEW_LINE> <INDENT> self.direction = char.direction | sets the direction of the spell to be the same as the player | 625941c2ab23a570cc250119 |
def put(self, id): <NEW_LINE> <INDENT> data = request.get_json() <NEW_LINE> if 'email' not in data: <NEW_LINE> <INDENT> email = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> email = data["email"] <NEW_LINE> <DEDENT> if 'first_name' not in data: <NEW_LINE> <INDENT> first_name = None <NEW_LINE> <DEDENT> else: <NEW_L... | PUT interface to update an interviewee by it's unique database id. All data for which is contained in the json
object is updated.
:param id:
:return: | 625941c2656771135c3eb805 |
def update_category( category_id: CategoryID, slug: str, title: str, description: str ) -> Category: <NEW_LINE> <INDENT> category = _get_category(category_id) <NEW_LINE> category.slug = slug.strip().lower() <NEW_LINE> category.title = title.strip() <NEW_LINE> category.description = description.strip() <NEW_LINE> db.ses... | Update the category. | 625941c201c39578d7e74dd4 |
def configure(self, url): <NEW_LINE> <INDENT> self._ftdi.open_mpsse_from_url( url, direction=self.direction, frequency=self._frequency) <NEW_LINE> cmd = array('B', (Ftdi.SET_BITS_LOW, 0x0, self.direction)) <NEW_LINE> self._ftdi.write_data(cmd) | Configure the FTDI interface as a JTAG controller | 625941c260cbc95b062c64db |
def hasNext(self): <NEW_LINE> <INDENT> if self.idx < len(self.queue): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | :rtype: bool | 625941c21d351010ab855ab5 |
def setUp(self): <NEW_LINE> <INDENT> self.driver = webdriver.Chrome( executable_path='/home/traiana/Desktop/HW_2/QA/testing/chromedriver') <NEW_LINE> self.driver.implicitly_wait(30) <NEW_LINE> self.base_url = "https://www.katalon.com/" <NEW_LINE> self.verification_errors = [] <NEW_LINE> self.accept_next_alert = True | set up class | 625941c22ae34c7f2600d0ca |
def update_Gp(self): <NEW_LINE> <INDENT> data = self.Jaccoo.data <NEW_LINE> row = self.Jaccoo.row <NEW_LINE> col = self.Jaccoo.col <NEW_LINE> data[self._Cbase:self._mbaseLin] = self.im.a0 * self._Cdata <NEW_LINE> Gcoo = sp.coo_matrix((data[:self._mbaseLin], (row[:self._mbaseLin], col[:self._mbaseLin])), (self.ckt.nD_di... | Recalculate Gp from im information | 625941c2e64d504609d747d9 |
def _choose_from_bounds(self, *bounds): <NEW_LINE> <INDENT> if isinstance(bounds[0], str): <NEW_LINE> <INDENT> lower, upper = self.bounds(*bounds) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> lower, upper = bounds <NEW_LINE> <DEDENT> return randint(lower, upper) | Returns a value that is within the given bounds. Each value has an equal chance
of being chosen. | 625941c2f7d966606f6a9f9b |
def __init__(self, cur, currentUser, threads): <NEW_LINE> <INDENT> self.cur = cur <NEW_LINE> self.currentUser = currentUser <NEW_LINE> self.threads = threads <NEW_LINE> self.pfam_hmm_dir = ConfigMetadata.PFAM_HMM_DIR <NEW_LINE> self.protein_file_suffix = ConfigMetadata.PROTEIN_FILE_SUFFIX <NEW_LINE> self.pfam_suffix = ... | Initialization. | 625941c255399d3f0558864c |
def modularity(self, membership, weights=None): <NEW_LINE> <INDENT> if isinstance(membership, VertexClustering): <NEW_LINE> <INDENT> if membership.graph != self: <NEW_LINE> <INDENT> raise ValueError("clustering object belongs to another graph") <NEW_LINE> <DEDENT> return GraphBase.modularity(self, membership.membership... | Calculates the modularity score of the graph with respect to a given
clustering.
The modularity of a graph w.r.t. some division measures how good the
division is, or how separated are the different vertex types from each
other. It's defined as M{Q=1/(2m)*sum(Aij-ki*kj/(2m)delta(ci,cj),i,j)}.
M{m} is the number of edge... | 625941c2b545ff76a8913daf |
def post_process_document(file_name, config): <NEW_LINE> <INDENT> substitute_headers_and_footers(file_name, config) | Apply final touchup to the output document after it has been saved.
The document object can be assumed to have been destroyed at this
point. The only access to it is through `file_name`. The current
implementation filters the headers and footers of the document and
does a keyword repacement on them. | 625941c216aa5153ce362411 |
def service_document(self): <NEW_LINE> <INDENT> return ServiceDocumentDepositClient(url=self.base_url, auth=self.auth).execute() | Retrieve service document endpoint's information. | 625941c2f8510a7c17cf9694 |
def _fix_package_tree(root_dir): <NEW_LINE> <INDENT> usr_dir = os.path.join(root_dir, 'usr') <NEW_LINE> if not os.path.exists(usr_dir): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for item in os.listdir(usr_dir): <NEW_LINE> <INDENT> src = os.path.join(root_dir, 'usr', item) <NEW_LINE> dst = os.path.join(root_dir, it... | Make the package tree comply with qiBuild.
| 625941c2d58c6744b4257bf9 |
def network_nsg_show(name, params=None, options='', **kargs): <NEW_LINE> <INDENT> cmd = "azure network nsg show %s %s" % (name, options) <NEW_LINE> if params: <NEW_LINE> <INDENT> cmd += add_option("--subscription", params.get("subscription", None)) <NEW_LINE> <DEDENT> return command(cmd, azure_json=True, **kargs) | Show Network Security Group properties
:param name: NSG name
:param params: Command properties
:param options: extra options
:param kargs: Additional args for running the command
:return: CmdResult object | 625941c260cbc95b062c64dc |
def get_progress_color(base_color): <NEW_LINE> <INDENT> if min(base_color) == max(base_color): <NEW_LINE> <INDENT> return _adjust_gray_luminence(base_color) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _adjust_color_luminence(base_color) | Return a color that is slightly brighter then the base_color.
For shades of gray the constant GRAY_FACTOR decides the brightness.
Higher factor gives more brightness.
For other colors the LUMINENCE_FACTOR decides the brightness.
Smaller factor gives more brightness. | 625941c2097d151d1a222df4 |
def make_secure_val(val): <NEW_LINE> <INDENT> return '%(value)s|%(hashed)s' % {'value': val, 'hashed': hash_str(val)} | Makes the hashed cookie for a given val.
The hashed cookie uses a pipe | as the separator between the value and it's
hash.
val: String
Returns: String | 625941c276d4e153a657eac9 |
def exact_match(y_true, y_pred): <NEW_LINE> <INDENT> m_list = [] <NEW_LINE> for i in range(y_true.shape[0]): <NEW_LINE> <INDENT> set_true = set( y_true[i] ) <NEW_LINE> set_pred = set( y_pred[i] ) <NEW_LINE> if set_true == set_pred: <NEW_LINE> <INDENT> m_list.append(1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> m_lis... | Compute the exact match measure for the multi-label case | 625941c2fff4ab517eb2f3d4 |
def load(path: Union[str, Path]) -> Any: <NEW_LINE> <INDENT> correct_file = _convert_path(path, _COMPRESS) <NEW_LINE> incorrect_file = _convert_path(path, not _COMPRESS) <NEW_LINE> if incorrect_file.exists(): <NEW_LINE> <INDENT> if ( not correct_file.exists() or incorrect_file.stat().st_mtime > correct_file.stat().st_m... | Loads json data (which may be compressed) from the given file. | 625941c282261d6c526ab435 |
def __or__(self, f): <NEW_LINE> <INDENT> return Nepomuk.TagWidget.ModeFlags() | Nepomuk.TagWidget.ModeFlags Nepomuk.TagWidget.ModeFlags.__or__(Nepomuk.TagWidget.ModeFlags f) | 625941c24a966d76dd550fa7 |
def print_tree(account): <NEW_LINE> <INDENT> raise NotImplementedError() | In the example output below, "GE" is the root account, "Jet Engines"
and "Appliances" are first-degree ChildAccounts, and "DoD Contracts"
and "Washing Machines" are second-degree ChildAccounts.
> print_tree(general_electric)
GE (Manufacturing, R&D): Daniel Testperson
Jet Engines (Manufacturing, R&D, Aerosp... | 625941c2ff9c53063f47c18d |
def x_update_command_display(self) -> None: <NEW_LINE> <INDENT> for command_parameter in self.parameters_list: <NEW_LINE> <INDENT> ui_obj = self.input_edit_objects[command_parameter] <NEW_LINE> value = self.get_current_value(ui_obj) <NEW_LINE> self.command_parameter_current_values[command_parameter] = value <NEW_LINE> ... | Each command dialog box has a command display that shows the string representation of the command with the
user-specified input parameters. It is updated dynamically as the user enters/selects values for the different
command parameter fields (this function is called when any text is changed in the input field Qt widge... | 625941c23c8af77a43ae3737 |
def apply ( self, info ): <NEW_LINE> <INDENT> return | Handles the **Apply** button being clicked.
| 625941c2091ae35668666efb |
@login_required <NEW_LINE> def delete_unit(request): <NEW_LINE> <INDENT> if request.method != 'PUT': <NEW_LINE> <INDENT> return JsonResponse({"error": "PUT method required."}, status=400) <NEW_LINE> <DEDENT> d = json.loads(request.body) <NEW_LINE> data = d["childunit"] <NEW_LINE> print(data) <NEW_LINE> unit = Unit.obje... | Given a unit ID via 'PUT', delete the corresponding unit from the DB only if
the requestor is the owner of that unit. | 625941c2d6c5a10208143fe2 |
def zero(self): <NEW_LINE> <INDENT> self.counter.set_value(0) | Zero the counter attribute | 625941c245492302aab5e25a |
def cleanup(self): <NEW_LINE> <INDENT> item = self.model(self.data["id"]) <NEW_LINE> item.delete() <NEW_LINE> del item | Override this to set a custom cleanup process. By default this takes
the key that was generated in `action()` and calls the models
`.delete()` function. | 625941c27b25080760e393f3 |
def edit_repo( name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, profile="github", ): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> allow_private_change = _get_config_value(profile, "allow_repo_privacy_changes") <NEW_LINE> <DEDENT> except CommandExecutionError: <NEW... | Updates an existing Github repository.
name
The name of the team to be created.
description
The description of the repository.
homepage
The URL with more information about the repository.
private
The visiblity of the repository. Note that private repositories require
a paid GitHub account.
has_... | 625941c2596a897236089a5c |
def _make_reversed_substrate(self): <NEW_LINE> <INDENT> reversed_substrate = datamodel.Substrate("{}_reversed".format(self._original_substrate.name)) <NEW_LINE> for node in self._original_substrate.nodes: <NEW_LINE> <INDENT> reversed_substrate.add_node(node, self._original_substrate.node[node]["supported_types"], self.... | Generate a copy of the substrate with all edges reversed. All default substrate
node & edge properties are preserved
:return: | 625941c297e22403b379cf32 |
def _lock(self): <NEW_LINE> <INDENT> if self.locked: <NEW_LINE> <INDENT> LOGGER.debug("Config and commit already locked - skipping") <NEW_LINE> return <NEW_LINE> <DEDENT> for lock_type in LOCK_TYPES: <NEW_LINE> <INDENT> cmd = TAKE_LOCK_API_CMD.format(lock_type) <NEW_LINE> try: <NEW_LINE> <INDENT> self.device.op(cmd=cmd... | Take lock for config editing and committing new configurations. | 625941c267a9b606de4a7e54 |
def get_success_url(self) -> str: <NEW_LINE> <INDENT> return self.object.get_absolute_url() | On success, return to the list view. | 625941c28c3a873295158351 |
def run(self): <NEW_LINE> <INDENT> showObj = findCertainShow(sickrage.srCore.SHOWLIST, int(self.indexerid)) <NEW_LINE> if showObj: <NEW_LINE> <INDENT> return _responds(RESULT_FAILURE, msg="An existing indexerid already exists in the database") <NEW_LINE> <DEDENT> if not os.path.isdir(self.location): <NEW_LINE> <INDENT>... | Add an existing show in SiCKRAGE | 625941c2be7bc26dc91cd59d |
def weightsInit(N,M): <NEW_LINE> <INDENT> return np.random.rand(M, N) | params:
N: # of columns of the input patterns
M: # of the outputs (# of rows of the output) | 625941c2711fe17d82542309 |
def copy_and_sum_families(family_source, family_target): <NEW_LINE> <INDENT> for every in family_source: <NEW_LINE> <INDENT> if every not in family_target: <NEW_LINE> <INDENT> family_target[every] = family_source[every] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> family_target[every] += family_source[every] | methods iterates thru source family and copies its entries to target family
in case key already exists in both families - then the values are added | 625941c263f4b57ef00010b7 |
def test_nothing_returned_fails(): <NEW_LINE> <INDENT> fake_client = Mock(spec=MQTTClient, message_received=Mock(return_value=None)) <NEW_LINE> expected = {"topic": "/a/b/c", "payload": "hello"} <NEW_LINE> verifier = MQTTResponse( fake_client, "Test stage", expected, {"strict": StrictLevel.all_on()} ) <NEW_LINE> with p... | Raises an error if no message was received | 625941c266673b3332b9202a |
def get_tol_2d(): <NEW_LINE> <INDENT> return geometry.gmGetXyTol() | Get the global tolerance for 2d float operations.
Value may not be meaningful if it has not been set yet. | 625941c2d99f1b3c44c6752d |
def AddMutexEnvVarsFlags(parser): <NEW_LINE> <INDENT> env_vars_util.AddUpdateEnvVarsFlags(parser) | Add flags for creating updating and deleting env vars. | 625941c2498bea3a759b9a49 |
def case_aresidueinvertresidue(self, node): <NEW_LINE> <INDENT> super().case_aresidueinvertresidue(node) <NEW_LINE> value = self.FALSE_VALUE <NEW_LINE> residue = self.comparator.create_mutation(node.get_integer(), node.get_mutatedaminoacid()) <NEW_LINE> residue = self.comparator.invert_mutation(residue) <NEW_LINE> for ... | TODO: fillme | 625941c2b57a9660fec3381b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.