code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@follows(mkdir("fastqc")) <NEW_LINE> @transform("*.fastq.*.gz", regex(r"(\S+).fastq.(\S+).gz"), r"fastqc/\1_read\2_fastqc.log") <NEW_LINE> def run_fastqc(infile, outfile): <NEW_LINE> <INDENT> statement = '''fastqc -o fastqc --nogroup --extract %(infile)s >& %(outfile)s ''' <NEW_LINE> P.run() | Run fastqc on raw reads | 625941c57d43ff24873a2ca2 |
def prepareMesh(self,face_group=None): <NEW_LINE> <INDENT> if face_group is None: <NEW_LINE> <INDENT> new_mesh = smesh.CopyMesh(self.mesh,'help_mesh',toKeepIDs = True) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_mesh = smesh.CopyMesh(face_group,'help_mesh',toKeepIDs = True) <NEW_LINE> <DEDENT> return new_mesh | Necessary preparation steps. | 625941c59c8ee82313fbb777 |
def get_tonic_index(tonic): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tonic_index = tonic_map[tonic[0]] <NEW_LINE> if tonic_index is not None: <NEW_LINE> <INDENT> for accidental in tonic[1:]: <NEW_LINE> <INDENT> tonic_index += accidental_map[accidental] <NEW_LINE> <DEDENT> tonic_index %= 12 <NEW_LINE> <DEDENT> retur... | Get the index of the tonic of the given chord tonic string.
Parameters
==========
tonic : string
A tonic pitch, including any sharps (#) and flats (b).
Returns
=======
tonic_index : int
The index of the given tonic string, on the range [0 (C), 11 (B)], or None if
the given tonic string is not a proper... | 625941c55f7d997b87174a99 |
def make_rectangle(length, height=0, placement=None, face=None, support=None): <NEW_LINE> <INDENT> if not App.ActiveDocument: <NEW_LINE> <INDENT> App.Console.PrintError("No active document. Aborting\n") <NEW_LINE> return <NEW_LINE> <DEDENT> if isinstance(length,(list,tuple)) and (len(length) == 4): <NEW_LINE> <INDENT> ... | make_rectangle(length, width, [placement], [face])
Creates a Rectangle object with length in X direction and height in Y
direction.
Parameters
----------
length, height : dimensions of the rectangle
placement : Base.Placement
If a placement is given, it is used.
face : Bool
If face is False, the rectangle i... | 625941c5377c676e912721ac |
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 9 <NEW_LINE> (_x.x, _x.y, _x.button1,) = _struct_2fB.unpack(str[start:end]) <NEW_LINE> self.button1 = bool(self.button1) <NEW_LINE> return self <NEW_LINE> <DEDENT> ... | unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module | 625941c523849d37ff7b3093 |
@pytest.fixture <NEW_LINE> def db(base_app): <NEW_LINE> <INDENT> if not database_exists(str(db_.engine.url)): <NEW_LINE> <INDENT> create_database(str(db_.engine.url)) <NEW_LINE> <DEDENT> db_.create_all() <NEW_LINE> yield db_ <NEW_LINE> db_.session.remove() <NEW_LINE> db_.drop_all() | Setup database. | 625941c591af0d3eaac9ba1a |
def __init__(self, count=None, urls=None): <NEW_LINE> <INDENT> self.count = count <NEW_LINE> self.urls = urls | :param count: (Optional)
:param urls: (Optional) | 625941c591f36d47f21ac4f4 |
def preprocess(image, resize_image=True): <NEW_LINE> <INDENT> image = crop(image) <NEW_LINE> image = rgb2yuv(image) <NEW_LINE> image = resize(image) <NEW_LINE> return image | preprocess image before feeding to model
1. crop the image to remove unnecessary parts
2. convert from RGB to YUV
3. convert to the shape expected by the the input of the model | 625941c5d53ae8145f87a275 |
def test_grammar(self): <NEW_LINE> <INDENT> p = ParserBase() <NEW_LINE> p.grammar(GRAMMAR) <NEW_LINE> p.parse('https://www.abcabc.com') <NEW_LINE> p.parse('https://www.bcaabc.co.uk') <NEW_LINE> p.parse('http://www.a.fr') <NEW_LINE> with self.assertRaises(NotFoundError): <NEW_LINE> <INDENT> p.parse('www.abc.com') <NEW_L... | Use the grammar method, also providing an opportunity to
check a more complex multi-rule example. | 625941c545492302aab5e2c5 |
def show_words_randomly(self, db, func_title): <NEW_LINE> <INDENT> import time <NEW_LINE> from random import choice <NEW_LINE> word_num = input('請輸入單字數量 (10~30): ') <NEW_LINE> sleep_sec = input('請輸入停頓秒數 (0~5): ') <NEW_LINE> if word_num.isdigit() and sleep_sec.isdigit(): <NEW_LINE> <INDENT> word_num = int(word_num) <NEW... | 亂數播放單字
| 625941c5cad5886f8bd26fdd |
def _build_case(branch_index, branch_graphs, branch_inputs, name=None): <NEW_LINE> <INDENT> _check_same_outputs(_CASE, branch_graphs) <NEW_LINE> case_inputs = _make_inputs_match(branch_graphs, branch_inputs) <NEW_LINE> with ops.control_dependencies( sum((list(bg.control_captures) for bg in branch_graphs), [])): <NEW_LI... | Creates an `Case` op from `branch_index`, branch graphs and inputs.
Note that this modifies `branch_graphs` to make the inputs match, and to
output all intermediates values so they're available for the gradient
computation.
`branch_graphs` need not have the same input types, but they must
have the same outpute types.... | 625941c5adb09d7d5db6c793 |
def process_users(self): <NEW_LINE> <INDENT> self.user_time_session = pd.DataFrame() <NEW_LINE> for _, frame in self.group_by_user: <NEW_LINE> <INDENT> user_frame = frame[['username', 'time', 'event_type', 'referer', 'page', 'classification_event_type', 'classification_referer', 'event', 'event_type_vertical']].copy() ... | To every group in the logs grouped by username, sorts, adds classification according
to the time between actions and enumerates the sessions. | 625941c5566aa707497f456e |
def get_name(self, index=None): <NEW_LINE> <INDENT> edges = len(self.G.edges()) <NEW_LINE> nodes = len(self.G.nodes()) <NEW_LINE> if index is None: <NEW_LINE> <INDENT> name = ("has_K" + str(self.clique) + "_edges-" + str(edges) + '_nodes-' + str(nodes) + ".txt") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = ("ha... | a method that determines the name of G
based upon properties of the graph
Parameters:
index: a value index to add to the end of the name
Returns:
name: the name of the graph | 625941c5004d5f362079a337 |
def click_customer_specific_routing_search_button(self): <NEW_LINE> <INDENT> self.click_element(self.customer_specific_routing_search_button_locator) | Implementing click customer specific routing search button functionality
:return: | 625941c57b180e01f3dc4804 |
def getMachineId(self, *args, **kwargs): <NEW_LINE> <INDENT> return _VISHNU.LocalAccount_getMachineId(self, *args, **kwargs) | getMachineId(self) -> EString | 625941c5de87d2750b85fd95 |
def _get_field_by_name(self, name): <NEW_LINE> <INDENT> for field in self._fields: <NEW_LINE> <INDENT> if field[0] == name: <NEW_LINE> <INDENT> return field <NEW_LINE> <DEDENT> <DEDENT> raise FieldError("{} has no field {!r}".format( self.__class__.__name__, name )) | Return the field by name
| 625941c54d74a7450ccd41c7 |
def scale_data(data, nm_per_pixel=1, I_multiplier=1): <NEW_LINE> <INDENT> q_size = data['q'].size <NEW_LINE> q_size = q_size - 1 if q_size % 2 == 1 else q_size <NEW_LINE> dq = 1.0 / (q_size * 2) * 1.0 / nm_per_pixel <NEW_LINE> out_data = data <NEW_LINE> out_data['q'] *= dq <NEW_LINE> out_data['I'] *= I_multiplier <NEW_... | scale q range based on nm_per_pixel at size of image | 625941c5cc40096d61595954 |
def get_ota_rect(self, ox, oy): <NEW_LINE> <INDENT> left, bottom = self.get_xy_from_oxy(ox, oy, 0, 0) <NEW_LINE> right, top = self.get_xy_from_oxy(ox, oy, self.OW, self.OH) <NEW_LINE> return (left, right), (bottom, top) | Return rect (in global x and y: l, r, b, t) of ota with given id | 625941c5ff9c53063f47c1f7 |
def parse_current_wait_time(data): <NEW_LINE> <INDENT> pass | Parses a given wait time | 625941c523e79379d52ee568 |
def read(self, request=None): <NEW_LINE> <INDENT> self._cook_check() <NEW_LINE> if not self._v_errors: <NEW_LINE> <INDENT> if not self.expand: <NEW_LINE> <INDENT> return self._text <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> context = self.pt_getContext(self, request) <NEW_LINE> return self.pt_render(context, source=1... | Gets the source, sometimes with macros expanded. | 625941c5cdde0d52a9e53035 |
def setMcuUserInfos(self, mcuUserInfos): <NEW_LINE> <INDENT> self.mcuUserInfos = mcuUserInfos | :param mcuUserInfos: (Optional) 参与混流人员参数 | 625941c54527f215b584c45c |
def max(self) -> Optional[float]: <NEW_LINE> <INDENT> if self.num_values == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return self._max * self.scale_factor | Return the max of added values. | 625941c50a366e3fb873e81c |
def __repr__(self): <NEW_LINE> <INDENT> return str(self.fait) | Representation d'un fait sous forme de string
| 625941c56fece00bbac2d740 |
def update(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> apt_cache = apt.cache.Cache() <NEW_LINE> import sys <NEW_LINE> orig_out = sys.stdout <NEW_LINE> sys.stdout = open(self.app.config.get('log.logging', 'file'), encoding='utf-8', mode='a') <NEW_LINE> apt_cache.update(apt.progress.text.AcquireProgress()) <NEW_L... | Similar to `apt-get upgrade` | 625941c5293b9510aa2c329b |
def test_api_users(self): <NEW_LINE> <INDENT> resp = self.client.get('/api/v1/users') <NEW_LINE> self.assertEqual(resp.status_code, 200) <NEW_LINE> self.assertEqual(resp.content_type, 'application/json') <NEW_LINE> data = json.loads(resp.data) <NEW_LINE> self.assertEqual(len(data), 2) <NEW_LINE> self.assertDictEqual( d... | Test users listing. | 625941c5099cdd3c635f0c5f |
def run_script(cli_string, shell=False, die=True): <NEW_LINE> <INDENT> encoding = locale.getdefaultlocale()[1] <NEW_LINE> header_returncode = ('[Return Code]') <NEW_LINE> header_stdout = ('[Output]') <NEW_LINE> header_stderr = ('[Error Message]') <NEW_LINE> header_bad_cmd = ('[ERROR: Bad Command]') <NEW_LINE> log_messa... | Run the cli_string UNIX CLI command and record output.
Args:
cli_string: Command to run on the CLI
die: Die if command runs with an error
Returns:
None | 625941c5187af65679ca5121 |
def is_equitable(self, partition, quotient_matrix=False): <NEW_LINE> <INDENT> from sage.misc.flatten import flatten <NEW_LINE> if sorted(flatten(partition, max_level=1)) != self.vertices(): <NEW_LINE> <INDENT> raise TypeError("Partition (%s) is not valid for this graph: vertices are incorrect."%partition) <NEW_LINE> <D... | Checks whether the given partition is equitable with respect to
self.
A partition is equitable with respect to a graph if for every pair
of cells C1, C2 of the partition, the number of edges from a vertex
of C1 to C2 is the same, over all vertices in C1.
INPUT:
- ``partition`` - a list of lists
- ``quotient_matr... | 625941c566656f66f7cbc1ae |
def bind_namespaces(graph): <NEW_LINE> <INDENT> n_space = {"cex": cex, "dct": dct, "dctype": dctype, "foaf": foaf, "lb": lb, "org": org, "qb": qb, "sdmx-concept": sdmx_concept, "time": time, "sdmx-code": sdmx_code, "": base, "base-obs": base_obs, "base-ind": base_ind, "base-slice": base_slice, "base-data-source": base_... | Binds Landportal uris with their corresponding prefixes | 625941c5a8370b77170528a4 |
@click.command() <NEW_LINE> @click.argument('query') <NEW_LINE> @click.option('--output_file', default="/tmp/{0}".format(uuid.uuid4())) <NEW_LINE> def search(query, output_file): <NEW_LINE> <INDENT> if query.count("?") > 0: <NEW_LINE> <INDENT> query = query.split("?")[1] <NEW_LINE> <DEDENT> params = parse_qs(query) <NE... | take query from http://54.158.101.33:8080/bopws/swagger/#!/default/export
python lts.py "http://54.158.101.33:8080/bopws/tweets/export?q.time=*&q.geo=%5B-90%2C-180%20TO%2090%2C180%5D&q.text=test&q.user=panchicore"
python lts.py "q.time=%5B2013-03-01%20TO%202013-04-01T00%3A00%3A00%5D&q.geo=%5B-90%2C-180%20TO%2090%2C180%... | 625941c5cb5e8a47e48b7aaf |
def __setstate__(self): <NEW_LINE> <INDENT> pass | For unpickling. | 625941c521bff66bcd684958 |
def normalizeText(self, text, **kw): <NEW_LINE> <INDENT> if text: <NEW_LINE> <INDENT> lines = text.splitlines() <NEW_LINE> if kw.get('stripspaces', 0): <NEW_LINE> <INDENT> lines = [line.rstrip() for line in lines] <NEW_LINE> <DEDENT> if not lines[-1] == u'': <NEW_LINE> <INDENT> lines.append(u'') <NEW_LINE> <DEDENT> tex... | Normalize text
Make sure text uses '
' line endings, and has a trailing
newline. Strip whitespace on end of lines if needed.
You should normalize any text you enter into a page, for
example, when getting new text from the editor, or when setting
new text manually.
@par... | 625941c5f9cc0f698b140600 |
def prepare_for_model_step(self, sc, time_step, model_time_datetime): <NEW_LINE> <INDENT> super(CyMover, self).prepare_for_model_step(sc, time_step, model_time_datetime) <NEW_LINE> if self.active: <NEW_LINE> <INDENT> uncertain_spill_count = 0 <NEW_LINE> uncertain_spill_size = np.array((0,), dtype=np.int32) <NEW_LINE> i... | Default implementation of prepare_for_model_step(...)
- Sets the mover's active flag if time is within specified timespan
(done in base class Mover)
- Invokes the cython mover's prepare_for_model_step
:param sc: an instance of gnome.spill_container.SpillContainer class
:param time_step: time step in seconds
:para... | 625941c5236d856c2ad447dc |
def as_list(self): <NEW_LINE> <INDENT> params = [] <NEW_LINE> for key, val in self.parameters.items(): <NEW_LINE> <INDENT> params.append({ "ParameterKey": key, "ParameterValue": val }) <NEW_LINE> <DEDENT> return params | Return params list
:return: | 625941c53617ad0b5ed67efc |
def resource_acl_delete(context, data_dict): <NEW_LINE> <INDENT> return resource_acl_create(context, data_dict) | Authorization check for deleting a acl for a resource
| 625941c5e64d504609d74843 |
def testEmpty(self): <NEW_LINE> <INDENT> data = '' <NEW_LINE> mockOpener = mockOpen(read_data=data) <NEW_LINE> with patch.object(builtins, 'open', mockOpener): <NEW_LINE> <INDENT> reads = SSFastaReads(data) <NEW_LINE> self.assertEqual([], list(reads)) | An empty PDB FASTA file results in an empty iterator. | 625941c5a219f33f3462896f |
def main(): <NEW_LINE> <INDENT> parser = ArgumentParser(description="grep tool wrapper for pre-commit") <NEW_LINE> parser.add_argument( "pattern", type=str, nargs=1, help="The pattern(s) passed to grep. " "You can pass multiple patterns as such: `(pattern1|...|patternN)`" ) <NEW_LINE> parser.add_argument("files", type=... | Simple wrapper to avoid having to conform to UPPER_CASE naming style.
It will be called by the `gphook` entry point. | 625941c5498bea3a759b9ab3 |
def get_project_repository(): <NEW_LINE> <INDENT> global _PROJECT_REPOSITORY <NEW_LINE> return _get_repository(_PROJECT_REPOSITORY, ProjectRepo) | Returns a singleton Project repository instance. | 625941c5e5267d203edcdca2 |
def set_password(self, clear_password): <NEW_LINE> <INDENT> self.password = md5.new(clear_password).digest() | Method to convert password passed as parameter to md5 hash and
update the user's password to the hashed string.
Keyword arguments:
clear_password -- A new password string. | 625941c5b545ff76a8913e1a |
def materialForFace(face, modl): <NEW_LINE> <INDENT> if not face.has_material: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return modl.materials[face.material_index] | Returns material name for the given face and modl | 625941c5283ffb24f3c55906 |
def _generate_uuid(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.unique_sequence = 1 if self.unique_sequence > self.sequence_max else self.unique_sequence <NEW_LINE> sequence = self.unique_sequence <NEW_LINE> left = 10 <NEW_LINE> l = [] <NEW_LINE> while sequence > 0: <NEW_LINE> <INDENT> l.append(str(sequence... | 生成唯一的协程ID,0_0_0_0_0_,0代表一位数字[0-9],_代表一个字符[a-zA-Z],考虑协程数最多100,000个,
用5位数表示,位与位之间嵌入随即的字符
:return: uuid | 625941c5be383301e01b548c |
def get(self, key): <NEW_LINE> <INDENT> if key in self.cache_data and key: <NEW_LINE> <INDENT> self.ages[key] = self.counter <NEW_LINE> self.count_used(key) <NEW_LINE> self.counter += 1 <NEW_LINE> return self.cache_data.get(key) <NEW_LINE> <DEDENT> return None | get an item from the cache | 625941c50a366e3fb873e81d |
def normalize(): <NEW_LINE> <INDENT> apply( input_filepath = TRANSACTIONS, output_filepath = TRANSACTIONS_SQUARED, func = square ) <NEW_LINE> apply( input_filepath = ADDRESSES, output_filepath = ADDRESSES_GENMETCALFE, func = generalized_metcalfe ) <NEW_LINE> create_stock_to_flow( supply_path = MONTHLY_SUPPLY, output_fi... | Normalize data - needs to be done in a routine basis after fetching data. | 625941c538b623060ff0adf2 |
def storeFilesNoZip(pmid, metaData, fulltextData, outDir): <NEW_LINE> <INDENT> fileDir = join(outDir, "files") <NEW_LINE> if not isdir(fileDir): <NEW_LINE> <INDENT> os.makedirs(fileDir) <NEW_LINE> <DEDENT> suppFnames = [] <NEW_LINE> suppUrls = [] <NEW_LINE> for suffix, pageDict in fulltextData.iteritems(): <NEW_LINE> <... | write files from dict (keys like main.html or main.pdf or s1.pdf, value is binary data)
to directory <outDir>/files | 625941c54a966d76dd551012 |
def validate(self, data): <NEW_LINE> <INDENT> user = authenticate(email=data['email'], password=data['password']) <NEW_LINE> if not user: <NEW_LINE> <INDENT> raise serializers.ValidationError('Invalid credentials') <NEW_LINE> <DEDENT> if not user.profile.can_access(): <NEW_LINE> <INDENT> raise serializers.ValidationErr... | Check credentials. | 625941c5be383301e01b548d |
def network(qmatrix): <NEW_LINE> <INDENT> from networkx import Graph <NEW_LINE> graph = Graph() <NEW_LINE> for i in range(qmatrix.nopen): graph.add_node(i, open=True) <NEW_LINE> for j in range(qmatrix.nshut): graph.add_node(i+j, open=False) <NEW_LINE> for i in range(qmatrix.matrix.shape[0]): <NEW_LINE> <INDENT> for j i... | Creates networkx graph object from a :class:`QMatrix` object.
Vertices have an "open" attribute to indicate whether they are open or shut. Edges have a
"k+" and "k-" attribute containing the transition rates for the node with smaller index to
the node with larger index, and vice-versa.
:param qmatrix:
A :class:`Q... | 625941c54a966d76dd551013 |
def get_soup(url): <NEW_LINE> <INDENT> opener = urllib2.build_opener() <NEW_LINE> request = urllib2.Request(url); <NEW_LINE> request.add_header('User-Agent','Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1'); <NEW_LINE> data = opener.open(request).read(); <NEW_LINE> return BeautifulSoup(dat... | Gets a page from url and returns the beautifulsoup for it | 625941c53c8af77a43ae37a3 |
def get_stellar_components(self): <NEW_LINE> <INDENT> log.info("Getting the stellar components ...") <NEW_LINE> for component_id in self.ski.get_stellar_component_ids(): <NEW_LINE> <INDENT> properties = self.ski.get_stellar_component_properties(component_id) <NEW_LINE> geometries = properties["children"]["geometry"]["c... | This function ...
:return: | 625941c591f36d47f21ac4f5 |
def _extract_model(self, name, model, session, autodetect, is_tensorflow=False, verbose=0): <NEW_LINE> <INDENT> code = "" <NEW_LINE> print("extracting model") <NEW_LINE> levels = { 0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG } <NEW_LINE> if verbose > 2: <NEW_LINE> <INDENT> verbose = 2 <NEW_LINE> <DEDENT> logg... | Extracts source code and any objects required to deploy the model.
Parameters
----------
name: string
name of your model
model: YhatModel
an instance of a Yhat model
session: globals()
your Python's session variables (i.e. "globals()")
verbose: int
log level | 625941c5b5575c28eb68e003 |
def version(self, name, instantiate=True): <NEW_LINE> <INDENT> version = (self._version_original if name == 'self' else self._versions.get(name, None)) <NEW_LINE> if not version: <NEW_LINE> <INDENT> raise IndexError('Version with name "%s" does not exists.' % name) <NEW_LINE> <DEDENT> return version.version(self.source... | version get method, for overrite behaviour of version creating to set
some attrs in all(any) versions directly (use on your own risk),
for example, like that:
def version(self, name, instantiate=False):
cls, args, kwargs = super(SomeClass, self).version(name, False)
kwargs.update({'lazy': True, 'quiet': False,... | 625941c5cc40096d61595955 |
def random_color(_min=MIN_COLOR, _max=MAX_COLOR): <NEW_LINE> <INDENT> return color(random.randint(_min, _max)) | Returns a random color between min and max. | 625941c510dbd63aa1bd2ba8 |
def PT_Date(Time=int(time.time()), Type=0): <NEW_LINE> <INDENT> Date_Str = {}; <NEW_LINE> tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst = time.localtime() <NEW_LINE> tm_mon = Pad( str(tm_mon), 2, '0', 2 ) <NEW_LINE> tm_mon = Pad( str(tm_mday), 2, '0', 2 ) <NEW_LINE> tm_mon = Pad( str(tm_... | PT_Date - return a date in various formats. | 625941c56fb2d068a760f0a0 |
def get_ue_signal_power(self, ue_id): <NEW_LINE> <INDENT> return self._format_and_parse( apis.UE_SIGNAL_POWER + str(ue_id)) | Method to calculate signal power between the UE and AP | 625941c5046cf37aa974cd4d |
def send_to_file(self, data): <NEW_LINE> <INDENT> return lib.core.common.write_to_log_file( data, lib.core.settings.NMAP_LOG_FILE_PATH, lib.core.settings.NMAP_FILENAME.format(self.ip) ) | send all the information to a JSON file for further use | 625941c5507cdc57c6306cdc |
def encode_lease_pb(self): <NEW_LINE> <INDENT> task_pb = taskqueue_service_pb2.TaskQueueQueryAndOwnTasksResponse().task.add() <NEW_LINE> task_pb.task_name = self.id.encode('utf-8') <NEW_LINE> epoch = datetime.datetime.utcfromtimestamp(0) <NEW_LINE> task_pb.eta_usec = int((self.get_eta() - epoch).total_seconds() * ... | Encode this task as a protocol buffer response.
Returns:
A TaskQueueQueryAndOwnTasksResponse.Task object. | 625941c5f7d966606f6aa007 |
def sample(self, features, max_length=30): <NEW_LINE> <INDENT> N = features.shape[0] <NEW_LINE> captions = self._null * np.ones((N, max_length), dtype=np.int32) <NEW_LINE> W_proj, b_proj = self.params['W_proj'], self.params['b_proj'] <NEW_LINE> W_embed = self.params['W_embed'] <NEW_LINE> Wx, Wh, b = self.params['Wx'], ... | Run a test-time forward pass for the model, sampling captions for input
feature vectors.
At each timestep, we embed the current word, pass it and the previous hidden
state to the RNN to get the next hidden state, use the hidden state to get
scores for all vocab words, and choose the word with the highest score as
the ... | 625941c5925a0f43d2549e7a |
def test_node_users(self): <NEW_LINE> <INDENT> params = { 'start': 0, 'perPage': 15, 'role_id': 1, 'entId': 'APICeShiQiYe', 'userId': 'ApiTest' } <NEW_LINE> nowlogin = Login().login('admin') <NEW_LINE> sendrequest = nowlogin.get(Login().url + '/service_org/organization/node/users', params=params) <NEW_LINE> outputreque... | 获取组织架构用户列表接口
应用访问地址:/organization/manage
平台应用场景:进入组织架构管理列表触发 | 625941c530bbd722463cbdc9 |
def make_cube(files=(file_nh311_dr1, file_nh322_dr1), rms_files=(file_rms_nh311_dr1, file_rms_nh322_dr1)): <NEW_LINE> <INDENT> files = np.atleast_1d([f for f in files]) <NEW_LINE> rms_files = np.atleast_1d([f for f in rms_files]) <NEW_LINE> if files.size > 1: <NEW_LINE> <INDENT> spc_dict = {f: pyspeckit.Cube(f) for f i... | Opens the cube and calculates all the pre-fitting attributes of interest. | 625941c5cdde0d52a9e53036 |
def train_calibration(self, probs, labels): <NEW_LINE> <INDENT> assert(probs.shape[0] >= self._num_calibration) <NEW_LINE> self._k = probs.shape[1] <NEW_LINE> assert self._k == labels.max() - labels.min() + 1 <NEW_LINE> labels_one_hot = torch_utils.get_labels_one_hot(labels, self._k) <NEW_LINE> self._calibrators = [] <... | Train a calibrator given probs and labels.
Args:
probs: A sequence of dimension (n, k) where n is the number of
data points, and k is the number of classes, representing
the output probabilities/confidences of the uncalibrated
model.
labels: A sequence of length n, where n is the number... | 625941c523849d37ff7b3094 |
def generateFolder(folderName): <NEW_LINE> <INDENT> newfolderName = os.path.abspath(folderName) <NEW_LINE> if os.getcwd()!=newfolderName: <NEW_LINE> <INDENT> if os.path.exists(newfolderName): shutil.rmtree(newfolderName, ignore_errors=True) <NEW_LINE> os.makedirs(newfolderName) <NEW_LINE> <DEDENT> return newfolderName | Generate folder to place files and return full path
Parameters
----------
folderName : str
Folder name to be created
Returns
-------
[str]
Full path of the new created folder | 625941c54f88993c3716c06d |
def dump_conf(self, config_pathname=None): <NEW_LINE> <INDENT> if not config_pathname: <NEW_LINE> <INDENT> config_pathname = self._get_option("admin.dump_conf").value <NEW_LINE> <DEDENT> opener = functools.partial(open, config_pathname, "w") <NEW_LINE> config_file_type = os.path.splitext(config_pathname)[1][1:] <NEW_LI... | write a config file to the pathname specified in the parameter. The
file extention determines the type of file written and must match a
registered type.
parameters:
config_pathname - the full path and filename of the target config
file. | 625941c5097d151d1a222e5f |
def set_duration(self, value): <NEW_LINE> <INDENT> value = value or 0 <NEW_LINE> hours = int(value) <NEW_LINE> minutes = int(60 * (value - hours)) <NEW_LINE> self.duration_hours = hours <NEW_LINE> self.duration_minutes = minutes | Sets (without saving) duration in hours and minutes given a decimal value.
e.g., a decimal value of 10.3 equals 10 hours and 18 minutes. | 625941c58e05c05ec3eea378 |
def updateActions(self): <NEW_LINE> <INDENT> doc = self._doc() <NEW_LINE> if doc: <NEW_LINE> <INDENT> import engrave <NEW_LINE> engraver = engrave.Engraver.instance(self.mainwindow()) <NEW_LINE> self.doc_toggle_sticky.setChecked(doc is engraver.stickyDocument()) | Called just before show. | 625941c50a50d4780f666e96 |
def getPixelValue(x, y): <NEW_LINE> <INDENT> color_buffer = pyglet.image.get_buffer_manager().get_color_buffer() <NEW_LINE> pix = color_buffer.get_region(x,y,1,1).get_image_data().get_data("RGBA", 4) <NEW_LINE> return pix[0], pix[1], pix[2], pix[3] | Return the RGBA 0-255 color value of the pixel at the x,y position. | 625941c515baa723493c3f79 |
def get_tag_num(self): <NEW_LINE> <INDENT> sql = "select distinct tag as num from tag" <NEW_LINE> self.cursor.execute(sql) <NEW_LINE> result = self.cursor.fetchall() <NEW_LINE> return len(result) | 获取标签数量
Returns:
[type] -- [description] | 625941c5442bda511e8be41f |
def GetInstances(self, instanceFilter, autoHandleToken=None): <NEW_LINE> <INDENT> return self.call("GetInstances", {"instanceFilter": instanceFilter}, autoHandleToken=autoHandleToken) | Get list of instances.
:param instanceFilter: Instance filter string.
:type instanceFilter: str
:param autoHandleToken: If set to True, the caller does not need to handle tokens of long running tasks, but instead has to wait for the result.
:type autoHandleToken: bool | 625941c5435de62698dfdc51 |
def get(path): <NEW_LINE> <INDENT> def decorator(func): <NEW_LINE> <INDENT> @functools.wraps(func) <NEW_LINE> def wrapper(*args,**kw): <NEW_LINE> <INDENT> return func(*args,**kw) <NEW_LINE> <DEDENT> wrapper.__method__ = 'GET' <NEW_LINE> wrapper.__route__ = path <NEW_LINE> return wrapper <NEW_LINE> <DEDENT> return decor... | define decorator @get('/path')
:param path: url
:return:decorator | 625941c556b00c62f0f1465d |
def testDisplayBytes_007(self): <NEW_LINE> <INDENT> bytes = 72372224 <NEW_LINE> result = displayBytes(bytes) <NEW_LINE> self.assertEqual("69.02 MB", result) <NEW_LINE> result = displayBytes(bytes, 3) <NEW_LINE> self.assertEqual("69.020 MB", result) | Test display for a positive value >= 1MB | 625941c5cad5886f8bd26fde |
def __contextMenuMoveFirst(self): <NEW_LINE> <INDENT> self.moveTab(self.contextMenuIndex, 0) | Private method to move a tab to the first position. | 625941c5b830903b967e9911 |
def get(self,l,r): <NEW_LINE> <INDENT> l += self.size <NEW_LINE> r += self.size <NEW_LINE> res = self.sta <NEW_LINE> while l < r: <NEW_LINE> <INDENT> if l & 1: <NEW_LINE> <INDENT> res =self.tree[l]^res <NEW_LINE> l += 1 <NEW_LINE> <DEDENT> if r & 1: <NEW_LINE> <INDENT> res = self.tree[r-1]^res <NEW_LINE> <DEDENT> l >>=... | take the value of [l r) with func (min or max) | 625941c5d164cc6175782d52 |
def get_latest_lp_addresses(data_directory: Path) -> List[ChecksumEthAddress]: <NEW_LINE> <INDENT> root_dir = Path(__file__).resolve().parent.parent.parent.parent.parent <NEW_LINE> our_downloaded_meta = data_directory / 'assets' / 'uniswapv2_lp_tokens.meta' <NEW_LINE> our_builtin_meta = root_dir / 'data' / 'uniswapv2_l... | Gets the latest lp addresses either locally or from the remote
Checks the remote (github) and if there is a newer file there it pulls it,
saves it and its md5 hash locally and returns the new lp addresses.
If there is no new file (same hash) or if there is any problem contacting the remote
then the builtin lp assets ... | 625941c5e76e3b2f99f3a812 |
def run(args): <NEW_LINE> <INDENT> if args.version: <NEW_LINE> <INDENT> print(version.version(short=True)) <NEW_LINE> print() <NEW_LINE> print() <NEW_LINE> print(qutebrowser.__copyright__) <NEW_LINE> print() <NEW_LINE> print(version.GPL_BOILERPLATE.strip()) <NEW_LINE> sys.exit(usertypes.Exit.ok) <NEW_LINE> <DEDENT> if ... | Initialize everthing and run the application. | 625941c5b5575c28eb68e004 |
def relative_max_euclidean_dist_frame(self, c1, c2): <NEW_LINE> <INDENT> return np.clip(np.ndarray.max(self.euclidean_dist(c1, c2), axis=1) / self.face_dimension(c1) * 100, 0, 100) | find the maximum euclidean distance per frames
| 625941c5e76e3b2f99f3a813 |
def hospital_admin_create_user_success(request): <NEW_LINE> <INDENT> username = request.user.username <NEW_LINE> if request.method == "POST": <NEW_LINE> <INDENT> return redirect('/healthnet/hospital_admin_index') <NEW_LINE> <DEDENT> return render(request, 'healthnet/hospital_admin_create_user_success.html', {'username'... | Displays a page stating that the creation of the user was
successful
Author: Nick Deyette | 625941c585dfad0860c3ae5f |
def ErrorRaw(self, rawText, *args): <NEW_LINE> <INDENT> self.errorRaised = True <NEW_LINE> if ((self.maxOutputLevel >= LEVEL.ERROR) and (self.outputSink == SINK.CONSOLE or self.outputSink == SINK.BOTH)): <NEW_LINE> <INDENT> for level in range(self.errorRawContextLevel): <NEW_LINE> <INDENT> print("**ErrorRaw** - Context... | Output error information without translation if the sink is CONSOLE.
| 625941c54d74a7450ccd41c8 |
def __init__(self, s, start, stop): <NEW_LINE> <INDENT> self.__s = s <NEW_LINE> self.__start = start <NEW_LINE> self.__stop = stop <NEW_LINE> if s.seekable(): <NEW_LINE> <INDENT> s.seek(start) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cnt = 0 <NEW_LINE> while(cnt < start): <NEW_LINE> <INDENT> s.read(1) <NEW_LINE> c... | Parameters
----------
s : Stream
the underlying stream
start : int
start position (0-based)
stop : int
end posistion (excluded) | 625941c5293b9510aa2c329c |
def value(self, index): <NEW_LINE> <INDENT> return self.client.send_si(self.handle, "value("+b2str(index)+")") | Returns element i of this vector. | 625941c567a9b606de4a7ebf |
def to_dictionary(self): <NEW_LINE> <INDENT> my_dict = {} <NEW_LINE> for attr in ["id", "size", "x", "y"]: <NEW_LINE> <INDENT> my_dict.update({attr: getattr(self, attr)}) <NEW_LINE> <DEDENT> return my_dict | returns the Square's dictionary representation
alternatives:
vars(self)
self.__dict__
Returns:
dict: dictionary representation of a Square | 625941c563f4b57ef0001122 |
def scan( self, package: Package, level: str ) -> Optional[List[Issue]]: <NEW_LINE> <INDENT> if "c_src" not in package.keys() or not package["c_src"]: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> if self.plugin_context is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> cccc_bin = "cccc" <NEW_LINE> if sel... | Run tool and gather output. | 625941c52ae34c7f2600d136 |
def GetPointer(self): <NEW_LINE> <INDENT> return _itkMaskImageFilterPython.itkMaskImageFilterIVF22IUL2IVF22_GetPointer(self) | GetPointer(self) -> itkMaskImageFilterIVF22IUL2IVF22 | 625941c5d10714528d5ffce6 |
def replace_from_dict(self, text, word_dict): <NEW_LINE> <INDENT> constants = self.application.get("constants") <NEW_LINE> for key in constants: <NEW_LINE> <INDENT> if isinstance(constants[key], int): <NEW_LINE> <INDENT> text = text.replace("{__" + key + "}", str(constants[key])) <NEW_LINE> <DEDENT> elif isinstance(con... | Remplace par leur valeur les mots entre accolades {mot} trouvés dans le dictionnaire
Ajout de la recherche des constante {__constant} | 625941c5ac7a0e7691ed40d4 |
def dpdtheta2(self, theta2): <NEW_LINE> <INDENT> theta2 = np.asarray(theta2, 'f') <NEW_LINE> total = np.zeros_like(theta2) <NEW_LINE> for ii in range(1, self.n_gauss() + 1): <NEW_LINE> <INDENT> A = self.pars['A_%d' % ii] <NEW_LINE> sigma = self.pars['sigma_%d' % ii] <NEW_LINE> total += A * exp(-theta2 / (2 * sigma ** 2... | dp / dtheta2 at position theta2 = theta ^ 2. | 625941c5e1aae11d1e749cbb |
def __init__(self, args): <NEW_LINE> <INDENT> self.args = args.args <NEW_LINE> self.varargs = args.vararg <NEW_LINE> self.kwarg = args.kwarg <NEW_LINE> self.kwonlyargs = args.kwonlyargs <NEW_LINE> self.defaults = args.defaults <NEW_LINE> self.kw_defaults = args.kw_defaults <NEW_LINE> self.arguments = list() <NEW_LINE> ... | Create an Argument container class.
Args:
args(list(ast.args): The arguments in a function AST node. | 625941c515fb5d323cde0b12 |
@Timer(name="part 2") <NEW_LINE> def part_two(): <NEW_LINE> <INDENT> memory = read_input("02_input.txt") <NEW_LINE> for n in range(0, 100): <NEW_LINE> <INDENT> for v in range(0, 100): <NEW_LINE> <INDENT> res = noun_verb(n, v) <NEW_LINE> if res == 19690720: <NEW_LINE> <INDENT> return 100 * n + v | Brute force solution | 625941c5596a897236089ac7 |
def destroy_fftsetup(): <NEW_LINE> <INDENT> with lock: <NEW_LINE> <INDENT> FFTSETUP_DATA.clear() <NEW_LINE> fftsetup.destroy() <NEW_LINE> fftsetupD.destroy() | Destroys all (double and single precision) setups. | 625941c566673b3332b92096 |
def test_similar_users(self): <NEW_LINE> <INDENT> post_result = self.register_one_user() <NEW_LINE> self.assertEqual(post_result.status_code, 201) <NEW_LINE> second_similar_post = self.register_one_user() <NEW_LINE> result = json.loads(second_similar_post.data.decode()) <NEW_LINE> self.assertEqual(result['message'], 'T... | A method to test no registration when the user had been registered
before | 625941c521bff66bcd684959 |
def concatenateParts(output, *args): <NEW_LINE> <INDENT> to_delete = [] <NEW_LINE> try: <NEW_LINE> <INDENT> if output.endswith(".bcf"): <NEW_LINE> <INDENT> outputformat = "b" <NEW_LINE> outputext = ".bcf" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> outputformat = "z" <NEW_LINE> outputext = ".vcf.gz" <NEW_LINE> <DEDEN... | Concatenate BCF files
Trickier than it sounds because when there are many files we might run into
various limits like the number of open files, or the length of a command line.
This function will bcftools concat in a tree-like fashion to avoid this. | 625941c55fdd1c0f98dc0238 |
def __init__(self, size, maze_type, algorithm, auto_generation=True): <NEW_LINE> <INDENT> self.size = size <NEW_LINE> self.maze_type = maze_type <NEW_LINE> self.type_value = getattr(self.Type, maze_type) <NEW_LINE> self.position = None <NEW_LINE> self.cell_size = None <NEW_LINE> self.graph_cell_size = None <NEW_LINE> s... | :param size:
:param maze_type:
:param algorithm:
:param auto_generation: if False, then reading from file | 625941c50383005118ecf5e9 |
def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw): <NEW_LINE> <INDENT> if 'ymin' in kw: <NEW_LINE> <INDENT> bottom = kw.pop('ymin') <NEW_LINE> <DEDENT> if 'ymax' in kw: <NEW_LINE> <INDENT> top = kw.pop('ymax') <NEW_LINE> <DEDENT> if kw: <NEW_LINE> <INDENT> raise ValueError("unrecognized kwargs: %s"... | Set the data limits for the y-axis
.. ACCEPTS: (bottom: float, top: float)
Parameters
----------
bottom : scalar, optional
The bottom ylim (default: None, which leaves the bottom
limit unchanged).
top : scalar, optional
The top ylim (default: None, which leaves the top limit
unchanged).
emit : bool,... | 625941c5adb09d7d5db6c795 |
def constructFileContent(self): <NEW_LINE> <INDENT> all_data = "" <NEW_LINE> magic_bytes = "f9beb4d9" <NEW_LINE> dataCount = len(self.data) <NEW_LINE> for id_data in self.data: <NEW_LINE> <INDENT> all_data += id_data.inFileContent <NEW_LINE> <DEDENT> self.content = magic_bytes + str(dataCount) + self.block_header + '|'... | What is written inside the blk*.dat files | 625941c566656f66f7cbc1af |
def test_staff_inputs_expressions_legacy(self): <NEW_LINE> <INDENT> problem = self.build_problem(answer="1+1j", tolerance=1e-3) <NEW_LINE> self.assert_grade(problem, '1+j', 'correct') | Test that staff may enter in a complex number as the answer. | 625941c557b8e32f5248349f |
def test_merge2_sql_semantics_outerjoin_single(): <NEW_LINE> <INDENT> foo, bar = TestDataset.sql_semantics2() <NEW_LINE> result = rt.merge2( foo, bar, on=('col1', 'col1'), how='outer', suffixes=('_foo', '_bar'), indicator=True, ) <NEW_LINE> assert result.get_nrows() == 19 <NEW_LINE> inv = rt.int32.inv <NEW_LINE> assert... | Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
full outer join
sql_semantics.... | 625941c50c0af96317bb81ed |
def apply_modifier(self, modifier: POWModifier): <NEW_LINE> <INDENT> self._modifiers.append(modifier) | Применяет данный модификатор к юниту.
:param modifier: Применяемый модификатор POW. | 625941c597e22403b379cf9e |
def user(name, password, **kwargs): <NEW_LINE> <INDENT> if not user_exists(name, **kwargs): <NEW_LINE> <INDENT> create_user(name, password, **kwargs) | Require a MySQL user | 625941c5d18da76e235324da |
def test_not_authenticated_get(self): <NEW_LINE> <INDENT> response = self.client.get('/sale-management/') <NEW_LINE> self.assertRedirects(response, '/login/?redirect_to=/sale-management/', status_code=302, target_status_code=200, fetch_redirect_response=True) | ログインせず、ログインページ以外のページにアクセスした場合、ログインページへリダイレクトすることを検証 | 625941c51f037a2d8b946203 |
def has_permission(self): <NEW_LINE> <INDENT> return True | Checks if this module may be loaded. This is not automatically respected
by render() or to_dict(). You need to check this yourself! | 625941c5f7d966606f6aa008 |
def test_year_year_zero_datetime_parse(self): <NEW_LINE> <INDENT> obj = awstats_reader.awstats_datetime('0') <NEW_LINE> self.assertEqual(obj,datetime.datetime(1,1,1)) | Ensure the Awstats 'year zero' is parsed correctly | 625941c5091ae35668666f66 |
def __init__(self, **op_init_kwargs: Any): <NEW_LINE> <INDENT> self._op_init_kwargs = op_init_kwargs <NEW_LINE> self._ops = [] | Create a new, empty pipeline.
Args:
**op_init_kwargs: Keyword arguments passed to ``opfunc`` in :meth:`add`. | 625941c52ae34c7f2600d137 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.unpack(str[start:end]) <NEW_LINE> start = end <NEW_LINE> end += length <NEW_LINE> if python3: <NEW_LINE> <INDENT> self.state = str[start:end].decode('utf-8') <NEW_... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941c50a366e3fb873e81e |
def weight(self, measurement, particle): <NEW_LINE> <INDENT> gauss = pr.Gaussian(m = measurement, v = self.cov) <NEW_LINE> f = gauss.pdf_mat() <NEW_LINE> w = f(particle) <NEW_LINE> return w[0] | measurement - 2D column numpy.matrix
particle - Pose2D | 625941c523e79379d52ee56b |
def is_positive(self): <NEW_LINE> <INDENT> return (self._num > 0) | -------------------------------------------------------
Is self greater than 0?
-------------------------------------------------------
Postconditions:
returns - True if the fraction corresponding to self is > 0,
False otherwise.
Note: This method is provided for convenience as it requires
less overhea... | 625941c5293b9510aa2c329d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.