code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def remove_temp_endpoint(self, endpoint): <NEW_LINE> <INDENT> if self._topology: <NEW_LINE> <INDENT> self._topology.remove_temp_endpoint(endpoint) | Remove temporary endpoints that never finished authorization.
Args:
endpoint: The endpoint that is not authorized to connect to the
network. | 625941f5566aa707497f4b9d |
def create(self, req, server_id, body): <NEW_LINE> <INDENT> context = req.environ['nova.context'] <NEW_LINE> if not body: <NEW_LINE> <INDENT> raise exc.HTTPUnprocessableEntity() <NEW_LINE> <DEDENT> volume_id = body['volumeAttachment']['volumeId'] <NEW_LINE> device = body['volumeAttachment']['device'] <NEW_LINE> msg = _... | Attach a volume to an instance. | 625941f59c8ee82313fbbdb5 |
def add_sequence(self, sequence: List[int]): <NEW_LINE> <INDENT> assert len(sequence) > 0 <NEW_LINE> token = int(sequence[0]) <NEW_LINE> if token not in self.children: <NEW_LINE> <INDENT> self.children[token] = ConstraintNode(token, parent=self) <NEW_LINE> <DEDENT> node = self.children[token] <NEW_LINE> if len(sequence... | Adds a constraint, represented as a list of integers, to
the trie. | 625941f56fece00bbac2dd85 |
def parse_rec(filename): <NEW_LINE> <INDENT> tree = ET.parse(filename) <NEW_LINE> objects = [] <NEW_LINE> for obj in tree.findall('object'): <NEW_LINE> <INDENT> obj_struct = {} <NEW_LINE> obj_struct['name'] = obj.find('name').text <NEW_LINE> obj_struct['pose'] = obj.find('pose').text <NEW_LINE> obj_struct['truncated'] ... | Parse a PASCAL VOC xml file | 625941f5fff4ab517eb2fa7f |
@marc21_holdings.over('location', '^852..') <NEW_LINE> @utils.for_each_value <NEW_LINE> @utils.filter_values <NEW_LINE> def location(self, key, value): <NEW_LINE> <INDENT> return { 'materials_specified': value.get('3'), 'source_of_classification_or_shelving_scheme': value.get('2'), 'linkage': value.get('6'), 'sequence_... | Location. | 625941f54f88993c3716c69e |
def test_sorting(self): <NEW_LINE> <INDENT> data = [ {'id':6, 'dataset': 'bla6', 'run':200}, {'id':1, 'dataset': 'bla1', 'run':100}, {'id':2, 'dataset': 'bla2', 'run':700}, {'id':3, 'dataset': 'bla3', 'run':400}, {'id':4, 'dataset': 'bla4', 'run':300}, {'id':5, 'dataset': 'bla5', 'run':800}, ] <NEW_LINE> sorted_data = ... | Test sorting routines | 625941f516aa5153ce362ab7 |
def format_output(delta: datetime.timedelta, domain: str) -> str: <NEW_LINE> <INDENT> return f"{delta.days} days remaining for domain {domain}" | Format output string from timedelta and domain. | 625941f53cc13d1c6d3c79b5 |
def getUDAAvailablePorts(Framework): <NEW_LINE> <INDENT> logger.debug("Start to get all ports of UD protocol") <NEW_LINE> credentialIds = netutils.getAvailableProtocols(Framework, ClientsConsts.DDM_AGENT_PROTOCOL_NAME, None) <NEW_LINE> ports = set([2738, 7738]) <NEW_LINE> for credentialId in credentialIds: <NEW_LINE> <... | Get all available ports of UD protocol
:param Framework:
:return: array of available ports, if it's not configured, just return [2738, 7738] | 625941f5bf627c535bc1380e |
def get_ca_definition(self): <NEW_LINE> <INDENT> cache = self.row_converter.block_converter.get_ca_definitions_cache() <NEW_LINE> return cache.get((None, self.display_name)) | Get custom attribute definition. | 625941f5a8370b7717052edb |
def join(self, timeout=None, propagate=True, interval=0.5): <NEW_LINE> <INDENT> time_start = time.time() <NEW_LINE> remaining = None <NEW_LINE> results = [] <NEW_LINE> for result in self.results: <NEW_LINE> <INDENT> remaining = None <NEW_LINE> if timeout: <NEW_LINE> <INDENT> remaining = timeout - (time.time() - time_st... | Gathers the results of all tasks as a list in order.
.. note::
This can be an expensive operation for result store
backends that must resort to polling (e.g. database).
You should consider using :meth:`join_native` if your backend
supports it.
.. warning::
Waiting for tasks within a task may le... | 625941f5d10714528d600329 |
def __init__(self): <NEW_LINE> <INDENT> self._includeAll = False <NEW_LINE> self._includeEndsWith = [] <NEW_LINE> self._includePatterns = [] <NEW_LINE> self._excludeEndsWith = [] <NEW_LINE> self._excludePatterns = [] <NEW_LINE> self._wildcardMatcher = re.compile(r'[*?\[\]]') | Constructor.
| 625941f58a349b6b435e87b1 |
def ensure_files(*args): <NEW_LINE> <INDENT> for path in args: <NEW_LINE> <INDENT> if not os.path.exists(path): <NEW_LINE> <INDENT> print('Can\'t find: {}'.format(path)) <NEW_LINE> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Ensure that all arguments are existing file paths. | 625941f50a50d4780f6674d6 |
def setVolume(self,level): <NEW_LINE> <INDENT> self.volume = str(level) | convert back to string | 625941f530c21e258bdfaae3 |
def verify(self, message): <NEW_LINE> <INDENT> return message | Implement :py:meth:`pymco.security.SecurityProvider.verify`.
It does nothing, returning always given message. | 625941f5ec188e330fd5adcf |
def _shrink_states(self, number_of_states): <NEW_LINE> <INDENT> copy_cell_colors = [None] * number_of_states <NEW_LINE> for cix in range(number_of_states): <NEW_LINE> <INDENT> copy_cell_colors[cix] = self.cell_colors[cix].copy() <NEW_LINE> <DEDENT> self.cell_colors = copy_cell_colors <NEW_LINE> copy_probability = [[1.0... | pre: self.states > number_of_states
pre: number_of_states > 0 | 625941f5507cdc57c6307329 |
def afterSetUp(self): <NEW_LINE> <INDENT> self.createBranchingSurvey() | Create a survey with four pages | 625941f523e79379d52eeb99 |
def checkline(self, filename, lineno): <NEW_LINE> <INDENT> globs = self.curframe.f_globals if hasattr(self, 'curframe') else None <NEW_LINE> line = linecache.getline(filename, lineno, globs) <NEW_LINE> if not line: <NEW_LINE> <INDENT> print('End of file', file=self.stdout) <NEW_LINE> return 0 <NEW_LINE> <DEDENT> line =... | Check whether specified line seems to be executable.
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
line or EOF). Warning: testing is not comprehensive. | 625941f5d10714528d60032a |
def create_team(team_name): <NEW_LINE> <INDENT> payload = {'name': team_name} <NEW_LINE> url = WEBEX_TEAMS_URL + '/teams' <NEW_LINE> header = {'content-type': 'application/json', 'authorization': WEBEX_TEAMS_AUTH} <NEW_LINE> team_response = requests.post(url, data=json.dumps(payload), headers=header, verify=False) <NEW... | This function will create a Webex Teams team with the name {team_name}
Call to Webex Teams - /teams
:param team_name: new Webex Teams team name
:return: the Webex Teams team id | 625941f507d97122c4178ed9 |
def createNumberFormat(self): <NEW_LINE> <INDENT> fmt = icVNumberFormat(self) <NEW_LINE> attrs = fmt.create() <NEW_LINE> return fmt | Создать формат. | 625941f52c8b7c6e89b35dfa |
def _convert_to_example(filename, image_buffer, label, text): <NEW_LINE> <INDENT> colorspace = 'RGB' <NEW_LINE> channels = 3 <NEW_LINE> image_format = 'JPEG' <NEW_LINE> example = tf.train.Example(features=tf.train.Features(feature={ 'image/colorspace': _bytes_feature(tf.compat.as_bytes(colorspace)), 'image/channels': _... | Build an Example proto for an example.
Args:
filename: string, path to an image file, e.g., '/path/to/example.JPG'
image_buffer: string, JPEG encoding of RGB image
label: integer, identifier for the ground truth for the network
text: string, unique human-readable, e.g. 'dog'
height: integer, image height in p... | 625941f5091ae35668667592 |
def __init__(self, column, constraint=None, use_alter=False, name=None, onupdate=None, ondelete=None, deferrable=None, initially=None, link_to_name=False): <NEW_LINE> <INDENT> self._colspec = column <NEW_LINE> self.constraint = constraint <NEW_LINE> self.use_alter = use_alter <NEW_LINE> self.name = name <NEW_LINE> self... | Construct a column-level FOREIGN KEY.
:param column: A single target column for the key relationship. A :class:`Column`
object or a column name as a string: ``tablename.columnkey`` or
``schema.tablename.columnkey``. ``columnkey`` is the ``key`` which has been assigned
to the column (defaults to the column name... | 625941f596565a6dacc8fd07 |
def rnn_forward(x, h0, Wx, Wh, b): <NEW_LINE> <INDENT> h, cache = None, None <NEW_LINE> N, T = x.shape[0], x.shape[1] <NEW_LINE> H = h0.shape[1] <NEW_LINE> cache = [] <NEW_LINE> h = np.zeros((N, T, H)) <NEW_LINE> prev_h = h0 <NEW_LINE> for i in range(T): <NEW_LINE> <INDENT> prev_h, cache_current = rnn_step_forward(x[:,... | Run a vanilla RNN forward on an entire sequence of data. We assume an input
sequence composed of T vectors, each of dimension D. The RNN uses a hidden
size of H, and we work over a minibatch containing N sequences. After running
the RNN forward, we return the hidden states for all timesteps.
Inputs:
- x: Input data fo... | 625941f566656f66f7cbc7eb |
def diffWaysToCompute(self, input): <NEW_LINE> <INDENT> nums, ops, temp = [], [], [] <NEW_LINE> for c in input: <NEW_LINE> <INDENT> if c in self.op_dict: <NEW_LINE> <INDENT> nums.append(int(''.join(temp))) <NEW_LINE> ops.append(c) <NEW_LINE> temp = [] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> temp.append(c) <NEW_LI... | :type input: str
:rtype: List[int] | 625941f596565a6dacc8fd08 |
def group(items): <NEW_LINE> <INDENT> groups = [(items.count(x), x) for x in set(items)] <NEW_LINE> return sorted(groups, reverse=True) | Return a list of [(count, x)...], highest count first, then highest x first. | 625941f54c3428357757c962 |
def step(self, r, f): <NEW_LINE> <INDENT> f = np.array(f) <NEW_LINE> r = np.array(r) <NEW_LINE> self.update(r, f, self.r0, self.f0) <NEW_LINE> s = self.s <NEW_LINE> y = self.y <NEW_LINE> rho = self.rho <NEW_LINE> H0 = self.H0 <NEW_LINE> loopmax = len(self.s) <NEW_LINE> a = np.empty((loopmax,), dtype=np.float64) <NEW_LI... | Take a single step
Use the given forces, update the history and calculate the next step --
then take it | 625941f592d797404e3047cc |
def euler_filter(): <NEW_LINE> <INDENT> pass | Fix large jumps and flips in the selected Euler Rotation F-Curves arising from rotation values being clipped when baking physics
| 625941f5be8e80087fb21275 |
def get_geometry_from_group(self, group): <NEW_LINE> <INDENT> if str(group['geometry_group'].attrs["NX_class"], 'utf8') == "NXoff_geometry": <NEW_LINE> <INDENT> vertices, faces, winding_order = self.get_off_geometry_from_group(group) <NEW_LINE> <DEDENT> elif str(group['geometry_group'].attrs["NX_class"], 'utf8') == "NX... | Get geometry information from the geometry group
:param group: Geometry group and its parent group in a dictionary
:return: vertices, faces and winding_order information from the group | 625941f53d592f4c4ed1d69a |
def create_issue_comment(self, body): <NEW_LINE> <INDENT> assert isinstance(body, (str, unicode)), body <NEW_LINE> post_parameters = { "body": body, } <NEW_LINE> headers, data = self._requester.requestJsonAndCheck( "POST", self._parentUrl(self._parentUrl(self.url)) + "/issues/" + str(self.number) + "/comments", None, p... | :calls: `POST /repos/:user/:repo/issues/:number/comments <http://developer.github.com/v3/todo>`_
:param body: string
:rtype: :class:`github.IssueComment.IssueComment` | 625941f594891a1f4081c0eb |
def preprocess_search_input(search_input, search_field): <NEW_LINE> <INDENT> is_search_input_incorrect = re.search(r'[^а-яА-Я, ]+', search_input) <NEW_LINE> if is_search_input_incorrect: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if search_field == 'ingredients.name' and (' и ' in search_input or ' или ' in se... | Preprocesses the search input | 625941f5656771135c3ebeb5 |
def update(self): <NEW_LINE> <INDENT> self._data = self.do_api_request(BASE_URL.format( self._host, self._port, '/happ_thermstat?action=getThermostatInfo')) <NEW_LINE> self._current_setpoint = int(self._data['currentSetpoint'])/100 <NEW_LINE> self._current_temp = int(self._data['currentTemp'])/100 <NEW_LINE> self._curr... | Update the data from the thermostat. | 625941f5f8510a7c17cf9d40 |
def setArray(self, *args): <NEW_LINE> <INDENT> return _MEDCalculator.MEDCouplingFieldDouble_setArray(self, *args) | setArray(self, DataArrayDouble array)
1 | 625941f5f548e778e58cdbbf |
def connect(): <NEW_LINE> <INDENT> return psycopg2.connect("dbname=hypermedia user=chronos") | Connect to the PostgreSQL database. Returns a database connection. | 625941f5e64d504609d74e7e |
def closestIdx(self, value, method='nearest'): <NEW_LINE> <INDENT> if self.isTime and isinstance(value,str): <NEW_LINE> <INDENT> value = iso8601STRtoNum(value) <NEW_LINE> <DEDENT> elif isinstance(value, dt.datetime): <NEW_LINE> <INDENT> value = dttonum(value) <NEW_LINE> <DEDENT> if self.isTime: <NEW_LINE> <INDENT> rang... | Returns the integer index that matches the closest 'value' in
dimensions values.
Arguments:
`value` : The value to search in the dimension values. If the object
contains a time dimension, this parameter can be a valid ISO 86091 string
or datetime.
`method` : The argument passed to pandas index.get_loc method
that ... | 625941f53539df3088e2e98a |
def test_put_tiddler_json_bad_path(): <NEW_LINE> <INDENT> http = httplib2.Http() <NEW_LINE> if type(store.storage) != tiddlyweb.stores.text.Store: <NEW_LINE> <INDENT> py.test.skip('skipping this test for non-text store') <NEW_LINE> <DEDENT> json = simplejson.dumps(dict(text='i fight for the users 2', tags=['tagone','ta... | / in tiddler title is an unresolved source of some confusion. | 625941f56fb2d068a760f6e6 |
def test_it_rejects_timeout_too_large(self): <NEW_LINE> <INDENT> response = self.client.post( reverse('hc-api-checks'), json.dumps({"api_key": "abc", "timeout": 10000000000}), content_type="application/json" ) <NEW_LINE> response_payload = response.json() <NEW_LINE> self.assertEqual(response_payload["error"], "timeout ... | Ensure that too large a timeout is rejected | 625941f5851cf427c661ab48 |
def unique_children_in_family(self): <NEW_LINE> <INDENT> for ID, family in self.family.items(): <NEW_LINE> <INDENT> unique_child_names = [] <NEW_LINE> for child in family.chil: <NEW_LINE> <INDENT> child_name = self.individuals[child].name <NEW_LINE> child_bday = self.individuals[child].birt <NEW_LINE> if (child_name, c... | US25: Checks to make sure that each child in a family has a unique name and birthdate | 625941f5dc8b845886cb5b76 |
def _makeD2PiEEOS(self, name, pionSel, eleSel, config): <NEW_LINE> <INDENT> return makeD2PiEEOS(name , pionSel , eleSel , DMAXDOCA = config['DMAXDOCA'] , DVCHI2DOF = config['DVCHI2DOF'] , DDIRA = config['DDIRA'] , DIPCHI2 = config['DIPCHI2'] , DMassWin = config['DMassWin'] , DMassLow = config['DMassLow'] , DimuonMass =... | Handy interface for D2PiEEOS | 625941f516aa5153ce362ab8 |
def test_if_ucr_pods_can_be_deployed_with_image_whiteout(dcos_api_session): <NEW_LINE> <INDENT> test_uuid = uuid.uuid4().hex <NEW_LINE> pod_definition = { 'id': '/integration-test-pods-{}'.format(test_uuid), 'scaling': {'kind': 'fixed', 'instances': 1}, 'environment': {'PING': 'PONG'}, 'containers': [ { 'name': 'contai... | Marathon pods inside ucr deployment integration test.
This test verifies that a marathon ucr pod can execute a docker image
with whiteout files. Whiteouts are files with a special meaning for
the layered filesystem. For more details, please see:
https://github.com/docker/docker/blob/master/pkg/archive/whiteouts.go
Pl... | 625941f51d351010ab856159 |
def remove_header(stdout): <NEW_LINE> <INDENT> actual_text = [] <NEW_LINE> off_header = False <NEW_LINE> lines = ( stdout.split("\n") if sys.hexversion < 0x03000000 else stdout.decode("ascii").split("\n") ) <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> off_header = line.startswith("Callable:") or off_header <NEW_LI... | Remove py.test header. | 625941f57b180e01f3dc4e2e |
def build_args(parser): <NEW_LINE> <INDENT> parser.add_argument("--in-template", type=Path, required=True) <NEW_LINE> parser.add_argument("--out-config", type=Path, required=True) <NEW_LINE> parser.add_argument("--expdir", type=Path, required=True) <NEW_LINE> parser.add_argument("--dataset-path", type=Path, required=Tr... | Constructs the command-line arguments for ``prepare_config``. | 625941f52eb69b55b151cef8 |
def glInitMapbufferOES(): <NEW_LINE> <INDENT> from OpenGL import extensions <NEW_LINE> return extensions.hasGLExtension( _EXTENSION_NAME ) | Return boolean indicating whether this extension is available | 625941f5236d856c2ad44e23 |
def _set_size_list(self): <NEW_LINE> <INDENT> for idx in range(len(SIZE)): <NEW_LINE> <INDENT> self.font_size.Append(str(SIZE[idx]), idx) | Set the list of font size | 625941f5379a373c97cfb186 |
def partVirtualHelixRemovingSlot(self, sender: NucleicAcidPartT, id_num: int, virtual_helix: VirtualHelixT, neighbors: List[int]): <NEW_LINE> <INDENT> if virtual_helix in self.outlineViewObjSet(): <NEW_LINE> <INDENT> self.disconnectSignals() <NEW_LINE> self.parent().removeChild(self) | Args:
sender (obj): Model object that emitted the signal.
id_num (int): VirtualHelix ID number. See `NucleicAcidPart` for description and related methods.
neighbors (list): | 625941f585dfad0860c3b49c |
def ResumeLiveStream(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("ResumeLiveStream", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.ResumeLiveStreamResponse() ... | 恢复某条流的推流。
:param request: Request instance for ResumeLiveStream.
:type request: :class:`tencentcloud.live.v20180801.models.ResumeLiveStreamRequest`
:rtype: :class:`tencentcloud.live.v20180801.models.ResumeLiveStreamResponse` | 625941f55e10d32532c5f563 |
def getDnamesCount(self): <NEW_LINE> <INDENT> dnames = dict() <NEW_LINE> for dname in self.domainfactory.domains: <NEW_LINE> <INDENT> dnames[dname]=len(dname.ipblocks) <NEW_LINE> <DEDENT> return dnames | Returns a dict with <domain name>:<cnt>, where <cnt> represents the
number of IPBlocks in which this domain name was found. | 625941f566673b3332b926d0 |
def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH): <NEW_LINE> <INDENT> if not os.path.isdir(housing_path): <NEW_LINE> <INDENT> os.makedirs(housing_path) <NEW_LINE> <DEDENT> tgz_path = os.path.join(housing_path,"housing.tgz") <NEW_LINE> urllib.request.urlretrieve(housing_url,tgz_path) <NEW_LINE>... | Fetch the data | 625941f54f88993c3716c69f |
def _proc_objs(root, proc, select=None, pred=None): <NEW_LINE> <INDENT> pred = pred or (lambda _1, _2: True) <NEW_LINE> nargs = len(args_spec(proc).args) <NEW_LINE> if nargs == 1: <NEW_LINE> <INDENT> do = lambda _, o: proc(o) <NEW_LINE> <DEDENT> elif nargs == 2: <NEW_LINE> <INDENT> do = lambda n, o: proc(n, o) <NEW_LIN... | Process selected objects, within a "root" object, that satisfy a predicate.
:param object root: the object from which to select contained objects
:param function(object) -> Iterable[str] proc: how to process an individual
subobject
:param function(object) -> bool select: how to select subobjects from the
root ... | 625941f5cc40096d61595f8c |
def filter_category(category, influencers): <NEW_LINE> <INDENT> new_list = list(set(influencers) & set(category)) <NEW_LINE> if new_list: <NEW_LINE> <INDENT> return new_list <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return np.nan | Ignore values not in the list of influencers
:param category: List, influencing points in a category
:param influencers: List, most popular infleuncing points
:return: List, only popular influencers | 625941f563d6d428bbe44b30 |
def load_from_stream(self, stream, to_container, **kwargs): <NEW_LINE> <INDENT> return self.load_from_string(stream.read(), to_container, **kwargs) | Load config from given stream `stream`.
:param stream: Config file or file-like object
:param to_container: callble to make a container object later
:param kwargs: optional keyword parameters to be sanitized :: dict
:return: Dict-like object holding config parameters | 625941f5d58c6744b425829c |
@contract(list_of_words='!None', n='>0', returns='list(str)') <NEW_LINE> def word_filter(list_of_words, n): <NEW_LINE> <INDENT> lista = [] <NEW_LINE> for item in list_of_words: <NEW_LINE> <INDENT> prueba(item, n, lista) <NEW_LINE> <DEDENT> return(lista) | 4: Filtra las palabras que contienen más de n caracteres
>>> word_filter(['hello', 'bye', 'computer', 'software', 'python'],5)
['computer', 'software', 'python'] | 625941f50a366e3fb873ee5f |
def IsSseResponse(): <NEW_LINE> <INDENT> return MatchesStructure( code=Equals(200), headers=HasHeader('Content-Type', ['text/event-stream']) ) | Match a status code of 200 on a treq.response object and check that a
header is set to indicate that the content type is an event stream. | 625941f5167d2b6e312191d3 |
def init(): <NEW_LINE> <INDENT> global ffi, cffi_sin, cffi_cos <NEW_LINE> if ffi is None: <NEW_LINE> <INDENT> ffi, dll = load_inline_module() <NEW_LINE> cffi_sin = dll._numba_test_sin <NEW_LINE> cffi_cos = dll._numba_test_cos <NEW_LINE> del dll | Initialize module globals. This can invoke external utilities, hence not
being executed implicitly at module import. | 625941f5e64d504609d74e7f |
def get_all_datasets(data_path): <NEW_LINE> <INDENT> images_folder = join(data_path, images_path) <NEW_LINE> all_files = listdir(images_folder) <NEW_LINE> all_datasets = [d for d in all_files if isdir(d)] <NEW_LINE> return all_datasets | Returns a list of all datasets in a data path
:param data_path: Path to training or test data (Ex:traffic_sign_svm\data raining_data)
:return: list of datasets (Ex: [00013, 00015]) | 625941f515fb5d323cde1159 |
def test_run_xml_match(self): <NEW_LINE> <INDENT> dir_path = os.path.dirname(os.path.realpath("sca")) <NEW_LINE> jour_file = dir_path + "/tests/fdpr_journal_example.xml" <NEW_LINE> problems = core.run_xml_match(jour_file) <NEW_LINE> self.assertEquals(6, len(problems)) <NEW_LINE> unroll_loop = problems['UNROLL LOOP'] <N... | Test the run_xml_match function and also the set_group_events() | 625941f591af0d3eaac9c05d |
def hashScan(self, hash_name, key_start, key_end, limit): <NEW_LINE> <INDENT> item_list = self.__conn.execute_command('hscan', hash_name, key_start, key_end, limit) <NEW_LINE> item_list = [_.decode() for _ in item_list if isinstance(_, bytes)] <NEW_LINE> hash_list = [{'key': item_list[index], 'value': item_list[index +... | List key-value pairs of a hashmap with keys in range (key_start, key_end].
Args:
hash_name: hash name
key_start: start key
key_end: end key
limit: limit
Returns:
list of hash item | 625941f56aa9bd52df0373e7 |
def rotate_right(x, n): <NEW_LINE> <INDENT> if 0 <= n & n < 32: <NEW_LINE> <INDENT> return (x >> n) | (x << (32 - n )) | x is a w-bit word,n is an integer with 0 ≤ n < w
(x) =(x >> n) ∨ (x << w - n). | 625941f599fddb7c1c9de9cc |
def set_command_line_options(subparsers): <NEW_LINE> <INDENT> parser = subparsers.add_parser('cfdelete', description='Delete the CloudFront' ' distribution for the s3' ' website', add_help=False, ) <NEW_LINE> parser.set_defaults(func=main) | Command line options for CloudFront distribution deletion
:param subparsers: argparse - The parser object | 625941f53d592f4c4ed1d69b |
def generate_hostslist(self): <NEW_LINE> <INDENT> groups = HostGroup.objects.all() <NEW_LINE> contents = "" <NEW_LINE> for group in groups: <NEW_LINE> <INDENT> contents = contents + "[" + group.group_name + "]" + "\n" <NEW_LINE> hosts = group.hostsinfo_set.all() <NEW_LINE> for host in hosts: <NEW_LINE> <INDENT> content... | 生成ansible hostslist文件
:return:None | 625941f5ff9c53063f47c82f |
def detrend_tod(tod=None, dets=None, data=None): <NEW_LINE> <INDENT> if data is None: <NEW_LINE> <INDENT> data = tod.data <NEW_LINE> <DEDENT> one_d = data.ndim == 1 <NEW_LINE> if one_d: <NEW_LINE> <INDENT> data.shape = (1,-1) <NEW_LINE> <DEDENT> if dets is None: <NEW_LINE> <INDENT> dets = np.ones(data.shape[0], 'bool')... | Subtract a line through the first and last datapoints of each tod,
preserving the data mean.
Instead of a tod, you can pass in a data array through data=... .
Returns (y0, y1), which are vectors of the values removed from the
first and last samples, respectively. | 625941f5656771135c3ebeb6 |
def __init__(self, template, dist_func=None): <NEW_LINE> <INDENT> self.set_template(template) <NEW_LINE> if dist_func is not None: <NEW_LINE> <INDENT> self.dist_func = dist_func <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.dist_func = lambda x,y: (x-y)**2 | Creates a class for calculating Dynamic Time Warping distance,
finding a warping path, and warping signals. Currently only for
1 dimentional signals
Parameters
-------------
template (t,y) array-like: template independent variable and signal
dist_func function: (optional) Distance function. Defaults to euclidean | 625941f5a934411ee3751cd5 |
def setup(app: Sphinx): <NEW_LINE> <INDENT> app.connect("build-finished", render_robots_txt) <NEW_LINE> app.add_directive("tags", TagsDirective) | Called by Sphinx.
:param app: Sphinx application object. | 625941f530bbd722463cc409 |
def apply_gradients(self, grads_and_vars, name=None): <NEW_LINE> <INDENT> grads_and_vars = _filter_grads(grads_and_vars) <NEW_LINE> var_list = [v for (_, v) in grads_and_vars] <NEW_LINE> if distribute_ctx.has_distribution_strategy(): <NEW_LINE> <INDENT> reduced_grads = merge_grads(grads_and_vars) <NEW_LINE> grads_and_v... | Apply gradients to variables.
This is the second part of `minimize()`. It returns an `Operation` that
applies gradients.
Args:
grads_and_vars: List of (gradient, variable) pairs as returned by
`compute_gradients()`.
name: Optional name for the returned operation. Default to the name
passed to the `Optimi... | 625941f51d351010ab85615a |
def setup(self): <NEW_LINE> <INDENT> self.kernel = MockKernel() <NEW_LINE> self.kernel.services = {} <NEW_LINE> try: <NEW_LINE> <INDENT> config.add_section('Database') <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> config.set('Database','connectionstring','sqlite://') <NEW_LINE> if self.kernel... | Call super(TESTNAME, self).setup() | 625941f538b623060ff0b42c |
def open_dialog(self): <NEW_LINE> <INDENT> responseFolder = fd.askdirectory(title="Open directory", initialdir=".") <NEW_LINE> if responseFolder: <NEW_LINE> <INDENT> logger.debug(responseFolder) <NEW_LINE> requiredResponseFile = 'success.json.erb' <NEW_LINE> if os.path.exists(os.path.join(responseFolder, requiredRespon... | Standard askopenfilename() invocation and result handling. | 625941f5a05bb46b383ece5b |
def reset_dataset_database(dataset_name: str): <NEW_LINE> <INDENT> mydb = create_database_connection() <NEW_LINE> pattern = re.compile(dataset_name + '[0-9]+-[0-9]+-+[0-9]+') <NEW_LINE> collections = mydb.list_collection_names() <NEW_LINE> for name in collections: <NEW_LINE> <INDENT> if pattern.match(name): <NEW_LINE> ... | Reset dataset in database
- delete everything from except crawled links and mention in DATASETS collection
Args:
dataset_name: name of dataset that has existing configuration file | 625941f5be7bc26dc91cdc33 |
@pubswh.route('/unapi') <NEW_LINE> def unapi(): <NEW_LINE> <INDENT> formats = {'rdf_bibliontology': {'type': 'application/xml', 'docs': "http://bibliontology.com/specification", 'template': 'rdf_bibliontology.rdf'}} <NEW_LINE> unapi_id = request.args.get('id') <NEW_LINE> unapi_format = request.args.get('format') <NEW_L... | this is an unapi format, which appears to be the only way to get a good export to zotero that has all the
Zotero fields, Documented here: http://unapi.info/specs/
:return: rendered template of (at this time) bibontology rdf, which maps directly to Zotero Fields | 625941f57047854f462a1a41 |
def _make_batch(self): <NEW_LINE> <INDENT> raise NotImplementedError("Please implement `_make_batch()`") | Format samples as needed. | 625941f53617ad0b5ed68536 |
def isValidSudoku(self, board): <NEW_LINE> <INDENT> rows = [set() for _ in xrange(9)] <NEW_LINE> cols = [set() for _ in xrange(9)] <NEW_LINE> squares = [[set() for _ in xrange(3)] for _ in xrange(3)] <NEW_LINE> for x in xrange(9): <NEW_LINE> <INDENT> for y in xrange(9): <NEW_LINE> <INDENT> if board[x][y] == '.': <NEW_L... | :type board: List[List[str]]
:rtype: bool | 625941f567a9b606de4a84f5 |
def template_documentation(): <NEW_LINE> <INDENT> indent_l0 = " " * 2 <NEW_LINE> indent_l1 = indent_l0 + " " * 2 <NEW_LINE> doc = [] <NEW_LINE> doc.append('Template names/values derived from easyconfig instance') <NEW_LINE> for name in TEMPLATE_NAMES_EASYCONFIG: <NEW_LINE> <INDENT> doc.append("%s%s: %s" % (indent_l1, n... | Generate the templating documentation | 625941f5711fe17d8254299c |
def test_open_file_objects(self): <NEW_LINE> <INDENT> test_source = unittest.source <NEW_LINE> if not test_source: <NEW_LINE> <INDENT> raise unittest.SkipTest("missing source") <NEW_LINE> <DEDENT> if not os.path.isfile(test_source): <NEW_LINE> <INDENT> raise unittest.SkipTest("source not a regular file") <NEW_LINE> <DE... | Tests the open_file_objects function. | 625941f55e10d32532c5f564 |
def select_dropdown_value(driver, locator, value): <NEW_LINE> <INDENT> function_module.wait_for_element_XPATH(driver, locator) <NEW_LINE> driver.find_element_by_xpath(locator).click() <NEW_LINE> Select(driver.find_element_by_xpath(locator)).select_by_visible_text(value) <NEW_LINE> driver.find_element_by_xpath(locator).... | objects selects value from dropdown at given xpath locator | 625941f5099cdd3c635f1297 |
def save(self, path: str): <NEW_LINE> <INDENT> print('save model parameters to [%s]' % path, file=sys.stderr) <NEW_LINE> params = { 'args': dict(word_embed_size=self.model_embeddings_source.word_embed_size, hidden_size=self.hidden_size, dropout_rate=self.dropout_rate), 'vocab': self.vocab, 'state_dict': self.state_dict... | Save the odel to a file.
@param path (str): path to the model | 625941f515baa723493c45ba |
def test_unpub_pub_unpub_pub_pattern(self): <NEW_LINE> <INDENT> response = self.client.get(self.path) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.journal_about_page.unpublish() <NEW_LINE> self.journal_about_page.get_children()[0].save_revision().publish() <NEW_LINE> self.journal_about_page.ge... | Test the 'unpub->pub->unpub->pub' pattern | 625941f53eb6a72ae02ecb2f |
def lightcurve_smooth(self, n, bandpasses, time_range=None, fluxed=False, energy_units='erg', nan_between=False, independent=False, order=None): <NEW_LINE> <INDENT> covered = self.check_wavelength_coverage(bandpasses) <NEW_LINE> if not _np.any(covered): <NEW_LINE> <INDENT> raise ValueError('None of the observations cov... | Parameters
----------
n
bandpasses
time_range
fluxed
energy_units
nan_between
Add NaN points between each observation. Useful; for plotting because it breaks the plotted line between
exposures.
independent :
Return only ever nth point in each exposure such that the points are statistically independent.
Ret... | 625941f5435de62698dfe28d |
def pad_sequences(sequences, seq_len): <NEW_LINE> <INDENT> padded_seqs = [] <NEW_LINE> for seq in sequences: <NEW_LINE> <INDENT> _seq = pad_sequence(seq, seq_len) <NEW_LINE> padded_seqs.append(_seq.split()) <NEW_LINE> <DEDENT> return padded_seqs | adds PAD, SOS, EOS, UNK to sequence | 625941f5379a373c97cfb187 |
def _apply_subscript(self, hosts, subscript): <NEW_LINE> <INDENT> if not hosts or not subscript: <NEW_LINE> <INDENT> return hosts <NEW_LINE> <DEDENT> (start, end) = subscript <NEW_LINE> if end: <NEW_LINE> <INDENT> return hosts[start:end+1] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return [ hosts[start] ] | Takes a list of hosts and a (start,end) tuple and returns the subset of
hosts based on the subscript (which may be None to return all hosts). | 625941f57cff6e4e81117fc5 |
@app.route("/data-gen/update", methods=['POST']) <NEW_LINE> def update_data(): <NEW_LINE> <INDENT> update_schema = request.get_json() <NEW_LINE> update_schema = json.dumps(update_schema) <NEW_LINE> try: <NEW_LINE> <INDENT> log.info('Updating schema for generator') <NEW_LINE> g = generator.DataGenerator(update_schema) <... | Update the data generator schema that will be used for the threaded generator and the temp generator for sample data
Route:
``POST /data-gen/update``
Returns:
json: A JSON object with a 'message' key. | 625941f5498bea3a759ba0ed |
def test_invalid_lattice_state(self): <NEW_LINE> <INDENT> eca = RewiredECA(30, size=3) <NEW_LINE> with self.assertRaises(ValueError): <NEW_LINE> <INDENT> eca.update([-1, 0, 1]) <NEW_LINE> <DEDENT> with self.assertRaises(ValueError): <NEW_LINE> <INDENT> eca.update([1, 0, -1]) <NEW_LINE> <DEDENT> with self.assertRaises(V... | Ensure that the states of the lattice are binary states | 625941f54a966d76dd551656 |
def deltaphicorr(self): <NEW_LINE> <INDENT> saxsdata = self.saxsdata <NEW_LINE> if hasattr(saxsdata,"mask") and self.saxsdata.mask is not None: <NEW_LINE> <INDENT> mask = saxsdata.mask <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> mask = None <NEW_LINE> <DEDENT> data = saxsdata.avg_img <NEW_LINE> x0, y0 = saxsdata.getx... | Makes the delta phi correlation for the data. | 625941f521a7993f00bc833c |
def has_feature(self, feature): <NEW_LINE> <INDENT> return feature in self.features | Test if a feature is declared by the links.
Parameters
----------
feature: str
The name of the feature of interest.
Returns
-------
bool | 625941f59c8ee82313fbbdb7 |
def _connect(self): <NEW_LINE> <INDENT> if self._client is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> client = SSHClient() <NEW_LINE> client.set_missing_host_key_policy(AutoAddPolicy()) <NEW_LINE> client.connect( self._host, username=self._user, password=self._password, look_for_keys=True, timeout=5000, key_fil... | Open connection to remote host.
Raises
------
AuthenticationException
If authentication fails | 625941f5b7558d58953c5546 |
def write(permissions_dict): <NEW_LINE> <INDENT> with open(CHANNEL_PERMISSIONS_JSON, 'w+') as f: <NEW_LINE> <INDENT> ujson.dump(permissions_dict, f) | Writes the permissions dict to a json file. | 625941f58a349b6b435e87b2 |
def setup_schema(command, conf, vars): <NEW_LINE> <INDENT> from addrbook import model <NEW_LINE> print("Creating tables") <NEW_LINE> model.metadata.create_all(bind=config['tg.app_globals'].sa_engine) <NEW_LINE> transaction.commit() <NEW_LINE> print('Initializing Migrations') <NEW_LINE> import alembic.config <NEW_LINE> ... | Place any commands to setup addrbook here | 625941f550485f2cf553d3dc |
def RecursiveDownload(dir_obj, target_dir, max_depth=10, depth=1, overwrite=False, max_threads=10): <NEW_LINE> <INDENT> if (not isinstance(dir_obj, aff4.AFF4Volume) or isinstance(dir_obj, standard.HashImage)): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> thread_pool = threadpool.ThreadPool.Factory("Downloader", max_t... | Recursively downloads a file entry to the target path.
Args:
dir_obj: An aff4 object that contains children.
target_dir: Full path of the directory to write to.
max_depth: Depth to download to. 1 means just the directory itself.
depth: Current depth of recursion.
overwrite: Should we overwrite files that exi... | 625941f5566aa707497f4ba0 |
def _validate_cert_url(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> url_object = urlparse.urlparse(self._signing_cert_url) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise ValueError('Invalid signing cert URL.') <NEW_LINE> <DEDENT> if url_object.scheme != 'https': <NEW_LINE> <INDENT> raise ValueError('Inval... | Checks to see if the certificate URL points to a AWS endpoint and
validates the signature using the .pem from the certificate URL. | 625941f57d43ff24873a32e6 |
def all_workers_are_free(self): <NEW_LINE> <INDENT> all_are_free = True <NEW_LINE> for wid in self.worker_ids: <NEW_LINE> <INDENT> all_are_free = self._worker_is_free(wid) and all_are_free <NEW_LINE> <DEDENT> if all_are_free: <NEW_LINE> <INDENT> return self._get_last_receive_time() <NEW_LINE> <DEDENT> else: <NEW_LINE> ... | Returns true if all workers are free. | 625941f5fff4ab517eb2fa81 |
def get_frames_data(filename, num_frames_per_clip=16, flip=False): <NEW_LINE> <INDENT> ret_arr = [] <NEW_LINE> s_index = 0 <NEW_LINE> pad_size = 0 <NEW_LINE> for parent, dirnames, filenames in os.walk(filename): <NEW_LINE> <INDENT> filenames = sorted(filenames) <NEW_LINE> if(len(filenames) < num_frames_per_clip): <NEW_... | Given a directory containing extracted frames, return a video clip of
(num_frames_per_clip) consecutive frames as a list of np arrays | 625941f53cc13d1c6d3c79b7 |
def test_US2_I2_userlist_post_with_perm(self): <NEW_LINE> <INDENT> user = self.set_up_perm() <NEW_LINE> client = APIClient() <NEW_LINE> client.force_authenticate(user=user) <NEW_LINE> response = client.post( '/api/usersmanagement/users/', { 'username': 'joey', 'password': 'machin', 'email': 'test@pic.brasserie-du-slalo... | Test if a user with permission can add an user.
Inputs:
post data (UserProfile): a mock-up for an user.
Expected Output:
We expect a 201 status code in the response. | 625941f566673b3332b926d1 |
def compute_sparse_comp(self, term_id, doc_topic_count): <NEW_LINE> <INDENT> logger.debug("compute sparse distribution for term: {0}".format(term_id)) <NEW_LINE> pdw = SparseVector(self.num_topics, dtype=self.dtype) <NEW_LINE> pdw_norm = 0. <NEW_LINE> for topic_id in doc_topic_count: <NEW_LINE> <INDENT> pdw[topic_id] =... | Args:
term_id:
doc_topic_count:
Returns:
Sparse component and its normalization | 625941f53346ee7daa2b33b2 |
def __generate_affectors(self, holder, state_filter=None, scope_filter=None): <NEW_LINE> <INDENT> affectors = set() <NEW_LINE> for modifier in holder.item.modifiers: <NEW_LINE> <INDENT> if state_filter is not None and modifier.state not in state_filter: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if scope_filter i... | Get all affectors spawned by holder.
Required arguments:
holder -- holder, for which affectors are generated
Optional arguments:
state_filter -- filter results by affector's required state,
which should be in this iterable; if None, no filtering
occurs (default None)
scope_filter -- filter results by affector's requi... | 625941f50fa83653e46575f7 |
def _presentErrors(self, err): <NEW_LINE> <INDENT> if err.generic: <NEW_LINE> <INDENT> self.errors.extend(err.generic) <NEW_LINE> <DEDENT> if err.fields: <NEW_LINE> <INDENT> self.errors.extend(err.fields) | Add any errors in our ErrorCollection to the view errors.
| 625941f5046cf37aa974d381 |
def hash_str(s): <NEW_LINE> <INDENT> return hmac.new(SECRET, s).hexdigest() | HMAC Hashing for Cookies | 625941f55fc7496912cc3fbd |
def _create_history(self, station: str, raw_info: List)-> Dict: <NEW_LINE> <INDENT> history = dict() <NEW_LINE> for antenna_info in raw_info: <NEW_LINE> <INDENT> antenna = AntennaSinex(self.station, antenna_info) <NEW_LINE> interval = (antenna.date_from, antenna.date_to) <NEW_LINE> history[interval] = antenna <NEW_LINE... | Create dictionary of antenna history for station
| 625941f5a8370b7717052edd |
def test_shares_id_delete(self): <NEW_LINE> <INDENT> pass | Test case for shares_id_delete
Delete an existing Share. | 625941f5d6c5a10208144690 |
def historia(self, pouzivatelia_id, operacia): <NEW_LINE> <INDENT> sql = "INSERT INTO historia (pouzivatelia_id, operacia, cas) values ('{}', '{}', NOW())" .format(pouzivatelia_id, operacia) <NEW_LINE> SQLdb.zapis(self, sql) | Zapise operaciu oo historie
:return: | 625941f592d797404e3047cd |
def test_not_power_2(self): <NEW_LINE> <INDENT> uneven_shape = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] <NEW_LINE> self.assertRaises(TypeError, Gate, uneven_shape) | ``Gate`` should fail if matrix is not ``n``X``n`` for ``n == 1`` or ``n`` a power of 2. | 625941f53eb6a72ae02ecb30 |
@click.command() <NEW_LINE> @click.option('--duration', help="The duration of this policy") <NEW_LINE> @click.argument("vus", type=int) <NEW_LINE> @click.pass_context <NEW_LINE> @CommandCategory("Composing") <NEW_LINE> def cli(ctx, duration, vus): <NEW_LINE> <INDENT> builder_data.register_context(ctx) <NEW_LINE> builde... | Defines a constant load policy for the current User Path
| 625941f57b25080760e39a95 |
def test_id_is_uuid(self): <NEW_LINE> <INDENT> item = self._create_item() <NEW_LINE> self.assertTrue(self.is_uuid(item.id)) | tests that Item identifier is a UUID | 625941f5507cdc57c630732b |
def time_func(func, name, *args, **kwargs): <NEW_LINE> <INDENT> tic = default_timer() <NEW_LINE> out = func(*args, **kwargs) <NEW_LINE> toc = default_timer() <NEW_LINE> print('%s took %0.2f seconds' % (name, toc - tic)) <NEW_LINE> return out | call a func with args and kwargs, print name of func and how
long it took. | 625941f507d97122c4178edb |
def get_aliases(self, sorted=True): <NEW_LINE> <INDENT> all_keys = self.getall(sorted=sorted) <NEW_LINE> pattern = to_unicode('^' + PREFIX) <NEW_LINE> matched_keys = [] <NEW_LINE> KEYPREFIX = re.compile(pattern, re.UNICODE) <NEW_LINE> for k in all_keys: <NEW_LINE> <INDENT> if KEYPREFIX.match(k): <NEW_LINE> <INDENT> mat... | Fetch all aliases as a alphabetically-sorted list | 625941f544b2445a339326d2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.