code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def assertCountEqual(self, first, second, msg=None): <NEW_LINE> <INDENT> self.assertEqual(set(first), set(second), msg)
Most simple backport of assertCountEqual for python 2.7 :return:
625941d41d351010ab855d11
def _stabilizer(degree, generators, alpha): <NEW_LINE> <INDENT> orb = [alpha] <NEW_LINE> table = {alpha: list(range(degree))} <NEW_LINE> table_inv = {alpha: list(range(degree))} <NEW_LINE> used = [False]*degree <NEW_LINE> used[alpha] = True <NEW_LINE> gens = [x._array_form for x in generators] <NEW_LINE> stab_gens = []...
Return the stabilizer subgroup of ``alpha``. The stabilizer of `\alpha` is the group `G_\alpha = \{g \in G | g(\alpha) = \alpha\}`. For a proof of correctness, see [1], p.79. degree : degree of G generators : generators of G Examples ======== >>> from sympy.combinatorics import Permutation >>> from sympy.co...
625941d4d53ae8145f87a463
def merge(self, intervals): <NEW_LINE> <INDENT> n = len(intervals) <NEW_LINE> if n <= 1: return intervals <NEW_LINE> sorted_intervals = sorted(intervals, key=lambda interval: interval.start) <NEW_LINE> merged, prev = [], sorted_intervals[0] <NEW_LINE> for i in range(1, n): <NEW_LINE> <INDENT> if sorted_intervals[i].sta...
:type intervals: List[Interval] :rtype: List[Interval]
625941d415fb5d323cde0d07
def cleanCase( caseDir , tmin, tmax, verbose , parallel = "auto" ) : <NEW_LINE> <INDENT> if parallel == "auto" : <NEW_LINE> <INDENT> if os.path.exists( os.path.join(caseDir , "processor0") ) : parallel = True <NEW_LINE> else : parallel = False <NEW_LINE> <DEDENT> if parallel : <NEW_LINE> <INDENT> for p in os.listdir( c...
Remove data between tmin and tmax
625941d4bde94217f3682fe5
def unassign_private_ip_addresses(self, network_interface_id=None, private_ip_addresses=None): <NEW_LINE> <INDENT> ret = self.aws.wrap( self.ec2.unassign_private_ip_addresses, network_interface_id=network_interface_id, private_ip_addresses=private_ip_addresses ) <NEW_LINE> return ret
UnAssign a private address from an instance
625941d426068e7796caeed7
def serialize_params(self): <NEW_LINE> <INDENT> return np.hstack([ _serialize_matrix(self.trans, self.trans_mask), _serialize_matrix(self.emiss, self.emiss_mask)])
@return: a float array
625941d47d847024c06be4b3
def tokenize(s, toks): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> while i < len(s): <NEW_LINE> <INDENT> tok = "" <NEW_LINE> skip = valid = 1 <NEW_LINE> if s[i] == '(': <NEW_LINE> <INDENT> tok = tok_list[0] <NEW_LINE> <DEDENT> elif s[i] == ')': <NEW_LINE> <INDENT> tok = tok_list[1] <NEW_LINE> <DEDENT> elif s[i] == '&': <NEW_L...
Tokenize ``s`` and place the tokens of ``s`` in ``toks``. INPUT: - ``s`` -- a string; this contains a boolean expression - ``toks`` -- a list; this will be populated with the tokens of ``s`` OUTPUT: ``None``; the tokens of ``s`` are placed in ``toks``. .. NOTE:: This function is for internal use by the :clas...
625941d46fece00bbac2d936
def test_file_names(mock_osp): <NEW_LINE> <INDENT> path = mock_osp.add_segment('000') <NEW_LINE> segment = Segment(path) <NEW_LINE> for i in range(10): <NEW_LINE> <INDENT> mock_osp.add_file(segment='000', name=str(i)) <NEW_LINE> <DEDENT> names = segment.file_names() <NEW_LINE> for i in range(10): <NEW_LINE> <INDENT> as...
Segment#file_names() should generate the file names.
625941d43cc13d1c6d3c756f
def update_street_type(name): <NEW_LINE> <INDENT> m = street_type_re.search(name) <NEW_LINE> if m: <NEW_LINE> <INDENT> street_type = m.group() <NEW_LINE> if street_type in mapping: <NEW_LINE> <INDENT> name = street_type_re.sub(mapping[street_type], name) <NEW_LINE> <DEDENT> <DEDENT> return name
Updates street type according to the mapping
625941d421a7993f00bc7ee7
def check_col(col, black_list): <NEW_LINE> <INDENT> for i in range(len(col) - 1): <NEW_LINE> <INDENT> if col[i][1] in black_list and col[i + 1][1] in black_list: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if col[i][1] not in black_list and col[i + 1][1] not in black_list: <NEW_LINE> <INDENT> return False <NEW...
takes in a list of cards and list of black suits and checks if the colors are alternating
625941d40fa83653e46571b0
def _make_elem_with_children(self, numchildren): <NEW_LINE> <INDENT> e = ET.Element('a') <NEW_LINE> for i in range(numchildren): <NEW_LINE> <INDENT> ET.SubElement(e, 'a%s' % i) <NEW_LINE> <DEDENT> return e
Create an Element with a tag 'a', with the given amount of children named 'a0', 'a1' ... and so on.
625941d40a366e3fb873ea10
def hideTableList(result): <NEW_LINE> <INDENT> if result == Message.OK and client.tableList: <NEW_LINE> <INDENT> if Debug.table: <NEW_LINE> <INDENT> logDebug('%s hiding table list because game started' % client.name) <NEW_LINE> <DEDENT> client.tableList.hide() <NEW_LINE> <DEDENT> return result
hide it only after player says I am ready
625941d4d4950a0f3b08c543
def make_list_into_float(list1): <NEW_LINE> <INDENT> return [float(num) for num in list1]
makes list of strings into list into list of floats
625941d4956e5f7376d71062
def update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button): <NEW_LINE> <INDENT> screen.fill(ai_settings.bg_color) <NEW_LINE> for bullet in bullets.sprites(): <NEW_LINE> <INDENT> bullet.draw_bullet() <NEW_LINE> <DEDENT> ship.blitme() <NEW_LINE> aliens.draw(screen) <NEW_LINE> sb.show_score() <N...
Atualiza as imagens na tela e alterna para a nova tela.
625941d4a17c0f6771cbe245
def get_value_at(self, address): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self._data[address] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return None
Returns the value stored in the position 'address'.
625941d40a50d4780f667089
def __init__(self, tuple_of_systems, game_type=None): <NEW_LINE> <INDENT> self.sys_tuple = tuple_of_systems <NEW_LINE> self.game = game_type
Constructs all the necessary attributes for pd experiment object Parameters ---------- tuple_of_systems : tuple a multi-dimensional matrix where each item of the first-dimension is an ordered list of systems, and the second dimension is an ordered-list of teams game_type : axelrod.game (object) contai...
625941d4287bf620b61d3c58
@unicode_error_handler <NEW_LINE> def read_utf8(file_name): <NEW_LINE> <INDENT> fn = file_name <NEW_LINE> with codecs.open(fn, encoding='utf8') as f: <NEW_LINE> <INDENT> raw_passage = f.read() <NEW_LINE> <DEDENT> return raw_passage
Read a utf8 coded file :param file_name: name of file :return: unicode string of file
625941d466656f66f7cbc3a2
def get_softselection(): <NEW_LINE> <INDENT> items = list() <NEW_LINE> softSelection = om.MGlobal.getRichSelection() <NEW_LINE> sel = softSelection.getSelection() <NEW_LINE> iter = om.MItSelectionList(sel) <NEW_LINE> while not iter.isDone(): <NEW_LINE> <INDENT> dagPath = iter.getDagPath() <NEW_LINE> transform = dagPath...
Get a list of all paths to transforms affected by current soft selection,
625941d4090684286d50eedc
def get_message_triggered_status(self, message): <NEW_LINE> <INDENT> return self.__reader_thread.get_message_triggered_status(message)
Get the status of a message triggered :type message: string :param path: message triggered :return: Message status :rtype: string
625941d4cdde0d52a9e53229
def _create_examples(self, lines, set_type): <NEW_LINE> <INDENT> examples = [] <NEW_LINE> for (i, line) in enumerate(lines): <NEW_LINE> <INDENT> if i == 0: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> text_a = line[0] <NEW_LINE> label = line[1] <NEW_LINE> examples.append(InputExample(text_a=text_a, text_b=None, lab...
Creates examples for the training and dev sets.
625941d4dc8b845886cb572b
def get_observed_danger_AvalancheEvaluation3V(region_id, start_date, end_date): <NEW_LINE> <INDENT> region_name = get_forecast_region_name(region_id) <NEW_LINE> oDataQuery = "DtObsTime gt datetime'{1}' and " "DtObsTime lt datetime'{2}' and " "ForecastRegionName eq '{0}' and " ...
:param region_id: :param start_date: :param end_date: :return:
625941d430c21e258bdfa693
def open_fastq(self,path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(path) as self._fastq: <NEW_LINE> <INDENT> row = self._fastq.readline() <NEW_LINE> head, tail = os.path.split(path) <NEW_LINE> root, ext = os.path.splitext(tail) <NEW_LINE> while row: <NEW_LINE> <INDENT> header = row.strip() <NEW_LINE> hea...
Function that reads and handles fasta sources
625941d430c21e258bdfa694
def mkdir(self, cmds): <NEW_LINE> <INDENT> print("\033[34;1madd working directory\033[0m") <NEW_LINE> obj = self.socket.recv(4) <NEW_LINE> res = struct.unpack('i', obj)[0] <NEW_LINE> if res: <NEW_LINE> <INDENT> print('\033[31;1mCongratulations add directory success\033[0m') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>...
增加目录 1,server返回1 增加成功 2,server返回2 增加失败
625941d44e696a04525c9641
def matrix_vector_mul(M, v): <NEW_LINE> <INDENT> assert M.D[1] == v.D <NEW_LINE> output = Vec(M.D[0], {}) <NEW_LINE> for d0 in M.D[0]: <NEW_LINE> <INDENT> for d1 in v.D: <NEW_LINE> <INDENT> output[d0] = output[d0] + v[d1]*M[d0,d1] <NEW_LINE> <DEDENT> <DEDENT> return output
Returns the product of matrix M and vector v
625941d476e4537e8c351869
def get_visibility(data: List[str], units: Units) -> Tuple[List[str], Optional[Number]]: <NEW_LINE> <INDENT> visibility = "" <NEW_LINE> if data: <NEW_LINE> <INDENT> item = copy(data[0]) <NEW_LINE> if item.endswith("SM"): <NEW_LINE> <INDENT> if item in ("P6SM", "M1/4SM", "M1/8SM"): <NEW_LINE> <INDENT> visibility = item[...
Returns the report list and removed visibility string
625941d48e05c05ec3eea56c
def set_user_comment_exif(input_fp, output_fp, user_comment_str=""): <NEW_LINE> <INDENT> set_exif(input_fp, output_fp, get_user_comment_exif_bytes(user_comment_str))
Sets the EXIF tags for a JPG image to containly only the given User Comment
625941d4cdde0d52a9e5322a
def post_process(out, pb, state, extend=False): <NEW_LINE> <INDENT> from sfepy.base.base import Struct <NEW_LINE> ev = pb.evaluate <NEW_LINE> stress = ev('ev_cauchy_stress.2.Omega(solid.D, u)', mode='el_avg') <NEW_LINE> vms = get_von_mises_stress(stress.squeeze()) <NEW_LINE> vms.shape = (vms.shape[0], 1, 1, 1) <NEW_LIN...
Calculate and output strain and stress for given displacements.
625941d4cad5886f8bd271cf
def test_iter(self): <NEW_LINE> <INDENT> assert list(iter(MyStringEnum)) == ["A Rafting Opportunity", "Big Apple"]
Tests that you can iterate over constants
625941d4d7e4931a7ee9e113
def get_I(self, name): <NEW_LINE> <INDENT> self._solve() <NEW_LINE> return self._Idict[name].canonical()
Current through component
625941d4d4950a0f3b08c544
def clearGroupSetting(self, groupName: str, settingName: str): <NEW_LINE> <INDENT> if groupName is None: <NEW_LINE> <INDENT> groupName = self._defaultGroupName <NEW_LINE> <DEDENT> groupSettings = self._groupSettings.get(groupName) <NEW_LINE> if groupSettings: <NEW_LINE> <INDENT> groupSettings.pop(settingName, None) <NE...
Clear setting for group, removing group settings dict if empty. :param groupName: Exact model group name, or None for default group. :param settingName: Exact setting name.
625941d43d592f4c4ed1d260
def max_ones_length(self, array, m): <NEW_LINE> <INDENT> n = len(array) <NEW_LINE> i, j = 0, 0 <NEW_LINE> curr_ones = 0 <NEW_LINE> max_ones = 0 <NEW_LINE> while j < n: <NEW_LINE> <INDENT> if array[j]: <NEW_LINE> <INDENT> curr_ones += 1 <NEW_LINE> j += 1 <NEW_LINE> max_ones = max(max_ones, curr_ones) <NEW_LINE> <DEDENT>...
Returns count of maximum consecutive ones that can be achieved by flipping m zeroes. Time complexity: O(n). Space complexity: O(1), n is len(array).
625941d46aa9bd52df036f9a
@task <NEW_LINE> def clean(ctx, docs=False, bytecode=False, lintrc=False, extra=""): <NEW_LINE> <INDENT> patterns = ["build"] <NEW_LINE> if docs: <NEW_LINE> <INDENT> patterns.append("docs/_build") <NEW_LINE> <DEDENT> if bytecode: <NEW_LINE> <INDENT> patterns.append("**/*.pyc") <NEW_LINE> <DEDENT> if lintrc: <NEW_LINE> ...
Cleanup
625941d47d43ff24873a2e96
def get_n_max_values(matrix): <NEW_LINE> <INDENT> max_value = matrix.max() <NEW_LINE> indexes = np.argwhere(matrix == max_value) <NEW_LINE> return max_value, indexes
GET n MAX VALUES RETURN MULTIPLE ITEMS IF THERE ARE MULTIPLE MAX VALUES (DUPLICATES) :param matrix: :return: VALUE AND INDEX
625941d415baa723493c416d
def call(self, inputs, training=None): <NEW_LINE> <INDENT> x = self._flatten_layer(inputs) <NEW_LINE> x = self._fc1(x) <NEW_LINE> x = self._dropout1(x, training) <NEW_LINE> x = self._fc2(x) <NEW_LINE> x = self._dropout2(x, training) <NEW_LINE> score = self._score_layer(x) <NEW_LINE> bboxes = self._roi_bboxes_layer(x) <...
输入 roi pooling 的结果 对每个 roi pooling 的结果进行预测(预测bboxes) :param inputs: roi_features, [num_rois, pool_size, pool_size, num_channels] :param training: :param mask: :return:
625941d45e10d32532c5f11c
def run(self): <NEW_LINE> <INDENT> if self.args.enable_pausing: <NEW_LINE> <INDENT> self.pausing_queue = multiprocessing.Queue() <NEW_LINE> self.do_pause = multiprocessing.Value('i', 0) <NEW_LINE> running_manager = multiprocessing.Process(target=self._run) <NEW_LINE> running_manager.start() <NEW_LINE> print("manager is...
Simple wrapper for self._run() Parameters: None Returns: None Algortihm: If --enable_pausing is not enabled, just call self._run() Otherwise, start self._run() as a subprocess and wait for keystrokes
625941d497e22403b379d190
def get_calendar_format_type(self): <NEW_LINE> <INDENT> return
Gets the calendar format ``Type``. :return: the calendar format type :rtype: ``osid.type.Type`` *compliance: mandatory -- This method must be implemented.*
625941d494891a1f4081bca0
def fit(self, X, y=None): <NEW_LINE> <INDENT> return self
All scikit-lear compatible transforms and classifiers have the same interface, and fit always returns the same object.
625941d429b78933be1e589f
def extract_info(File_path): <NEW_LINE> <INDENT> if '.xls' in File_path: <NEW_LINE> <INDENT> wb = pyxl.load_workbook(File_path, read_only=True, data_only=True) <NEW_LINE> if 'Command' in wb.get_sheet_names(): <NEW_LINE> <INDENT> settings = _openpylx_sinton2014_extractsserdata(wb) <NEW_LINE> <DEDENT> else: <NEW_LINE> <I...
This grabs the calculated data from sinton Extracts columns A-G of the raw data page. Can't extract columns H-I as it is not complete data and this would take some more work This outputs the data as a structured array, with the names as the column
625941d4099cdd3c635f0e50
def __init__(self, _from=None): <NEW_LINE> <INDENT> self.__from = _from
V1DeploymentCauseImageTrigger - a model defined in Swagger
625941d4eab8aa0e5d26dd4e
def _render_movie(movie): <NEW_LINE> <INDENT> rendered_movie = _get_movie_template().format( title = movie.title, year = movie.year, director = movie.director, length = movie.length, genre = movie.genre, excerpt = movie.excerpt, cast = movie.cast_string, youtube_trailer = movie.youtube_trailer, rendered_rate = _render_...
Render the movie object into an HTML string. Args: movie (Movie): A movie object. Returns: HTML string repersents the passed movie object.
625941d4f9cc0f698b1407f0
def new_transactions(transactions_db, transactions): <NEW_LINE> <INDENT> a_len = len(transactions_db) <NEW_LINE> b = transactions[::-1] <NEW_LINE> for i in range(a_len): <NEW_LINE> <INDENT> if transactions_db[i:] == b[:a_len-i]: <NEW_LINE> <INDENT> return b[a_len-i:] <NEW_LINE> <DEDENT> <DEDENT> return b
Find a list of new transactions. Finds the sequence that's present in transactions and in transactions_db Args: transactions_db (list): All previous transactions saved. transactions (list): The ten most recent transactions scraped. Returns: b (list): The new transactions sequence.
625941d4f8510a7c17cf98f2
def __init__(self,duration): <NEW_LINE> <INDENT> self.duration = duration
the StandStillCondition class is an Entity Condition used by the EntityTrigger Parameters ---------- duration (float): time of standstill
625941d4462c4b4f79d1d8c6
def p_c(p): <NEW_LINE> <INDENT> pass
c : empty | "," b
625941d4627d3e7fe0d69047
def signup(request): <NEW_LINE> <INDENT> if request.method=="POST": <NEW_LINE> <INDENT> if request.user.is_authenticated: <NEW_LINE> <INDENT> return render(request, "noteapp/index.html", {"message":None}) <NEW_LINE> <DEDENT> username = request.POST["username"] <NEW_LINE> password = request.POST["password"] <NEW_LINE> e...
Authenticate the signup process and return home page
625941d41b99ca400220aca8
def post(self): <NEW_LINE> <INDENT> err_msgs = self.parse_new_user_post() <NEW_LINE> try: <NEW_LINE> <INDENT> user_created = self.process_new_user_post(err_msgs) <NEW_LINE> continue_url = self.request.get('continue') <NEW_LINE> if user_created and continue_url: <NEW_LINE> <INDENT> self.redirect(str(continue_url), self....
Handler for POST requests.
625941d44f88993c3716c25d
def GrantPermission(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!')
Grants a permission to the specified SQL Server user.
625941d4a8370b7717052a95
def get_key_value(self, section, key): <NEW_LINE> <INDENT> return self.ini[section][key].strip()
Get the list of sections defined in the ini file
625941d4be7bc26dc91cd7f4
def delete_confirm(self, request): <NEW_LINE> <INDENT> query = request.GET <NEW_LINE> path = u'%s' % os.path.join(self.directory, query.get('dir', '')) <NEW_LINE> fileobject = FileObject(os.path.join(path, query.get('filename', '')), site=self) <NEW_LINE> if fileobject.filetype == "Folder": <NEW_LINE> <INDENT> filelist...
Delete existing File/Directory.
625941d456b00c62f0f14850
def read(filename): <NEW_LINE> <INDENT> return open(os.path.join(os.path.dirname(__file__), filename)).read()
Utility function to read the README file, used for the long_description. It's nice, because now 1) we have a top level README file and 2) it's easier to type in the README file than to put a raw string in below. :param filename: The name of the file to read from. :return: The contents of the file.
625941d49b70327d1c4e0fcb
def _get_cloudformation_parameters_for_db(self): <NEW_LINE> <INDENT> json_parameter_list = [] <NEW_LINE> cf_parameter_prefixes = ["ExperimentDb", "ModelDb", "JoinDb"] <NEW_LINE> for parameter_prefix in cf_parameter_prefixes: <NEW_LINE> <INDENT> json_params = [ { "ParameterKey": parameter_prefix + "Name", "ParameterValu...
Return config values for each ddb table Returns: list: A list json blobs containing config values for each ddb table
625941d4f7d966606f6aa1fc
def size(self): <NEW_LINE> <INDENT> return len(self._adjacency_list)
Graph method that returns the total number of nodes in the graph Args: None In: None Out: integer
625941d4b7558d58953c5108
def _write_config(config, newlines=2): <NEW_LINE> <INDENT> text = config <NEW_LINE> if isinstance(config, dict) and len(list(list(config.keys()))) == 1: <NEW_LINE> <INDENT> key = next(six.iterkeys(config)) <NEW_LINE> text = config[key] <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> with salt.utils.fopen(__SYSLOG_NG_CONFI...
Writes the given parameter config into the config file.
625941d463f4b57ef000130c
def _InitializeLog2TimelinePath(self): <NEW_LINE> <INDENT> self._log2timeline_path = os.path.join(self._tools_path, 'log2timeline.py')
Initializes the location of log2timeline.
625941d46e29344779a62807
def get_by_service(self, service_id): <NEW_LINE> <INDENT> return self.driver.get_by_service(service_id)
Returns Endpoint Templates by service
625941d4e8904600ed9f2125
def process_echo_filter(procstatus, dscfg, radar_list=None): <NEW_LINE> <INDENT> if procstatus != 1: <NEW_LINE> <INDENT> return None, None <NEW_LINE> <DEDENT> echoid_field = None <NEW_LINE> for datatypedescr in dscfg['datatype']: <NEW_LINE> <INDENT> radarnr, _, datatype, _, _ = get_datatype_fields(datatypedescr) <NEW_L...
Masks all echo types that are not of the class specified in keyword echo_type Parameters ---------- procstatus : int Processing status: 0 initializing, 1 processing volume, 2 post-processing dscfg : dictionary of dictionaries data set configuration. Accepted Configuration Keywords:: datatype : list of...
625941d4046cf37aa974cf3d
def __init__(self, path=None, clear_temp=None): <NEW_LINE> <INDENT> AObject.__init__(self, path=path); <NEW_LINE> self.initWithPath(path=path, clear_temp=clear_temp);
If you provide a directory, it will look for a existing AFileManager.json in that directory, or create one if it does not already exist. If you provide a json, it will use that json, unless the json doesn't exist, in which case it will complain...
625941d4fb3f5b602dac388b
def precision_and_recall(output, target, tp=0, fp=0, tn=0, fn=0): <NEW_LINE> <INDENT> tp += torch.sum((output > 0) & (target > 0.5)) <NEW_LINE> fp += torch.sum((output > 0) & (target <= 0.5)) <NEW_LINE> tn += torch.sum((output <= 0) & (target <= 0.5)) <NEW_LINE> fn += torch.sum((output <= 0) & (target > 0.5)) <NEW_LINE...
Compute precision and recall.
625941d47047854f462a15fe
def itervalues(self): <NEW_LINE> <INDENT> for k in self.iterkeys(): <NEW_LINE> <INDENT> yield self[k]
Include default values.
625941d450485f2cf553cf91
@login_required <NEW_LINE> @log_func <NEW_LINE> def AssignVolunteerView(request, volunteer_id): <NEW_LINE> <INDENT> reviewer = validate_perms(request, ('Volunteer Coordinator',)) <NEW_LINE> if int(volunteer_id) == 0 and request.method == 'POST': <NEW_LINE> <INDENT> volunteer_id = int(request.POST['volunteer']) <NEW_LIN...
Show a bid which needs to be assigned to shifts by the coordinator. To show: display useful information about the bid, If user is not a coordinator, politely decline to show anything.
625941d4cb5e8a47e48b7c9f
def categorised(context, original): <NEW_LINE> <INDENT> return categorised_by_key_fn(context, original, lambda row: row['category'], label="categorised")
Really meant for use on periodic summaries.
625941d43539df3088e2e541
def unsubscribe(self, subscription_arn): <NEW_LINE> <INDENT> t = datetime.datetime.utcnow() <NEW_LINE> amzdate = t.strftime('%Y%m%dT%H%M%SZ') <NEW_LINE> subscription_arn = urllib.parse.quote(subscription_arn) <NEW_LINE> canonical_querystring = 'AWSAccessKeyId={}' '&Action=Unsubscribe' ...
Method for unsubscribing to the specified topic. :param access_key: Provided by amazon for that account :param secret_key: Provided by amazon for that account :param end_point: The user's phone number in the for 15803010000 :param topicArn: The Arn for the topic to unsubscribe from :return: True if successful error cod...
625941d4f548e778e58cd775
def getVDF(TRAIN_CSV): <NEW_LINE> <INDENT> dataframe = pd.read_excel(TRAIN_CSV, sep=",",error_bad_lines=False,header= 0, encoding = "Latin1") <NEW_LINE> dataframe = dataframe.drop(axis=1,columns=['Commit URL', 'Sha','URL','Author Name','Author Email','Commit Date','Verification','Author Date']) <NEW_LINE> dataframe = ...
Get data from the training sample CSV and perform various cleaning and data preprocessing
625941d44f6381625f114c32
def test_apply_operator(self): <NEW_LINE> <INDENT> vec = numpy.array([1, 2, 3, 4]) <NEW_LINE> matvec_expected = numpy.array([2, 1, 4, 3]) <NEW_LINE> self.assertTrue( numpy.allclose( apply_operator((LinearQubitOperator(QubitOperator('X1')), vec)), matvec_expected))
Tests apply_operator() since it's executed on other processors.
625941d4293b9510aa2c348b
@app.route('/api/v2/add_show', methods=['POST']) <NEW_LINE> @auth.login_required <NEW_LINE> def add_show(): <NEW_LINE> <INDENT> show_id = postgres.create_show(request.get_json()['show_name']) <NEW_LINE> if not show_id: <NEW_LINE> <INDENT> message = {"message": "Something went wrong adding your show"} <NEW_LINE> return ...
Add a show to the database
625941d455399d3f055888ab
def get_updated_strings_block(): <NEW_LINE> <INDENT> util.chdir_repo(commcare_android_repo) <NEW_LINE> subprocess.call('git checkout master', shell=True) <NEW_LINE> os.chdir(ccodk_strings_subfolder) <NEW_LINE> tree = ET.parse(ccodk_strings_filename) <NEW_LINE> resources = tree.getroot() <NEW_LINE> string_list = [] <NEW...
Return a string containing the updated text that should go into the master hq translations file from the strings.xml file in the mobile codebase. Because it is an xml file instead of a plain text file, the extraction needs to be done in a different way from all of the other files
625941d46e29344779a62808
def initMenu(self, mainMenu): <NEW_LINE> <INDENT> menu = QMenu(self.menuTitle(), mainMenu) <NEW_LINE> menu.setIcon(UI.PixmapCache.getIcon("vcsRebase.png")) <NEW_LINE> menu.setTearOffEnabled(True) <NEW_LINE> menu.addAction(self.hgRebaseAct) <NEW_LINE> menu.addAction(self.hgRebaseContinueAct) <NEW_LINE> menu.addAction(se...
Public method to generate the extension menu. @param mainMenu reference to the main menu (QMenu) @return populated menu (QMenu)
625941d4435de62698dfde44
def save_to_file(lst): <NEW_LINE> <INDENT> credit, GPA = 0, 0 <NEW_LINE> for ls in lst[1:]: <NEW_LINE> <INDENT> credit += eval(ls[7]) <NEW_LINE> GPA += eval(ls[7])*eval(ls[9]) <NEW_LINE> <DEDENT> lst.append('GPA={:.2f}'.format(GPA/credit)) <NEW_LINE> with open('score.csv', 'w') as csvfile: <NEW_LINE> <INDENT> csv.write...
计算GPA,将提取到的内容保存到csv文件中
625941d45fcc89381b1e18b7
def TestIamPermissions(self, request, global_params=None): <NEW_LINE> <INDENT> config = self.GetMethodConfig('TestIamPermissions') <NEW_LINE> return self._RunMethod( config, request, global_params=global_params)
Tests the specified permissions against the IAM access control policy. for the specified IAM resource. Args: request: (IamProjectsServiceAccountsTestIamPermissionsRequest) input message global_params: (StandardQueryParameters, default: None) global arguments Returns: (TestIamPermiss...
625941d45166f23b2e1a5350
def bottleneck_block(inputs, filters, strides, training, projection_shortcut, data_format): <NEW_LINE> <INDENT> shortcut = inputs <NEW_LINE> if projection_shortcut is not None: <NEW_LINE> <INDENT> shortcut = projection_shortcut(inputs) <NEW_LINE> <DEDENT> inputs = padded_conv2d( inputs=inputs, kernel_size=1, filters=fi...
3-layer bottleneck residual block with batch normalization and relu after convolution layer. :param inputs: Input images :param filters: number of filters :param strides: strides of convolutions :param training: a flag to indicate whether during training or not :param projection_shortcut: a function if projection is ne...
625941d46aa9bd52df036f9b
def get_limit_offset_data(obj): <NEW_LINE> <INDENT> offset = request.args.to_dict().get('offset', 0) <NEW_LINE> limit = request.args.to_dict().get('limit', current_app.config['MAX_PER_PAGE']) <NEW_LINE> if int(limit) > current_app.config['MAX_PER_PAGE']: <NEW_LINE> <INDENT> limit = current_app.config['MAX_PER_PAGE'] <N...
获取分页数据,使用limit和offset obj: 数据模型
625941d43c8af77a43ae3998
def set_passwords(console, root=DEFAULT_ROOT_PW, admin='a'): <NEW_LINE> <INDENT> console.send_keys(root) <NEW_LINE> console.send_keys(root) <NEW_LINE> console.send_keys(admin) <NEW_LINE> console.send_keys(admin) <NEW_LINE> time.sleep(SECTION_PROCESS_PAUSE)
Set the root and admin user passwords
625941d4d268445f265b5065
def get(self): <NEW_LINE> <INDENT> stats = {} <NEW_LINE> if self.start_date is not None: <NEW_LINE> <INDENT> stats["start_date"] = self.start_date <NEW_LINE> <DEDENT> if self.end_date is not None: <NEW_LINE> <INDENT> stats["end_date"] = self.end_date <NEW_LINE> <DEDENT> if self.aggregated_by is not None: <NEW_LINE> <IN...
:return: response stats dict
625941d4f7d966606f6aa1fd
def get_project_list(self) : <NEW_LINE> <INDENT> project_list = self.DBManager.get_from_cache(Project, fresh_only=False, must_be_unique=False) <NEW_LINE> if project_list == None : <NEW_LINE> <INDENT> project_list = [] <NEW_LINE> <DEDENT> return project_list
return list of ProjectObjects
625941d4fff4ab517eb2f633
def makepage(directory=DATADIR, output=None, level=None): <NEW_LINE> <INDENT> logging.debug('running `makepage` on %s' % directory) <NEW_LINE> output, level = output if output else [], level if level else [] <NEW_LINE> pushdir(level, directory) <NEW_LINE> posts = specialsort(os.listdir('.')) <NEW_LINE> logging.debug('p...
Scan folders and files to build the Kybyz page
625941d4a219f33f34628b5e
def write_hrtc_glasgow_hrtc_nocolon(instance, filename): <NEW_LINE> <INDENT> write_hrtc_glasgow_hrtc(instance, filename, False)
Writes an Instance to a file in the Glasgow HRTC, without colons.
625941d499fddb7c1c9de588
def receive(event, context): <NEW_LINE> <INDENT> if not is_request_valid(event): <NEW_LINE> <INDENT> logging.error("Authentication Failed") <NEW_LINE> return response({"message": "Authentication Failed"}, 401) <NEW_LINE> <DEDENT> if 'headers' not in event or 'X-GitHub-Event' not in event['headers']: <NEW_LINE> <INDENT>...
Handler for events sent via GitHub webhook
625941d430dc7b7665901b5c
def deprecate_dataset_version( dataset_version_id: str, reason: str ) -> DatasetVersion.DatasetVersionState: <NEW_LINE> <INDENT> dataset_version = get_dataset_version(dataset_version_id=dataset_version_id) <NEW_LINE> if dataset_version.state == DatasetVersion.DatasetVersionState.deleted: <NEW_LINE> <INDENT> deprecate_d...
Change the current state of a DatasetVersion to deprecate (see DatasetVersionState) :param dataset_version_id: ID of the dataset version to deprecate :param reason: Reason for deprecating a dataset :return: The new DatasetVersionState (should be deprecated)
625941d4ff9c53063f47c3ea
def test_query_highlight_boolean_one_field(self): <NEW_LINE> <INDENT> id = get_rand_string() <NEW_LINE> user_id = data = get_rand_string() <NEW_LINE> self.add(id=id, user_id=user_id, data=data) <NEW_LINE> self.conn.commit() <NEW_LINE> response = self.query( self.conn, "id:" + id, highlight=True, fields="id") <NEW_LINE>...
Test whether highlighting works for one field when given a highlight=True parameter.
625941d4566aa707497f475d
@pytest.fixture <NEW_LINE> def fixstr(): <NEW_LINE> <INDENT> def load(testset, filename): <NEW_LINE> <INDENT> return resource_string(__name__, 'fixtures/{}/{}'.format( testset, filename)).decode('ascii') <NEW_LINE> <DEDENT> return load
Loads generic fixture as string.
625941d43539df3088e2e542
def process_task_queues(queue_name=None): <NEW_LINE> <INDENT> stub = apiproxy_stub_map.apiproxy.GetStub("taskqueue") <NEW_LINE> tasks = _get_queued_tasks(stub, queue_name) <NEW_LINE> client = Client() <NEW_LINE> while tasks: <NEW_LINE> <INDENT> task = tasks.pop(0) <NEW_LINE> decoded_body = task['body'].decode('base64')...
Processes any queued tasks inline without a server. This is useful for end-to-end testing background tasks.
625941d4cc40096d61595b47
def send_turn_on_script_to_cluster_node(node, script_filename): <NEW_LINE> <INDENT> transport = Transport((node['IP'], 22)) <NEW_LINE> transport.connect(username=node['username'], password=node['username']) <NEW_LINE> sftp = SFTPClient.from_transport(transport) <NEW_LINE> src_sricpt_filepath = SRC_SCRIPT_FOLDER + 'node...
Send start up script to cluster node. This script generated for each cluster node specially. The generation algorithm depends on mapping of simulated topology on cluster topology. Args: node_IP: IP address of cluster node. script_filename: Name of script file. File on Cluster Manager machine and on cluster no...
625941d4498bea3a759b9ca6
def load_mnist(normalize=True, flatten=True, one_hot_label=False): <NEW_LINE> <INDENT> if not os.path.exists(save_file): <NEW_LINE> <INDENT> init_mnist() <NEW_LINE> <DEDENT> with open(save_file, 'rb') as f: <NEW_LINE> <INDENT> dataset = pickle.load(f) <NEW_LINE> <DEDENT> if normalize: <NEW_LINE> <INDENT> for key in ('t...
MNISTデータセットの読み込み Parameters ---------- normalize : 画像のピクセル値を0.0~1.0に正規化する one_hot_label : one_hot_labelがTrueの場合、ラベルはone-hot配列として返す one-hot配列とは、たとえば[0,0,1,0,0,0,0,0,0,0]のような配列 flatten : 画像を一次元配列に平にするかどうか Returns ------- (訓練画像, 訓練ラベル), (テスト画像, テストラベル)
625941d4fbf16365ca6f63bc
def data_handling(data): <NEW_LINE> <INDENT> data['BHATNAGAR SANJAY']['total_stock_value'] = data['BHATNAGAR SANJAY']['restricted_stock_deferred'] <NEW_LINE> data['BHATNAGAR SANJAY']['restricted_stock_deferred'] = data['BHATNAGAR SANJAY']['restricted_stock'] <NEW_LINE> data['BHATNAGAR SANJAY']['restricted_stock'] = dat...
Responsavel pela correcao das informacoes no conjunto de dados da Enron. :param data: Dicionario de dados para correcao :return: Dados com dados corrigidos
625941d4656771135c3eba67
def parser(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser() <NEW_LINE> parser.description = "Config generator" <NEW_LINE> parser.add_argument("-o", "--stdout", action='store_true', help="write result in stdout") <NEW_LINE> parser.add_argument("--noheader", action='store_true', help="do not write header informa...
Create parser class to check input arguments
625941d4e8904600ed9f2126
def rcpt_to(self, rcpt_list): <NEW_LINE> <INDENT> answer = {} <NEW_LINE> for mail in rcpt_list: <NEW_LINE> <INDENT> cmd = b'rcpt to:' +mail.encode() <NEW_LINE> self.socket.send(cmd) <NEW_LINE> answer[mail] = self.socket.recieve_singleline() <NEW_LINE> <DEDENT> return answer
rcpt to command as defined in rfc821 returns: bytes retruned by server
625941d491af0d3eaac9bc11
def show_img_and_wait_close(window_name, img): <NEW_LINE> <INDENT> cv2.imshow(window_name, img) <NEW_LINE> cv2.waitKey(0)
Display an image and wait that the user close it :param window_name: window's name :type window_name: str :param img: Image :type img: numpy.array :return: None :rtype: None
625941d476d4e153a657ed29
def close(self): <NEW_LINE> <INDENT> pass
Override in your subclass to perform any necessary cleanup. Environments will automatically close() themselves when garbage collected or when the program exits.
625941d415fb5d323cde0d09
def test_symbol_01_symbolpatch(self): <NEW_LINE> <INDENT> class MySymbol(Symbol): <NEW_LINE> <INDENT> def show_name(self): <NEW_LINE> <INDENT> return "cool " + self.name <NEW_LINE> <DEDENT> def internal_name(self): <NEW_LINE> <INDENT> return "tjrs " <NEW_LINE> <DEDENT> <DEDENT> class MyFun(MySymbol, Fun): <NEW_LINE> <I...
Test of symbol mangling redefinition. For custom language due to method order resolution (python MRO) in multi-inheritance, just use follow the good order. Overloads first.
625941d4c4546d3d9de72c2c
def init_iron_mq(): <NEW_LINE> <INDENT> return IronMQ(host=settings.MQ_HOST, project_id=settings.MQ_PROJECT_ID, token=settings.MQ_TOKEN)
Initiate the Iron MQ, which is the message queue service of Heroku
625941d4be7bc26dc91cd7f5
def enqueueNeighbors(self, row, column): <NEW_LINE> <INDENT> directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] <NEW_LINE> for direction in directions: <NEW_LINE> <INDENT> if self.__isCellInside(row + direction[0], column + direction[1]) == True and self.__computerRepository.isCellUnknown(row + direction[0], column + dire...
This function pushes into the computer moves queue the neighbors of the specified cell :param row: the row of the cell :param column: the column of the cell :return: nothing
625941d4e64d504609d74a37
def gleu_compare(self ,t ,o): <NEW_LINE> <INDENT> o_gleu = self.ngrams(o) <NEW_LINE> t_gleu = self.ngrams(t) <NEW_LINE> t_len = len(t_gleu) <NEW_LINE> o_len = len(o_gleu) <NEW_LINE> if not t_len or not o_len: <NEW_LINE> <INDENT> return 0.0 <NEW_LINE> <DEDENT> common_length = len(o_gleu & t_gleu) <NEW_LINE> return min(c...
返回两个句子的gleu @paras o:原句子 @paras t:对比的句字 @return :gleu值
625941d426068e7796caeed8
def make_download_segmentation_tasks(self): <NEW_LINE> <INDENT> rh_logger.logger.report_event("Making tasks to fetch segmentation gt") <NEW_LINE> self.seg_butterfly_tasks = np.zeros( (self.n_z, self.n_y, self.n_x), object) <NEW_LINE> for zi in range(self.n_z): <NEW_LINE> <INDENT> z0, z1 = self.zs[zi], self.zs[zi+1] <NE...
Make the tasks that download neuron segmentations from bfly
625941d4796e427e537b07be
def ProbeInto(func): <NEW_LINE> <INDENT> return Probe(func=func)
ProbeInto looks inside the context and extracts a part of it using a lambda instead of printing the entire context. Example:: >>> st = "junk"/RepeatUntil(obj_ == 0,Byte) + "num"/Byte + Probe() >>> st.parse(b"xcnzxmbjskahuiwerhquiehnsdjk\x00\xff") ===========================================================...
625941d43cc13d1c6d3c7571
def __eq__(self, other): <NEW_LINE> <INDENT> return self.x == other.x and self.y == other.y
Two points are equal if they have the same coordinates.
625941d4d58c6744b4257e56
def test_finance_accounts_index_out(self): <NEW_LINE> <INDENT> response = self.client.get(reverse('finance_index_accounts')) <NEW_LINE> self.assertRedirects(response, reverse('user_login'))
Testing /finance/accounts/
625941d491af0d3eaac9bc12
def updateStamp(self, depVersions, stamp): <NEW_LINE> <INDENT> temp = self.newVersion() <NEW_LINE> try: <NEW_LINE> <INDENT> self.build(depVersions, temp) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> self.rollbackVersion(temp) <NEW_LINE> raise <NEW_LINE> <DEDENT> self.commitVersion(temp, stamp)
Regenerate a single stamp from the original, using the provided dependency versions
625941d47cff6e4e81117b7d
def generatePiece(probs): <NEW_LINE> <INDENT> total = sum(probs.values()) <NEW_LINE> if total <= 0: <NEW_LINE> <INDENT> raise ValueError('sum of weights must be > 0') <NEW_LINE> <DEDENT> r = random.random() <NEW_LINE> for c in 'jiltso': <NEW_LINE> <INDENT> r -= probs.get(c, 0) / total <NEW_LINE> if r < 0: <NEW_LINE> <I...
generate a random piece from the weights given: probs = {"j": <float>, "i": <float>, ...}. missing weights are taken to be 0. at least one non-zero weight must be given.
625941d4097d151d1a223050
def __init__(self, brd, top=None, path='yosys/'): <NEW_LINE> <INDENT> super(Yosys, self).__init__(brd, top=top, path=path) <NEW_LINE> self.sdc_file = '' <NEW_LINE> self._core_file_list = set() <NEW_LINE> self._default_project_file = None
use yosys synthesis (mainly for testing) This toolflow creates more than the actual tool supports. This is done for automated testing. Many of the vendor FPGA tools are not convienently installable on the CI environments.
625941d4a219f33f34628b5f
def test_markets_quotes_post(self): <NEW_LINE> <INDENT> pass
Test case for markets_quotes_post
625941d4c432627299f04e3f
def _make_stream_binary(stream): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> fileno = stream.fileno() <NEW_LINE> <DEDENT> except _UnsupportedOperation: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> _make_binary_on_windows(fileno) <NEW_LINE> <DEDENT> return _unwrap_text(stream)
Ensure that a stream will be binary safe. See _make_binary_on_windows. :return: A binary version of the same stream (some streams cannot be 'fixed' but can be unwrapped).
625941d43eb6a72ae02ec6d8