code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_who_results(self, search_id: str) -> dict: <NEW_LINE> <INDENT> response = self.session.get(self.base_api + f'/who_else_results/{search_id}') <NEW_LINE> if response.status_code == 200: <NEW_LINE> <INDENT> return response.json() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return {'Error Code': response.status_c... | View the results for a single Who Else search by specifying its ID.
:param search_id: Unique search identifier - May be string or integer.
:return: | 625941da3317a56b86939f14 |
def FetchCommits(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | Missing associated documentation comment in .proto file. | 625941da8a43f66fc4b54324 |
def module_path(path: str) -> Tuple[str, Optional[str]]: <NEW_LINE> <INDENT> parts = path.split(':', 1) <NEW_LINE> module = parts.pop(0) <NEW_LINE> qualname = parts[0] if parts else None <NEW_LINE> if os.sep in module: <NEW_LINE> <INDENT> raise argparse.ArgumentTypeError( f'{module} does not look like a valid Python im... | Parse <module>[:<qualname>] into its constituent parts. | 625941da96565a6dacc8f98c |
def family_clone(dst, src): <NEW_LINE> <INDENT> raise NotImplementedError | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L66.
Positional arguments:
dst -- nl_object class instance.
src -- nl_object class instance.
Returns:
Integer. | 625941da187af65679ca53e1 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, RequestTimeoutError): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941da379a373c97cfae08 |
def findMin(self, nums): <NEW_LINE> <INDENT> left = 0 <NEW_LINE> right = len(nums) - 1 <NEW_LINE> while left < right: <NEW_LINE> <INDENT> mid = left + (right - left) // 2 <NEW_LINE> if nums[mid] > nums[right]: <NEW_LINE> <INDENT> left = mid + 1 <NEW_LINE> <DEDENT> elif nums[mid] < nums[right]: <NEW_LINE> <INDENT> right... | Args:
nums: list[int]
Return:
int | 625941da26068e7796caefa4 |
def testCapacity_007(self): <NEW_LINE> <INDENT> expectedUsed = 1 * 2048.0 <NEW_LINE> expectedAvailable = MB700 - SLEAD - expectedUsed <NEW_LINE> media = MediaDefinition(MEDIA_CDR_80) <NEW_LINE> boundaries = (0, 1) <NEW_LINE> capacity = CdWriter._calculateCapacity(media, boundaries) <NEW_LINE> self.assertEqual(expectedU... | Test _calculateCapacity for boundaries of (0, 1) and MEDIA_CDR_80. | 625941da63d6d428bbe447b1 |
def Persist(self, point): <NEW_LINE> <INDENT> pass | шүргэлдээнийг барих =D | 625941dab57a9660fec33b49 |
def get_match_ids_by_queue(self, queue: str, date: str, hour: str) -> list: <NEW_LINE> <INDENT> date = date <NEW_LINE> url = f"{self.create_method_url('getmatchidsbyqueue')}/{queue}/{date}/{hour}" <NEW_LINE> return requests.get(url).json() | ------------------------------------------------------------------------------------
example: queue:'426', date:'2020-05-26', hour:'12,40'
------------------------------------------------------------------------------------
Lists all Match IDs for a particular Match Queue;
useful for API developers interested in constr... | 625941da82261d6c526ab765 |
def __len__(self): <NEW_LINE> <INDENT> return len(self._key_ids) | The number of different keys.
>>> m = MultiMap([('a', 1), ('b', 2), ('b', 3), ('c', 4), ('d', 5), ('c', 6)])
>>> len(m)
4 | 625941da1f037a2d8b9464bf |
def _get_jinja_error_slug(tb_data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return [ x for x in tb_data if x[2] in ('top-level template code', 'template') ][-1] <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> pass | Return the line number where the template error was found | 625941dab57a9660fec33b4a |
def clear_tags(self): <NEW_LINE> <INDENT> active_tSeries = self.tSeries_list.currentItem() <NEW_LINE> rois = self.plot.get_selected_items() <NEW_LINE> rois = active_tSeries.update_rois(rois) <NEW_LINE> if not len(rois): <NEW_LINE> <INDENT> self.plot.unselect_all() <NEW_LINE> return <NEW_LINE> <DEDENT> for roi in rois: ... | Remove tags from the selected ROIs | 625941da92d797404e30444d |
def get_values( model: nn.Module, dataloader: DataLoader, gpu: bool = True, use_dist: bool = False, use_chars: bool = False, ) -> Tuple[List[float], List[float]]: <NEW_LINE> <INDENT> model = model.eval() <NEW_LINE> model.cuda() if gpu else model.cpu() <NEW_LINE> predictions: List[float] = [] <NEW_LINE> true: List[float... | Get the classification output for the given dataset.
:param model: A trained model.
:param dataloader: The input data.
:param gpu: If true, run on the gpu. Otherwise use the cpu.
:returns: A list of classification values and a list of true samples. | 625941da30dc7b7665901c26 |
def update(self): <NEW_LINE> <INDENT> self.rect.y += 1 | 控制火球向下移动 | 625941dae8904600ed9f21f2 |
def size(self): <NEW_LINE> <INDENT> return _core.MatrixXdVec_size(self) | size(MatrixXdVec self) -> std::vector< MatrixXd >::size_type
Parameters:
self: std::vector< MatrixXd > const * | 625941da91f36d47f21ac7b7 |
def connect_JSON(config): <NEW_LINE> <INDENT> testnet = config.get('testnet', '0') <NEW_LINE> testnet = (int(testnet) > 0) <NEW_LINE> if not 'rpcport' in config: <NEW_LINE> <INDENT> config['rpcport'] = 18332 if testnet else 8332 <NEW_LINE> <DEDENT> connect = "http://%s:%s@127.0.0.1:%s"%(config['rpcuser'], config['rpcpa... | Connect to a diosys JSON-RPC server | 625941dabd1bec0571d908f1 |
def get_gifs_from_giphy(search_string): <NEW_LINE> <INDENT> baseurl = "https://api.giphy.com/v1/gifs/search?q={}&api_key={}&limit=5".format(search_string, api_key) <NEW_LINE> r = requests.get(baseurl).text <NEW_LINE> data = json.loads(r)['data'][:5] <NEW_LINE> return data | Returns data from Giphy API with up to 5 gifs corresponding to the search input | 625941daf548e778e58cd841 |
def duration_update_handler(self, context, parameters): <NEW_LINE> <INDENT> if self.maximum != int(context.globals['duration']) and not self.default_range: <NEW_LINE> <INDENT> def duration_updated(d): <NEW_LINE> <INDENT> if not self.update_lock.locked(): <NEW_LINE> <INDENT> self.update_timeline_range() <NEW_LINE> self.... | Handle DurationUpdate event.
There is a potential synchronization issue here: duration may
be updated while an update_model is already occuring. In this
case, the update_lock is held and the update_model call will
not do anything. However, we also will miss the correct update
of the timeline duration.
We should check... | 625941da796e427e537b088a |
def nextGreaterElement(self, n): <NEW_LINE> <INDENT> num = [c for c in str(n)] <NEW_LINE> i = len(num) - 1 <NEW_LINE> while i > 0 and num[i - 1] >= num[i]: <NEW_LINE> <INDENT> i -= 1 <NEW_LINE> <DEDENT> if i == 0: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> j = i <NEW_LINE> while j + 1 < len(num) and num[j + 1] >... | :type n: int
:rtype: int | 625941da009cb60464c63672 |
def load_data(): <NEW_LINE> <INDENT> data_2007, data_2003 = {}, {} <NEW_LINE> with open(_FILE, 'r') as f: <NEW_LINE> <INDENT> reader = csv.reader(f) <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> if row[0] == 'SIC 2007' or len(row) != 3: continue <NEW_LINE> sic7, sic3, act = row <NEW_LINE> if sic7 in data_2007: data... | Load data from the CSV file into memory and return it in various formats.
| 625941dab830903b967e9bcb |
def cpu_keyboard_routines(self): <NEW_LINE> <INDENT> cpu_operation = self.cpu_operand & ADDRESS_2 <NEW_LINE> cpu_source = (self.cpu_operand & ADDRESS_3) >> 8 <NEW_LINE> cpu_key_to_check = self.cpu_registers['v'][cpu_source] <NEW_LINE> cpu_keys_pressed = key.get_pressed() <NEW_LINE> if cpu_operation == 0x9E: <NEW_LINE> ... | Keyboard routines are fired based up current operandyth. | 625941da4e696a04525c970e |
def verify_env(dirs): <NEW_LINE> <INDENT> for dir_ in dirs: <NEW_LINE> <INDENT> if not os.path.isdir(dir_): <NEW_LINE> <INDENT> os.makedirs(dir_) | Verify that the named directories are in place and that the environment
can shake the salt | 625941dadc8b845886cb57f8 |
def draw(self, surface): <NEW_LINE> <INDENT> surface.blit(self.surface, self.rect) | Draw ball on the surface | 625941da287bf620b61d3d24 |
def load_table(table, in_fd): <NEW_LINE> <INDENT> for i in _json_iterload(in_fd): <NEW_LINE> <INDENT> data = {} <NEW_LINE> for k, v in six.iteritems(i): <NEW_LINE> <INDENT> if isinstance(v, list): <NEW_LINE> <INDENT> data[k] = set(v) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> data[k] = v <NEW_LINE> <DEDENT> <DEDENT>... | Load items into a table from a file-like object. | 625941da099cdd3c635f0f1c |
def __getBridgeNameMap(self, dbNics, hypervisorNode): <NEW_LINE> <INDENT> cfg_filename = os.path.join( self._cm.getKitConfigBase(), 'adapter-defaults-vmware.conf') <NEW_LINE> cfg = configparser.ConfigParser() <NEW_LINE> cfg.read(cfg_filename) <NEW_LINE> section_name = hypervisorNode.name if hypervisorNode el... | Raises:
CommandFailed
MissingHypervisorNetwork
TortugaException | 625941da507cdc57c6306fa2 |
def gen_hrf(self, nItMin=30, nItMax=30, estimateSigmaH=0, estimateBeta=0, Onsets={'nuages': array([0])}, scale=1, ): <NEW_LINE> <INDENT> areas = ['ra'] <NEW_LINE> labelFields = {} <NEW_LINE> cNames = ['inactiv', 'activ'] <NEW_LINE> spConf = RegularLatticeMapping((self.height, self.width, 1)) <NEW_LINE> graph = graph_fr... | allow to generate figures
:param nItMin: Minimum number of iteration
:type nItMin: int
:param nItMax: Maximum number of iteration
:type nItMax: int
:param estimateSigmaH: estimation of sigmaH
:type estimateSigmaH: int
:param estimateBeta: estimation of Beta
:type estimateBeta: int
:param scale: scale factor
:type scal... | 625941daa219f33f34628c28 |
def substitute(self, **kwargs): <NEW_LINE> <INDENT> return type(self)(*substitute(self[:], **kwargs)) | Substitute in all arguments. | 625941da442bda511e8be6d7 |
def run_djikstra(): <NEW_LINE> <INDENT> source = int(input("Input source node: ")) <NEW_LINE> example = input("Are you using the example graph? ") <NEW_LINE> if example != "y": <NEW_LINE> <INDENT> graph_filename = input("Input filename of graph: ") <NEW_LINE> matrix = produce_adjacency_matrix(graph_filename) <NEW_LINE>... | Runs dijkstra's algorithm with all required inputs. | 625941da090684286d50efaa |
def get_exif(self): <NEW_LINE> <INDENT> exif = {} <NEW_LINE> if self.mime == "image/heic": <NEW_LINE> <INDENT> heif = pyheif.read_heif(self.fp) <NEW_LINE> for metadata in heif.metadata or []: <NEW_LINE> <INDENT> if metadata['type'] == 'Exif': <NEW_LINE> <INDENT> data = metadata.get('data', {}) <NEW_LINE> exif = piexif.... | Returns the EXIF data for a photo. Includes support for HEIC file
format. | 625941da1f037a2d8b9464c0 |
def extract_yaml(fileobj, keywords, comment_tags, options): <NEW_LINE> <INDENT> from bibed.gtk import Gtk <NEW_LINE> from bibed.foundations import AttributeDict <NEW_LINE> from bibed.preferences import defaults <NEW_LINE> myglobal = Anything() <NEW_LINE> myglobal.index = 0 <NEW_LINE> depth_level = 0 <NEW_LINE> def recu... | Extract messages from XXX files.
:param fileobj: the file-like object the messages should be extracted
from
:param keywords: a list of keywords (i.e. function names) that should
be recognized as translation functions
:param comment_tags: a list of translator tags to search for and
... | 625941da460517430c394442 |
def __init__( self, path, sysfs_path_pfx, netlink_conf, poll_interval_sec, alpha): <NEW_LINE> <INDENT> super(Network, self).__init__(path) <NEW_LINE> self._speed_file_pfx = sysfs_path_pfx <NEW_LINE> self._speed_files_cache = {} <NEW_LINE> self._netlink_speed_mbits = netlink_conf.speed_mbits <NEW_LINE> self._default_net... | Init procfs network metric with specified path. | 625941da7d43ff24873a2f64 |
def __init__(self, year): <NEW_LINE> <INDENT> self.mfl_export_url = 'http://football.myfantasyleague.com/{}/export'.format(year) | Create an instance of the MFL API.
Args:
year (int): The year to get data for (e.g. 2013). | 625941dad6c5a1020814430f |
def plot( self, x, y=None ): <NEW_LINE> <INDENT> W,H = self._surf.get_size() <NEW_LINE> x0,y0,xs,ys = tuple(( float(x) for x in self.axes )) <NEW_LINE> if y is None: <NEW_LINE> <INDENT> py = H*(np.asarray(x)-x0)/xs <NEW_LINE> px = np.arange(0,W,float(W)/len(py)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> px = W*(np.... | Plot a line with the specified points
INPUTS:
x -- numbers -- x coordinates, in plot(x,y) form, or y coordinates
in plot(y) form.
y -- numbers or None -- y coordinates of points | 625941da21a7993f00bc7fb6 |
def test_Debugger_do_break_non_executable_line(): <NEW_LINE> <INDENT> mock_socket = mock.MagicMock() <NEW_LINE> db = mu.debugger.runner.Debugger(mock_socket, 'localhost', 9999) <NEW_LINE> db.output = mock.MagicMock() <NEW_LINE> db.is_executable_line = mock.MagicMock(return_value=False) <NEW_LINE> db.do_break('foo.py', ... | If the referenced file and line are not a executable line, output an error
message to the client. | 625941dadc8b845886cb57f9 |
def batch_norm(scale: (int, float) = 1.0) -> layers.Sequential: <NEW_LINE> <INDENT> return layers.Sequential(layers.BatchNormLayer(scale=scale)) | Action which returns an instance of :py:class:`anvil.layers.BatchNormLayer`.
Parameters
----------
scale
The multiplicative factor applied to the standardised data.
Returns
-------
anvil.layers.Sequential
An instance of :py:class:`anvil.layers.BatchNormLayer` wrapped by
:py:class:`anvil.layers.Sequential`... | 625941da32920d7e50b28495 |
def version(*a): <NEW_LINE> <INDENT> print("vimp %s" % __version__) <NEW_LINE> print("Made by %s" % __author__) <NEW_LINE> print(__license__) <NEW_LINE> sys.exit(0) | Prints program version and exits. | 625941dad53ae8145f87a52e |
@mock.patch("civis.cli.__main__.add_extra_commands") <NEW_LINE> @mock.patch("civis.cli.__main__.retrieve_spec_dict") <NEW_LINE> def test_generate_cli_petstore(mock_retrieve_spec_dict, mock_add_extra_commands): <NEW_LINE> <INDENT> with open(os.path.join(THIS_DIR, "petstore.json")) as f: <NEW_LINE> <INDENT> petstore_spec... | Test loading the OpenAPI petstore example. | 625941daf9cc0f698b1408bc |
def get_air_quality(city): <NEW_LINE> <INDENT> if not city or not city.strip(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> print('获取 {} 的空气质量...'.format(city)) <NEW_LINE> try: <NEW_LINE> <INDENT> url = 'http://api.waqi.info/feed/{city}/?token={token}'.format(city=city, token=AQICN_TOKEN) <NEW_LINE> resp = requests.... | 通过城市名获取空气质量
官网:http://aqicn.org/here/
token 申请地址:http://aqicn.org/data-platform/token/#/
:param city: 城市
:return: | 625941da566aa707497f4828 |
def _remove(self, cluster: Cluster) -> None: <NEW_LINE> <INDENT> self._edges -= set(self.edges_from(cluster)) <NEW_LINE> self.clusters.remove(cluster) <NEW_LINE> return | Removes the cluster and all associated edges from the graph.
Assumes that the cluster is in the graph.
Caller need to invalidate cache. | 625941dacad5886f8bd2729b |
def test__repr__and__str__(self): <NEW_LINE> <INDENT> a = A() <NEW_LINE> self.assertEqual("%s" % a, "str") <NEW_LINE> self.assertEqual("%r" % a, "repr") <NEW_LINE> b = B() <NEW_LINE> self.assertEqual("%r" % b, "repr") | test that %s / %r work correctly | 625941da377c676e9127246a |
def isAbsentNamespace (self): <NEW_LINE> <INDENT> return self.__uri is None | Return True iff this namespace is an absent namespace.
Absent namespaces have no namespace URI; they exist only to
hold components created from schemas with no target
namespace. | 625941dad4950a0f3b08c60f |
def parse_url(url, is_connect=False): <NEW_LINE> <INDENT> if isinstance(url, six.text_type): <NEW_LINE> <INDENT> url = url.encode('iso-8859-1') <NEW_LINE> <DEDENT> elif hasattr(url, 'tobytes'): <NEW_LINE> <INDENT> url = url.tobytes() <NEW_LINE> <DEDENT> elif not isinstance(url, bytes): <NEW_LINE> <INDENT> url = bytes(u... | Split a URL into its components.
This function is similar to :func:`urllib.parse.urlsplit` but it uses the
http-parser URL splitter via CFFI.
The return value is a sequence: (scheme, host, port, path, query, fragment,
userinfo). | 625941daec188e330fd5aa5d |
def waitForState(instanceObj, state): <NEW_LINE> <INDENT> cnt = 0 <NEW_LINE> while instanceObj.state_code not in state: <NEW_LINE> <INDENT> time.sleep(1) <NEW_LINE> instanceObj.update() <NEW_LINE> cnt +=1 <NEW_LINE> if cnt % 10 == 0: <NEW_LINE> <INDENT> print('still waiting for operation on "{}" to complete'.format(ins... | Wait until the instance is in a desired state. This function
doesn't initiate any change, so if not used carefully it may wait
forever.
@param insanceObj: ec2.Instance -- Instance to be manipulated.
@param state: list of int -- List of acceptable states.
@returns: None | 625941da24f1403a92600e27 |
def addPopulationToStates(statePopulations): <NEW_LINE> <INDENT> for state in statePopulations: <NEW_LINE> <INDENT> if state == "District of Columbia": continue <NEW_LINE> stateObj = State.objects.get(name=state) <NEW_LINE> stateObj.population = statePopulations[state] <NEW_LINE> stateObj.save() | For migration, most likely, though maybe to update when we get
newer data? | 625941da2c8b7c6e89b35a82 |
def rm_rf(rm_path, file_label, must_exist=False, use_logger=False, warn_only=False, exit_val=exitvals['startup']['num']): <NEW_LINE> <INDENT> if os.path.isdir(fix_path(rm_path)): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> shutil.rmtree(os.path.realpath(fix_path(rm_path)), False) <NEW_LINE> <DEDENT> except OSError as ... | Remove a file or directory, recursively if necessary.
Parameters:
rm_path: the file/directory to remove
see file_error_handler() for the rest
Dependencies:
globals: exitvals['startup']
functions: fix_path(), file_error_handler()
modules: os, shutil | 625941da0fa83653e465727c |
def __init__(self, delivery_dates: list = []): <NEW_LINE> <INDENT> self._delivery_dates = delivery_dates <NEW_LINE> self.ini_parser = configparser.ConfigParser() <NEW_LINE> self.ini_parser.read(self.ini_path) <NEW_LINE> self.check_ini() | Constructor | 625941da23e79379d52ee824 |
def __init__(self, channel): <NEW_LINE> <INDENT> self.SayHello = channel.unary_unary( '/hello.HelloService/SayHello', request_serializer=hello__pb2.HelloReq.SerializeToString, response_deserializer=hello__pb2.HelloResp.FromString, ) <NEW_LINE> self.SayHelloStrict = channel.unary_unary( '/hello.HelloService/SayHelloStri... | Constructor.
Args:
channel: A grpc.Channel. | 625941da91af0d3eaac9bcde |
def calc_r(m,new_polys,old_polys,items): <NEW_LINE> <INDENT> for p in new_polys + old_polys: <NEW_LINE> <INDENT> l = list(p.lead_term) <NEW_LINE> if all([i<=j for i,j in zip(l,m)]) and len(l) == len(m): <NEW_LINE> <INDENT> c = [j-i for i,j in zip(l,m)] <NEW_LINE> if not l == m: <NEW_LINE> <INDENT> return p.mon_mult(c) ... | Finds the r polynomial that has a leading monomial m
Returns the polynomial. | 625941da3d592f4c4ed1d32b |
def __init__(self): <NEW_LINE> <INDENT> self.logMethods = [] <NEW_LINE> self.logPriority = [] <NEW_LINE> self.logLock = threading.RLock() | Initialize the empty log function list
| 625941da55399d3f05588978 |
def ParseJarInfoFile(info_path): <NEW_LINE> <INDENT> info_data = dict() <NEW_LINE> if os.path.exists(info_path): <NEW_LINE> <INDENT> with open(info_path, 'r') as info_file: <NEW_LINE> <INDENT> for line in info_file: <NEW_LINE> <INDENT> line = line.strip() <NEW_LINE> if line: <NEW_LINE> <INDENT> fully_qualified_name, pa... | Parse a given .jar.info file as a dictionary.
Args:
info_path: input .jar.info file path.
Returns:
A new dictionary mapping fully-qualified Java class names to file paths. | 625941da4c3428357757c5ea |
def nestSections(block, level=1): <NEW_LINE> <INDENT> cur = block.first_child <NEW_LINE> if cur is not None: <NEW_LINE> <INDENT> children = [] <NEW_LINE> nest = False <NEW_LINE> while cur is not None: <NEW_LINE> <INDENT> if cur.t == 'heading' and cur.level == level: <NEW_LINE> <INDENT> nest = True <NEW_LINE> break <NEW... | Sections aren't handled by CommonMark at the moment.
This function adds sections to a block of nodes.
'title' nodes with an assigned level below 'level' will be put in a child section.
If there are no child nodes with titles of level 'level' then nothing is done | 625941dad53ae8145f87a52f |
def TaskFilterSpecByTime(vim, *args, **kwargs): <NEW_LINE> <INDENT> obj = vim.client.factory.create('ns0:TaskFilterSpecByTime') <NEW_LINE> if (len(args) + len(kwargs)) < 1: <NEW_LINE> <INDENT> raise IndexError('Expected at least 2 arguments got: %d' % len(args)) <NEW_LINE> <DEDENT> required = [ 'timeType' ] <NEW_LINE> ... | This data object type specifies a time range used to filter task history. | 625941da16aa5153ce36273b |
def __init__(self, name, filter, limit, action): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.filter = None <NEW_LINE> self.limit = None <NEW_LINE> self.action = None <NEW_LINE> self.check_limit(limit) .build_filter(filter) .build_action(action) | Initializes a newly created Rule with the following arguments:
*name* is the name of the Rule. It helps you identify the Rule.
*filter* is a string containing the regular expressions that Ellis
will try to detect. It is converted in a :class:`filter.Filter`
object.
Each journald message that matches the *filter* inc... | 625941da44b2445a33932358 |
def filenames(self): <NEW_LINE> <INDENT> if self.topic.has_file: <NEW_LINE> <INDENT> yield self.topic.filename <NEW_LINE> <DEDENT> for reply in self.replies: <NEW_LINE> <INDENT> if reply.has_file: <NEW_LINE> <INDENT> yield reply.filename | Returns the filenames of all files attached to posts in the thread. | 625941da8c0ade5d55d3ec80 |
def SetProbability(self, *args): <NEW_LINE> <INDENT> return _itkSaltAndPepperNoiseImageFilterPython.itkSaltAndPepperNoiseImageFilterIUC3IUC3_SetProbability(self, *args) | SetProbability(self, double _arg) | 625941da57b8e32f52483760 |
def init_document(): <NEW_LINE> <INDENT> document = { 'author': '', 'body': '' } <NEW_LINE> return document | function: init_document
-----------------------
initialize new empty document skeleton
:returns: dictionary @document of document fields
@dictionary['words'] is a dictionary
@dictionary['body'] is a list for the body text terms | 625941da76e4537e8c351938 |
def canonicalise_params(params, attrs=None, length=None): <NEW_LINE> <INDENT> final_attrs = {} <NEW_LINE> if params and isinstance(params[0], DictType): <NEW_LINE> <INDENT> final_attrs = params[0] <NEW_LINE> params = params[1:] <NEW_LINE> <DEDENT> if attrs is False and final_attrs : <NEW_LINE> <INDENT> raise Exception(... | Convenience function for handling the common case where you are called with;
(some-element, attrs-dict, param1, param2, ...)
and you want to set ups some defaults for the attrs-dict, then
override it with attrs-dict but also handle the case where there
are no overrides. | 625941da3eb6a72ae02ec7a7 |
def add(self, key, value, time=0, namespace=None): <NEW_LINE> <INDENT> namespace = namespace or self.default_namespace <NEW_LINE> return self.namespaces[namespace].add(key, value, time, namespace) | Sets a key's value, if and only if the item is not
already. | 625941da1d351010ab855ddf |
def test_create_aggregate_init_final(self): <NEW_LINE> <INDENT> self.db.execute("DROP AGGREGATE IF EXISTS a1(integer)") <NEW_LINE> self.db.execute_commit("DROP FUNCTION IF EXISTS f2(integer)") <NEW_LINE> self.db.execute_commit(DROP_STMT2) <NEW_LINE> inmap = new_std_map() <NEW_LINE> inmap['schema public'].update({'funct... | Create an aggregate with an INITCOND and a FINALFUNC | 625941da67a9b606de4a817b |
def __init__(self, value=None): <NEW_LINE> <INDENT> super(FileVersions, self).__init__() <NEW_LINE> self._value = None <NEW_LINE> if value is not None: <NEW_LINE> <INDENT> self.value = value | FileVersions - a model defined in Swagger | 625941da26238365f5f0f135 |
def prune(adj): <NEW_LINE> <INDENT> g = networkx.from_numpy_matrix(adj) <NEW_LINE> cycles = networkx.cycles.cycle_basis(g) <NEW_LINE> adjNew = np.zeros(adj.shape) <NEW_LINE> for c in cycles: <NEW_LINE> <INDENT> for i in range(len(c)): <NEW_LINE> <INDENT> adjNew[c[i - 1], c[i]] = adj[c[i - 1], c[i]] <NEW_LINE> adjNew[c[... | This method eliminates all branches from the graph which are not involved in a cycle.
This is done by constructing the cycle basis and using only those nodes. | 625941da6fece00bbac2da05 |
def pool_runGibbs(gene_id): <NEW_LINE> <INDENT> return runGibbs(gene_id, inp, gpprior, betaprior, args) | Helper function calling runGibbs() using the "global" variables made by _pool_init
Input:
* gene_id - which row of the input CSV is the current child, the only variable part of the input | 625941daf8510a7c17cf99c1 |
def open_unreconcile(self, cr, uid, ids, context=None): <NEW_LINE> <INDENT> assert len(ids) == 1, "You can only open entries from one profile at a time" <NEW_LINE> obj_move_line = self.pool.get('account.move.line') <NEW_LINE> for task in self.browse(cr, uid, ids, context=context): <NEW_LINE> <INDENT> line_id... | Open the view of move line with the unreconciled move lines | 625941da097d151d1a22311b |
def shuffle(self): <NEW_LINE> <INDENT> random.shuffle(self.cards) | 洗牌的功能 | 625941da4f88993c3716c329 |
def check_authorization(self, access_token): <NEW_LINE> <INDENT> p = self.session.params <NEW_LINE> auth = (p.get('client_id'), p.get('client_secret')) <NEW_LINE> if access_token and auth: <NEW_LINE> <INDENT> url = self._build_url('applications', str(auth[0]), 'tokens', str(access_token)) <NEW_LINE> resp = self._get(ur... | Check an authorization created by a registered application.
OAuth applications can use this method to check token validity
without hitting normal rate limits because of failed login attempts.
If the token is valid, it will return True, otherwise it will return
False.
:returns: bool | 625941da851cf427c661a7d0 |
def minimumTotal(self, triangle): <NEW_LINE> <INDENT> if not triangle: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> for i in xrange(1, len(triangle)): <NEW_LINE> <INDENT> for j in xrange(len(triangle[i])): <NEW_LINE> <INDENT> if j == 0: <NEW_LINE> <INDENT> triangle[i][j] = triangle[i][j] + triangle[i-1][j] <NEW_... | :type triangle: List[List[int]]
:rtype: int | 625941dabd1bec0571d908f2 |
def setUp(self): <NEW_LINE> <INDENT> sack = base.TestSack(repo_dir=self.repo_dir) <NEW_LINE> sack.load_yum_repo(load_updateinfo=True) <NEW_LINE> self.apackage = find_apackage(sack, 'tour.noarch.rpm') | Prepare the test fixture. | 625941da566aa707497f4829 |
def wait_for_no_active_cells(self, timeout=20000): <NEW_LINE> <INDENT> self.selenium.wait_for_condition("selenium.browserbot.getCurrentWindow().active_cell_list.length == 0", "%s"%timeout) | Tells Selenium to wait until they're are no active cells on the worksheet. | 625941da4a966d76dd5512d5 |
def exploding_snake_12(): <NEW_LINE> <INDENT> snake_12_leds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18] <NEW_LINE> explode_speed = 0.020 <NEW_LINE> for i in range(175, 226, 1): <NEW_LINE> <INDENT> LOGGER.debug("Pulse speed is: %s", i) <NEW_LINE> PYGLOW.led(snake_12_leds, 100, speed=i, pulse=True) <NEW_LINE> sleep(0) <NEW... | Lights up and turns off the LEDs on arms 1 and 2 | 625941da0a366e3fb873eae0 |
def __init__(self, x_whole, params, encoder, idx2token=None): <NEW_LINE> <INDENT> super(Streaming, self).__init__() <NEW_LINE> self.x_whole = x_whole <NEW_LINE> self.xmax_whole = len(x_whole) <NEW_LINE> self.input_dim = x_whole.shape[1] <NEW_LINE> self.enc_type = encoder.enc_type <NEW_LINE> self.idx2token = idx2token <... | Args:
x_whole (FloatTensor): `[T, input_dim]`
params (dict): decoding hyperparameters
encoder (torch.nn.module): encoder module
idx2token (): converter from index to token | 625941da656771135c3ebb35 |
def test_manual_update(self): <NEW_LINE> <INDENT> path = '/foo' <NEW_LINE> foo = 'foo' <NEW_LINE> bar = 'bar' <NEW_LINE> state = ApplicationState(application_host=foo, configuration_path=path) <NEW_LINE> cache = self._create_app_state_cache() <NEW_LINE> cache._cache.update({path: state.to_dictionary()}) <NEW_LINE> self... | Test that the manual update actually updates the state in the cache | 625941da67a9b606de4a817c |
def __nonzero__(self): <NEW_LINE> <INDENT> return True | ::
boolean = bool(url)
Always true. (Python 2.x) | 625941da8e7ae83300e4b291 |
def load_fff_returns_daily(filename='F-F_Research_Data_5_Factors_2x3_daily.csv'): <NEW_LINE> <INDENT> returns = pd.read_csv(os.path.join(FACTOR_DATA_DIR, filename), header=0, index_col=0) / 100 <NEW_LINE> returns.index = pd.to_datetime(returns.index, format="%Y%m%d") <NEW_LINE> return returns | Load the Fama-French Research Factor Daily Dataset | 625941da9b70327d1c4e109a |
def eval_guess(guess,word): <NEW_LINE> <INDENT> max_attempts = length + 1 <NEW_LINE> available_letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z" <NEW_LINE> guessed_letters = [] <NEW_LINE> newstring = [] <NEW_LINE> correct_guesses = 0 <NEW_LINE> wrong_guesses = 0 <NEW_LINE> while True and max_attempts > 1... | Gets guess from player,checks if
word contains the guess and print progress made
so far, else return failure report | 625941da71ff763f4b549954 |
def __send_chunk(self, data_memory, flags, timeleft, end): <NEW_LINE> <INDENT> data_sent = 0 <NEW_LINE> len_data_memory = len(data_memory) <NEW_LINE> started_timer = 0 <NEW_LINE> while data_sent < len_data_memory: <NEW_LINE> <INDENT> chunk = data_memory[data_sent:] <NEW_LINE> if timeleft is None: <NEW_LINE> <INDENT> da... | Send the complete contents of ``data_memory`` before returning.
This is the core loop around :meth:`send`.
:param timeleft: Either ``None`` if there is no timeout involved,
or a float indicating the timeout to use.
:param end: Either ``None`` if there is no timeout involved, or
a float giving the absolute end ti... | 625941da3317a56b86939f16 |
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'shorty.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are you sure ... | Run administrative tasks. | 625941da462c4b4f79d1d994 |
def load_n_file(self): <NEW_LINE> <INDENT> reference_info = [("ZnSe_n.csv", "wl_n_ZnSe", "n_ZnSe"), ("ZnSe_k.csv", "wl_k_ZnSe", "k_ZnSe"), ("BaF2_n.csv", "wl_n_BaF2", "n_BaF2"), ("BaF2_k.csv", "wl_k_BaF2", "k_BaF2"), ("Ge_n_293K.csv", "wl_n_Ge", "n_Ge"), ("Ge_k.csv", "wl_k_Ge", "k_Ge"), ("ZnS_n.csv", "wl_n_ZnS", "n_ZnS... | Load all material refractive index data. | 625941da379a373c97cfae0a |
def _get_version(self, schema, version): <NEW_LINE> <INDENT> pass | Returns a schema version
:param schema: The schema
:param version: The version required
:return: The schema version or None if schema version doesn't exist | 625941da3cc13d1c6d3c763d |
def is_interrupted_system_call(zmq_error): <NEW_LINE> <INDENT> return str(zmq_error) == "Interrupted system call" | predicate to test a zmq.ZMQError object for interrupted system call
This normally occurs when a process is terminated while blocking on
a ZMQ socket. It's an error we generally choose to ignore. | 625941daa934411ee3751958 |
def validatePassword(self, password): <NEW_LINE> <INDENT> if len(password) < 5: <NEW_LINE> <INDENT> return self.translate(u'Passwords must contain at least 5 letters.', domain='plone') <NEW_LINE> <DEDENT> return True | Is this p_password valid? | 625941da91af0d3eaac9bcdf |
def _order(queryset): <NEW_LINE> <INDENT> return queryset.order_by("-pk" if history_latest_first else "pk") | Applies the correct ordering to the given version queryset. | 625941da63b5f9789fde73aa |
def missing_vars(self, source): <NEW_LINE> <INDENT> return '$' in source | Determines if a source string contains variables that were not replaced | 625941da73bcbd0ca4b2c33a |
def _build_graph(dg, path, roles): <NEW_LINE> <INDENT> for role in roles: <NEW_LINE> <INDENT> dg.add_node(role) <NEW_LINE> md = _open_yaml_file(os.path.join(path, role, 'meta', 'main.yml')) <NEW_LINE> if md is None: <NEW_LINE> <INDENT> logger.warning('{} has no meta/main.yml'.format(role)) <NEW_LINE> <DEDENT> else: <NE... | Return a directed graph where each node is a role and each edge is a dependency relationship. | 625941dabe8e80087fb20f03 |
def parse_json_message(message: str) -> Dict[str, Any]: <NEW_LINE> <INDENT> row = json.loads(message) <NEW_LINE> return { "url": row["url"], "score": 1.0 if row["review"] == "positive" else 0.0, "processing_time": int(time.time()), } | Parse the input json message and add 'score' & 'processing_time' keys. | 625941dad99f1b3c44c6784f |
def switch_turn(self): <NEW_LINE> <INDENT> if self.turn == 'W': <NEW_LINE> <INDENT> self.turn = 'B' <NEW_LINE> <DEDENT> elif self.turn == 'B': <NEW_LINE> <INDENT> self.turn = 'W' | Switches the turn | 625941da293b9510aa2c3557 |
def get_text(self, text): <NEW_LINE> <INDENT> if sys.maxunicode == 0xFFFF: <NEW_LINE> <INDENT> return text[self.offset : self.offset + self.length] <NEW_LINE> <DEDENT> if not isinstance(text, bytes): <NEW_LINE> <INDENT> entity_text = text.encode("utf-16-le") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> entity_text = t... | Get value of entity
:param text: full text
:return: part of text | 625941da8a349b6b435e8437 |
def getLongestString(self, strs): <NEW_LINE> <INDENT> if len(strs)==0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if len(strs)==1: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> for size in range(len(strs),-1, -1): <NEW_LINE> <INDENT> for low in range(len(strs)): <NEW_LINE> <INDENT> high = low + (size-1) <NEW_L... | 滑动窗口:获取最长子串
| 625941dab57a9660fec33b4c |
def countPrimeSetBits(self, L, R): <NEW_LINE> <INDENT> nums = [i for i in range(L, R + 1)] <NEW_LINE> res = 0 <NEW_LINE> prime_num = [] <NEW_LINE> for i in nums: <NEW_LINE> <INDENT> count = bin(i)[2:].count('1') <NEW_LINE> if count < 2: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> elif count not in prime_num: <NEW_... | :type L: int
:type R: int
:rtype: int | 625941da97e22403b379d25f |
def log_partition_Wishart(self, W, n): <NEW_LINE> <INDENT> D, D_ = W.shape <NEW_LINE> if not D == D_: <NEW_LINE> <INDENT> raise ValueError('Matrix is not symmetric.') <NEW_LINE> <DEDENT> if not n > D-1: <NEW_LINE> <INDENT> raise ValueError('Degrees of freedom too low for dimensionality.') <NEW_LINE> <DEDENT> lmG = self... | Logarithmic partition function of the Wishart distribution.
To compute variational expectations, the partition of the Wishart
distribution is sometimes needed. The current computation follows
Appendix B, equations B.78 to B.82 from Bishop's "Pattern Recognition &
Machine Learning."
Parameters
----------
W : array
... | 625941da4d74a7450ccd4487 |
@gen.engine <NEW_LINE> def get_request(url): <NEW_LINE> <INDENT> text = yield async_request(url) <NEW_LINE> print("get_request: {0:d} characters".format(len(text))) <NEW_LINE> print(text[:1024]) | Get request | 625941da45492302aab5e58a |
def SetFullyConnected(self, *args): <NEW_LINE> <INDENT> return _itkLabelContourImageFilterPython.itkLabelContourImageFilterIUS3IUS3_SetFullyConnected(self, *args) | SetFullyConnected(self, bool _arg) | 625941da31939e2706e4d12a |
def get_magnitudes(array): <NEW_LINE> <INDENT> vector_points = np.array(list(map(lambda x: x.value, array))) <NEW_LINE> magnitudes = LA.norm(vector_points,axis=1) <NEW_LINE> magnitudes = magnitudes.tolist() <NEW_LINE> return magnitudes | Convert 3D vector data to magnitudes.
Input is an array of time points. | 625941da2eb69b55b151cb76 |
def __state_changed(self, obj): <NEW_LINE> <INDENT> self.__option.set_value(self.get_active()) | Handle the change of the value made by the user. | 625941da55399d3f05588979 |
def __init__(self, ai_game): <NEW_LINE> <INDENT> self.ai_game = ai_game <NEW_LINE> self.screen = ai_game.screen <NEW_LINE> self.screen_rect = self.screen.get_rect() <NEW_LINE> self.settings = ai_game.settings <NEW_LINE> self.stats = ai_game.stats <NEW_LINE> self.text_color = (30, 30, 30) <NEW_LINE> self.font = pygame.f... | инициализирует атрибуты подсчета очков | 625941da30bbd722463cc08c |
def country(request, id=0): <NEW_LINE> <INDENT> country = get_object_or_404(Country, pk=id) <NEW_LINE> context = { "country": country } <NEW_LINE> return render(request, 'basis/country.html', context) | Return the country according to the id | 625941da4e4d5625662d4699 |
def _set_optimization_parameters(self, parameters): <NEW_LINE> <INDENT> if self.use_gradient_accumulation: <NEW_LINE> <INDENT> parameters.gradient_accumulation_status = ( optimization_parameters_pb2.GradientAccumulationStatus.ENABLED) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> parameters.gradient_accumulation_status... | Sets the optimizer fields in the OptimizationParameters. | 625941da7047854f462a16cb |
def set_name(self, name): <NEW_LINE> <INDENT> self._name = str(name) | This function sets the name of a TC
:type: str
:param name: name to be given | 625941dad8ef3951e3243802 |
def test_format_standard_file_header_with_comment_line_prefix(): <NEW_LINE> <INDENT> comment_line_prefix = "TEST PREFIX:" <NEW_LINE> expected = [] <NEW_LINE> progname = os.path.basename(sys.argv[0]) <NEW_LINE> try: <NEW_LINE> <INDENT> progver = app_util.program_properties['ProgramVersion'] <NEW_LINE> <DEDENT> except Ke... | Test this function passing in a comment line prefix. | 625941da91f36d47f21ac7b9 |
def __truediv__(self, other): <NEW_LINE> <INDENT> if isinstance(other, PathField): <NEW_LINE> <INDENT> other = other.val <NEW_LINE> <DEDENT> return self.__class__(self.val / other, default=self.default, name=self.name, _store=self.store, _section=self.section) | Apply '/' operator on `self` by `other`
Parameters
----------
other : PathField, str
other path to add to end of this path using pathlib.Path.__truediv__ behaviour.
Returns
-------
field : PathField
New PathField object.
Warnings
--------
New field can only derive it's `_store` and `_section` values from `se... | 625941da32920d7e50b28496 |
def get_lmfdb_tables(databases=None, is_good_database=_is_good_database, is_good_table=_is_good_table): <NEW_LINE> <INDENT> if not databases: <NEW_LINE> <INDENT> databases = get_lmfdb_databases(is_good_database=is_good_database) <NEW_LINE> <DEDENT> if not hasattr(databases, '__iter__'): <NEW_LINE> <INDENT> databases = ... | Routine to get a dictionary with keys of all databases and member lists
of tables in that database | 625941daa8ecb033257d3390 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.