code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def sample_noise(self, x: torch.tensor, num: int, batch_size) -> np.ndarray: <NEW_LINE> <INDENT> raise NotImplementedError
Sample the base classifier's prediction under noisy corruptions of the input x. :param x: the input [channel x width x height] :param num: number of samples to collect :param batch_size: :return: an ndarray[int] of length num_classes containing the per-class counts
625941ca50812a4eaa59c3ce
def receive(self, command_list: List[Command]) -> None: <NEW_LINE> <INDENT> for cmd in command_list: <NEW_LINE> <INDENT> if not cmd.gate == FlushGate(): <NEW_LINE> <INDENT> self._store(cmd) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._run() <NEW_LINE> self._flushed = True <NEW_LINE> self._reset()
Receives a command list and, for each command, stores it until completion. :param command_list: List of commands to execute.
625941cab7558d58953c4fc1
def process_request(self, req): <NEW_LINE> <INDENT> if req.headers.get('X-Identity-Status') == 'Confirmed': <NEW_LINE> <INDENT> req.context = self._get_authenticated_context(req) <NEW_LINE> <DEDENT> elif req.headers.get('X-Auth-Token') is not None: <NEW_LINE> <INDENT> req.context = self._get_auth_token_context(req) <NE...
Convert authentication information into a request context Generate a glance.context.RequestContext object from the available authentication headers and store on the 'context' attribute of the req object. :param req: wsgi request object that will be given the context object :raises webob.exc.HTTPUnauthorized: when val...
625941ca57b8e32f52483546
def __init__(self, protein): <NEW_LINE> <INDENT> aaList = ''.join(protein).split() <NEW_LINE> self.proteinInput = ''.join(aaList).upper() <NEW_LINE> self.aaComp = {} <NEW_LINE> for aa in self.aa2mw.keys(): <NEW_LINE> <INDENT> self.aaComp[aa] = float(self.proteinInput.count(aa))
Takes the string splices it such that only valid characters are recieved. They are then read and the values are saved (not the string itself)
625941ca004d5f362079a3df
def SetUserAgent(self, user_agent): <NEW_LINE> <INDENT> self._request_headers['User-Agent'] = user_agent
Override the default user agent Args: user_agent: a string that should be send to the server as the User-agent
625941ca1d351010ab855bc7
def put(self, key, value, dupdata=True, overwrite=True, append=False, db=None): <NEW_LINE> <INDENT> flags = 0 <NEW_LINE> if not dupdata: <NEW_LINE> <INDENT> flags |= _lib.MDB_NODUPDATA <NEW_LINE> <DEDENT> if not overwrite: <NEW_LINE> <INDENT> flags |= _lib.MDB_NOOVERWRITE <NEW_LINE> <DEDENT> if append: <NEW_LINE> <INDE...
Store a record, returning ``True`` if it was written, or ``False`` to indicate the key was already present and `overwrite=False`. On success, the cursor is positioned on the new record. Equivalent to `mdb_put() <http://symas.com/mdb/doc/group__mdb.html#ga4fa8573d9236d54687c61827ebf8cac0>`_ `key`: Bytestri...
625941ca9b70327d1c4e0e80
def nag_hsas_rec(): <NEW_LINE> <INDENT> now = datetime.utcnow() <NEW_LINE> def _get_hsas_ready_for_nag(warning_time, extra_filter_params={}): <NEW_LINE> <INDENT> reqs = get_hsa_stock_requests_pending_pickup(warning_time) <NEW_LINE> hsa_warnings = [] <NEW_LINE> for req in reqs: <NEW_LINE> <INDENT> if not NagRecord.objec...
Send non-reporting HSAs a predefined nag message. Notify their supervisor if they've been sufficiently delinquent.
625941caa219f33f34628a16
def update_site_forward(apps, schema_editor): <NEW_LINE> <INDENT> Site = apps.get_model("sites", "Site") <NEW_LINE> Site.objects.update_or_create( id=settings.SITE_ID, defaults={ "domain": "backend.geoalert.ru", "name": "geoalert_backend", }, )
Set site domain and name.
625941ca1f037a2d8b9462a9
def parse_clock(self): <NEW_LINE> <INDENT> for category in self.parsed_data['Children']: <NEW_LINE> <INDENT> if category['Text'] == 'Clocks': <NEW_LINE> <INDENT> self.clock.parse(category['Children'])
Get clocks informations from GPU
625941caec188e330fd5a84b
def reduce(self, func, dim=None, keep_attrs=False, **kwargs): <NEW_LINE> <INDENT> if 'dimension' in kwargs and dim is None: <NEW_LINE> <INDENT> dim = kwargs.pop('dimension') <NEW_LINE> utils.alias_warning('dimension', 'dim') <NEW_LINE> <DEDENT> if isinstance(dim, basestring): <NEW_LINE> <INDENT> dims = set([dim]) <NEW_...
Reduce this dataset by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `f(x, axis=axis, **kwargs)` to return the result of reducing an np.ndarray over an integer valued axis. dim : str or sequence of str, optional Dimension(s) over...
625941ca07f4c71912b1152d
def show_time(self, day, time, max): <NEW_LINE> <INDENT> day += 1 <NEW_LINE> time += 1 <NEW_LINE> print >> sys.stderr, "%04d:%05d%s" % (day, time, "\b"*11), <NEW_LINE> if day*time == max: <NEW_LINE> <INDENT> print >> sys.stderr, "\n"
Print current tick on stderr
625941ca7b25080760e39505
def _colors(dark=False, color=True, color_index=None, **kwargs): <NEW_LINE> <INDENT> if color_index is None: <NEW_LINE> <INDENT> idx = slice(None) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> idx = slice(color_index, color_index + 1) <NEW_LINE> <DEDENT> if color: <NEW_LINE> <INDENT> if dark: <NEW_LINE> <INDENT> return...
Determine the colors to be used.
625941ca8a349b6b435e821f
def listReservedWords(): <NEW_LINE> <INDENT> words = list(RESERVED) <NEW_LINE> words.sort() <NEW_LINE> return words
Return list of words that are reserved for atom selections and internal variables. These words are:
625941ca8e71fb1e9831d855
def __state_calback(self, event): <NEW_LINE> <INDENT> if event.m_state != STATE_BROKEN: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not self.m_fRunning: <NEW_LINE> <INDENT> print_debug('Simple session manager continues on first break.') <NEW_LINE> self.m_fRunning = True <NEW_LINE> self.request_go() <NEW_LINE> ret...
Handle state change notifications from the debugge.
625941ca7047854f462a14b6
def iter_column(self): <NEW_LINE> <INDENT> for i in xrange(self.ncol): <NEW_LINE> <INDENT> yield self.rx(rinterface.MissingArg, i+1)
iterator across columns
625941cacc40096d615959fc
def _validate_and_parse_args(self): <NEW_LINE> <INDENT> if len(self.args) != 1: <NEW_LINE> <INDENT> raise CommandValidationError('The `deletenotebook` command takes exactly 1 parameter, the notebook ID.') <NEW_LINE> <DEDENT> self.notebook_id = self.args[0]
Ensure only 1 argument is passed in, the notebook ID.
625941ca009cb60464c6345e
def _construct_report_request(self): <NEW_LINE> <INDENT> with self._mutex: <NEW_LINE> <INDENT> report = ttypes.ReportRequest(self._runtime, self._span_records, self._log_records) <NEW_LINE> self._span_records = [] <NEW_LINE> self._log_records = [] <NEW_LINE> return report
Construct a report request.
625941cad58c6744b4257d0c
def stops_near(self, point, max_distance=2000, stopclass=1023, n=5000): <NEW_LINE> <INDENT> params = self.stop_params.copy() <NEW_LINE> params['look_maxdist'] = max_distance <NEW_LINE> params['look_stopclass'] = stopclass <NEW_LINE> if point.epsg != 4326: <NEW_LINE> <INDENT> raise ValueError('Point has to be in WGS84!'...
get closest station to given point (tuple of x,y; epsg: 4326) ordered by distance (ascending)
625941ca8e7ae83300e4b078
def test_delete_translation_resource_button(self): <NEW_LINE> <INDENT> resp = self.client['maintainer'].get(self.urls['resource_edit']) <NEW_LINE> self.assertTemplateUsed(resp, 'resources/resource_form.html') <NEW_LINE> self.assertContains(resp, 'Delete resource', status_code=200) <NEW_LINE> for user in ['anonymous', '...
Test that delete translation resource button is rendered correctly.
625941caac7a0e7691ed4179
def test_unusual_column_elements_clauselist(self): <NEW_LINE> <INDENT> from sqlalchemy.sql.expression import ClauseList <NEW_LINE> s = select( [table1.c.col1, ClauseList(table1.c.col2, table1.c.col3)] ).subquery() <NEW_LINE> eq_(list(s.c), [s.c.col1, s.c.col2, s.c.col3])
Test that raw ClauseList is expanded into .c.
625941caa934411ee375173f
def search(self, item): <NEW_LINE> <INDENT> cur = self.__head <NEW_LINE> if self.is_empty(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> while cur.next != self.__head: <NEW_LINE> <INDENT> if cur.elem == item: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cur = cur.next <NEW_LIN...
查看节点是否存在
625941cacc0a2c11143dcf3c
def parseAge(data, indicator): <NEW_LINE> <INDENT> start_time = datetime(2000, 1, 1, 0, 0) <NEW_LINE> delta = np.array([timedelta(i) for i in data['age']/24.]) <NEW_LINE> times_ = start_time + delta <NEW_LINE> year = np.ones(indicator.size, 'i') <NEW_LINE> month = np.ones(indicator.size, 'i') <NEW_LINE> day = np.ones(i...
Parse the TC age information to get a proxy date record. Assumes every TC starts at 2000-01-01 00:00 and calculates year, month, day, hour and minute values based on the age field. Assumes the age is given in hours since the initial timestep. :param dict data: :class:`dict` of arrays that contains the data loaded ...
625941cad53ae8145f87a31d
def get_closest_version( settings: configuration.Settings, target_version: Optional[versions.Version], sql_tpl: str, existing_files: Iterable[str], force_version: Optional[versions.Version] = None, ) -> Optional[versions.Version]: <NEW_LINE> <INDENT> known_versions = files.get_known_versions(settings=settings) <NEW_LIN...
Get the version of a file (schema or fixtures) to use to init a DB. Take the closest to the target_version. Can be the same version, or older.
625941ca507cdc57c6306d85
def path(self, which=None): <NEW_LINE> <INDENT> if which == "sync": <NEW_LINE> <INDENT> return f'{super().path(which="self")}/{which}' <NEW_LINE> <DEDENT> return super().path(which)
Extend ``nailgun.entity_mixins.Entity.path``. The format of the returned path depends on the value of ``which``: sync /products/<product_id>/sync ``super`` is called otherwise.
625941ca8e05c05ec3eea420
def _loop(self): <NEW_LINE> <INDENT> fds = self._watch_files.keys() <NEW_LINE> if self._alarms or self._did_something: <NEW_LINE> <INDENT> if self._alarms: <NEW_LINE> <INDENT> tm = self._alarms[0][0] <NEW_LINE> timeout = max(0, tm - time.time()) <NEW_LINE> <DEDENT> if self._did_something and (not self._alarms or (self....
A single iteration of the event loop
625941ca97e22403b379d045
def assignableignore(self) -> ast.Name: <NEW_LINE> <INDENT> return ast.Name(id="_")
Translates an assignment to a variable which is ignored In python the variable "_" is used to ignore an assignment. So we translate this to ast.Name(id="_").
625941caf548e778e58cd629
def FileOperateBiStreamFlow(self, request_iterator, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!')
stream in file chunks for a geometry file type and stream back results for each geometry encountered
625941ca76e4537e8c35171e
def _get_has_relation_query(self, relation): <NEW_LINE> <INDENT> from .relations import Relation <NEW_LINE> return Relation.no_constraints( lambda: getattr(self.get_model(), relation)() )
Get the "has" relation base query :type relation: str :rtype: Builder
625941ca099cdd3c635f0d07
def test_decimal_time(self): <NEW_LINE> <INDENT> self.year = np.array([1990, 1995, 2000]) <NEW_LINE> self.month = np.array([1, 6, 12]) <NEW_LINE> self.day = np.array([1, 30, 31]) <NEW_LINE> self.hour = np.array([0, 12, 23]) <NEW_LINE> self.minute = np.array([0, 30, 59]) <NEW_LINE> self.second = np.array([0.0, 30.0, 59....
Tests the function utils.decimal_time
625941ca26238365f5f0ef19
def _cross_reference_optimization(self): <NEW_LINE> <INDENT> for unused_key, deqatn in iteritems(self.dequations): <NEW_LINE> <INDENT> deqatn.cross_reference(self) <NEW_LINE> <DEDENT> for unused_key, dresp in iteritems(self.dresps): <NEW_LINE> <INDENT> dresp.cross_reference(self) <NEW_LINE> <DEDENT> for unused_key, dco...
cross references the optimization objects
625941cabaa26c4b54cb11cc
def download(url): <NEW_LINE> <INDENT> r = requests.get(url, stream=True) <NEW_LINE> if not r.ok: <NEW_LINE> <INDENT> raise ProcessingInputError('document ' + url + " could not be accessed!") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> filename = re.findall("filename=(.+)", r.headers['content-disposition'])[0] <NEW_LI...
Downloads the document at the given URL. Returns a saved models.Document instance.
625941caadb09d7d5db6c83c
def itemToggled(self, item): <NEW_LINE> <INDENT> if item.checkState: <NEW_LINE> <INDENT> item.plotDataItem.setData( x=item.x_data(), y=item.y_data(), ) <NEW_LINE> item.setLegend(self.checkBox_legend_dfname.isChecked(), self.checkBox_legend_label.isChecked(), self.checkBox_legend_ycolumn.isChecked()) <NEW_LINE> <DEDENT>...
process checking/unchecking of a StructuredDataFrame in the plot Parameters ---------- item : DFItem
625941ca0a366e3fb873e8c6
def all_instruments_in_asset_class(self, asset_class: str) -> list: <NEW_LINE> <INDENT> asset_class_data = self.get_instrument_asset_classes() <NEW_LINE> list_of_instrument_codes = self.get_instrument_list() <NEW_LINE> asset_class_instrument_list = asset_class_data.all_instruments_in_asset_class( asset_class, must_be_i...
Return all the instruments in a given asset class :param asset_class: str :return: list of instrument codes
625941cadd821e528d63b255
def check_continue_legalize_scope(self, indexstr, ustr): <NEW_LINE> <INDENT> ret = None <NEW_LINE> return ret
批准延续的认证范围 清洗验证
625941ca10dbd63aa1bd2c50
def _send_media_key(self, key): <NEW_LINE> <INDENT> def doKey(down): <NEW_LINE> <INDENT> ev = Quartz.NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( self.NSSystemDefined, (0, 0), 0xa00 if down else 0xb00, 0, 0, 0, 8, (key << 16) | ((0xa if down else 0xb) << 8), -1 ...
Sends key using Quartz. Valid values are self.NX_KEYTYPE_... defined in this class. Main part taken from http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
625941cacdde0d52a9e530df
def searchListNested(self): <NEW_LINE> <INDENT> self.searcher.setSearch('"Foo"') <NEW_LINE> o(self.searcher.search({ "bar": [0, 1, { "bar": "foo" }, [3, "foo", 5], 6] })).equals(False)("Checking first nested list search.") <NEW_LINE> o(self.searcher.search({ "bar": [0, 1, { "bar": "foo" }, [3, "Foo", 5], 6] })).equals(...
Tests nested list search.
625941ca56b00c62f0f14705
def getParms(self, values_dict): <NEW_LINE> <INDENT> if values_dict['public_flag']: <NEW_LINE> <INDENT> public_flag = 'true' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> public_flag = 'false' <NEW_LINE> <DEDENT> parms = {'api_key': self.pluginPrefs.get('apiKey', ''), 'elevation': self.pluginPrefs.get('elevation'...
Construct the API URL for upload to Thingspeak Construct the values needed for the data upload to the Thingspeak server. ----- :param values_dict:
625941cad7e4931a7ee9dfc9
def merge(self, nums1, m, nums2, n): <NEW_LINE> <INDENT> nums1[m:] = nums2[:] <NEW_LINE> nums1.sort()
:type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead.
625941ca656771135c3eb91a
def to_tup(self): <NEW_LINE> <INDENT> A = self.to_lst() <NEW_LINE> retval = tuple(*A) <NEW_LINE> return [retval]
Push the tuple representation of the TOS to the stack: [[1 2 3]] => [(1 2 3)]
625941ca63b5f9789fde7191
def create_value(self, value_name, value_type=REG_SZ, value_value=''): <NEW_LINE> <INDENT> key = self.create_key() <NEW_LINE> win32api.RegSetValueEx(key, value_name, 0, value_type, value_value) <NEW_LINE> key.close() <NEW_LINE> return True
create value
625941ca66673b3332b9213d
def clearLocks(context=None, path=None, recursive=True): <NEW_LINE> <INDENT> portal = getSite() <NEW_LINE> pc = getToolByName(portal, 'portal_catalog') <NEW_LINE> query = {} <NEW_LINE> if path is None: <NEW_LINE> <INDENT> query['path'] = "/%s" % portal.id <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> query['path'] = pa...
Little util method to clear locks on a given path Pass in a PhysicalPath to restrict to a specific section
625941ca851cf427c661a5bb
def _get_symlinks_in_folder(self, parent_path): <NEW_LINE> <INDENT> SYMLINK_SUFFIX = ".symlink.yml" <NEW_LINE> data = [] <NEW_LINE> items_in_folder = os.listdir(parent_path) <NEW_LINE> symlinks = [f for f in items_in_folder if f.endswith(SYMLINK_SUFFIX)] <NEW_LINE> for file_name in symlinks: <NEW_LINE> <INDENT> full_pa...
Returns all xxx.symlink.yml files in a location. :param parent_path: file system folder to scan :returns: list of (name, target_expression, full_metadata) where name is the name of the symlink and target_expression is a target expression to be passed into the folder creation. For example, if the fi...
625941ca56ac1b37e626427c
def get_deleted_objects(objs, user): <NEW_LINE> <INDENT> using = router.db_for_write(objs[0].__class__) <NEW_LINE> collector = NestedObjects(using=using) <NEW_LINE> collector.collect(objs) <NEW_LINE> perms_needed = set() <NEW_LINE> def format_callback(obj): <NEW_LINE> <INDENT> opts = obj._meta <NEW_LINE> no_edit_link =...
Find all objects related to ``objs`` that should also be deleted. ``objs`` must be a homogeneous iterable of objects (e.g. a QuerySet). Returns a nested list of strings suitable for display in the template with the ``unordered_list`` filter. Copied and updated from django.contrib.admin.utils for front end display.
625941ca1f037a2d8b9462aa
def _find_paths( dirpath: T.Path, path_type: int, recursive=False, prefix: T.Prefix = None, suffix: T.Suffix = None, filter_=None ) -> T.FinderReturn: <NEW_LINE> <INDENT> dirpath = normpath(dirpath, force_abspath=True) <NEW_LINE> for root, dirs, files in os.walk(dirpath): <NEW_LINE> <INDENT> root = normpath(root) <NEW_...
General files/dirs finder. Args: dirpath: path_type: int[0, 1]. 0: file, 1: dir. suffix: 1. each item must be string start with '.' ('.jpg', '.txt', etc.) 2. case insensitive. 3. param type is str or tuple[str], cannot be list[str]. recursive: filter_: optional[function] ...
625941caa219f33f34628a17
def resetQueue(self, host=None): <NEW_LINE> <INDENT> def dq(): return DeferredQueue(self.maxQueued, self.maxBacklog) <NEW_LINE> if not host: <NEW_LINE> <INDENT> self.queue = WWWInsensitiveDefaultDict(dq) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.queue[host] = dq()
Resets a queue of requests. @type host: c{str} @param host: An option host queue to reset. If no host is provided the entire queue is reset.
625941ca293b9510aa2c3343
def _matches(self, item): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> for creature in item.creatures: <NEW_LINE> <INDENT> if creature.name == self.creature: <NEW_LINE> <INDENT> count = count + 1 <NEW_LINE> <DEDENT> <DEDENT> return self.amount.matches(count)
Check if matcher matches item :param item: object to match against :returns: True if matching, otherwise False :rtype: Boolean
625941ca38b623060ff0ae9a
def test_teachers_statistics_group_dispatch(self): <NEW_LINE> <INDENT> users = User.objects.all() <NEW_LINE> with self.assertRaisesMessage(BadRequest, '错误的参数'): <NEW_LINE> <INDENT> TeachersStatisticsService.teachers_statistics_group_dispatch( users, 100, True) <NEW_LINE> <DEDENT> data = TeachersStatisticsService.teache...
test teachers_statistics_group_dispatch function
625941ca9c8ee82313fbb821
def predict(self, test_set): <NEW_LINE> <INDENT> x = tf.placeholder(tf.float32, [None, self.__num_feature]) <NEW_LINE> W = tf.constant(self.__W) <NEW_LINE> b = tf.constant(self.__b) <NEW_LINE> y = tf.nn.softmax(tf.matmul(x, W) + b) <NEW_LINE> sess = tf.Session() <NEW_LINE> predict = sess.run(tf.argmax(y, 1), feed_dict ...
:param test_set: numpy array, shape is (num_test_sample, num_feature) :return:
625941cab5575c28eb68e0ac
def parse_html(self, url): <NEW_LINE> <INDENT> response = requests.get(url) <NEW_LINE> return html.fromstring(response.text)
start up a parser and return the tree for further processing
625941ca5fcc89381b1e176b
def defining_ideal(self): <NEW_LINE> <INDENT> return self._I
Return the ideal generating this quotient Lie algebra. EXAMPLES:: sage: L = lie_algebras.Heisenberg(QQ, 1) sage: p,q,z = L.basis() sage: Q = L.quotient(p) sage: Q.defining_ideal() Ideal (p1) of Heisenberg algebra of rank 1 over Rational Field
625941ca07d97122c4178937
def test_init(self): <NEW_LINE> <INDENT> payload = payloads.ArchiveRequestPayload() <NEW_LINE> self.assertEqual(None, payload.unique_identifier)
Test that an Archive request payload can be constructed with no arguments.
625941ca8c3a873295158466
def test(): <NEW_LINE> <INDENT> logger.debug('Init test') <NEW_LINE> h = Eb2() <NEW_LINE> companies = h.getCompanies('take=5') <NEW_LINE> logger.info(companies) <NEW_LINE> idc=4 <NEW_LINE> company = h.getCompany(idc) <NEW_LINE> logger.info(company) <NEW_LINE> ext_id='AG1' <NEW_LINE> company = h.getCompanyFromExt_id(ext...
test Eb2 class.
625941ca851cf427c661a5bc
@cmd("notice", raw_nick = True) <NEW_LINE> @pmcmd("notice", raw_nick = True) <NEW_LINE> def mark_prefer_notice(cli, nick, *rest): <NEW_LINE> <INDENT> nick, _, __, cloak = parse_nick(nick) <NEW_LINE> if cloak in var.PREFER_NOTICE: <NEW_LINE> <INDENT> var.PREFER_NOTICE.remove(cloak) <NEW_LINE> var.remove_prefer_notice(cl...
Makes the bot NOTICE you for every interaction.
625941cad18da76e23532582
def info(self, message, event=None, log_entry_id=None): <NEW_LINE> <INDENT> self.log(logging.INFO, message, event=event, log_entry_id=log_entry_id)
Generates a log message with priority logging.INFO.
625941ca442bda511e8be4c5
def populate_cases(case_path_array, N_simulations, Vx_RHS, Vy_RHS, Vx_LHS, Vy_LHS, foam_files_templates): <NEW_LINE> <INDENT> pass
Loop through the list of case_path_array and paste the static files required for the simulations, AND WRITE the files that are dynamic: Should just be U-initial boundary_conditions at this point Args: case_path_array (array): 1D array full of string elemets pertaining to the full case folder paths. foam_files_t...
625941ca1f5feb6acb0c4bfe
def test_f_regression_center(): <NEW_LINE> <INDENT> X = np.arange(-5, 6) <NEW_LINE> n_samples = X.size <NEW_LINE> Y = np.ones(n_samples) <NEW_LINE> Y[::2] *= -1. <NEW_LINE> Y[0] = 0. <NEW_LINE> F1, _ = f_regression(X, Y, center=True) <NEW_LINE> F2, _ = f_regression(X, Y, center=False) <NEW_LINE> assert_array_almost_equ...
Test whether f_regression preserves dof according to 'center' argument We use two centered variates so we have a simple relationship between F-score with variates centering and F-score without variates centering.
625941cabf627c535bc1327b
def reflection_from_matrix(matrix): <NEW_LINE> <INDENT> M = numpy.array(matrix, dtype=numpy.float64, copy=False) <NEW_LINE> l, V = numpy.linalg.eig(M[:3, :3]) <NEW_LINE> i = numpy.where(abs(numpy.real(l) + 1.0) < 1e-8)[0] <NEW_LINE> if not len(i): <NEW_LINE> <INDENT> raise ValueError("no unit eigenvector corresponding ...
Return mirror plane point and normal vector from reflection matrix. >>> v0 = numpy.random.random(3) - 0.5 >>> v1 = numpy.random.random(3) - 0.5 >>> M0 = reflection_matrix(v0, v1) >>> point, normal = reflection_from_matrix(M0) >>> M1 = reflection_matrix(point, normal) >>> is_same_transform(M0, M1) True
625941ca6fece00bbac2d7ea
def add_udls(self): <NEW_LINE> <INDENT> LOG.info(_("Adding configured user defined load libraries.")) <NEW_LINE> password = self._get_database_password() <NEW_LINE> loaded_udls = [] <NEW_LINE> for lib in system.UDL_LIBS: <NEW_LINE> <INDENT> func_name = lib['func_name'] <NEW_LINE> lib_name = lib['lib_name'] <NEW_LINE> l...
Load the user defined load libraries into the database.
625941caf9cc0f698b1406a8
def callback(self,*arg): <NEW_LINE> <INDENT> return self.canvas.create_rectangle(0,0,300,200, fill = self.changeColor())
CallBack function to cahange the color of canvas
625941cac432627299f04cf2
def ModifyTimeWindow(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("ModifyTimeWindow", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.ModifyTimeWindowResponse() ...
本接口(ModifyTimeWindow)用于更新云数据库实例的维护时间窗口。 :param request: 调用ModifyTimeWindow所需参数的结构体。 :type request: :class:`tencentcloud.cdb.v20170320.models.ModifyTimeWindowRequest` :rtype: :class:`tencentcloud.cdb.v20170320.models.ModifyTimeWindowResponse`
625941ca1b99ca400220ab5e
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self.type <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x.encode('utf-8') <NEW_LINE> length = len(_x) <NEW_LINE> <DEDENT> if python3: <NEW_LINE> <INDENT> buff.write(struct.pack('<I%sB'%leng...
serialize message into buffer :param buff: buffer, ``StringIO``
625941ca23849d37ff7b313c
def __div__(self, value): <NEW_LINE> <INDENT> return ErrorBar(self.lower / value, self.upper / value)
This function ... :param value: :return:
625941ca26068e7796caed8b
def test__socket_to_pdu(self): <NEW_LINE> <INDENT> dul = DummyDUL() <NEW_LINE> self.assertEqual(dul._socket_to_pdu(b'\x99\x98'), None)
Test that good PDU paramters return expected results
625941cac4546d3d9de72ae0
def test_signin_view_remember_me_on(self): <NEW_LINE> <INDENT> response = self.client.post(reverse('userena_signin'), data={'identification': 'john@example.com', 'password': 'blowfish', 'remember_me': True}) <NEW_LINE> self.assertEqual(self.client.session.get_expiry_age(), userena_settings.USERENA_REMEMBER_ME_DAYS[1] *...
A ``POST`` to the signin with tells it to remember the user for ``REMEMBER_ME_DAYS``.
625941ca31939e2706e4cf18
def try_int(o:Any)->Any: <NEW_LINE> <INDENT> if isinstance(o, (np.ndarray,Tensor)): return o if o.ndim else int(o) <NEW_LINE> if isinstance(o, collections.Sized) or getattr(o,'__array_interface__',False): return o <NEW_LINE> try: return int(o) <NEW_LINE> except: return o
Try to convert `o` to int, default to `o` if not possible.
625941ca56ac1b37e626427d
def run(self): <NEW_LINE> <INDENT> os.chdir(os.path.join("doc", "sphinx")) <NEW_LINE> if not self.dry_run: <NEW_LINE> <INDENT> run_command_or_exit("make clean") <NEW_LINE> run_command_or_exit("python{:d}.{:d} autogen.py aeidon gaupol" .format(*sys.version_info[:2])) <NEW_LINE> run_command_or_exit("make {}".format(self....
Build documentation from source code.
625941caa4f1c619b28b00e7
def send( self, topic:str=None, payload=None, qos=0, retain=False ): <NEW_LINE> <INDENT> if not topic: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> msg = { "topic" : topic.replace(" ", "_"), "payload" : payload } <NEW_LINE> self.publish( msg )
Wie publish aber mit seperater topic und payload Angabe. Parameters ---------- topic : str, optional Der zu sendende Topic. The default is None. payload : TYPE, optional Nachrichteninhalt. The default is None. qos : int, optional Quality of Service. The default is 0. retain : bool, optional Retain-Flag...
625941ca21bff66bcd684a00
def getThumbfile(self, plot): <NEW_LINE> <INDENT> thumbfile = os.path.join(self.outDir, plot['thumbFile']) <NEW_LINE> return thumbfile
Return the thumbnail file name for a given plot.
625941ca956e5f7376d70f1a
def test_02(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> a2 = self.createA2() <NEW_LINE> a3 = self.createA3() <NEW_LINE> a4 = self.createA4() <NEW_LINE> self.addLocationsA2() <NEW_LINE> self.addLocationsA3() <NEW_LINE> self.addLocationsA4() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return self.skipTest("Co...
get_track/add_location
625941ca7b25080760e39506
def save_wav(self, filename=None, offline=False): <NEW_LINE> <INDENT> self.chirpsdk.save_wav(self, filename, offline)
Saves the Chirp as a local wav file. Set offline to True if you want to generate the file locally instead of fetching it from our servers.
625941caab23a570cc25022f
def set_keepalive_time(self, keepalive_time=0.1): <NEW_LINE> <INDENT> self._keepalive_time = float(keepalive_time) <NEW_LINE> if self._keepalive_time/2 > 0.1: <NEW_LINE> <INDENT> self._wakeup_time = 0.1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._wakeup_time = self._keepalive_time/2
Set the minimum time in seconds for which any object in the cache is kept alive. The time is not precise, and sets a minimum time to be alive. In practice, it may be up to twice as long before the object is deleted from the cache (due to implementational details).
625941ca76d4e153a657ebdd
def get_movable_points(self): <NEW_LINE> <INDENT> return self.movable.get_xy_data()
Return the movable line's points as a list of [x,y] pairs
625941cade87d2750b85fe3f
def write(entries, output=None): <NEW_LINE> <INDENT> with _file_obj(output, 'a') as foutput: <NEW_LINE> <INDENT> for descr, seq in entries: <NEW_LINE> <INDENT> foutput.write('>' + descr.replace('\n', '\n;') + '\n') <NEW_LINE> foutput.write(''.join([('%s\n' % seq[i:i+70]) for i in range(0, len(seq), 70)]) + '\n') <NEW_L...
Create a FASTA file with ``entries``. Parameters ---------- entries : iterable of (str, str) tuples An iterable of 2-tuples in the form (description, sequence). output : file-like or str, optional A file open for writing or a path to write to. If the file exists, it will be opened for appending. Default is...
625941ca15fb5d323cde0bbc
def test_invalid_token(self): <NEW_LINE> <INDENT> token = self.user_1.create_auth_token() <NEW_LINE> self.assertFalse(self.user_2.validate_auth_token(token))
Using a different user's token is not valid.
625941ca3346ee7daa2b2e18
def __init__(self): <NEW_LINE> <INDENT> gtk.VBox.__init__(self) <NEW_LINE> self.set_can_focus(True) <NEW_LINE> self.connect("expose-event", self.expose_background_box)
Initialize the BackgroundBox class.
625941cad6c5a102081440f7
def _find_with_manual_intersection(self, types=None, data=None, file_uri=None, mimetype=None, id_pool=None, ids_only=False, query_order=("data", "file_uri", "mimetype", "types")): <NEW_LINE> <INDENT> if id_pool is not None: <NEW_LINE> <INDENT> id_pool = set(id_pool) <NEW_LINE> <DEDENT> query_map = {"data": (self._do_da...
Perform a _find() that uses id_pool intersection. Provided as a workaround for large id_pools potentially tripping the compile time SQL limit on maximum variables in a query.
625941cab830903b967e99b8
def test_can_delete_unused_group_configuration(self): <NEW_LINE> <INDENT> self.course_fixture._update_xblock(self.course_fixture._course_location, { "metadata": { u"user_partitions": [ self.create_user_partition_json( 0, 'Configuration 1', 'Description of the group configuration.', [Group("0", 'Group 0'), Group("1", 'G...
Scenario: Ensure that the user can delete unused group configuration. Given I have a course with 2 group configurations And I go to the Group Configuration page When I delete the Group Configuration with name "Configuration 1" Then I see that there is one Group Configuration When I edit the Group Configuration with nam...
625941cabe7bc26dc91cd6ae
def sample_structure_anchor_patches(hparams, networkx_graph, device, max_sim_epochs): <NEW_LINE> <INDENT> n_samples = max_sim_epochs * hparams['n_anchor_patches_structure'] * hparams['n_layers'] <NEW_LINE> all_patches = [] <NEW_LINE> start_nodes = list(np.random.choice(list(networkx_graph.nodes), n_samples, replace = T...
Generate a large number of structure anchor patches from which we can sample later max_sim_epochs: multiplication factor to ensure we generate more AP than are actually needed Returns a tensor of shape (n sampled patches, max patch length)
625941caeab8aa0e5d26dc04
def gamehasbegun(self): <NEW_LINE> <INDENT> self.begingame()
gamehasbegun() -> None This call arrives in the state-description burst if the game started before we showed up. Do the same stuff we do in begingame().
625941ca57b8e32f52483547
def get_user_details_by_accountid(self, accountid, expand=None): <NEW_LINE> <INDENT> url = "rest/api/user" <NEW_LINE> params = {"accountId": accountid} <NEW_LINE> if expand: <NEW_LINE> <INDENT> params["expand"] = expand <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> response = self.get(url, params=params) <NEW_LINE> <DED...
Get information about a user through accountid :param accountid: The account id :param expand: OPTIONAL expand for get status of user. Possible param is "status". Results are "Active, Deactivated" :return: Returns the user details
625941ca50485f2cf553ce46
def tearDown(self): <NEW_LINE> <INDENT> del self.test_obj
Destroy the test Datac object
625941ca3d592f4c4ed1d11c
def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): <NEW_LINE> <INDENT> return (nodes.node_database(context=ncontext), uri)
try to locate the node in uri, Return a tuple (node_dir, remaining_path)
625941ca66656f66f7cbc257
def extract_unique_names_from_members(members: Iterable[Dict]) -> List[str]: <NEW_LINE> <INDENT> return [m['Element']['UniqueName'] if 'Element' in m and m['Element'] else m['UniqueName'] for m in members]
Extract list of unique names from part of the cellset response in: [{'UniqueName': '[dim1].[dim1].[elem1]', 'Element': {'UniqueName': '[dim1].[dim1].[elem1]'}}, {'UniqueName': '[dim2].[dim2].[elem3]', 'Element': {'UniqueName': '[dim2].[dim2].[elem3]'}}] out: ["[dim1].[dim1].[elem1]", "[dim2].[dim2].[elem3]"] :param mem...
625941ca76e4537e8c35171f
def get_drawings(year, month, day): <NEW_LINE> <INDENT> drawings = [] <NEW_LINE> id_set = set() <NEW_LINE> page = 1 <NEW_LINE> done = False <NEW_LINE> while not done: <NEW_LINE> <INDENT> html = get_html("https://www.ohiolottery.com/WinningNumbers/KenoDrawings/KenoDrawingsArchive?date={}/{}/{}&page={}".format(month, day...
get_drawings() : scrapes paginated tables to get a day's Keno drawings Params: - year (int) : the year for the drawing - month (int) : the month for the drawing - day (int) : the day for the drawing Returns: - (list) : a list of KenoDrawing objects
625941cabe8e80087fb20cf0
def _json_parse(self, data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> return json.loads(data); <NEW_LINE> <DEDENT> except Exception as err: <NEW_LINE> <INDENT> print("%%Error: parse data (%s...) error: %s" % (data, err)) <NEW_LINE> <DEDENT> return {};
parse json string
625941ca498bea3a759b9b5c
def write_gif_data(): <NEW_LINE> <INDENT> response = {'response_code': '204 No Content', 'response_headers': [('Content-Type', 'image/gif'), ('Cache-Control', 'private, no-cache, no-cache=Set-Cookie, proxy-revalidate'), ('Pragma', 'no-cache'), ('Expires', 'Wed, 17 Sep 1975 21:32:10 GMT'), ], 'response_body': '', } <NEW...
// Writes the bytes of a 1x1 transparent gif into the response. Returns a dictionary with the following values: { 'response_code': '200 OK', 'response_headers': [(Header_key, Header_value), ...] 'response_body': 'binary data' }
625941cad18da76e23532583
def contains_duplicate_by_sort(self, nums): <NEW_LINE> <INDENT> if not nums: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> sorted_nums = sorted(nums) <NEW_LINE> for index, value in enumerate(sorted_nums[1:], start=1): <NEW_LINE> <INDENT> if value == sorted_nums[index - 1]: <NEW_LINE> <INDENT> return True <NEW_LI...
sort first and then traverse @Runtime: 52 ms :param nums: :return:
625941ca796e427e537b0673
def station_within_distance(instance): <NEW_LINE> <INDENT> if LATITUDE - DISTANCE_DG <= float(instance['gegrLat']) <= LATITUDE + DISTANCE_DG: <NEW_LINE> <INDENT> if LONGITUDE - DISTANCE_DG <= float(instance['gegrLon']) <= LONGITUDE + DISTANCE_DG: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <IND...
Check if station is within set distance from coordinates
625941ca627d3e7fe0d68efc
def check_app_new_firmware(self, test=False): <NEW_LINE> <INDENT> theLog = "Check for new firmware" <NEW_LINE> parseNode = f".//{c.GET_DEVICE_CONFIG_INFO}Response" <NEW_LINE> toParse = [ 'BlankState', 'NewBlockSiteEnable', 'NewBlockSiteName', 'NewTimeZone', 'NewDaylightSaving' ] <NEW_LINE> theInfo = self._get( theLog, ...
Parse CheckAppNewFirmware and return dict.
625941ca30c21e258bdfa54a
def get_kafka_consumer(topic=None, value_deserializer=lambda v: json.loads(v.decode('utf-8'))): <NEW_LINE> <INDENT> consumer = KafkaConsumer( topic, bootstrap_servers=get_kafka_brokers(), security_protocol='SSL', ssl_context=get_kafka_ssl_context(), value_deserializer=value_deserializer ) <NEW_LINE> return consumer
Return a KafkaConsumer that uses the SSLContext created with create_ssl_context.
625941caad47b63b2c50a02c
def edit_distance(word1: str, word2: str) -> int: <NEW_LINE> <INDENT> m, n = len(word1), len(word2) <NEW_LINE> dp = [[0] * (m+1) for _ in range(n+1)] <NEW_LINE> for i in range(1, n+1): <NEW_LINE> <INDENT> dp[i][0] = i <NEW_LINE> <DEDENT> for j in range(1, m+1): <NEW_LINE> <INDENT> dp[0][j] = j <NEW_LINE> <DEDENT> print...
dp[i][j] = dp[i-1][j-1] if word1[i-1] == word[j-1] dp[i][j] = min(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]) + 1 dp[i][j] represent word1 pre i trans to word2 pre j edit distance :return:
625941cae1aae11d1e749d64
def __max_depth(self, node): <NEW_LINE> <INDENT> if not node: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> max_l = 0 <NEW_LINE> max_r = 0 <NEW_LINE> if node.left: <NEW_LINE> <INDENT> max_l = self.__max_depth(node.left) <NEW_LINE> <DEDENT> if node.right: <NEW_LINE> <INDENT> max_r = self.__max_depth(node.right) <NEW_...
获取指定数的最大深度
625941cabde94217f3682e9e
def test_other_int_properties(self): <NEW_LINE> <INDENT> from utils import Properties <NEW_LINE> PROPS = Properties("utils/tests/test.conf", environment="other") <NEW_LINE> self.assertEquals(100, PROPS.getInt("test.int.key"))
Demo for usage
625941cad8ef3951e32435ea
def make_flag(): <NEW_LINE> <INDENT> open(flag, 'a').close()
Makes a lockfile to prevent race conditions
625941ca99fddb7c1c9de43e
def apply_svd(self, n): <NEW_LINE> <INDENT> transformed_traces = [] <NEW_LINE> for trace in self.traces: <NEW_LINE> <INDENT> U,s,V = np.linalg.svd(trace, full_matrices=True) <NEW_LINE> transformed_traces.append(U[:,:n]) <NEW_LINE> <DEDENT> self.traces = transformed_traces <NEW_LINE> self.wavelengths = np.arange(n)
Replaces spectral traces with their SVD transformed equivalents truncating at the nth component
625941cad6c5a102081440f8
def build_dataframe(URSI, methods, config_file, csv_files): <NEW_LINE> <INDENT> first = True <NEW_LINE> for method in methods: <NEW_LINE> <INDENT> for csv_file in csv_files: <NEW_LINE> <INDENT> print(''.join(["Loading ", csv_file])) <NEW_LINE> if (os.path.basename(csv_file) != ".DS_Store" and method == os.path.basename...
Function to pull openSMILE output csv into a pandas dataframe Parameters ---------- URSI : string participant identifier method : list noise replacement methods config_file : string openSMILE configuration file filename csv_files : list list of paths to openSMILE output files Returns ------- d ...
625941ca44b2445a33932143
def _random_user_agent() -> str: <NEW_LINE> <INDENT> return choice(USER_AGENTS)
Obtenha um user agent aleatório.
625941ca8a349b6b435e8220
def second_index(text: str, symbol: str): <NEW_LINE> <INDENT> if text.count(symbol) <2: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return text.find(symbol, text.find(symbol) + 1)
returns the second index of a symbol in a given text
625941cab830903b967e99b9
def format_emperor_autograph(metadata_fp, coords_fp, language='HTML'): <NEW_LINE> <INDENT> _languages = {'HTML':('<!--', '-->'), 'Python':('"""', '"""'), 'C':('/*', '*/'), 'Bash':('<<COMMENT', 'COMMENT')} <NEW_LINE> assert language in _languages.keys(), '%s is not a supported language' % language <NEW_LINE> auto...
Create a signature with some meta-data of the Emperor package language: language to which it will be formatted as a multi-line comment
625941ca71ff763f4b549738
def RotateQuaternion(Angle, Axis, Quaternion): <NEW_LINE> <INDENT> w1 = cos(Angle / 2.0) <NEW_LINE> v1 = sprod(sin(Angle / 2.0), Axis) <NEW_LINE> return MultiplyQuaternions((w1,) + v1, Quaternion)
Rotate a quaternion by an angle about an axis.
625941cad164cc6175782dfb