code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def check_one_subreddit(subreddit_name,notifications,reddit,start_time,end_time): <NEW_LINE> <INDENT> new_posts = get_reddit_posts(subreddit_name,reddit,start_time,end_time) <NEW_LINE> notifications_to_send = [] <NEW_LINE> for post in new_posts: <NEW_LINE> <INDENT> for notification in notifications: <NEW_LINE> <INDENT>... | Checks subreddit /r/subreddit_name for each notification in notifications.
Reddit is a praw instance, start and end times indicate the interval to check. | 625941d7baa26c4b54cb1383 |
def update_value(self, inst): <NEW_LINE> <INDENT> self.text = "%s/%s/%s" % tuple(self.cal.active_date) <NEW_LINE> self.focus = False | Update textinput value on popup close | 625941d7a4f1c619b28b029b |
def test_signal_post(self): <NEW_LINE> <INDENT> user1 = ProfileFactory().user <NEW_LINE> topic1 = TopicFactory(forum=self.forum11, author=self.user) <NEW_LINE> PostFactory(topic=topic1, author=self.user, position=1) <NEW_LINE> post2 = PostFactory(topic=topic1, author=user1, position=2) <NEW_LINE> PostFactory(topic=topi... | To test when a member quote anyone post. | 625941d7498bea3a759b9d14 |
def submit(request): <NEW_LINE> <INDENT> if settings.REQUIRE_LOGIN and not request.user.is_authenticated(): <NEW_LINE> <INDENT> raise Http404 <NEW_LINE> <DEDENT> url = None <NEW_LINE> link_form = None <NEW_LINE> if request.GET: <NEW_LINE> <INDENT> link_form = LinkSubmitForm(request.GET) <NEW_LINE> <DEDENT> elif request... | View for submitting a URL | 625941d77b25080760e396be |
def test_remove(self): <NEW_LINE> <INDENT> name = 'Disk space - /' <NEW_LINE> def check_disk(rtn, disk='/'): <NEW_LINE> <INDENT> return { 'status': 0, 'message': 'All is OK' } <NEW_LINE> <DEDENT> self.add( name=name, monitor=check_disk, interval=1, args='a') <NEW_LINE> assert_in(name, self.monitors) <NEW_LINE> self.rem... | Test the removal of a monitor from the monitoring list | 625941d75fc7496912cc3be4 |
def remove_field(self, model, field): <NEW_LINE> <INDENT> if ((isinstance(field, ManyToManyField) or field.get_internal_type() == 'ManyToManyField') and field.rel.through._meta.auto_created): <NEW_LINE> <INDENT> return self.delete_model(field.rel.through) <NEW_LINE> <DEDENT> if field.db_parameters(connection=self.conne... | Removes a field from a model. Usually involves deleting a column,
but for M2Ms may involve deleting a table. | 625941d7adb09d7d5db6c9f4 |
def get_qq(request): <NEW_LINE> <INDENT> if request.method == "GET" and request.is_ajax(): <NEW_LINE> <INDENT> return TemplateResponse(request, 'question_div.html', {"choices": QUESTION_TYPE_CHOICES}) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise Http404 | AJAX-вьюха для получения кода div'а для одного вопроса (c полями). | 625941d7442bda511e8be67b |
def valid_password(password): <NEW_LINE> <INDENT> return password and PASSWORD_RE.match(password) | password check | 625941d7a05bb46b383eca86 |
def get_queryset(self): <NEW_LINE> <INDENT> return Question.objects.filter( pud_date__lte=timezone.now() ).order_by('-pud_date')[:5] | Return the last five published question (not including those set to be
published in the future). | 625941d755399d3f0558891b |
def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, V1beta2ReplicaSet): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict() | Returns true if both objects are not equal | 625941d745492302aab5e52c |
def test_create_user(self): <NEW_LINE> <INDENT> data = { 'username': 'foobar', 'password': 'somepassword' } <NEW_LINE> response = self.client.post(self.create_url, data, format='json') <NEW_LINE> user = User.objects.latest('id') <NEW_LINE> token = Token.objects.get(user=user) <NEW_LINE> self.assertEqual(User.objects.co... | Ensure we can create a new user and a valid token is created with it. | 625941d70fa83653e4657220 |
def set_filter(self, filter): <NEW_LINE> <INDENT> self._filters = [] <NEW_LINE> self._filters.append(filter) | Set the current active filter. | 625941d74c3428357757c58d |
def choose_configurator_plugins(config, plugins, verb): <NEW_LINE> <INDENT> req_auth, req_inst = cli_plugin_requests(config) <NEW_LINE> if verb == "run": <NEW_LINE> <INDENT> need_inst = need_auth = True <NEW_LINE> from letsencrypt.cli import cli_command <NEW_LINE> if req_auth in noninstaller_plugins and not req_inst: <... | Figure out which configurator we're going to use, modifies
config.authenticator and config.installer strings to reflect that choice if
necessary.
:raises errors.PluginSelectionError if there was a problem
:returns: (an `IAuthenticator` or None, an `IInstaller` or None)
:rtype: tuple | 625941d701c39578d7e750a1 |
def performance_detail(): <NEW_LINE> <INDENT> return { 'type': 'class', 'base': None, 'is_abstract': False, 'is_document': False, 'properties': [ ('coupling_cost', 'float', '0.1', "Coupling cost measures the overhead caused by coupling. This can include the cost of the coupling algorithm itself (which may involve grid ... | Information about how the various components of performance were
related.
| 625941d715fb5d323cde0d78 |
def trim_buffer(self, idx: int, trim_len: int) -> None: <NEW_LINE> <INDENT> assert self.__is_empty, "Trimmed buffer must be empty" <NEW_LINE> assert idx > self.__start, "Trimmed buffer must have: idx {idx} > self.__start {self.__start}" <NEW_LINE> assert self.__start >= 0, f"Trim without recording! self.__start {self._... | Trim is called once to fix buffer length. Buffer must be multiple of trim_len.
If this length is negative use only idx value | 625941d7283ffb24f3c55b65 |
def __init__(self, base_file: Optional[str], user_file: Optional[str] = "") -> None: <NEW_LINE> <INDENT> if base_file is None or not os.path.exists(base_file): <NEW_LINE> <INDENT> self.config: Any = [] <NEW_LINE> return <NEW_LINE> <DEDENT> self.config = self.get_config_from_file(base_file) <NEW_LINE> if user_file and o... | Initialize configuration. | 625941d7c432627299f04ead |
def process_command(self, command): <NEW_LINE> <INDENT> self._run_command(command, self._commands) | This function ...
:param command:
:return: | 625941d763d6d428bbe44755 |
def itkBinaryMagnitudeImageFilterIUC3IUC3IUC3_Superclass_cast(*args): <NEW_LINE> <INDENT> return _itkBinaryMagnitudeImageFilterPython.itkBinaryMagnitudeImageFilterIUC3IUC3IUC3_Superclass_cast(*args) | itkBinaryMagnitudeImageFilterIUC3IUC3IUC3_Superclass_cast(itkLightObject obj) -> itkBinaryMagnitudeImageFilterIUC3IUC3IUC3_Superclass | 625941d730c21e258bdfa704 |
def _add_row(self, row): <NEW_LINE> <INDENT> df = self._df <NEW_LINE> col_names, col_data = zip(*row) <NEW_LINE> col_names = list(col_names) <NEW_LINE> col_data = list(col_data) <NEW_LINE> index_col_val = dict(row)[df.index.name] <NEW_LINE> required_cols = set(df.columns.values).union({df.index.name}) - {sel... | Append a new row to the end of the DataFrame given a list of 2-tuples
of (column name, column value). This method will work for DataFrames
with arbitrary index types. | 625941d7ec188e330fd5aa01 |
def solution(): <NEW_LINE> <INDENT> n1 = 1 <NEW_LINE> n2 = 1 <NEW_LINE> k = 3 <NEW_LINE> while True: <NEW_LINE> <INDENT> n = n1 + n2 <NEW_LINE> num_digits = int(math.ceil(math.log10(n))) <NEW_LINE> if num_digits < 9: <NEW_LINE> <INDENT> n1, n2 = n2, n <NEW_LINE> k += 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> last_9_dig... | problem solution | 625941d7b5575c28eb68e268 |
def tearDown(self): <NEW_LINE> <INDENT> pgagent_utils.delete_pgagent_step(self) <NEW_LINE> pgagent_utils.delete_pgagent_job(self) | Clean up code | 625941d7bf627c535bc13435 |
def test_export_to_archive_jobs(self, get_barestates_root, targets_list): <NEW_LINE> <INDENT> uri = "job_store.test_jobstore_register_job" <NEW_LINE> for target in targets_list: <NEW_LINE> <INDENT> self.store.add_host(fqdn=target.host, osid=target.id, ipv4="127.0.0.1", ipv6="::1") <NEW_LINE> <DEDENT> jid = self.store.n... | Test export to an archive jobs.
:param targets_list
:return: | 625941d73539df3088e2e5b1 |
def test_coordinate(self): <NEW_LINE> <INDENT> nr1 = NodeRegion(origin=PhyDim2(0, 0), dim=self.ps1.dim(), type=NodeRegion.PROC) <NEW_LINE> nr2 = NodeRegion(origin=PhyDim2(0, 0), dim=self.ps2.dim(), type=NodeRegion.PROC) <NEW_LINE> for ps, nr in zip([self.ps1, self.ps2], [nr1, nr2]): <NEW_LINE> <INDENT> coord_list = [ps... | Get coordinate. | 625941d794891a1f4081bd10 |
def merge_colinear(points, scale): <NEW_LINE> <INDENT> points = np.asanyarray(points, dtype=np.float64) <NEW_LINE> scale = float(scale) <NEW_LINE> if len(points.shape) != 2 or points.shape[1] != 2: <NEW_LINE> <INDENT> raise ValueError('only for 2D points!') <NEW_LINE> <DEDENT> if len(points) < 3: <NEW_LINE> <INDENT> re... | Given a set of points representing a path in space,
merge points which are colinear.
Parameters
----------
points : (n, dimension) float
Points in space
scale : float
Scale of drawing for precision
Returns
----------
merged : (j, d) float
Points with colinear and duplicate
points merged, where (j < n) | 625941d73eb6a72ae02ec748 |
def getMetadataHistoryJson(self, fqn): <NEW_LINE> <INDENT> ds = self.load_single_ds(fqn) <NEW_LINE> return self._read_meta_hist(ds).toJson() | Returns the metadata history for a given fqn | 625941d79c8ee82313fbb9dc |
def create(self, identity, twilio_authy_sandbox_mode=values.unset): <NEW_LINE> <INDENT> data = values.of({'Identity': identity, }) <NEW_LINE> headers = values.of({'Twilio-Authy-Sandbox-Mode': twilio_authy_sandbox_mode, }) <NEW_LINE> payload = self._version.create(method='POST', uri=self._uri, data=data, headers=headers... | Create the EntityInstance
:param unicode identity: Unique identity of the Entity
:param unicode twilio_authy_sandbox_mode: The Twilio-Authy-Sandbox-Mode HTTP request header
:returns: The created EntityInstance
:rtype: twilio.rest.authy.v1.service.entity.EntityInstance | 625941d7287bf620b61d3cc9 |
def __init__(self): <NEW_LINE> <INDENT> self.capturing = False <NEW_LINE> VF_CAPS = Gst.Caps.from_string('video/x-raw, width=1280, height=720, framerate=30/1') <NEW_LINE> PHOTO_CAPS = Gst.Caps.from_string('video/x-raw, width=2304, height=1536') <NEW_LINE> print ('Create webcam') <NEW_LINE> webcam = Gst.ElementFactory.m... | Constructor | 625941d7627d3e7fe0d690b7 |
def is_hostname_localhost(hostname: str) -> bool: <NEW_LINE> <INDENT> ipv4_address = ipaddress.ip_address(socket.gethostbyname(hostname)) <NEW_LINE> local_ipv4_addresses = get_local_ipv4_addresses() <NEW_LINE> return ipv4_address in local_ipv4_addresses | Returns whether the IPv4 address associated with the given hostname
is bound to one of the local network interfaces
Parameters
----------
hostname
hostname to be checked
Returns
-------
bool
true, if the IPv4 address associated with the given hostname is bound to
one of the local network interfaces | 625941d76fb2d068a760f306 |
def __init__(self, permissionIds, ): <NEW_LINE> <INDENT> self.permissionIds = permissionIds | :param permissionIds: 权限id集合 | 625941d73d592f4c4ed1d2cf |
def _cdf(self, x: sf.TReal) -> sf.TReal: <NEW_LINE> <INDENT> z = (x - self.Mean) / self.Sigma <NEW_LINE> Result = 0.5 * (1 + math.erf(z / math.sqrt(2))) <NEW_LINE> return Result | The actual implementation of the CDF function.
Signature:
int OR float -> 0 < float < 1
1.0.0.0 | 625941d7d18da76e2353273e |
def check_trigger(self, tag: str, *args): <NEW_LINE> <INDENT> if self.text.tag_cget(tag, "foreground") == self.colour_trigger_on: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif self.text.tag_cget(tag, "foreground") == self.colour_trigger_off: <NEW_LINE> <INDENT> return False | Checks the value of a trigger. | 625941d78c0ade5d55d3ec23 |
def test_download_package__too_many_packages(bucket_and_keys): <NEW_LINE> <INDENT> bucket, keys = bucket_and_keys <NEW_LINE> with pytest.raises(SystemExit) as exit_error: <NEW_LINE> <INDENT> download.prefer_wheels(keys, parse_package("error_pkg")) <NEW_LINE> <DEDENT> expected = ( "Found too many results for error-pkg:\... | If requesting a package with too many options, raise SystemExit. | 625941d7099cdd3c635f0ec0 |
def vertices(self) -> List[str]: <NEW_LINE> <INDENT> return list(self.__graph.keys()) | :return: list of vertices' names in the graph | 625941d7ec188e330fd5aa02 |
def read_custom_resource(custom_objects: CustomObjectsApi, namespace, plural, name) -> object: <NEW_LINE> <INDENT> print(f"Getting info for {name} in namespace {namespace}") <NEW_LINE> try: <NEW_LINE> <INDENT> response = custom_objects.get_namespaced_custom_object( "k8s.nginx.org", "v1", namespace, plural, name ) <NEW_... | Get CRD information (kubectl describe output)
:param custom_objects: CustomObjectsApi
:param namespace: The custom resource's namespace
:param plural: the custom resource's plural name
:param name: the custom object's name
:return: object | 625941d7f7d966606f6aa26d |
def send_update(self, msg_type, content): <NEW_LINE> <INDENT> msg = self.message_manager.build(msg_type, content, self.curr_parent) <NEW_LINE> self.iopub_sock.publish(msg) | Send messages on the IOPub socket such
as execution_result or (out/err) stream
:param msg_type: type of IOPub message
:type msg_type: string
:param content: message content
:type content: dict | 625941d730bbd722463cc02e |
def test_create_url_for_hotel_list(): <NEW_LINE> <INDENT> from .tools import create_url_for_hotel_list <NEW_LINE> key = os.environ.get('SKYSCANNER_API_KEY') <NEW_LINE> location_id = '27547145' <NEW_LINE> check_in = '12/04/2016' <NEW_LINE> check_out = '12/10/2016' <NEW_LINE> result = 'http://partners.api.skyscanner.net/... | Test for getting hotel list. | 625941d7627d3e7fe0d690b8 |
def logoutput(meth): <NEW_LINE> <INDENT> @functools.wraps(meth) <NEW_LINE> def wrapper(*args, **kwargs): <NEW_LINE> <INDENT> buf = io.StringIO() <NEW_LINE> with contextlib.redirect_stdout(buf): <NEW_LINE> <INDENT> meth(*args, **kwargs) <NEW_LINE> <DEDENT> return {'content': buf.getvalue()} <NEW_LINE> <DEDENT> return ex... | Decorator to use log output | 625941d77b180e01f3dc4a60 |
def __init__(self, options=None): <NEW_LINE> <INDENT> super(ChartColumn, self).__init__() <NEW_LINE> if options is None: <NEW_LINE> <INDENT> options = {} <NEW_LINE> <DEDENT> self.subtype = options.get('subtype') <NEW_LINE> if not self.subtype: <NEW_LINE> <INDENT> self.subtype = 'clustered' <NEW_LINE> <DEDENT> self.hori... | Constructor. | 625941d74f6381625f114ca2 |
def approximate_r10(lmrs): <NEW_LINE> <INDENT> print('R10 approximation') <NEW_LINE> for lmr in lmrs: <NEW_LINE> <INDENT> decodingf = partial(complexity.r10_complexity, reloverhead=1.02) <NEW_LINE> optimize.set_wait_for( lmr=lmr, overhead=1.02, decodingf=decodingf, ) <NEW_LINE> <DEDENT> r10 = droplets.simulate( partial... | Approximation of R10 performance. | 625941d75166f23b2e1a53bf |
def test_rows(self): <NEW_LINE> <INDENT> opt = MenuOption("AB\nCD", width=6, height=4, on_select=lambda x: print("AB CD!"), subtext="It says some letters", pad_horizontal=1, pad_vertical=1, color=(200, 200, 200)) <NEW_LINE> rows: RenderableArray = opt.rows <NEW_LINE> a: RenderableItem = rows[3][3] <NEW_LINE> assert a[0... | Tests that the MenuOption can render itself to a row x col 2D list of (character, (r, g, b)) tuples. | 625941d7a8370b7717052b05 |
def save_modspec_list(self, mspec_name_new=None): <NEW_LINE> <INDENT> if (mspec_name_new is not None): <NEW_LINE> <INDENT> new_mspec = getDATA(mspec_name_new) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_mspec = getDATA(self.modspeclist.filename) <NEW_LINE> <DEDENT> print("Writing model spectrum list to file: {0:s... | Save the modified model spectrum list
The class model spectrum list is modified to contain the references
to the correct extensions in the model spectra file created.
The method saves the model spectrum list to the disk with a name
given in the input
@param mspec_name_new: name for the modified model spectra file
@ty... | 625941d7a8ecb033257d3333 |
def getFlags(self): <NEW_LINE> <INDENT> pass | Получает флаги настройки объекта SplFileObject | 625941d7fb3f5b602dac38fc |
def get_blocks(self, block_ids): <NEW_LINE> <INDENT> return list( filter( lambda b: b is not None, map(self._get_block_by_id_or_none, block_ids))) | Returns all blocks with the given set of block_ids.
If a block id in the provided iterable does not exist in the block
store, it is ignored.
Args:
block_ids (:iterable:str): an iterable of block ids
Returns
list of block wrappers found for the given block ids | 625941d7f8510a7c17cf9964 |
def arcs_helper(self): <NEW_LINE> <INDENT> arcs_queue = [] <NEW_LINE> for var in self.domains: <NEW_LINE> <INDENT> neighbours = self.crossword.neighbors(var) <NEW_LINE> n = list((var, neighbour) for neighbour in neighbours) <NEW_LINE> for arc in n: <NEW_LINE> <INDENT> arcs_queue.append(arc) <NEW_LINE> <DEDENT> <DEDENT>... | Returns a list of all arcs (nodes that are connected) | 625941d71f5feb6acb0c4db3 |
def __set_status(self, status): <NEW_LINE> <INDENT> old_status = self.status <NEW_LINE> self.status = status <NEW_LINE> if old_status.msg != status.msg or old_status.normal != status.normal: <NEW_LINE> <INDENT> self.callback(status) | This will always set the status, but only fire an event if the message or normalcy changed
:param status: The new status | 625941d7e1aae11d1e749f20 |
def github_latest_release(repo_dict): <NEW_LINE> <INDENT> supported_file_types = ['dmg', 'zip', 'gz'] <NEW_LINE> user = repo_dict['user'] <NEW_LINE> repo = repo_dict['repo'] <NEW_LINE> if not user or not repo: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> dest = str( u'https://api.github.... | Download the latest release based on a repo | 625941d756ac1b37e6264433 |
def findUnfinishedJobs(branch, since=None): <NEW_LINE> <INDENT> pass | Find any `IRosettaUploadJob`s for `branch` that haven't run yet.
:param branch: Branch to find unfinished jobs for.
:param since: Optional cutoff date: ignore jobs older than this.
:return: Any jobs for `branch` (and newer than `since`, if
given) whose status is neither "complete" nor "failed." | 625941d7d10714528d5fff4c |
def makeRequest(url): <NEW_LINE> <INDENT> curl_cmd = CURL_ARGS[:] <NEW_LINE> if args.insecure: curl_cmd += CURL_INSECURE_ARGS <NEW_LINE> curl_cmd += [url] <NEW_LINE> if args.verbosity >= 2: <NEW_LINE> <INDENT> print("command:", *curl_cmd) <NEW_LINE> <DEDENT> response = subprocess.check_output(curl_cmd, timeout=REQ_TIME... | Makes a request to the passed url
This is made difficult by the fact that the DH API hangs if there are too many available
ciphers, therefore we limit ourselves to just one using curl.
There is a good chance this will need changing in the future. | 625941d715fb5d323cde0d79 |
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> buff.write(_struct_i.pack(self.ID)) <NEW_LINE> _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_LIN... | serialize message into buffer
:param buff: buffer, ``StringIO`` | 625941d760cbc95b062c67aa |
def encode_ad_passwd(u): <NEW_LINE> <INDENT> quoted = '"{}"'.format(u) <NEW_LINE> return quoted.encode('utf-16le') | Encode a plain text password for use in the `unicodePwd` attribute. | 625941d73346ee7daa2b2fd4 |
def __init__(self, crop_size, crop_type=0): <NEW_LINE> <INDENT> if crop_type not in {0, 1, 2, 3, 4}: <NEW_LINE> <INDENT> raise ValueError('crop_type must be in {0, 1, 2, 3, 4}') <NEW_LINE> <DEDENT> self.crop_size = crop_size <NEW_LINE> self.crop_type = crop_type | Perform a special crop - one of the four corners or center crop
Arguments
---------
crop_type : integer in {0,1,2,3,4}
0 = center crop
1 = top left crop
2 = top right crop
3 = bottom right crop
4 = bottom left crop | 625941d7d486a94d0b98e3ad |
def test_do_request_user_agent(api_client): <NEW_LINE> <INDENT> with requests_mock.Mocker() as m: <NEW_LINE> <INDENT> m.register_uri('GET', 'https://my.client/page/api/thing/list_things', additional_matcher=lambda req: req.headers['user-agent'] == 'Python API') <NEW_LINE> assert api_client.doRequest('/thing/list_things... | The API client uses a fixed User Agent | 625941d73317a56b86939ebb |
def on_release(self, key): <NEW_LINE> <INDENT> if key in LISTENER_COMBINATION and key in self.keys_pressed: <NEW_LINE> <INDENT> self.keys_pressed.remove(key) | When a key is released, remove it from the set remembering keys | 625941d78e7ae83300e4b234 |
def write_bands(bands_data, filename): <NEW_LINE> <INDENT> warnings.warn( "The 'write_bands' function is deprecated, use 'write' instead", DeprecationWarning ) <NEW_LINE> write(data=bands_data, filename=filename) | .. note:: This function is deprecated, use :func:`write` instead.
Write an AiiDA Data instance to a file in bands_inspect HDF5 format.
Parameters
----------
data :
The AiiDA data instance to be written.
filename :
Path of the file being written to. | 625941d756b00c62f0f148c1 |
def T_shape_LA(modules, script_params): <NEW_LINE> <INDENT> modules['atts'][8][0][0][0] = script_params[0] <NEW_LINE> modules['lgns'][8][0][0][0] = 0.7 <NEW_LINE> modules['lgns'][8][0][1][0] = 0.7 <NEW_LINE> modules['lgns'][8][0][2][0] = 0.7 <NEW_LINE> modules['lgns'][8][0][3][0] = 0.7 <NEW_LINE> modules['lgns'][8][0][... | generates a t-shaped visual input to neural network with parameters given"
Good intensity is about .69625 and this appears to be very sensitive | 625941d7d7e4931a7ee9e185 |
def _exec_cmd(cmd2_app, command: str, echo: bool) -> CommandResult: <NEW_LINE> <INDENT> copy_stdout = StdSim(sys.stdout, echo) <NEW_LINE> copy_stderr = StdSim(sys.stderr, echo) <NEW_LINE> copy_cmd_stdout = StdSim(cmd2_app.stdout, echo) <NEW_LINE> cmd2_app._last_result = None <NEW_LINE> try: <NEW_LINE> <INDENT> cmd2_app... | Helper to encapsulate executing a command and capturing the results
:param cmd2_app: cmd2 app that will run the command
:param command: command line being run
:param echo: if True, output will be echoed to stdout/stderr while the command runs
:return: result of the command | 625941d75166f23b2e1a53c0 |
def test_possible_scenes(self): <NEW_LINE> <INDENT> elem = TestUtil.load_xml('test_files/site3.xml') <NEW_LINE> passage = convert.from_site(elem) <NEW_LINE> scenes.extract_possible_scenes(passage) | Tests that the API isn't broken, not validity of the result. | 625941d7090684286d50ef4e |
def vocab2id(train_data,test_data,vocabfile): <NEW_LINE> <INDENT> vocab=[] <NEW_LINE> for example in train_data+test_data: <NEW_LINE> <INDENT> for w in example.sentence: <NEW_LINE> <INDENT> vocab.append(w) <NEW_LINE> <DEDENT> <DEDENT> words = list(set(vocab)) <NEW_LINE> vocab2id = {w:i for i,w in enumerate(words,1)} <N... | 将训练数据与测试数据中所有出现的单词去重后映射到id
:param train_data:
:param test_data:
:param vocabfile:
:return: 将vocab2id的映射写入磁盘 | 625941d750485f2cf553d002 |
def _process_storage_option( self, custom_resource: CustomResource, storage_option: Optional[Union[str, CloudPakForDataStorageVendor]] ): <NEW_LINE> <INDENT> if storage_option is not None: <NEW_LINE> <INDENT> if isinstance(storage_option, str): <NEW_LINE> <INDENT> custom_resource.spec["storageClass"] = storage_option <... | Adds the given storage option to the given custom resource object
Parameters
----------
custom_resource
custom resource to be modified
storage_option
storage option to be added | 625941d71d351010ab855d82 |
def step_RK4_auto(y, h, f, *args): <NEW_LINE> <INDENT> s1 = f(y, *args) <NEW_LINE> s2 = f(y + (h / 2) * s1, *args) <NEW_LINE> s3 = f(y + (h / 2) * s2, *args) <NEW_LINE> s4 = f(y + h * s3, *args) <NEW_LINE> return y + (h / 6) * (s1 + (2 * s2) + (2 * s3) + s4) | Performing a single step of the Runge-Kutta fourth order method.
This is for general autonomous (time-invariant) systems with additional arguments args.
Parameters:
f: RHS of ODEs to be integrated
y: numerical approximation of w at time t
h: unit/integration step length
args: Arguments... | 625941d75510c4643540f646 |
def CreateList(self, name, mode=None, description=None): <NEW_LINE> <INDENT> url = '%s/lists/create.json' % self.base_url <NEW_LINE> parameters = {'name': name} <NEW_LINE> if mode is not None: <NEW_LINE> <INDENT> parameters['mode'] = mode <NEW_LINE> <DEDENT> if description is not None: <NEW_LINE> <INDENT> parameters['d... | Creates a new list with the give name for the authenticated user.
Args:
name (str):
New name for the list
mode (str, optional):
'public' or 'private'. Defaults to 'public'.
description (str, optional):
Description of the list.
Returns:
twitter.list.List: A twitter.List instance representing the ne... | 625941d74c3428357757c58e |
def get_latest_blog(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> post = ( wp_blog.objects.filter(disabled=False).latest('posted_datetime') ) <NEW_LINE> <DEDENT> except Exception as ex: <NEW_LINE> <INDENT> log.error('Unable to retrieve latest blog post:\n{}'.format(ex)) <NEW_LINE> return None <NEW_LINE> <DEDENT> retu... | retrieve the last posted blog entry (wp_blog object) | 625941d721bff66bcd684bb8 |
def get_point_projection(self, vect=(0, 1, 0), point=None): <NEW_LINE> <INDENT> if point is None: <NEW_LINE> <INDENT> point = [self.x[0], self.y[0], self.z[0]] <NEW_LINE> <DEDENT> xyz = np.transpose([self.x, self.y, self.z]) - point <NEW_LINE> return np.dot(xyz, vect) | Projects each point in the tree (x,y,z) - input_point
to a selected vector. This gives the orientation of
each section according to a vector in space, if normalized,
otherwise it returns the relative length of the section. | 625941d756b00c62f0f148c2 |
def dns_mx(host, mailserver, server=None): <NEW_LINE> <INDENT> mailserver = dns.name.from_text(mailserver) <NEW_LINE> for rdata in _query(host, 'MX', server): <NEW_LINE> <INDENT> if mailserver == rdata.exchange: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> raise TwillAssertionError | >> dns_mx <name> <mailserver> [<name server>]
Assert that <mailserver> is a mailserver for <name>. | 625941d730bbd722463cc02f |
def authn_request(self, context, entity_id): <NEW_LINE> <INDENT> if self.idp_blacklist_file: <NEW_LINE> <INDENT> with open(self.idp_blacklist_file) as blacklist_file: <NEW_LINE> <INDENT> blacklist_array = json.load(blacklist_file)['blacklist'] <NEW_LINE> if entity_id in blacklist_array: <NEW_LINE> <INDENT> satosa_loggi... | Do an authorization request on idp with given entity id.
This is the start of the authorization.
:type context: satosa.context.Context
:type entity_id: str
:rtype: satosa.response.Response
:param context: The current context
:param entity_id: Target IDP entity id
:return: response to the user agent | 625941d74e696a04525c96b3 |
def one_one_alignment(srcs, tgts): <NEW_LINE> <INDENT> with open(os.path.join(M2M_ALIGNER_PATH, 'input'), 'w', encoding='utf8') as file: <NEW_LINE> <INDENT> for src, tgt in zip(srcs, tgts): <NEW_LINE> <INDENT> src = [token.replace(' ', '*') for token in src] <NEW_LINE> tgt = [token.replace(' ', '*') for token in tgt] <... | Gets alignments on how seq2 is aligned to seq1.
Args:
srcs: list of sequences, eg. [['i', 'n', 'd', 'i', 'a'], .. ]
tgts: list of sequences eg. [['I', 'N', 'D', 'I', 'A], .. ]
Returns:
alignment: list of list containing index which ith token of tgt is mapped to
eg. [[0, 1, 2, 3, 4], .. ] | 625941d744b2445a339322fc |
def update_lifecycle_rules(self, rule, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.update_lifecycle_rules_with_http_info(rule, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.update_lifecycle_rules_wit... | Modify an object lifecycle rule.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.update_lifecycle_rules(rule, c... | 625941d7d164cc6175782fb6 |
def load_config(filename): <NEW_LINE> <INDENT> with open(filename, 'r') as jfile: <NEW_LINE> <INDENT> json_network = K.models.model_from_json(jfile.read()) <NEW_LINE> return json_network | load json configuration | 625941d7d486a94d0b98e3ae |
def residualAnalysis(self, disaggregatedFile, lowResFilename, lowResQualityFilename = None, doCorrection = True): <NEW_LINE> <INDENT> if not os.path.isfile(str(disaggregatedFile)): <NEW_LINE> <INDENT> scene_HR = disaggregatedFile <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> scene_HR = gdal.Open(disaggregatedFile) <NEW... | Perform residual analysis and (optional) correction on the
disaggregated file (see [Gao2012] 2.4).
Parameters
----------
disaggregatedFile: string or GDAL file object
If string, path to the disaggregated image file; if gdal file
object, the disaggregated image.
lowResFilename: string
Path to the low-reso... | 625941d7097d151d1a2230bf |
def __init__(self, color, brand, volume): <NEW_LINE> <INDENT> self.color = color <NEW_LINE> self.brand = brand <NEW_LINE> self.volume = volume | a little something | 625941d710dbd63aa1bd2e0a |
def deep_update(source, overrides): <NEW_LINE> <INDENT> if sys.version_info >= (3, 0): <NEW_LINE> <INDENT> items = overrides.items() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> items = overrides.iteritems() <NEW_LINE> <DEDENT> for key, value in items: <NEW_LINE> <INDENT> if isinstance(value, collections.Mapping) and ... | Update a nested dictionary or similar mapping.
Modify ``source`` in place. | 625941d78c3a873295158624 |
def load_all_loan_requests(self, user): <NEW_LINE> <INDENT> assert isinstance(user, User) <NEW_LINE> user = self._get_user(user) <NEW_LINE> pending_loan_requests = [] <NEW_LINE> for pending_loan_request_id in user.loan_request_ids: <NEW_LINE> <INDENT> if self.db.get(LoanRequest.type, pending_loan_request_id).status[use... | Display all pending loan requests for the specific bank
:param user: The bank :any:`User`
:type user: :any:`User`
:return: A list of lists containing the :any: 'LoanRequest's and the :any: 'House's
:rtype: list | 625941d75e10d32532c5f18e |
@view_config(name='render_tree_navigation', permission='view', renderer='kotti:templates/edit/nav-tree.pt') <NEW_LINE> @view_config(name='navigate', permission='view', renderer='kotti:templates/edit/nav-tree-view.pt') <NEW_LINE> def render_tree_navigation(context, request): <NEW_LINE> <INDENT> from kotti.views.util imp... | Renders the navigation view.
:result: Dictionary passed to the template for rendering.
:rtype: dict | 625941d7b5575c28eb68e269 |
def make_text(chains): <NEW_LINE> <INDENT> keys = choice(list(chains.keys())) <NEW_LINE> words = [keys[0], keys[1]] <NEW_LINE> word = choice(chains[keys]) <NEW_LINE> while word is not None: <NEW_LINE> <INDENT> keys = (keys[1], word) <NEW_LINE> words.append(word) <NEW_LINE> word = choice(chains[keys]) <NEW_LINE> <DEDENT... | Return text from chains. | 625941d79c8ee82313fbb9dd |
def test_dtype_int_multigraph(self): <NEW_LINE> <INDENT> G = nx.MultiGraph(nx.complete_graph(3)) <NEW_LINE> A = nx.to_numpy_matrix(G, dtype=int) <NEW_LINE> assert A.dtype == int | Test that setting dtype int actually gives an integer matrix.
For more information, see GitHub pull request #1363. | 625941d7d8ef3951e32437a5 |
def match_file(self, file_, **kargs): <NEW_LINE> <INDENT> return self.get_match_file()(file_, **kargs) | Parse the contents of a file, returning a sequence of
(results, stream) pairs and using a stream internally. | 625941d721a7993f00bc7f5a |
def pull_data(): <NEW_LINE> <INDENT> symbol1 = ['EUR/USD', 'USD/JPY', 'USD/CAD'] <NEW_LINE> symbol2 = ['USD/CHF', 'AUD/USD', 'GBP/USD'] <NEW_LINE> symbol3 = ['NZD/USD'] <NEW_LINE> overall_symbol = [symbol1, symbol2, symbol3] <NEW_LINE> API_KEY_list = [API_KEY1, API_KEY2, API_KEY3] <NEW_LINE> price_1h = {} <NEW_LINE> fo... | Pulls data from fcsapi for historical data of 7 major pairs
Timescale = 1hr | 625941d7a17c0f6771cbe2b7 |
def grab_snapshot_request( self, current_state: GuestState, new_state: GuestState, set_values: Optional[Dict[str, Any]] = None, **details: Any ) -> None: <NEW_LINE> <INDENT> if self.result: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> assert self.snapshotname <NEW_LINE> assert self.guestname <NEW_LINE> r = _update_sn... | "Grab" the snapshot for task by changing its state.
**OUTCOMES:**
* ``SUCCESS`` if the guest does not exist or is not in the given state.
* ``FAIL`` | 625941d7435de62698dfdeb5 |
def save_data(self, abv, plot_summary): <NEW_LINE> <INDENT> path = os.path.join(os.path.dirname(__file__), 'data', abv + '.json') <NEW_LINE> self.data.to_json(path) <NEW_LINE> path = os.path.join(os.path.dirname(__file__), 'data', abv + '_sum.csv') <NEW_LINE> plot_summary.to_csv(path) | Saves the data to a JSON | 625941d73539df3088e2e5b2 |
def to_JSON(self): <NEW_LINE> <INDENT> return json.dumps({"reference_time": self._reference_time, "location": json.loads(self._location.to_JSON()), "interval": self._interval, "so2_samples": self._so2_samples, "reception_time": self._reception_time, }) | Dumps object fields into a JSON formatted string
:returns: the JSON string | 625941d8379a373c97cfadad |
@pytest.fixture <NEW_LINE> def git_config_cmd(git_cmd): <NEW_LINE> <INDENT> return lambda *args: git_cmd(*(('config', '--local') + args)) | Provide a Git config command helper. | 625941d7cdde0d52a9e5329c |
def test_home_view_contains_link_to_topics_page(self): <NEW_LINE> <INDENT> board_topics_url = reverse('board_topics', kwargs={'board_id': self.board.pk}) <NEW_LINE> self.assertContains(self.response, 'href="{}"'.format(board_topics_url)) | test if the response body contains a given text. | 625941d85fdd1c0f98dc049b |
def fshift(sig, theta): <NEW_LINE> <INDENT> return sig*np.exp(1j*2*np.pi*theta*(np.arange(0,len(sig)))) | Frequency shift a signal. | 625941d860cbc95b062c67ab |
def test_write(self): <NEW_LINE> <INDENT> credential = objects.Credential( credential_type=enums.CredentialType.USERNAME_AND_PASSWORD, credential_value=objects.UsernamePasswordCredential( username="Fred", password="password1" ) ) <NEW_LINE> stream = utils.BytearrayStream() <NEW_LINE> credential.write(stream) <NEW_LINE>... | Test that a Credential struct can be written to a data stream. | 625941d84f6381625f114ca3 |
def _winrm_connect(self): <NEW_LINE> <INDENT> display.vvv("ESTABLISH WINRM CONNECTION FOR USER: %s on PORT %s TO %s" % (self._winrm_user, self._winrm_port, self._winrm_host), host=self._winrm_host) <NEW_LINE> netloc = '%s:%d' % (self._winrm_host, self._winrm_port) <NEW_LINE> endpoint = urlunsplit((self._winrm_scheme, n... | Establish a WinRM connection over HTTP/HTTPS. | 625941d8fbf16365ca6f642e |
def dequeue_and_transmit_packer(self): <NEW_LINE> <INDENT> assert (len(self.queue) > 0) <NEW_LINE> packet_size = self.queue.pop(0) <NEW_LINE> self.transmit_packet(packet_size) <NEW_LINE> self.change_state(Node.TX) <NEW_LINE> self.logger.log_queue_length(self, len(self.queue)) | Utility method to transmit the next packet in the queue. | 625941d816aa5153ce3626df |
def define_property(self, name, field_level, value=None, readable=True, writable=True): <NEW_LINE> <INDENT> if field_level not in ["internal", "private"]: <NEW_LINE> <INDENT> raise ValueError("'field_level' must be in ['internal', 'private'].") <NEW_LINE> <DEDENT> if field_level == "internal": <NEW_LINE> <INDENT> field... | define_property(self, name, value=None, readable=True, writable=True) -> None
define a property
Parameters
----------
self : a class instance
a class instance to define the property in
name : str
name of the property
field_level : str
level of accessibility
value : object (default : No... | 625941d88e05c05ec3eea5de |
def copy(src_net, tar_net): <NEW_LINE> <INDENT> tar_net.load_state_dict(src_net.state_dict()) | Copy model weights from src to target | 625941d85f7d997b87174d01 |
@task <NEW_LINE> def test(fast=False): <NEW_LINE> <INDENT> with lcd(BASEDIR): <NEW_LINE> <INDENT> if fast: <NEW_LINE> <INDENT> local('virtenv/bin/coverage run runtests.py -v2 --failfast') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> local('virtenv/bin/coverage run runtests.py -v2') <NEW_LINE> <DEDENT> local('virtenv/b... | Tests code with django unittests | 625941d80383005118ecf84a |
def decompose_signal(gsr_l): <NEW_LINE> <INDENT> if len(gsr_l)<20: <NEW_LINE> <INDENT> return 'NA','NA' <NEW_LINE> <DEDENT> b,a = signal.butter(4,0.5/2) <NEW_LINE> gsr_filt = signal.filtfilt(b,a,gsr_l) <NEW_LINE> b,a = signal.butter(4,0.05/2,'highpass') <NEW_LINE> scr = signal.filtfilt(b,a,gsr_filt) <NEW_LINE> scl = [x... | Decompose GSR signal into SCR and SCL respectively. | 625941d8379a373c97cfadae |
def change_rate(self, new_baud_rate): <NEW_LINE> <INDENT> self.debug_print("Setting baud to", new_baud_rate) <NEW_LINE> with self.baud_rate.get_lock(): <NEW_LINE> <INDENT> self.baud_rate.value = new_baud_rate <NEW_LINE> <DEDENT> self.debug_print("Set baud to", self.baud_rate.value) | For external use
:param new_baud_rate:
:return: | 625941d87b25080760e396c0 |
def hyperg(k, n, K, N): <NEW_LINE> <INDENT> return comb(k, K)*comb(n-k, N-K)/comb(n, N) | Probability of drawing exactly k objects in n draws,
given that there are K objects in N total | 625941d85fc7496912cc3be6 |
def run(self): <NEW_LINE> <INDENT> now = datetime.now() <NEW_LINE> if self.lock: <NEW_LINE> <INDENT> threshold = getattr(settings, 'CRONKITE_LOCK_TIMEOUT', None) <NEW_LINE> if threshold is None or abs(now - self.lock).seconds < threshold: <NEW_LINE> <INDENT> raise exceptions.JobIsLocked <NEW_LINE> <DEDENT> <DEDENT> try... | Execute the job one time and update the next_run timestamp. | 625941d845492302aab5e52e |
def from_xmcda(self, xmcda): <NEW_LINE> <INDENT> if xmcda.tag != 'alternativeAffectation': <NEW_LINE> <INDENT> raise TypeError('alternativeAffectation::invalid tag') <NEW_LINE> <DEDENT> altid = xmcda.find('alternativeID') <NEW_LINE> self.id = altid.text <NEW_LINE> catid = xmcda.find('categoryID') <NEW_LINE> self.catego... | Read the MCDA object from XMCDA input | 625941d821a7993f00bc7f5b |
def test_get_entity_is_working_properly(self): <NEW_LINE> <INDENT> from stalker_pyramid.testing import DummyRequest <NEW_LINE> request = DummyRequest() <NEW_LINE> request.matchdict['id'] = self.test_structure1.id <NEW_LINE> structure_view = structure.StructureViews(request) <NEW_LINE> response = structure_view.get_enti... | testing if get_entity() method is working properly
| 625941d82eb69b55b151cb19 |
@Builder.register(PES) <NEW_LINE> def build_pes(model, pes, rule): <NEW_LINE> <INDENT> conn = rule.connection <NEW_LINE> error = Signal(np.zeros(rule.size_in), name="PES:error") <NEW_LINE> model.add_op(Reset(error)) <NEW_LINE> model.sig[rule]['in'] = error <NEW_LINE> acts = model.build(Lowpass(pes.pre_tau), model.sig[c... | Builds a `.PES` object into a model.
Calls synapse build functions to filter the pre activities,
and adds several operators to implement the PES learning rule.
Unlike other learning rules, there is no corresponding `.Operator`
subclass for the PES rule. Instead, the rule is implemented with
generic operators like `.El... | 625941d830c21e258bdfa706 |
def is_result_ok(results, requirements): <NEW_LINE> <INDENT> results = sorted(results) <NEW_LINE> for res, req in zip(results, requirements): <NEW_LINE> <INDENT> if res < req: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Czy zgłoszenie jest dobre dla danego wyniku rzutu?
is_result
@param results: list[int]
@param requirements: list[int]
:rtype: bool
>>> is_result_ok([1,1,1,2],[1,1,1,1])
True
>>> is_result_ok([1,1,1,2],[1,1,1,2])
True
>>> is_result_ok([1,1,1,2],[1,1,1,3])
False
>>> is_result_ok([1,2,2,3,4,6], [1,1,1,1,1,1])
True
>>> is... | 625941d899fddb7c1c9de5f9 |
def __init__(self, pika_params): <NEW_LINE> <INDENT> self.params = pika_params <NEW_LINE> self.conn = pika.BlockingConnection(self.params) <NEW_LINE> self.chan = self.conn.channel() | Constructor | 625941d8be383301e01b56eb |
def nameToStructure(self, name, params=None): <NEW_LINE> <INDENT> if params is None: <NEW_LINE> <INDENT> params = "" <NEW_LINE> <DEDENT> self._setSessionId() <NEW_LINE> return self.IndigoObject(self, self._checkResult(Indigo._lib.indigoNameToStructure(name.encode(ENCODE_ENCODING), params.encode(ENCODE_ENCODING)))) | Converts a chemical name into a corresponding structure
Args:
* name - a name to parse
* params - a string containing parsing options or nullptr if no options are changed
Raises:
Exception if parsing fails or no structure is found
::
Since version 1.3.0 | 625941d8a17c0f6771cbe2b8 |
def ldap_provider_group_provider_exists(handle, group_name, name, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> mo = ldap_provider_group_provider_get(handle, group_name, name, caller="ldap_provider_group_provider_exists") <NEW_LINE> <DEDENT> except UcsOperationError: <NEW_LINE> <INDENT> return (False, None) <... | checks if provider added ldap provider group
Args:
handle (UcsHandle)
group_name (string): ldap provider group name
name (string): ldap provider name
**kwargs: key-value pair of managed object(MO) property and value, Use
'print(ucscoreutils.get_meta_info(<classid>).config_props)'
... | 625941d8a79ad161976cc3ae |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.