code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get(node_key:str, property_name:str, default=None): <NEW_LINE> <INDENT> node_names = split_node_key(node_key) <NEW_LINE> node = root <NEW_LINE> try: <NEW_LINE> <INDENT> property = node.properties[property_name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> property = default <NEW_LINE> <DEDENT> for node_... | Lookup value of a property in the hierarchy.
Args:
node_key: dotted name, typically a module's __name__ attribute.
property_name: the global variable's name e.g. 'lut' for pyqtgraph colormap lookup table default.
default: default value to return if property not found
Returns:
property value | 625941bade87d2750b85fc2a |
def cleanup(self): <NEW_LINE> <INDENT> LOGGER.info('Cleaning up after observation %s!' % self.archive_name) <NEW_LINE> self.arch_files_remote = None <NEW_LINE> self.arch_files_local = [] <NEW_LINE> self.arch_urls = None <NEW_LINE> self.ar_files = None <NEW_LINE> self.psr_archive = None <NEW_LINE> rmtree(self.local_arch... | short fix, use multiprocessing | 625941ba32920d7e50b28069 |
def freq_handler(freqdict_entry,site,ads): <NEW_LINE> <INDENT> perfect_matches = [] <NEW_LINE> partial_matches = [] <NEW_LINE> if self.frequency_surface_names is None: <NEW_LINE> <INDENT> self.frequency_surface_names = [] <NEW_LINE> <DEDENT> for entry in freqdict_entry: <NEW_LINE> <INDENT> masked = [entry[0] in self.fr... | Returns a single list of frequencies from a freqdict_entry, which is a list
of all frequency data for a given species. Entries matching both site
and surface (if specified in self.frequency_surface_names) are preferred over
those that only match surface. If more than match of the highest validity
is found, the mean o... | 625941bae8904600ed9f1dc5 |
def plot_projs_topomap(projs, layout=None, cmap='RdBu_r', sensors='k,', colorbar=False, res=256, size=1, show=True): <NEW_LINE> <INDENT> import matplotlib.pyplot as plt <NEW_LINE> if layout is None: <NEW_LINE> <INDENT> from .layouts import read_layout <NEW_LINE> layout = read_layout('Vectorview-all') <NEW_LINE> <DEDENT... | Plot topographic maps of SSP projections
Parameters
----------
projs : list of Projection
The projections
layout : None | Layout | list of Layout
Layout instance specifying sensor positions (does not need to be
specified for Neuromag data). Or a list of Layout if projections
are from different sensor t... | 625941ba6fece00bbac2d5d8 |
def get_schema_validation_errors(action_data, schema, allow_unknown_fields=False): <NEW_LINE> <INDENT> errors = [] <NEW_LINE> for name, field in getFieldsInOrder(schema): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> value = action_data[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> if not field.required... | Validate a dict against a schema.
Return a list of basic schema validation errors (required fields,
constraints, but doesn't check invariants yet).
Loosely based on zope.schema.getSchemaValidationErrors, but:
- Processes fields in schema order
- Handles dict subscription access instead of object attribute access
- R... | 625941baa79ad161976cbfe1 |
def defSix(my, ny): <NEW_LINE> <INDENT> if type(my) == tuple or type(ny) == tuple: <NEW_LINE> <INDENT> if type(my) == tuple: <NEW_LINE> <INDENT> my = list(my) <NEW_LINE> <DEDENT> if type(ny) == tuple: <NEW_LINE> <INDENT> ny = list(ny) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> if type(my) != frozenset: <NEW... | Check wheter calculation of linear factor is allowed.
if there are contradictory parts or a part is ff
then reject and return false(ff)
Input: two ltl formulas
Output: Union of both or false. | 625941ba63f4b57ef0000fbe |
def _file_archive_hash_paths(self, named_paths=None): <NEW_LINE> <INDENT> if named_paths is None: <NEW_LINE> <INDENT> named_paths = sorted( self._working_dir_mgr.name_to_path('archive').items()) <NEW_LINE> <DEDENT> for name, path in named_paths: <NEW_LINE> <INDENT> if not name: <NEW_LINE> <INDENT> name = self._working_... | Helper function for the *upload_args methods. The names of
archives to pass to the ``--files`` switch of ``spark-submit``,
since we can't use ``--archives``.
The names in *named_paths* should be of the archive destination
(the 'archive' type in WorkingDirManager)
not of the filename we're going to copy the archive to ... | 625941bae64d504609d746dd |
def make_payment(self, id, amount): <NEW_LINE> <INDENT> if id in self.accounts: <NEW_LINE> <INDENT> return self.accounts[id].make_payment(amount, self.current_date) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('Unknown account id') <NEW_LINE> return 0 | Make payment on specified account | 625941ba1f5feb6acb0c49f1 |
def format(self, *args, **kwargs): <NEW_LINE> <INDENT> name = self.formatter_name <NEW_LINE> cache = getattr(self, '_formatter_cache', None) <NEW_LINE> if not cache or name != cache[0]: <NEW_LINE> <INDENT> formatter = formatters.registry.get(name)(self) <NEW_LINE> self._formatter_cache = (name, formatter) <NEW_LINE> <D... | Convenience method for formatting data relative to this concept's
associated formatter. To prevent redundant initializations (say, in
a tight loop) the formatter instance is cached until the formatter
name changes. | 625941ba4428ac0f6e5ba68e |
def to_pair_of_standard_tableaux(self): <NEW_LINE> <INDENT> from sage.combinat.tableau import Tableau <NEW_LINE> n = self.semilength() <NEW_LINE> if n == 0: <NEW_LINE> <INDENT> return (Tableau([]), Tableau([])) <NEW_LINE> <DEDENT> elif self.height() == n: <NEW_LINE> <INDENT> T = Tableau([list(range(1, n + 1))]) <NEW_LI... | Convert ``self`` to a pair of standard tableaux of the same shape and
of length less than or equal to two.
EXAMPLES::
sage: DyckWord([1,0,1,0]).to_pair_of_standard_tableaux()
([[1], [2]], [[1], [2]])
sage: DyckWord([1,1,0,0]).to_pair_of_standard_tableaux()
([[1, 2]], [[1, 2]])
sage: DyckWord([1,1,... | 625941ba7c178a314d6ef2f6 |
def interval_cardinality(self): <NEW_LINE> <INDENT> return len(list(self.lower_contained_intervals())) | Return the cardinality of the interval, i.e., the number of elements
(binary trees or Dyck words) in the interval represented by ``self``.
Not to be confused with :meth:`size` which is the number of
vertices.
EXAMPLES::
sage: TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]).interval_cardinality()
4
sage:... | 625941ba287bf620b61d390a |
def run_Vagrant(node, command, input): <NEW_LINE> <INDENT> return run_Command( "vagrant ssh %s -c \"%s\"" % (node, command,), input, ) | Run a command using 'vagrant ssh <node> -c <command>
:param node: The name of the vagrant node to run the command
:type node: ``list`` of ``bytes``.
:param command: The command to run via vagrant ssh on the node
:type command: ``list`` of ``bytes``.
:return: stdout as ``bytes`` | 625941ba4f88993c3716bf10 |
def __iter__(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Abstract iterator must be implemented in a subclass. | 625941ba6e29344779a624b1 |
@view_config(context=APIResource, name='fetch', renderer='json', permission=NO_PERMISSION_REQUIRED) <NEW_LINE> @argify(wheel=bool, prerelease=bool) <NEW_LINE> def fetch_requirements(request, requirements, wheel=True, prerelease=False): <NEW_LINE> <INDENT> if not request.access.can_update_cache(): <NEW_LINE> <INDENT> re... | Fetch packages from the fallback_url
Parameters
----------
requirements : str
Requirements in the requirements.txt format (with newlines)
wheel : bool, optional
If True, will prefer wheels (default True)
prerelease : bool, optional
If True, will allow prerelease versions (default False)
Returns
-------
pk... | 625941ba7d847024c06be15d |
def _priority(self, key): <NEW_LINE> <INDENT> return self.attribute_definition[key].priority | get priority of attribute key | 625941bae5267d203edcdb3d |
def get_driver_status(self): <NEW_LINE> <INDENT> self.check_validity() <NEW_LINE> return GetDriverStatus(*self.ipcon.send_request(self, BrickSilentStepper.FUNCTION_GET_DRIVER_STATUS, (), '', 16, 'B B B ! B ! B B')) | Returns the current driver status.
* Open Load: Indicates if an open load is present on phase A, B or both. This could mean that there is a problem
with the wiring of the motor. False detection can occur in fast motion as well as during stand still.
* Short To Ground: Indicates if a short to ground is present on ph... | 625941ba31939e2706e4cd0c |
def host_exists(host, port): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> socket.getaddrinfo(host, port) <NEW_LINE> <DEDENT> except socket.gaierror: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Determine whether or not the given host exists. Return true if hosts
exists, false otherwise. | 625941ba56ac1b37e6264072 |
def __init__(self, method_type, route, template, dictionary): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.method_type = method_type <NEW_LINE> self.route_url = route <NEW_LINE> self.template = template <NEW_LINE> self.dictionary = dictionary <NEW_LINE> self._compiled_url = self.compile_route_to_regex() | Class used for view routes.
This class should be returned when a view is called on an HTTP route.
This is useful when returning a view that doesn't need any special logic and only needs a dictionary.
Arguments:
method_type {string} -- The method type (GET, POST, PUT etc)
route {string} -- The current route (/... | 625941ba004d5f362079a1d3 |
def __init__(self, obj, parent=None): <NEW_LINE> <INDENT> print ("######## STEREO '%s' INITIALIZING ########" % obj.name) <NEW_LINE> super(self.__class__,self).__init__(obj, parent) <NEW_LINE> self.num_cameras = 0 <NEW_LINE> self.camera_list = [] <NEW_LINE> for child in obj.children: <NEW_LINE> <INDENT> try: <NEW_LINE>... | Constructor method.
Receives the reference to the Blender object.
The second parameter should be the name of the object's parent. | 625941ba99fddb7c1c9de22f |
def remove_chat_context(self, ctx): <NEW_LINE> <INDENT> self.manager.remove_chat_context(ctx) | Remove a chat context | 625941ba15fb5d323cde09a7 |
def _X_ik_star(self, i: v.Species, k: v.Species): <NEW_LINE> <INDENT> X_ik = self._n_ik_star(i, k) / sum(self._n_ik_star(a, x) for a, x in self._pairs) <NEW_LINE> return X_ik | Return the endmember fraction, X^*_i/k, for a the pair i/k.
Follows Lambotte JCT 2011 Eq. A.5, but this is simply Poschmann Eq. 6
with n^*_ik instead of n_ik.
This term is only used in the pair part of the entropy and as a
sub-expression of F_i (also part of the pair part of the entropy). | 625941ba8c3a87329515825b |
def test_set(filler_set, target_set, switch_set, index): <NEW_LINE> <INDENT> display_set = [] <NEW_LINE> for word in filler_set[index]: <NEW_LINE> <INDENT> display_set.append(word) <NEW_LINE> <DEDENT> display_set.append(target_set[index]) <NEW_LINE> display_set.append(switch_set[index]) <NEW_LINE> random.shuffle(displa... | Function to combine the filler, target and switch words into one set (at the
specified index), shuffle and display it for n seconds, then clear the screen,
replace the target word with the switch word of the next set up (index + 1,
or 0 if index is equal to the last set), ask the player to enter the target
word (i.e. t... | 625941ba30bbd722463cbc60 |
@Moduleloader.setup <NEW_LINE> def setup_quoter(ts3bot): <NEW_LINE> <INDENT> global bot, dont_send <NEW_LINE> bot = ts3bot <NEW_LINE> ts3conn = bot.ts3conn <NEW_LINE> for g in ts3conn.servergrouplist(): <NEW_LINE> <INDENT> if g.get('name', '') in ["Guest", "Admin Server Query"]: <NEW_LINE> <INDENT> dont_send.append(int... | Setup the quoter. Define groups not to send quotes to.
:return: | 625941ba9c8ee82313fbb611 |
def select_output_file(self): <NEW_LINE> <INDENT> filename = QFileDialog.getSaveFileName(self.dlg, "Select output file ","", '*.csv') <NEW_LINE> self.dlg.lineEdit.setText(filename) | This opens a file browser with where to save | 625941ba66656f66f7cbc047 |
def test_deny_list(self): <NEW_LINE> <INDENT> option = ImageClassifierOptions(label_deny_list=_DENY_LIST) <NEW_LINE> classifier = ImageClassifier(_MODEL_FILE, options=option) <NEW_LINE> categories = classifier.classify(self.image) <NEW_LINE> for category in categories: <NEW_LINE> <INDENT> label = category.label <NEW_LI... | Test the label_deny_list option. | 625941ba925a0f43d2549d10 |
def main(): <NEW_LINE> <INDENT> f = open('password_v3.0.txt','r') <NEW_LINE> for line in f: <NEW_LINE> <INDENT> print('read:{}'.format(line)) <NEW_LINE> <DEDENT> f.close() | 主函数 | 625941babf627c535bc13073 |
def nettoie_mieux(ZZ, factor=2.0): <NEW_LINE> <INDENT> ZZr = ZZ.copy() <NEW_LINE> for i in range(ZZ.shape[1]): <NEW_LINE> <INDENT> iZZ = ZZ[:,i] <NEW_LINE> thresh = factor*np.median(iZZ) <NEW_LINE> ZZr[iZZ<thresh,i] = 1.0 <NEW_LINE> <DEDENT> return ZZr | clean noise in matrix - hard thresholding columnwise | 625941bad164cc6175782beb |
def _makeSybCstr(self, addr, db, uid, pwd, **kwds): <NEW_LINE> <INDENT> if not (addr and db): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> cs = self._getrawcs("sybase") <NEW_LINE> if not cs: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> miscs = [] <NEW_LINE> if "autoCP" in kwds: <NEW_LINE> <INDENT> if "cha... | make a connect string for sybase connection
if you want a direct connect, call getSybConn() instead
@param addr: IP of the server
@param uid & pwd: the userId and password
@param tests: the key=value pair with ; as delimiter
@param autoCP: get the code page automatically | 625941ba50812a4eaa59c1c1 |
def md_cmd( self, f, c, p, o, po, out, name='MDRUN', num_threads=6, t='', *a, **kw): <NEW_LINE> <INDENT> rc = self.grompp(f, c, p, o, po, t=t, **kw) <NEW_LINE> cmd = [ MDRUN, '-s', o, '-deffnm', out] <NEW_LINE> return self.proc_cmd( cmd=cmd, cmd_name=name, pc=rc, nt=num_threads, *a, **kw) | For generating MDRUN commands | 625941bab57a9660fec3371d |
@plugin(native="systemctl") <NEW_LINE> def hybridsleep(jarvis, s): <NEW_LINE> <INDENT> os.system("sudo systemctl hybrid-sleep") | Hybrid sleep.
Will quickly wake up but also survive power cut.
Performs both suspend AND hibernate.
Will quickly wake up but also survive power cut. | 625941baac7a0e7691ed3f76 |
def tag_parser(element, default): <NEW_LINE> <INDENT> tags = [] <NEW_LINE> all_tags = element.findall('tag') <NEW_LINE> for tag in all_tags: <NEW_LINE> <INDENT> key = tag.attrib['k'] <NEW_LINE> val = tag.attrib['v'] <NEW_LINE> tag_dict = {'id' : element.attrib['id']} <NEW_LINE> tag_dict['value'] = fc_cleaner.process(ke... | Adds an attribute dictionary for each child element to a list | 625941baadb09d7d5db6c630 |
def list(self, start, end, metadata=None): <NEW_LINE> <INDENT> if metadata is None: <NEW_LINE> <INDENT> metadata = {} <NEW_LINE> <DEDENT> opts = { 'start': start.isoformat(), 'end': end.isoformat() } <NEW_LINE> if metadata: <NEW_LINE> <INDENT> opts['metadata'] = metadata <NEW_LINE> <DEDENT> qparams = {} <NEW_LINE> for ... | List volume usages.
List volume usages between start and end that also have the provided
metadata.
:param start: Datetime
:param end: Datetime
:param metadata: json | 625941ba76d4e153a657e9cd |
def main(): <NEW_LINE> <INDENT> updater = Updater("487836253:AAEQRmd6SaK3U22XYnsFzPWqLJEAnBACHRY") <NEW_LINE> dp = updater.dispatcher <NEW_LINE> dp.add_handler(CommandHandler("find", find)) <NEW_LINE> updater.start_polling() <NEW_LINE> updater.idle() | Start the bot. | 625941bab57a9660fec3371e |
def get_transform(self): <NEW_LINE> <INDENT> return self._transform | Return the `.Transform` associated with this scale. | 625941bae1aae11d1e749b51 |
def _Enter(data, frame_name, is_constant=False, parallel_iterations=10, use_ref=True, use_input_shape=True, name=None): <NEW_LINE> <INDENT> data = ops.internal_convert_to_tensor_or_indexed_slices(data, as_ref=True) <NEW_LINE> if isinstance(data, ops.Tensor): <NEW_LINE> <INDENT> if data.dtype._is_ref_dtype and use_ref: ... | Creates or finds a child frame, and makes `data` available to it.
The unique `frame_name` is used by the `Executor` to identify frames. If
`is_constant` is true, `data` is a constant in the child frame; otherwise
it may be changed in the child frame. At most `parallel_iterations`
iterations are run in parallel in the ... | 625941ba090684286d50eb7e |
def define_song_inputs(self): <NEW_LINE> <INDENT> lengthsatisfy = False <NEW_LINE> while lengthsatisfy == False: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> songlength = int(input("How long in seconds do you want your song to be?\n")) <NEW_LINE> if songlength > 0: <NEW_LINE> <INDENT> lengthsatisfy = True <NEW_LINE> <D... | Takes all inputs necessary to generate the song.
Side Effects:
Stores 'songlength' input
Stores 'inputkey' input
Stores 'songname' input
Prints "Invalid song length" if input is less than 1.
Prints "Invalid key" if the key input is incorrect. | 625941ba23849d37ff7b2f2f |
def insert(self, head, data): <NEW_LINE> <INDENT> temp = Node(data) <NEW_LINE> if head is None: <NEW_LINE> <INDENT> head = temp <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> last = head <NEW_LINE> while last.next is not None: <NEW_LINE> <INDENT> last = last.next <NEW_LINE> <DEDENT> last.next = temp <NEW_LINE> <DEDENT> ... | Insert a node to the end of the list. | 625941ba23e79379d52ee405 |
def test_months_with_28_29(): <NEW_LINE> <INDENT> for item in MONTHS_WITH_28_or_29: <NEW_LINE> <INDENT> assert days_in_month(item) == "28 or 29" | Test months with 28 or 29 days | 625941ba2eb69b55b151c749 |
def save(self, *args, **kwargs): <NEW_LINE> <INDENT> self = tag_presave(self) <NEW_LINE> super(Tag, self).save() | Autopopulates the hash_id. | 625941baa4f1c619b28afede |
def get_sheetnames(self): <NEW_LINE> <INDENT> return list(self._book.dict.keys()) | return a list with the names of all sheets in this book | 625941ba9f2886367277a72e |
def get_serialnumber(self) -> str: <NEW_LINE> <INDENT> if self._current_cert == None: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> serialstring = "" <NEW_LINE> serialnumber = "{0:x}".format(self._current_cert.serial_number) <NEW_LINE> for i in range(0, len(serialnumber), 2): <NEW_LINE> <INDENT> serialstring += ser... | Return serialnumber of current certificate | 625941bab7558d58953c4db8 |
def set_move_to_get_here(self,move): <NEW_LINE> <INDENT> self.move_to_get_here = move | setting which operator is required to get to this node | 625941ba7b25080760e392f8 |
def delete_all_content(self): <NEW_LINE> <INDENT> self.delete_medias() <NEW_LINE> self.delete_pages() <NEW_LINE> self.delete_widgets() | Delete all content WordPress | 625941ba5fc7496912cc3823 |
def __init__(self, max_size = 8, max_waiting_num = 8): <NEW_LINE> <INDENT> DictDataContainer.__init__(self, max_waiting_num) <NEW_LINE> DataContainerWithMaxSize.__init__(self, max_size, max_waiting_num) | Initialize data container instance. | 625941ba1d351010ab8559ba |
def _get_resp_body_errors(self): <NEW_LINE> <INDENT> if self._resp_body_errors and len(self._resp_body_errors) > 0: <NEW_LINE> <INDENT> return self._resp_body_errors <NEW_LINE> <DEDENT> errors = [] <NEW_LINE> warnings = [] <NEW_LINE> resp_codes = [] <NEW_LINE> if self.verb is None: <NEW_LINE> <INDENT> return errors <NE... | Parses the response content to pull errors.
Child classes should override this method based on what the errors in the
XML response body look like. They can choose to look at the 'ack',
'Errors', 'errorMessage' or whatever other fields the service returns.
the implementation below is the original code that was part of ... | 625941bacb5e8a47e48b794c |
def test_command_line_interface(self): <NEW_LINE> <INDENT> runner = CliRunner() <NEW_LINE> result = runner.invoke(cli.main) <NEW_LINE> assert result.exit_code == 0 <NEW_LINE> assert 'ticketshow.cli.main' in result.output <NEW_LINE> help_result = runner.invoke(cli.main, ['--help']) <NEW_LINE> assert help_result.exit_cod... | Test the CLI. | 625941ba099cdd3c635f0afa |
def get_core(self): <NEW_LINE> <INDENT> if self.gluecard and self.status == False: <NEW_LINE> <INDENT> return pysolvers.gluecard3_core(self.gluecard) | Get an unsatisfiable core if the formula was previously
unsatisfied. | 625941baaad79263cf3908d9 |
def plot_S(S, per=False, fs=(15, 15), save='', title='', show=True): <NEW_LINE> <INDENT> colormap = 'hot' <NEW_LINE> nph = np.max(S) <NEW_LINE> ndim = np.ndim(S) <NEW_LINE> if ndim == 1: <NEW_LINE> <INDENT> plt.figure() <NEW_LINE> if not per: <NEW_LINE> <INDENT> plt.matshow( np.array( [S]), cmap=plt.get_cmap( colormap,... | Plot structure. | 625941babde94217f3682c99 |
def calc_index_of_coincidence(cipher_text): <NEW_LINE> <INDENT> freqs = freq_count(cipher_text) <NEW_LINE> numpy_arr = np.array(list(freqs.values())) <NEW_LINE> n = sum(numpy_arr) <NEW_LINE> return (sum((numpy_arr * (numpy_arr - 1)))/(n * (n - 1)), n) | get all the frequencies from cipher_text
convert it to numpy array for faster computation using Vectorization technique
formulae: summation[(n(i)(n(i) - 1))/n(n - 1)]
where, n(i) is frequency of each alphabet e.g. n(a) = 5, n(b) = 8..
n is total frequency | 625941baa17c0f6771cbdef1 |
def testUserSamlProviderResponseModel(self): <NEW_LINE> <INDENT> pass | Test UserSamlProviderResponseModel | 625941ba507cdc57c6306b71 |
def _load_config(self): <NEW_LINE> <INDENT> source_dir = os.path.dirname(os.path.abspath(__file__)) <NEW_LINE> config_file = os.path.abspath('config.py') <NEW_LINE> if not os.path.exists(config_file): <NEW_LINE> <INDENT> config_file = os.path.join(source_dir, 'config.py') <NEW_LINE> <DEDENT> if not os.path.exists(confi... | Load config.py as a variable file in a way that the individual
variables can be overriden on command line as if it was loaded
explicitly as a variables file. | 625941baa8ecb033257d2f74 |
def test_no_epochs(tmpdir): <NEW_LINE> <INDENT> raw, events = _get_data()[:2] <NEW_LINE> reject = dict(grad=4000e-13, mag=4e-12, eog=150e-6) <NEW_LINE> raw.info['bads'] = ['MEG 2443', 'EEG 053'] <NEW_LINE> epochs = mne.Epochs(raw, events, reject=reject) <NEW_LINE> epochs.save(op.join(str(tmpdir), 'sample-epo.fif'), ove... | Test that having the first epoch bad does not break writing. | 625941ba3c8af77a43ae363b |
def _distribute_homeless_shares(mappings, homeless_shares, peers_to_shares): <NEW_LINE> <INDENT> servermap_peerids = set([key for key in peers_to_shares]) <NEW_LINE> servermap_shareids = set() <NEW_LINE> for key in sorted(peers_to_shares.keys()): <NEW_LINE> <INDENT> for share in peers_to_shares[key]: <NEW_LINE> <INDENT... | Shares which are not mapped to a peer in the maximum spanning graph
still need to be placed on a server. This function attempts to
distribute those homeless shares as evenly as possible over the
available peers. If possible a share will be placed on the server it was
originally on, signifying the lease should be renewe... | 625941ba21a7993f00bc7b88 |
def __iadd__(self, x): <NEW_LINE> <INDENT> if isinstance(x, NoddyOutput): <NEW_LINE> <INDENT> self.block += x.block <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.block += x <NEW_LINE> <DEDENT> return self | Augmented assignment addtition: add value to all grid blocks
**Arguments**:
- *x*: can be either a numerical value (int, float, ...) *or* another
NoddyOutput object! Note that, in both cases, the own block is updated
and no new object is created (compare to overwritten addition operator!)
Note: This metho... | 625941bae5267d203edcdb3e |
def deactivate_guider_decenter(cmd, cmdState, actorState, stageName): <NEW_LINE> <INDENT> multiCmd = SopMultiCommand(cmd, actorState.timeout, '') <NEW_LINE> prep_guider_decenter_off(multiCmd) <NEW_LINE> if not handle_multiCmd(multiCmd, cmd, cmdState, stageName, 'failed to disable decentered guide mode.', finish=False):... | Prepare for non-MaNGA observations by disabling guider decenter mode. | 625941ba3539df3088e2e1e9 |
def get_total_background_gen_binning(self): <NEW_LINE> <INDENT> total_bg_hist = None <NEW_LINE> for name, hist in self.backgrounds_gen_binning.items(): <NEW_LINE> <INDENT> if total_bg_hist is None: <NEW_LINE> <INDENT> total_bg_hist = hist.Clone() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> total_bg_hist.Add(hist) <NE... | Get total cumulative background with generator binning | 625941ba07f4c71912b11325 |
def __call__(self): <NEW_LINE> <INDENT> return self._rot | Returns complex rotation vector | 625941ba57b8e32f5248333e |
def append_line(self, linespec): <NEW_LINE> <INDENT> retval = self.ConfigObjs.append(linespec) <NEW_LINE> return self.ConfigObjs[-1] | Unconditionally insert linespec (a text line) at the end of the configuration | 625941ba6aa9bd52df036c40 |
def ord_dh(csp, var = None): <NEW_LINE> <INDENT> vars = csp.get_all_unasgn_vars() <NEW_LINE> maxVar = None <NEW_LINE> max = -1 <NEW_LINE> for var in vars: <NEW_LINE> <INDENT> count = 0 <NEW_LINE> if var.assignedValue == None: <NEW_LINE> <INDENT> for scopeVar in csp.get_cons_with_var(var): <NEW_LINE> <INDENT> for otherv... | ord_dh(csp):
A var_ordering function that takes CSP object csp and returns Variable object var,
according to the Degree Heuristic (DH), as covered in lecture.
Given the constraint graph for the CSP, where each variable is a node,
and there exists an edge from two variable nodes v1, v2 iff there exists
at least one cons... | 625941ba796e427e537b0460 |
def testPullGoodRdf(self): <NEW_LINE> <INDENT> data = ('<?xml version="1.0" encoding="utf-8"?>\n' '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' '<channel><my header="data"/></channel>' '<item><guid>1</guid><updated>123</updated>wooh</item>' '</rdf:RDF>') <NEW_LINE> topic = 'http://example.com/my-t... | Tests when the RDF (RSS 1.0) XML can parse just fine. | 625941bafbf16365ca6f605b |
def get_csci_salt() -> bytes: <NEW_LINE> <INDENT> load_dotenv() <NEW_LINE> salt = bytes.fromhex(os.environ["CSCI_SALT"]) <NEW_LINE> return salt | Returns the appropriate salt for CSCI E-29
:return: bytes representation of the CSCI salt | 625941bae64d504609d746de |
def __eq__(self, other): <NEW_LINE> <INDENT> if type(self) != type(other): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if len(self.packages) != len(other.packages): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for pkg in self.packages: <NEW_LINE> <INDENT> if not pkg in other.packages: <NEW_LINE> <INDEN... | Compare one profile to another to determine if anything has changed. | 625941ba99cbb53fe6792a85 |
def save(self, *args, **kwargs): <NEW_LINE> <INDENT> if self.rank is None: <NEW_LINE> <INDENT> self.rank = 0 <NEW_LINE> <DEDENT> super(OCtype, self).save(*args, **kwargs) | saves a manifest item with a good slug | 625941baa8370b771705273f |
def getCatIds(self, catNms=[], catIds=[]): <NEW_LINE> <INDENT> catNms = catNms if type(catNms) == list else [catNms] <NEW_LINE> catIds = catIds if type(catIds) == list else [catIds] <NEW_LINE> if len(catNms) == len(supNms) == len(catIds) == 0: <NEW_LINE> <INDENT> cats = self.dataset['categories'] <NEW_LINE> <DEDENT> el... | filtering parameters. default skips that filter.
:param catNms (str array) : get cats for given cat names
:param catIds (int array) : get cats for given cat ids
:return: ids (int array) : integer array of cat ids | 625941ba6fb2d068a760ef38 |
def test_4_update(self): <NEW_LINE> <INDENT> modified = self.updater.update([os.path.join(self.testdir, "4_update.update")]) <NEW_LINE> assert modified <NEW_LINE> entries = self.ld.get_entries( self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) <NEW_LINE> assert len(entries) == 1 <NEW_LINE> entry = entries[0] <N... | Test the updater adding a new value to a single-valued attribute (test_4_update) | 625941ba0a50d4780f666d2d |
def update_weights(self, weights): <NEW_LINE> <INDENT> self.weights = weights | Update weights
This method updates the values of the weights
Parameters
----------
weights : np.ndarray
Array of weights | 625941bafb3f5b602dac352d |
def check_last_run_table(self, component): <NEW_LINE> <INDENT> logging.info("Getting the last run time in seconds for component: {0}".format(component)) <NEW_LINE> last_record_time = '2000-01-01 00:00:00' <NEW_LINE> last_run = LastRun.objects.filter(component=component).values('last_run') <NEW_LINE> for last_run in las... | Get all the date/time of the last run by components .. | 625941ba498bea3a759b994f |
def extractFeatures(source, where=None, geom=None, srs=None, onlyGeom=False, onlyAttr=False, asPandas=True, indexCol=None, **kwargs): <NEW_LINE> <INDENT> if not asPandas: <NEW_LINE> <INDENT> return _extractFeatures(source=source, geom=geom, where=where, srs=srs, onlyGeom=onlyGeom, onlyAttr=onlyAttr) <NEW_LINE> <DEDENT>... | Creates a generator which extract the features contained within the source
* Iteratively returns (feature-geometry, feature-fields)
Note:
-----
Be careful when filtering by a geometry as the extracted features may not
necessarily be IN the given shape
* Sometimes they may only overlap
* Sometimes they are only i... | 625941bae8904600ed9f1dc7 |
def get_logger(module_name, level='INFO', to_file=True, to_console=True): <NEW_LINE> <INDENT> path = os.path.join(os.path.expanduser("~"), ".pygtktalog", "app.log") <NEW_LINE> log = logging.getLogger(module_name) <NEW_LINE> log.setLevel(LEVEL[level]) <NEW_LINE> if to_console: <NEW_LINE> <INDENT> console_handler = loggi... | Prepare and return log object. Standard formatting is used for all logs.
Arguments:
@module_name - String name for Logger object.
@level - Log level (as string), one of DEBUG, INFO, WARN, ERROR and
CRITICAL.
@to_file - If True, additionally stores full log in file inside
.pygtkta... | 625941bac4546d3d9de728cf |
def addCnsCurve(parent, name, centers, degree=1): <NEW_LINE> <INDENT> if degree == 3: <NEW_LINE> <INDENT> if len(centers) == 2: <NEW_LINE> <INDENT> centers.insert(0, centers[0]) <NEW_LINE> centers.append(centers[-1]) <NEW_LINE> <DEDENT> elif len(centers) == 3: <NEW_LINE> <INDENT> centers.append(centers[-1]) <NEW_LINE> ... | Create a curve attached to given centers. One point per center
Arguments:
parent (dagNode): Parent object.
name (str): Name
centers (list of dagNode): Object that will drive the curve.
degree (int): 1 for linear curve, 3 for Cubic.
Returns:
dagNode: The newly created curve. | 625941ba96565a6dacc8f573 |
def _sampling_concrete(self, args): <NEW_LINE> <INDENT> return sampling_concrete(args, (self.batch_size, self.latent_disc_dim)) | Sampling from a concrete distribution | 625941baa4f1c619b28afedf |
def error(self, token): <NEW_LINE> <INDENT> if token: <NEW_LINE> <INDENT> lineno = getattr(token, 'lineno', 0) <NEW_LINE> if lineno: <NEW_LINE> <INDENT> sys.stderr.write(f'yacc: Syntax error at line {lineno}, token={token.type}\n') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sys.stderr.write(f'yacc: Syntax error, tok... | Default error handling function. This may be subclassed. | 625941ba711fe17d82542210 |
def check_pip_version(min_version='6.0.0'): <NEW_LINE> <INDENT> if StrictVersion(pip.__version__) < StrictVersion(min_version): <NEW_LINE> <INDENT> print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, min_version, GET_PIP)) <NEW_LINE> sys.exit(1) | Ensure that a minimum supported version of pip is installed. | 625941ba6fb2d068a760ef39 |
def save(self, url, addr, clues): <NEW_LINE> <INDENT> assert url and addr <NEW_LINE> urldir = self._mkdir(os.path.join(self.root, self._sanitize(url))) <NEW_LINE> filename = self._sanitize(addr) + os.extsep + self.ext <NEW_LINE> cluefile = os.path.join(urldir, filename) <NEW_LINE> Halberd.clues.file.save(cluefile, clue... | Hierarchically write clues.
:param url: URL scanned (will be used as a directory name).
@type url: C{url}
:param addr: Address of the target.
@type addr: C{str}
:param clues: Clues to be stored.
@type clues: C{list}
@raise OSError: If the directories can't be created.
@raise IOError: If the file can't be stored suc... | 625941ba187af65679ca4fbb |
def XPLMIsFeatureEnabled(inFeature): <NEW_LINE> <INDENT> pass | This returns 1 if a feature is currently enabled for your plugin, or 0 if
it is not enabled. It is an error to call this routine with an unsupported
feature. | 625941ba45492302aab5e15f |
def publish_event( self, event_name: int, event_payload: Dict[str, Any], publisher_id: Optional[str] = None, ) -> None: <NEW_LINE> <INDENT> if not self.flags.enable_events: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> assert self.event_queue <NEW_LINE> self.event_queue.publish( self.uid, event_name, event_payload, pu... | Convenience method provided to publish events into the global event queue. | 625941ba9f2886367277a72f |
def check_link(self): <NEW_LINE> <INDENT> item = self.gui.tree_url.currentItem() <NEW_LINE> url = item.text(1) <NEW_LINE> x = self.gui.webView.page() <NEW_LINE> self.x = x.mainFrame() <NEW_LINE> self.x.load(QtCore.QUrl(url)) | Open url in browser | 625941bad7e4931a7ee9ddba |
def itest_deltafactor(fwp, tvars): <NEW_LINE> <INDENT> pseudo = abidata.pseudo("Si.GGA_PBE-JTH-paw.xml") <NEW_LINE> flow = abilab.AbinitFlow(workdir=fwp.workdir, manager=fwp.manager) <NEW_LINE> kppa = 20 <NEW_LINE> ecut = 2 <NEW_LINE> pawecutdg = ecut * 2 if pseudo.ispaw else None <NEW_LINE> from pseudo_dojo.dojo.dojo_... | Test the flow used for the computation of the deltafactor. | 625941bae64d504609d746df |
def resolveFrame(frame, who=''): <NEW_LINE> <INDENT> if not isinstance(frame, Frame): <NEW_LINE> <INDENT> if frame not in Frame.Names: <NEW_LINE> <INDENT> raise excepting.ResolveError("ResolveError: Bad frame link name", frame, who) <NEW_LINE> <DEDENT> frame = Frame.Names[frame] <NEW_LINE> <DEDENT> return frame | Returns resolved frame instance from frame
frame may be name of frame or instance
Frame.Names registry must be setup | 625941ba38b623060ff0ac8d |
def fill_region(self, x, y, union_find): <NEW_LINE> <INDENT> R, C = union_find.R, union_find.C <NEW_LINE> q = [(int(x), int(y))] <NEW_LINE> visited = set(union_find.id.keys()) | {(x, y)} <NEW_LINE> while q: <NEW_LINE> <INDENT> next_level = [] <NEW_LINE> for node in q: <NEW_LINE> <INDENT> for neighbor in self.get_neighb... | Creates a shape by spreading out from the location (x, y) until | 625941ba4f88993c3716bf12 |
def kthSmallest(self, root, k): <NEW_LINE> <INDENT> self.rv = None <NEW_LINE> def inorder(node, known_smaller = 0): <NEW_LINE> <INDENT> if node is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> assert known_smaller < k <NEW_LINE> left_tree_size = inorder(node.left, known_smaller) <NEW_LINE> if self.rv is not No... | :type root: TreeNode
:type k: int
:rtype: int | 625941ba4e696a04525c92eb |
def test_active_lstar_05(self): <NEW_LINE> <INDENT> q0 = automaton.State('0') <NEW_LINE> q1 = automaton.State('1') <NEW_LINE> expected_dfa = automaton.DFA({'a'}, start_state=q0) <NEW_LINE> expected_dfa.add_transition(q0, q1, 'a') <NEW_LINE> expected_dfa.add_transition(q1, q0, 'a') <NEW_LINE> expected_dfa.accept_states.... | Try to let L* learn the regular language A.
A is a language over the alphabet sigma = {a},
that accepts all strings with an odd number of
a's. | 625941ba4e4d5625662d427b |
def display_batch(img_array_batch, nrows=2, ncols=2, title=''): <NEW_LINE> <INDENT> if img_array_batch is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if (utils.image.is_float_image(img_array_batch[0])): <NEW_LINE> <INDENT> max_value = 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> max_value = 255 <NEW_LINE> <... | Display a batch of images given as a 4D numpy array.
Remarks: Some RGB images might be displayed with changed colors.
Parameters
----------
img_array_batch : numpy.ndarray
The image numpy data in format [batch_size, height, width, channels]
or a list of numpy arrays in format [height, width, channels],
whic... | 625941ba004d5f362079a1d5 |
def xueqiu(code,path=None,price=True,textv=False,n=1): <NEW_LINE> <INDENT> driver.get("https://xueqiu.com") <NEW_LINE> waitForLoad(driver) <NEW_LINE> driver.find_element_by_xpath('//div[@class="nav__login__btn"]/span').click() <NEW_LINE> usename=driver.find_element_by_xpath('//input[@name="username"]') <NEW_LINE> usena... | code:股票代码,
n:对应雪球下方的讨论等文本的获取 | 625941bae5267d203edcdb3f |
def url_traceback(self, url): <NEW_LINE> <INDENT> if '..' not in url: <NEW_LINE> <INDENT> return url <NEW_LINE> <DEDENT> data = url.split('/') <NEW_LINE> new_data = [] <NEW_LINE> for p in data: <NEW_LINE> <INDENT> if p=='..': <NEW_LINE> <INDENT> new_data.pop(-1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_data.ap... | 路径回溯处理 | 625941baab23a570cc25001e |
def deserialize(self, data): <NEW_LINE> <INDENT> values = [int(value) if value != ' ' else None for value in data.split('*')] <NEW_LINE> if not (values and values[0] is not None): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> root = TreeNode(values[0]) <NEW_LINE> node_queue = collections.deque([root]) <NEW_LINE> ... | Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode | 625941ba8c3a87329515825d |
def getIcon(self): <NEW_LINE> <INDENT> return os.path.join(iconPath, 'EM_FHSolver.svg') | Return the icon which will appear in the tree view. This method is optional
and if not defined a default icon is shown. | 625941bade87d2750b85fc2d |
def declutter(obj): <NEW_LINE> <INDENT> outstring = '' <NEW_LINE> for element in obj: <NEW_LINE> <INDENT> headings = element.filter_headings() <NEW_LINE> for heading in headings: <NEW_LINE> <INDENT> element.remove(heading) <NEW_LINE> <DEDENT> table_tags = element.filter_tags(element.RECURSE_OTHERS, matches=lambda n: n.... | function for removing elements from the wikitext that would otherwise not be removed fully by using the
strip_code() function
:param obj: Wikicode object from get_sections()
:return: Wikicode stripped of all headings, tags (table was the tricky one bringing problems) and thumbnail
wikilinks, and external url links, con... | 625941ba627d3e7fe0d68ced |
def get_build_sha1(binary): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(binary, "rb") as fp: <NEW_LINE> <INDENT> contents = fp.read() <NEW_LINE> <DEDENT> <DEDENT> except IOError as e: <NEW_LINE> <INDENT> raise HighLevelConfigurationError("Cannot calculate the SHA1 of the high-level extractor binary: {}".form... | Calculate the SHA1 of the binary we're using. | 625941ba30bbd722463cbc62 |
def sign_request(self, signature_method, consumer, token): <NEW_LINE> <INDENT> if not self.is_form_encoded: <NEW_LINE> <INDENT> self['oauth_body_hash'] = base64.b64encode(sha(self.body.encode('utf-8')).digest()).decode() <NEW_LINE> <DEDENT> if 'oauth_consumer_key' not in self: <NEW_LINE> <INDENT> self['oauth_consumer_k... | Set the signature parameter to the result of sign. | 625941baa934411ee3751539 |
def record_property(Property:"Property"): <NEW_LINE> <INDENT> properties = get_properties() <NEW_LINE> state = Property.state <NEW_LINE> county = Property.county <NEW_LINE> if not properties.get(state): <NEW_LINE> <INDENT> properties[state] = {} <NEW_LINE> <DEDENT> state_properties = properties.get(state) <NEW_LINE> if... | Loads properties, then adds provided property to the
dict | 625941ba9c8ee82313fbb614 |
def extend_context(start, end): <NEW_LINE> <INDENT> return ''.join(' {}\n'.format(line.rstrip()) for line in self.a[start:end]) | Add context lines. | 625941bacad5886f8bd26e81 |
def to_crs(self, crs): <NEW_LINE> <INDENT> if self.crs == crs: <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> transform = osr.CoordinateTransformation(self.crs._crs, crs._crs) <NEW_LINE> return GeoPolygon([p[:2] for p in transform.TransformPoints(self.points)], crs) | Duplicates polygon while transforming to a new CRS
:param CRS crs: Target CRS
:return: new GeoPolygon with CRS specified by crs
:rtype: GeoPolygon | 625941bad6c5a10208143ee6 |
def select_shapes(self, select_function, **kwargs): <NEW_LINE> <INDENT> self.shapes_to_draw.append( {'shapes': self.shapes[self.shapes.apply(select_function, axis=1)]['path'].values, 'args': kwargs} ) | Selects shapes based on an arbitrary function such as: lambda shape: shape['highway'] == 'motorway'
:param select_function: boolean function to include a shape or not
:param kwargs: arguments for the drawing
:return: | 625941ba7047854f462a12ac |
def workdue(self, task): <NEW_LINE> <INDENT> wv = (self.workview(task) and task.get_due_date() and task.get_days_left() < 2) <NEW_LINE> return wv | Filter for tasks due within the next day | 625941ba91f36d47f21ac392 |
def test015_get_process_details_in_container(self): <NEW_LINE> <INDENT> self.lg.info('Choose one random container of list of running nodes') <NEW_LINE> container_name = self.create_contaienr(self.node_id) <NEW_LINE> self.assertTrue(container_name) <NEW_LINE> self.lg.info('Choose one random process of list of process.')... | GAT-036
*post:/node/{nodeid}/containers/containerid/processes/processid *
**Test Scenario:**
#. Choose one random node of list of running nodes.
#. Choose one random conatainer of list of running containers.
#. Choose one random process of list of process.
#. Send get nodes/{nodeid}/containers/containerid/processes/p... | 625941bafbf16365ca6f605c |
def test_get_property(self): <NEW_LINE> <INDENT> def get_values(db): <NEW_LINE> <INDENT> ans = {} <NEW_LINE> for label, loc in iteritems(db.FIELD_MAP): <NEW_LINE> <INDENT> if isinstance(label, numbers.Integral): <NEW_LINE> <INDENT> label = '#'+db.custom_column_num_map[label]['label'] <NEW_LINE> <DEDENT> label = unicode... | Test the get_property interface for reading data | 625941ba851cf427c661a3b1 |
def low(balance, annualInterestRate): <NEW_LINE> <INDENT> monthlyInterestRate = annualInterestRate/12.0 <NEW_LINE> low = balance / 12 <NEW_LINE> high = (balance * (1+monthlyInterestRate)**12) /12.0 <NEW_LINE> payment = (high+low)/2 <NEW_LINE> debt = balance <NEW_LINE> while low <= (high - .1): <NEW_LINE> <INDENT> debt ... | INPUT: balance = 320000
annualInterestRate = .2
OUTPUT: 29157.09 | 625941bac432627299f04ae3 |
def derivation1(data): <NEW_LINE> <INDENT> length = len(data) <NEW_LINE> der = [float('nan') for i in range(length)] <NEW_LINE> last = length - 1 <NEW_LINE> for i in range(1, last): <NEW_LINE> <INDENT> der[i] = (data[i + 1] - data[i - 1]) / 2 <NEW_LINE> <DEDENT> return der | 计算光谱一阶微分
@param data 光谱数据
@return data 光谱的一阶微分 | 625941ba30dc7b7665901809 |
def export_rows_analysisID_sqlalchemyModel_table_js(self, model_I, analysis_id_I, data1_keys, data1_nestkeys, data1_keymap, used__I=True, tabletype_I='responsivecrosstable_01', data_dir_I='tmp'): <NEW_LINE> <INDENT> data_O = []; <NEW_LINE> queryselect = sbaas_base_query_select(session_I=self.session,engine_I=self.engin... | Export a tabular representation of the data
INPUT:
model_I = sqlalchemy model object
analysis_id_I = string, | 625941babe383301e01b532b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.