code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@app.cli.command('resetdb') <NEW_LINE> @click.pass_context <NEW_LINE> def reset_db(ctx): <NEW_LINE> <INDENT> ctx.invoke(drop_db) <NEW_LINE> ctx.invoke(init_db) <NEW_LINE> ctx.invoke(seed_db) | Drops, initializes, then seeds tables with data | 625941be07d97122c417879e |
def text_features_grouped(file_name): <NEW_LINE> <INDENT> print("--------Grouped Features---------\n") <NEW_LINE> from sklearn.feature_extraction.text import CountVectorizer <NEW_LINE> with open(os.getcwd() + "/data/datafinal_60-16.json") as data_file: <NEW_LINE> <INDENT> data = json.load(data_file) <NEW_LINE> <DEDENT>... | - Open JSON file and get unique set of words
Parameters
----------
file_name: String
Returns
-------
None
Examples
--------
>>> text_features_grouped(file_name)
tuple(X, Y) | 625941be4a966d76dd550f25 |
def _ConvertMapFieldValue(self, value, message, field): <NEW_LINE> <INDENT> if not isinstance(value, dict): <NEW_LINE> <INDENT> raise ParseError( 'Map field {0} must be in a dict which is {1}.'.format( field.name, value)) <NEW_LINE> <DEDENT> key_field = field.message_type.fields_by_name['key'] <NEW_LINE> value_field = ... | Convert map field value for a message map field.
Args:
value: A JSON object to convert the map field value.
message: A protocol message to record the converted data.
field: The descriptor of the map field to be converted.
Raises:
ParseError: In case of convert problems. | 625941be507cdc57c6306bed |
def init_model_(model, init_method): <NEW_LINE> <INDENT> get_initializer(init_method) <NEW_LINE> model.apply(_init) <NEW_LINE> logger.info("Init params with: {}".format(init_method)) | Usage:
from initializer import init_model_
model = Model()
init_method = hoge
init_model_(model, init_method) | 625941be6fb2d068a760efb3 |
def hasCalibration(self, thermistors): <NEW_LINE> <INDENT> if not self.calibration: <NEW_LINE> <INDENT> print("Missing calibration file") <NEW_LINE> return False <NEW_LINE> <DEDENT> missing = [] <NEW_LINE> for name in thermistors: <NEW_LINE> <INDENT> if not self.calibration[name]: <NEW_LINE> <INDENT> missing.append(nam... | checks if a list of thermistors (names) have calibration data | 625941be8da39b475bd64e89 |
def test_tuple_normalized_rgb(self): <NEW_LINE> <INDENT> colour1 = colourettu.Colour( (0.5656023325553875, 0.8070789468680986, 0.8006291331865334), normalized_rgb=True, ) <NEW_LINE> self.assertEqual(colour1.hex(), "#90CDCC") | Get value of colour given as a tuple of normalized rgb values | 625941be7d847024c06be1d1 |
def success(self, *args: Any, **kwargs: Any) -> None: <NEW_LINE> <INDENT> super(WolfLogger, self).log(SUCCESS, *args, **kwargs) | Logs a success message. | 625941be23e79379d52ee47f |
def _equ(s, P, Q): <NEW_LINE> <INDENT> return P[0] * Q[1] == P[1] * Q[0] | Is P equals to Q? | 625941bed486a94d0b98e05d |
def _resize_columns(self): <NEW_LINE> <INDENT> self.table.column('#0', width=36) <NEW_LINE> for head, width in self.headings.items(): <NEW_LINE> <INDENT> self.table.column(head, width=width) | Resize columns in treeview. | 625941bede87d2750b85fca8 |
def walk_up(start, sentinel): <NEW_LINE> <INDENT> from os.path import abspath, exists, isdir, join, dirname <NEW_LINE> current = abspath(start) <NEW_LINE> if not exists(current) or not isdir(current): <NEW_LINE> <INDENT> raise OSError('Invalid directory "%s"' % current) <NEW_LINE> <DEDENT> previouspath = None <NEW_LINE... | Given a `start` directory walk-up the file system tree until either the
FS root is reached or the `sentinel` is found.
The `sentinel` must be a string containing the file name to be found.
.. warning:: If `sentinel` is an absolute path that exists this will return
`start`, no matter what `start` is (in windows thi... | 625941be4c3428357757c242 |
def set_gpu_fraction(sess=None, gpu_fraction=0.3): <NEW_LINE> <INDENT> print(" tensorlayer: GPU MEM Fraction %f" % gpu_fraction) <NEW_LINE> gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_fraction) <NEW_LINE> sess = tf.Session(config = tf.ConfigProto(gpu_options = gpu_options)) <NEW_LINE> return sess | Set the GPU memory fraction for the application.
Parameters
----------
sess : a session instance of TensorFlow
TensorFlow session
gpu_fraction : a float
Fraction of GPU memory, (0 ~ 1]
References
----------
- `TensorFlow using GPU <https://www.tensorflow.org/versions/r0.9/how_tos/using_gpu/index.html>`_ | 625941be9f2886367277a7a8 |
def scrape(self) -> List[Article]: <NEW_LINE> <INDENT> content = self.content_provider(self.URL) <NEW_LINE> return self._parse(content) | Scrapes the first page of Hacker News. | 625941bee64d504609d74758 |
def opposite(self, v): <NEW_LINE> <INDENT> if not isinstance(v, Graph.Vertex): <NEW_LINE> <INDENT> raise TypeError('v must be a Vertex') <NEW_LINE> <DEDENT> if v is self._origin: <NEW_LINE> <INDENT> return self._destination <NEW_LINE> <DEDENT> elif v is self._destination: <NEW_LINE> <INDENT> return self._origin <NEW_LI... | Return the vertex that is opposite v on this edge. | 625941bed58c6744b4257b79 |
def Substract(*args): <NEW_LINE> <INDENT> return _ParaMEDMEM.DataArrayInt_Substract(*args) | Substract(DataArrayInt a1, DataArrayInt a2) -> DataArrayInt
1 | 625941be91af0d3eaac9b92e |
def object_vault(self, function_name): <NEW_LINE> <INDENT> def wrapper(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def nested_f(*args, **kwargs): <NEW_LINE> <INDENT> vault = Vault() <NEW_LINE> return_values = func(vault, *args, **kwargs) <NEW_LINE> if self.handle_multiple_calls: <NEW_LINE> <INDENT> n = self.call... | Decorator to provide a vault to store multiple objects.
args:
- function_name (str): name of the function
- chat_id (str): ID of group or user
**** Note that the function being decorated must have
as its first argument the vault. All variables
must be stored to this vault **** | 625941be7b180e01f3dc471b |
def move_lat(val, steps, flag): <NEW_LINE> <INDENT> bit_len = steps * 2 <NEW_LINE> lat_val = val & int('aaaaaaaaaaaaaaaa', 16) <NEW_LINE> lon_val = val & int('5555555555555555', 16) <NEW_LINE> step_val = int('5555555555555555', 16) >> (64 - bit_len) <NEW_LINE> if flag > 0: <NEW_LINE> <INDENT> lat_val += (step_val + 1) ... | Move latitude to different direction based on flag | 625941be498bea3a759b99c8 |
def infocalypse_setupfms(ui_, **opts): <NEW_LINE> <INDENT> execute_setupfms(ui_, opts) | Setup or modify the fms configuration. | 625941bed6c5a10208143f61 |
def intersect_lines(line1, line2): <NEW_LINE> <INDENT> homogeneous = np.cross(line1, line2) <NEW_LINE> homogeneous = homogeneous.astype(float) <NEW_LINE> homogeneous /= homogeneous[2] <NEW_LINE> return homogeneous[0:2] | Finds intersection of 2 lines
:param line1: 3-tuple ax+by+c=0
:param line2: 3-tuple ax+by+c=0
:return: x,y, the intersection of the lines | 625941be3d592f4c4ed1cf8d |
def get_object(self): <NEW_LINE> <INDENT> lookup_args = {} <NEW_LINE> for field_name, mapping_name in self.get_fields.items(): <NEW_LINE> <INDENT> lookup_args[field_name] = self.kwargs.get(mapping_name, None) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self.get_queryset().get(**lookup_args) <NEW_LINE> <DEDENT> ... | Retrieve the object from the database.
:return:
An instance of the model class containing the retrieved object.
:raise:
:py:exc:`!werkzeug.exceptions.NotFound` when the document does not
exist. | 625941be6e29344779a6252d |
def threeSum(self, nums): <NEW_LINE> <INDENT> res = list() <NEW_LINE> length = len(nums) <NEW_LINE> nums.sort() <NEW_LINE> i = 0 <NEW_LINE> while i < length-2 and nums[i] <= 0: <NEW_LINE> <INDENT> if i > 0 and nums[i-1] == nums[i]: <NEW_LINE> <INDENT> i = i+1 <NEW_LINE> continue <NEW_LINE> <DEDENT> j = i+1 <NEW_LINE> k... | :type nums: List[int]
:rtype: List[List[int]] | 625941bef548e778e58cd495 |
def test3_RI(self): <NEW_LINE> <INDENT> self.failUnless(not self.s.ri, "RI -> 0") | Test RI | 625941bebe7bc26dc91cd51e |
def load_json_data(file_name): <NEW_LINE> <INDENT> with open(f"data/{file_name}.json") as jf: <NEW_LINE> <INDENT> content = json.load(jf) <NEW_LINE> <DEDENT> return content | Loads the data from a json file, returns it.
r-type: dict | 625941bef7d966606f6a9f1a |
def get_classifiers(filename=None): <NEW_LINE> <INDENT> assert filename is not None <NEW_LINE> return readconfig(filename, conffile=False) | Reads python classifiers from a file.
:param filename: a filename containing python classifiers
(one classifier per line).
:return: a list with each classifier.
:rtype: ``list``
.. versionadded:: 0.1 | 625941be0fa83653e4656ed5 |
def get_model(self): <NEW_LINE> <INDENT> return 'NA' | Retrieves the part number of the component
Returns:
string: Part number of component | 625941be435de62698dfdb65 |
def propstat_by_status(propstat): <NEW_LINE> <INDENT> bystatus = {} <NEW_LINE> for propstat in propstat: <NEW_LINE> <INDENT> ( bystatus.setdefault( (propstat.statuscode, propstat.responsedescription), [] ).append(propstat.prop) ) <NEW_LINE> <DEDENT> return bystatus | Sort a list of propstatus objects by HTTP status.
:param propstat: List of PropStatus objects:
:return: dictionary mapping HTTP status code to list of PropStatus objects | 625941bed7e4931a7ee9de35 |
def OR_Query(arglist): <NEW_LINE> <INDENT> line = "','".join(arglist) <NEW_LINE> Data = "('" + line + "')" <NEW_LINE> if CON=='ALL': <NEW_LINE> <INDENT> Query = "select distinct FileName from jsoncallworddata where Keyword in " + Data <NEW_LINE> <DEDENT> elif CON=='START50WORD': <NEW_LINE> <INDENT> Query = "select dist... | This function perform OR Operation.
arglist : data item in List.
return : Call_id as data. | 625941bed99f1b3c44c674ae |
def get(self, block=True, timeout=None): <NEW_LINE> <INDENT> self.not_empty.acquire() <NEW_LINE> try: <NEW_LINE> <INDENT> if not block: <NEW_LINE> <INDENT> if self._empty(): <NEW_LINE> <INDENT> raise Empty <NEW_LINE> <DEDENT> <DEDENT> elif timeout is None: <NEW_LINE> <INDENT> while self._empty(): <NEW_LINE> <INDENT> se... | Remove and return an item from the queue.
If optional args `block` is True and `timeout` is None (the
default), block if necessary until an item is available. If
`timeout` is a positive number, it blocks at most `timeout`
seconds and raises the ``Empty`` exception if no item was
available within that time. Otherwise ... | 625941be31939e2706e4cd86 |
def put(self, key, value): <NEW_LINE> <INDENT> self.leveldb.Put(str(key), value) | Stores the object `value` named by `key` in leveldb.
Args:
key: Key naming `value`.
value: the object to store. | 625941be7b180e01f3dc471c |
def is_word_guessed(secret_word, letters_guessed): <NEW_LINE> <INDENT> return all(letter in letters_guessed for letter in secret_word) | secret_word: string, the word the user is guessing; assumes all letters are
lowercase
letters_guessed: list (of letters), which letters have been guessed so far;
assumes that all letters are lowercase
returns: boolean, True if all the letters of secret_word are in letters_guessed;
False otherwise | 625941be45492302aab5e1d9 |
def memText(self): <NEW_LINE> <INDENT> if self.debug: qDebug("[PTM] [main.py] [memText]") <NEW_LINE> line = self.ptm['vars']['formats']['mem'] <NEW_LINE> if (line.split('$memtotgb')[0] != line): <NEW_LINE> <INDENT> mem = "%4.1f" %((self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used']) / (1024.0 * 1024.... | function to set mem text | 625941be1f037a2d8b946118 |
def odds(string): <NEW_LINE> <INDENT> new_str = '' <NEW_LINE> for i in range(len(string)): <NEW_LINE> <INDENT> if i % 2 == 1: <NEW_LINE> <INDENT> new_str += string[i] <NEW_LINE> <DEDENT> <DEDENT> return new_str | This function takes one string argument (string) and returns
a new string consisting of all of the odd position
characters in the argument. | 625941be379a373c97cfaa5c |
def close(self): <NEW_LINE> <INDENT> self.fd.close() <NEW_LINE> self.fd = None | Close pid file *without* removing it. | 625941be7d847024c06be1d2 |
def testExportImageCloudApi(self): <NEW_LINE> <INDENT> with apitestcase.UsingCloudApi(): <NEW_LINE> <INDENT> region = ee.Geometry.Rectangle(1, 2, 3, 4) <NEW_LINE> config = dict( region=region['coordinates'], maxPixels=10**10, crs='foo', crs_transform='[9,8,7,6,5,4]', tiffCloudOptimized=True, fileDimensions=1024, ) <NEW... | Verifies the task created by Export.image(). | 625941be3cc13d1c6d3c7294 |
def testDigitalIOStatus(self): <NEW_LINE> <INDENT> dummy = dwf.DigitalIOStatus(self.hdwf) | Test DigitalIOStatus | 625941be5510c4643540f304 |
def sendmsg(word, word_eol, userdata): <NEW_LINE> <INDENT> channel = hexchat.get_info("channel") <NEW_LINE> context = hexchat.find_context(channel=channel) <NEW_LINE> if not userdata and len(word) < 3: <NEW_LINE> <INDENT> context.emit_print("Channel Message", __module_name__, help_gpg) <NEW_LINE> return hexchat.EAT_ALL... | Function called by /gpg. Parses user input, encrypts, and sends. | 625941bead47b63b2c509e99 |
def show_traffic(self): <NEW_LINE> <INDENT> traffic = {} <NEW_LINE> section = '' <NEW_LINE> for line in self.get_show_section('traffic'): <NEW_LINE> <INDENT> if len(line): <NEW_LINE> <INDENT> if line == line.lstrip(): <NEW_LINE> <INDENT> section = line <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if section not in tra... | Parser for show traffic | 625941be24f1403a92600a82 |
def __init__(self): <NEW_LINE> <INDENT> self.model = MyModel() <NEW_LINE> self.model.setPath("data/file.csv") | :return: | 625941be4f88993c3716bf84 |
def random(self): <NEW_LINE> <INDENT> self._random = True <NEW_LINE> self.assign_node_pos() | Button handler to toggle random node distribution | 625941be96565a6dacc8f5e5 |
def pop(self): <NEW_LINE> <INDENT> return self._stack.pop() | Remove the last layer from the loop stack. | 625941be45492302aab5e1da |
def expand_sophisticated(src, dest, preds, mapping_data, msg): <NEW_LINE> <INDENT> logger.debug(msg) <NEW_LINE> for src_rule in src.rules_iter: <NEW_LINE> <INDENT> if src_rule.alloc: <NEW_LINE> <INDENT> for dest_rule in dest.rules_iter: <NEW_LINE> <INDENT> for pred_call in dest_rule.calles: <NEW_LINE> <INDENT> if set(m... | Iterates over allocated nodes on src side and search for predicate call
containing node in arguments. Expands chosen predicate and
returns True on success, False otherwise | 625941be566aa707497f4486 |
def get_fuv_parameters(self): <NEW_LINE> <INDENT> return self.data["FUV"] | This function ...
:return: | 625941bed7e4931a7ee9de36 |
def urlretrieve(url, dest, timeout=300): <NEW_LINE> <INDENT> with open(dest, 'wb') as f: <NEW_LINE> <INDENT> r = requests.get(url, allow_redirects=True, timeout=timeout) <NEW_LINE> if r.status_code == 200: <NEW_LINE> <INDENT> f.write(r.content) <NEW_LINE> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return -1 | Download a file.
:param url: The url of the source file.
:param dest: destination file path. | 625941befff4ab517eb2f353 |
def get_pem_data(self): <NEW_LINE> <INDENT> return self.pki.do_get_pem_data() | Returns the fingerprint of CA | 625941be21bff66bcd68486e |
def register(self): <NEW_LINE> <INDENT> Storage().compile_sass() | Compile Sass.
Compile Sass if the libsass module is installed. Once installed, all
Sass files are compiled when the server is ran. This will only run
once when the server is first started. | 625941bee64d504609d74759 |
def dumpGustsFromTracks(self, trackiter, windfieldPath, timeStepCallback=None): <NEW_LINE> <INDENT> if timeStepCallback: <NEW_LINE> <INDENT> results = map(self.calculateExtremesFromTrack, trackiter, itertools.repeat(timeStepCallback)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> results = map(self.calculateExtremesFro... | Dump the maximum wind speeds (gusts) observed over a region to
netcdf files. One file is created for every track file.
:type trackiter: list of :class:`Track` objects
:param trackiter: a list of :class:`Track` objects.
:type windfieldPath: str
:param windfieldPath: the path where to store the gust output files.
:t... | 625941be56b00c62f0f14571 |
def fixside(self, opts=None): <NEW_LINE> <INDENT> self._run_method('fixside', opts) | StructureChecking.fixside
Complete side chains (heavy atoms, protein only). Check only with no options. Options accepted as command-line string, or python dictionary.
Args:
opts (str | dict - Options dictionary):
* fix:
* **all** - Fix all residues
* **residue_list** - Fix... | 625941bec432627299f04b5d |
def get_language_count(self): <NEW_LINE> <INDENT> return self.get_languages().count() | Returns number of languages used in this project. | 625941be07d97122c417879f |
def print_handled_ex(ex): <NEW_LINE> <INDENT> if DEBUG: <NEW_LINE> <INDENT> traceback.print_exc() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print(ex, file=stderr) | Print the exception or traceback to terminal depending on whether we're in debug mode | 625941bed53ae8145f87a18d |
def tv_loss(self, input): <NEW_LINE> <INDENT> tv_loss = torch.sum(torch.abs(input[:, :, :, :-1] - input[:, :, :, 1:])) + torch.sum(torch.abs(input[:, :, :-1, :] - input[:, :, 1:, :])) <NEW_LINE> return tv_loss | Total Variation Loss. | 625941be1d351010ab855a36 |
def doesConflictingEventExist(event, context): <NEW_LINE> <INDENT> event_body = json.loads(event.get("body", "")) <NEW_LINE> print("event body:") <NEW_LINE> print(event_body) <NEW_LINE> table = dynamodb.Table(calendar_table_name) <NEW_LINE> user = event_body["user_id"] <NEW_LINE> site = event_body["site"] <NEW_LINE> ti... | Calendar reservations should only let the designated user use the observatory.
If there are no reservations, anyone can use it.
Args:
event.body.user_id: auth0 user 'sub' (eg. "google-oauth2|xxxxxxxxxxxxx")
event.body.site: site code (eg. "wmd")
event.body.time: UTC datestring (eg. '2020-05-14T17:30:00Z')
... | 625941be0383005118ecf4fd |
def shift_vertical(self, n: int) -> None: <NEW_LINE> <INDENT> for cell in self.cells: <NEW_LINE> <INDENT> cell.set_y(cell.y + int(n)) <NEW_LINE> <DEDENT> self.reset_cell_coordinates() <NEW_LINE> return | Change the ``y`` coordinates of all :attr:`cells` by ``n``.
Args:
n (int): number to increment vertical position of cells | 625941be7d43ff24873a2bb7 |
def any_food(self, direction): <NEW_LINE> <INDENT> snake_head = self.snake.snake_body[0] <NEW_LINE> check_for_food = [] <NEW_LINE> if not self.game_over: <NEW_LINE> <INDENT> if direction == 'up': <NEW_LINE> <INDENT> for i in range(1, (BOARD_SIZE - (BOARD_SIZE - snake_head[0]) + 1)): <NEW_LINE> <INDENT> check_for_food.a... | return True if there is any food in the given direction | 625941be5f7d997b871749ae |
def attack(c1,e1,c2,e2,n) : <NEW_LINE> <INDENT> l=egcd(e1,e2) <NEW_LINE> d={max(e1,e2) : l[1] , min(e1,e2) : l[2]} <NEW_LINE> if l[0]==0 : <NEW_LINE> <INDENT> print("Cant be attacked viz this method") <NEW_LINE> <DEDENT> else : <NEW_LINE> <INDENT> if d[e1] < 0 : <NEW_LINE> <INDENT> c1,c2=c2,c1 <NEW_LINE> e1,e2=e2,e1 <N... | This function is used to decipher a message when the same message is sent by someone to two people but use the same modulus .One had in hand only the public key parameters and the cipher text :
attack(c1,e1,c2,e2,n) :
c1,c2 - ciphertext 1 and 2
e1,e2 - public key parameters 1 and 2
n - the common modul... | 625941be96565a6dacc8f5e6 |
@invoke.task <NEW_LINE> def serve(ctx): <NEW_LINE> <INDENT> docker_command = get_base_docker_command() <NEW_LINE> docker_command.extend(["jekyll", "serve", "--drafts", "--incremental"]) <NEW_LINE> ctx.run(" ".join(docker_command)) | Serves auto-reloading blog via Docker. | 625941be97e22403b379ceb2 |
def __str__( self, ): <NEW_LINE> <INDENT> return self.ascii_diagram(time_lines='both') | String representation of this Circuit (an ASCII circuit diagram). | 625941be92d797404e3040a3 |
def testMtoMeValues(self): <NEW_LINE> <INDENT> for m, me in self.knownValuesMtoMe: <NEW_LINE> <INDENT> result = conversions.convertMilesToMeters(m) <NEW_LINE> self.assertEqual(me, result) | convertMilesToMeters should return the correct F value | 625941beaad79263cf390956 |
def search(self, nums, target): <NEW_LINE> <INDENT> low, high = 0, len(nums) - 1 <NEW_LINE> while low <= high: <NEW_LINE> <INDENT> mid = (low + high) // 2 <NEW_LINE> if nums[mid] == target: <NEW_LINE> <INDENT> return mid <NEW_LINE> <DEDENT> if nums[mid] >= nums[low]: <NEW_LINE> <INDENT> if nums[low] <= target < nums[mi... | :type nums: List[int]
:type target: int
:rtype: int | 625941be85dfad0860c3ad73 |
def puzzle_01() -> None: <NEW_LINE> <INDENT> with open("src/day_02/input.txt", "r") as f: <NEW_LINE> <INDENT> lines = f.readlines() <NEW_LINE> total = 0 <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> stripped = line.strip() <NEW_LINE> dimensions = stripped.split("x") <NEW_LINE> l = int(dimensions[0]) <NEW_LINE> w = ... | The elves are running low on wrapping paper, and so they need to submit an
order for more. They have a list of the dimensions (length l, width w, and
height h) of each present, and only want to order exactly as much as they
need.
Fortunately, every present is a box (a perfect right rectangular prism),
which makes calc... | 625941be0fa83653e4656ed6 |
def revoke_qualification(qual_id, worker_id): <NEW_LINE> <INDENT> check_keys() <NEW_LINE> operation_name = "RevokeQualification" <NEW_LINE> param_dict = {} <NEW_LINE> param_dict["Operation"] = operation_name <NEW_LINE> param_dict["SubjectId"] = worker_id <NEW_LINE> param_dict["QualificationTypeId"] = qual_id <NEW_LINE>... | Removes the qualification with id `qual_id` from the worker with id `worker_id`. | 625941beaad79263cf390957 |
def encode_huffman_tree(root, dtype): <NEW_LINE> <INDENT> converter = {'float32':float2bitstr, 'int32':int2bitstr} <NEW_LINE> code_list = [] <NEW_LINE> def encode_node(node): <NEW_LINE> <INDENT> if node.value is not None: <NEW_LINE> <INDENT> code_list.append('1') <NEW_LINE> lst = list(converter[dtype](node.value)) <NEW... | Encodes a huffman tree to string of '0's and '1's | 625941be3346ee7daa2b2c84 |
def test2(self): <NEW_LINE> <INDENT> session=requests.Session() <NEW_LINE> login_res=session.post(url=self.TestData["login"]["login_url"],data=self.TestData["login"]["login_data"],headers=self.headers) <NEW_LINE> if login_res.status_code==200: <NEW_LINE> <INDENT> session.post(url=self.TestData["updateAgency"]["agency_u... | 尾单波次列表信息显示 | 625941be23849d37ff7b2faa |
def json_resource_file(baseurl, jsondata, resource_info): <NEW_LINE> <INDENT> response_file = StringIO() <NEW_LINE> json.dump(jsondata, response_file, indent=2, separators=(',', ': '), sort_keys=True) <NEW_LINE> response_file.seek(0) <NEW_LINE> return response_file | Return a file object that reads out a JSON version of the supplied entity values data.
baseurl base URL for resolving relative URI references.
(Unused except for diagnostic purposes.)
jsondata is the data to be formatted and returned.
resource_info is a dictionary of values about the ... | 625941be293b9510aa2c31b2 |
def process_parent_edges(self, edges): <NEW_LINE> <INDENT> assert len({e.parent for e in edges}) == 1 <NEW_LINE> parent = edges[0].parent <NEW_LINE> S = [] <NEW_LINE> for edge in edges: <NEW_LINE> <INDENT> x = self.A_head[edge.child] <NEW_LINE> while x is not None: <NEW_LINE> <INDENT> if x.right > edge.left and edge.ri... | Process all of the edges for a given parent. | 625941bea8370b77170527ba |
def rating(self): <NEW_LINE> <INDENT> return super(PikabuProfile, self).rating(self.settings["login"]) | Возвращает рейтинг пользователя | 625941be82261d6c526ab3b6 |
def hiving_swarms_ended(self): <NEW_LINE> <INDENT> pass | Called when the swarm hiving stage has completed. | 625941bebde94217f3682d0d |
def get_bldg_footprint_frm_bldg_occsolid(bldg_occsolid, tolerance = 1e-05, roundndigit = 6, distance = 0.1): <NEW_LINE> <INDENT> bounding_footprint = get_building_bounding_footprint(bldg_occsolid) <NEW_LINE> b_midpt = py3dmodel.calculate.face_midpt(bounding_footprint) <NEW_LINE> loc_pt = (b_midpt[0], b_midpt[1], b_midp... | This function gets the footprint of a building.
Parameters
----------
bldg_occsolid : OCCsolid
The OCCsolid that is a building to be analysed.
tolearnce : float, optional
The tolerance used for the analysis, the smaller the float it is more precise. Default = 1e-05.
roundndigit : int, optional
The nu... | 625941be0c0af96317bb8102 |
def ei_of_rho_p(self, rho, p): <NEW_LINE> <INDENT> return p / self._gm1 | Internal energy density as a function of density (rho) and pressure (p) | 625941becad5886f8bd26ef4 |
def open_menu(self, title): <NEW_LINE> <INDENT> if title != '': <NEW_LINE> <INDENT> menu = self.get_menu(title) <NEW_LINE> self.wait_elem_visible('.app_List span[title="' + title + '"]') <NEW_LINE> self.scroll_to_target_element(menu) <NEW_LINE> self.find_elem_is_clickable('.app_List span[title="' + title + '"]').click(... | 打开菜单 | 625941bead47b63b2c509e9a |
def __init__(self, units, num_heads, use_bias=True, dtype='float32', weight_initializer=None, bias_initializer=None, prefix=None, params=None): <NEW_LINE> <INDENT> super().__init__(prefix=prefix, params=params) <NEW_LINE> if not isinstance(num_heads, (list, tuple)): <NEW_LINE> <INDENT> num_heads = (int(num_heads),) <NE... | Multiple Dense with different parameters and the same number of units
The inner shapes of the weight and bias are
weight: (self._parallel_num[0] * ... * self._parallel_num[k] * units, in_units)
bias: (self._parallel_num[0] * ... * self._parallel_num[k],)
Parameters
----------
units : int
The basic units.
nu... | 625941bed6c5a10208143f62 |
def find_element(self, by: str = By.ID, value: Union[str, Dict] = None) -> T: <NEW_LINE> <INDENT> return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {"using": by, "value": value})['value'] | Find an element given a By strategy and locator
Override for Appium
Prefer the find_element_by_* methods when possible.
Args:
by: The strategy
value: The locator
Usage:
element = element.find_element(By.ID, 'foo')
Returns:
`appium.webdriver.webelement.WebElement` | 625941bea8370b77170527bb |
def collide_widget_relative(self, widget): <NEW_LINE> <INDENT> self_x, self_y = self.to_window(*self.pos) <NEW_LINE> self_right = self_x + self.width <NEW_LINE> self_top = (self_y + self.height) <NEW_LINE> result = True <NEW_LINE> if self_x > widget.right: <NEW_LINE> <INDENT> result = False <NEW_LINE> <DEDENT> if self_... | Collide Widget test that takes into account relative layouts. | 625941bee1aae11d1e749bcf |
def set_quantity(self, quantity): <NEW_LINE> <INDENT> self.__quantity = quantity | set order last recently shares' qty | 625941be9b70327d1c4e0cee |
def talk_m10_15_x37(): <NEW_LINE> <INDENT> if GetEventFlag(205230) != 0 and GetEventFlag(102800) != 1 and GetEventFlag(104340) != 1: <NEW_LINE> <INDENT> assert talk_m10_15_x16(lot3=1771000, z7=102800, text4=77106000, text5=77106010) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> assert talk_m10_15_x1(text1=77102400, z20... | Enclosed person: Menu conversation | 625941bebe8e80087fb20b61 |
def get_available_rewards(): <NEW_LINE> <INDENT> avail_rewards_script = "return document.getElementsByClassName('rewards-total-value')[0];" <NEW_LINE> avail_rewards = ba.driver.execute_script(avail_rewards_script).get_attribute('textContent').strip() <NEW_LINE> if avail_rewards != '$ 0': <NEW_LINE> <INDENT> return avai... | Determines if any rewards are available | 625941be91f36d47f21ac40a |
def publish(self, link, data): <NEW_LINE> <INDENT> if(link in self.publishable_links): <NEW_LINE> <INDENT> self._mqtt_client.send_message(link, data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> error_msg = 'Link ({0}) not contained in publishable links ({1})'.format(link, self.publishable_links) <NEW_LINE> self._logg... | Publishes data on a particular link. Link should have been classified as STREAM in node descriptor.
Args:
link (str): Link on which data is published.
data (bytes): Bytes to be published over MQTT.
Raises:
ValueError: If the provided link is not classified as STREAM. | 625941be046cf37aa974cc64 |
def _vec_range_J(self, a): <NEW_LINE> <INDENT> ret = zeros(self.codim) <NEW_LINE> start = 0 <NEW_LINE> for r, s in sorted(a, reverse=True): <NEW_LINE> <INDENT> tp = a[r, s].reshape(-1) <NEW_LINE> ret[start:start+tp.shape[0]] = tp <NEW_LINE> start += tp.shape[0] <NEW_LINE> <DEDENT> return ret | vectorize an elememt of rangeJ
a.reshape(-1) | 625941bedd821e528d63b0c5 |
def test_iodu_get_descriptor(self): <NEW_LINE> <INDENT> obj_id, refr = create_descriptor(dal=self.dal) <NEW_LINE> self.assertEqual(obj_id, 1) <NEW_LINE> obj = self.dal.get(Descriptor, obj_id) <NEW_LINE> self.assertEqual(obj.descriptor_id, obj_id) <NEW_LINE> self.assertEqual(obj.ui, refr["ui"]) <NEW_LINE> self.assertEqu... | Tests the IODU insertion of a `Descriptor` record via the
`iodu_descriptor` method of the `DalMesh` class and its retrieval
via the `get` method. | 625941be56ac1b37e62640ee |
def encrypt(key, text): <NEW_LINE> <INDENT> result = split_text(key, text) <NEW_LINE> return hexlify(result) | Takes a key(string), text(string) and returns a hex
encoded string XOR encrypted against the key. | 625941be097d151d1a222d76 |
def jsonify(self, *args, **kwargs): <NEW_LINE> <INDENT> warnings.warn( 'Schema.jsonify is deprecated. Call jsonify on the ' 'output of Schema.dump instead.', category=DeprecationWarning ) <NEW_LINE> return jsonify(self.data, *args, **kwargs) | Return a JSON response of the serialized data.
.. deprecated:: 0.4.0 | 625941beb7558d58953c4e33 |
def get_background(array, mode = 'histogram'): <NEW_LINE> <INDENT> if mode == 'histogram': <NEW_LINE> <INDENT> x, y = histogram(array[::2,::2,::2], log = True, plot = False) <NEW_LINE> y = numpy.log(y + 1) <NEW_LINE> y = ndimage.filters.gaussian_filter1d(y, sigma=1) <NEW_LINE> air_index = numpy.argmax(y) <NEW_LINE> fla... | Get the background intensity. | 625941beb545ff76a8913d30 |
def get_tfds_path(relative_path): <NEW_LINE> <INDENT> path = os.path.join(tfds_dir(), relative_path) <NEW_LINE> return path | Returns absolute path to file given path relative to tfds root. | 625941be009cb60464c632ce |
def zip_site_init(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> curdir = os.getcwd() <NEW_LINE> root = os.path.join(curdir, "blogofile", "site_init") <NEW_LINE> for d in os.listdir(root): <NEW_LINE> <INDENT> d = os.path.join(root, d) <NEW_LINE> if os.path.isdir(d): <NEW_LINE> <INDENT> os.chdir(root) <NEW_LINE> zf = d... | Zip up all of the subdirectories of site_init
This function should only be called by setuptools | 625941be956e5f7376d70d89 |
def apply_driver_hacks(self, app, info, options): <NEW_LINE> <INDENT> super(SQLAlchemy, self).apply_driver_hacks(app, info, options) <NEW_LINE> if info.drivername == 'sqlite': <NEW_LINE> <INDENT> connect_args = options.setdefault('connect_args', {}) <NEW_LINE> if 'isolation_level' not in connect_args: <NEW_LINE> <INDEN... | Call before engine creation. | 625941be656771135c3eb786 |
def init(self, userCmd=None, timeLim=3, getStatus=True): <NEW_LINE> <INDENT> log.info("%s.init(userCmd=%s, timeLim=%s, getStatus=%s)" % (self, userCmd, timeLim, getStatus)) <NEW_LINE> userCmd = expandCommand(userCmd) <NEW_LINE> return userCmd | Called automatically on startup after the connection is established.
Only thing to do is query for status or connect if not connected
getStatus ignored? | 625941be1f5feb6acb0c4a6e |
def create_date_frame_year(self, date): <NEW_LINE> <INDENT> b = datetime.date(date.year, 1, 1) <NEW_LINE> e = datetime.date(date.year, 12, 31) <NEW_LINE> index = pd.date_range(b, e, freq='D') <NEW_LINE> df = pd.DataFrame(index=index, columns=self.columns) <NEW_LINE> return df | Create Statistics Dataframe | 625941be21a7993f00bc7c05 |
def parse_bdist_wininst(name): <NEW_LINE> <INDENT> lower = name.lower() <NEW_LINE> base, py_ver, plat = None, None, None <NEW_LINE> if lower.endswith('.exe'): <NEW_LINE> <INDENT> if lower.endswith('.win32.exe'): <NEW_LINE> <INDENT> base = name[:-10] <NEW_LINE> plat = 'win32' <NEW_LINE> <DEDENT> elif lower.startswith('.... | Return (base.css,pyversion) or (None,None) for possible .exe name | 625941be07d97122c41787a0 |
def cook_refs(refs, eff=None, n=4): <NEW_LINE> <INDENT> reflen = [] <NEW_LINE> maxcounts = dict() <NEW_LINE> for ref in refs: <NEW_LINE> <INDENT> rl, counts = precook(ref, n) <NEW_LINE> reflen.append(rl) <NEW_LINE> for (ngram,count) in counts.items(): <NEW_LINE> <INDENT> maxcounts[ngram] = max(maxcounts.get(ngram,0), c... | Takes a list of reference sentences for a single segment
and returns an object that encapsulates everything that BLEU
needs to know about them. | 625941be8c0ade5d55d3e8da |
def line(self, serie, rescale=False): <NEW_LINE> <INDENT> serie_node = self.svg.serie(serie) <NEW_LINE> if rescale and self.secondary_series: <NEW_LINE> <INDENT> points = [ (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale) for x, y in serie.points if y is not None] <NEW_LINE> <DEDENT> else: <NEW_LINE> <IN... | Draw the line serie | 625941bed99f1b3c44c674af |
def getGenericLocation(self, *args): <NEW_LINE> <INDENT> return _libsbol.OwnedInteraction_getGenericLocation(self, *args) | Get the child object.
templateparam
-------------
* `SBOLClass` :
The type of the child object
* `SBOLSubClass` :
A derived class of SBOLClass. Use this type specialization when adding
multiple types of SBOLObjects to a container.
Parameters
----------
* `uri` :
The specific URI for a chil... | 625941be8da39b475bd64e8b |
def MultiOpen(self, urns, mode="rw", token=None, aff4_type=None, age=NEWEST_TIME, follow_symlinks=True): <NEW_LINE> <INDENT> if token is None: <NEW_LINE> <INDENT> token = data_store.default_token <NEW_LINE> <DEDENT> if mode not in ["w", "r", "rw"]: <NEW_LINE> <INDENT> raise RuntimeError("Invalid mode %s" % mode) <NEW_L... | Opens a bunch of urns efficiently. | 625941beb57a9660fec3379b |
def update_playlist_details(sp, playlist_id, playlist_name, playlist_description): <NEW_LINE> <INDENT> username = sp.me()['id'] <NEW_LINE> results = sp.user_playlist_change_details( username, playlist_id=playlist_id, name=playlist_name, description=playlist_description) <NEW_LINE> return results | Updates playlist details.
NOTE: There are several reports of issues when updating playlist descriptions in the Spotify community.
Currently, it seems the only solution is to wait for the server to update, which could take a day. | 625941bed486a94d0b98e05f |
def __init__(self, input_tensors, output_tensors, return_input=False, sess=None): <NEW_LINE> <INDENT> def normalize_name(t): <NEW_LINE> <INDENT> if isinstance(t, six.string_types): <NEW_LINE> <INDENT> return get_op_tensor_name(t)[1] <NEW_LINE> <DEDENT> return t <NEW_LINE> <DEDENT> self.return_input = return_input <NEW_... | Args:
input_tensors (list): list of names.
output_tensors (list): list of names.
return_input (bool): same as :attr:`PredictorBase.return_input`.
sess (tf.Session): the session this predictor runs in. If None,
will use the default session at the first call.
Note that in TensorFlow, defau... | 625941be23e79379d52ee481 |
def __init__(self, indices, values, dense_shape): <NEW_LINE> <INDENT> with ops.name_scope(None, "SparseTensor", [indices, values, dense_shape]): <NEW_LINE> <INDENT> indices = ops.convert_to_tensor( indices, name="indices", dtype=dtypes.int64) <NEW_LINE> values = ops.internal_convert_to_tensor(values, name="values") <NE... | Creates a `SparseTensor`.
Args:
indices: A 2-D int64 tensor of shape `[N, ndims]`.
values: A 1-D tensor of any type and shape `[N]`.
dense_shape: A 1-D int64 tensor of shape `[ndims]`. | 625941bebf627c535bc130e9 |
def GetAssembly(self): <NEW_LINE> <INDENT> pass | GetAssembly(self: IAssemblable) -> Assembly | 625941bed164cc6175782c68 |
def onCreateConflict(self,index): <NEW_LINE> <INDENT> confEditorDialog = ConflictEditorDialog(self.parentWidget()) <NEW_LINE> if confEditorDialog.exec_() == QDialog.Accepted: <NEW_LINE> <INDENT> strParent = self.parent() <NEW_LINE> conflictNode = ConflictNode(confEditorDialog.conflict,strParent) <NEW_LINE> self.strMode... | Slot raised when user selects to define new conflict information. | 625941beadb09d7d5db6c6ac |
def test_policy_set_gateway_for_vm_with_host_routes(self): <NEW_LINE> <INDENT> cidr = self._next_sequential_cidr(IP(self.base_cidr)) <NEW_LINE> allocation_pools = [{"start": str(IP(cidr[2].ip)), "end": str(IP(cidr[-2].ip))}] <NEW_LINE> net, subnet = self._create_network_with_subnet( 'hostroutes', str(cidr), allocation_... | This test verifies that defining a host route 0.0.0.0/0 for a network
translates in a default route for vm's connected to that network | 625941be6fece00bbac2d657 |
def _handle_action_set_message(self, message): <NEW_LINE> <INDENT> self.session.message_change_succeed(message) <NEW_LINE> self.session.contacts.me.message = message <NEW_LINE> contact = self.session.contacts.me <NEW_LINE> account = Logger.Account.from_contact(contact) <NEW_LINE> self.session.log('message change', cont... | handle Action.ACTION_SET_MESSAGE
| 625941be85dfad0860c3ad74 |
def test_P_A_W_AA_Deps_Force(self): <NEW_LINE> <INDENT> doc = ISE(PAR(ACTION(tools.getMockActionCmd(ACTION_RC_WARNING, "A1.STD", "A1.ERR"), id="1"), ACTION(tools.getMockActionCmd(ACTION_RC_OK, "A2.STD", "A2.ERR"), id="2"), ACTION(tools.getMockActionCmd(ACTION_RC_OK, "A3.STD", "A3.ERR"), id="3", deps="1,2"), desc="P_A_W... | A parallel with three actions. The last one has an explicit
dependency on first ones. The first one will fail with a
WARNING but with force mode. Therefore, the second one should
get executed, *and* also the third one. | 625941be004d5f362079a250 |
def _on_before_selection(self, widget, model_index, style_options): <NEW_LINE> <INDENT> self._on_before_paint(widget, model_index, style_options) <NEW_LINE> widget.set_selected(True) <NEW_LINE> sg_item = shotgun_model.get_sg_data(model_index) <NEW_LINE> num_actions = self._action_manager.populate_menu( widget.actions_m... | Called when the associated widget is selected. This method
implements all the setting up and initialization of the widget
that needs to take place prior to a user starting to interact with it.
:param widget: The widget to operate on (created via _create_widget)
:param model_index: The model index to operate on
:param ... | 625941be01c39578d7e74d56 |
@spiceErrorCheck <NEW_LINE> def tpictr(sample, lenout=_default_len_out, lenerr=_default_len_out): <NEW_LINE> <INDENT> sample = stypes.stringToCharP(sample) <NEW_LINE> pictur = stypes.stringToCharP(lenout) <NEW_LINE> errmsg = stypes.stringToCharP(lenerr) <NEW_LINE> lenout = ctypes.c_int(lenout) <NEW_LINE> lenerr = ctype... | Given a sample time string, create a time format picture
suitable for use by the routine timout.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/tpictr_c.html
:param sample: A sample time string.
:type sample: str
:param lenout: The length for the output picture string.
:type lenout: int
:param lenerr: The le... | 625941be283ffb24f3c5581f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.