code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def chooseRandomWord(freqDict,weighted=False): <NEW_LINE> <INDENT> list = [] <NEW_LINE> if weighted: <NEW_LINE> <INDENT> for key in freqDict: <NEW_LINE> <INDENT> list.append((freqDict[key],key)) <NEW_LINE> <DEDENT> total = sum(pair[0] for pair in list) <NEW_LINE> r = random.randint(1, total) <NEW_LINE> for (count, word...
Choose a weighted random word from a dictionary of words and word counts Keyword arguments: freqDict -- Dictionary of words mapped to their frequencies weighted -- whether to use weights to generate a random word
625941ec8e71fb1e9831dcbc
def set_AppSecret(self, value): <NEW_LINE> <INDENT> super(ZipFolderInputSet, self)._set_input('AppSecret', value)
Set the value of the AppSecret input for this Choreo. ((required, string) The App Secret provided by Dropbox (AKA the OAuth Consumer Secret).)
625941ec5fcc89381b1e1bd8
def schedule_create_volume(self, context, request_spec, filter_properties): <NEW_LINE> <INDENT> elevated = context.elevated() <NEW_LINE> volume_id = request_spec.get('volume_id') <NEW_LINE> snapshot_id = request_spec.get('snapshot_id') <NEW_LINE> image_id = request_spec.get('image_id') <NEW_LINE> volume_properties = re...
Picks a host that is up and has the fewest volumes.
625941ec26068e7796caf1fc
def poll(self, timeout=None): <NEW_LINE> <INDENT> return list(self._poll(timeout))
Wait for sockets to become ready. Wait for up to timeout seconds for registered sockets to be ready and return a list of 3-tuples (socket, event, callback) or an empty list if no sockets are ready within the timeout period.
625941eccad5886f8bd274ed
def single_LLDs(file_path): <NEW_LINE> <INDENT> df = load_features_opensmile(file_path) <NEW_LINE> array = df.values <NEW_LINE> return array
载入一个时序特征文件,返回一个numpy array
625941ec656771135c3ebd8a
def ssh_config(host_string=None): <NEW_LINE> <INDENT> from fabric.state import env <NEW_LINE> dummy = {} <NEW_LINE> if not env.use_ssh_config: <NEW_LINE> <INDENT> return dummy <NEW_LINE> <DEDENT> if '_ssh_config' not in env: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> conf = ssh.SSHConfig() <NEW_LINE> path = os.path.e...
Return ssh configuration dict for current env.host_string host value. Memoizes the loaded SSH config file, but not the specific per-host results. This function performs the necessary "is SSH config enabled?" checks and will simply return an empty dict if not. If SSH config *is* enabled and the value of env.ssh_config...
625941ec6aa9bd52df0372bd
def _read_channel(self, channel, stdout, stderr): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> stdout_data = None <NEW_LINE> stderr_data = None <NEW_LINE> if channel.recv_ready(): <NEW_LINE> <INDENT> stdout_data = channel.recv(CHUNK_SIZE) <NEW_LINE> stdout.write(stdout_data) <NEW_LINE> <DEDENT> if channel.recv_s...
Read the channels stdout and stderr until there is no more data
625941ecc432627299f0515f
def login(): <NEW_LINE> <INDENT> Log.info("用户登录") <NEW_LINE> time.sleep(.1) <NEW_LINE> while True: <NEW_LINE> <INDENT> username = input("请输入帐号:").strip() <NEW_LINE> while not username: <NEW_LINE> <INDENT> username = input("帐号不能把为空,请重新输入:").strip() <NEW_LINE> <DEDENT> password = input("请输入密码:").strip() <NEW_LINE> while ...
用户登录方法 :return: bool
625941ec004d5f362079a845
def list_models(self, group, name_pattern=None, predicate=None): <NEW_LINE> <INDENT> raise NotImplementedError
Lists models within given group, filters results by given name pattern on predicate on attributes. Non-recursive. Pattern syntax - "%" symbol means "any number of characters "?" symbol means "one charanter" other symbols match as is. :type group: typing.Optional[Group] :type name_patt...
625941ec07d97122c4178dad
def add_arguments(self, parser): <NEW_LINE> <INDENT> parser.add_argument( 'rating', type=rating_value) <NEW_LINE> return parser
Song rating gets single parameter `rating`
625941ec85dfad0860c3b372
def Logout(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.
625941ec8a349b6b435e8688
def __add_place_clicked(self, obj): <NEW_LINE> <INDENT> skip_list = set() <NEW_LINE> i = self.__model.get_iter_first() <NEW_LINE> while (i): <NEW_LINE> <INDENT> gid = self.__model.get_value(i, 1) <NEW_LINE> place = self.__db.get_place_from_gramps_id(gid) <NEW_LINE> skip_list.add(place.get_handle()) <NEW_LINE> i = self....
Handle the add place button.
625941ec4a966d76dd55152a
def hasPathSum(self, root, sum): <NEW_LINE> <INDENT> import collections <NEW_LINE> if not root: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> q = collections.deque([]) <NEW_LINE> q.append((root, root.val)) <NEW_LINE> while q: <NEW_LINE> <INDENT> cur, s = q.popleft() <NEW_LINE> if not cur.left and not cur.right a...
:type root: TreeNode :type sum: int :rtype: bool
625941ec96565a6dacc8fbdf
@node.route('/blockchain.json', methods=['GET']) <NEW_LINE> def blockchain(): <NEW_LINE> <INDENT> node_blocks = sync.sync() <NEW_LINE> python_blocks = [] <NEW_LINE> for block in node_blocks: <NEW_LINE> <INDENT> python_blocks.append(block.__dict__()) <NEW_LINE> <DEDENT> json_blocks = json.dumps(python_blocks) <NEW_LINE>...
Shoots back the blockchain, which in our case, is a json list of hashes with the block information which is: index, timestamp, data, hash, prev_hash
625941ec187af65679ca5635
def run_preprocessor(): <NEW_LINE> <INDENT> EXTENSION = ".pre" <NEW_LINE> for py_processor_file in find_extension_files(SCRIPT_DIR, EXTENSION): <NEW_LINE> <INDENT> output_file = py_processor_file[:-len(EXTENSION)] <NEW_LINE> if not exists(output_file) or getmtime(py_processor_file) > getmtime(output_file...
Generate python files using a file prepocessor (essentially macros that generate multiple versions of the code for each dtype supported by a Dali operation)
625941eca79ad161976cc65b
def invoke_add_remove_commands(command_function, file, prefix): <NEW_LINE> <INDENT> lines = read_lines(file) <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> if check_prefix(prefix, line): <NEW_LINE> <INDENT> line = remove_line_feed(line) <NEW_LINE> args = parse_add_remove(line) <NEW_LINE> command_function(*args)
Invokes cli's add/remove command for conf files
625941ec8c3a8732951588d6
def test_missing_assignment(self, gradebook): <NEW_LINE> <INDENT> self._copy_file("files/submitted-changed.ipynb", "source/ps1/p1.ipynb") <NEW_LINE> run_command('nbgrader assign ps1 --db="{}" '.format(gradebook)) <NEW_LINE> self._copy_file("files/submitted-changed.ipynb", "submitted/ps2/foo/p1.ipynb") <NEW_LINE> run_co...
Is an error thrown when the assignment is missing?
625941ec50812a4eaa59c832
def check_for_kills(self): <NEW_LINE> <INDENT> for i, combatant in enumerate(self.combatants): <NEW_LINE> <INDENT> if (combatant and (combatant.stats.hp <= 0 or combatant.stats.stam <= 0)): <NEW_LINE> <INDENT> self.combatants[i] = None
Check if any combatants have HP or stamina <= 0 and remove them. Sets Combatants that have been killed to None so that they can be removed later.
625941ecbf627c535bc136e5
@pytest.fixture(name="auth_error") <NEW_LINE> def mock_api_authentication_error(): <NEW_LINE> <INDENT> with patch( "transmissionrpc.Client", side_effect=TransmissionError("401: Unauthorized") ): <NEW_LINE> <INDENT> yield
Mock an api.
625941ec99fddb7c1c9de8a4
def _record_request(self): <NEW_LINE> <INDENT> ctx = self.server.context <NEW_LINE> res = {} <NEW_LINE> res['method'] = self.command <NEW_LINE> res['path'] = self.path <NEW_LINE> res['headers'] = self.headers.items() <NEW_LINE> res['request_version'] = self.request_version <NEW_LINE> if self.headers.get('Content-Length...
Store all the relevant data of the request into the endpoint context.
625941ec0fa83653e46574cd
def compile_rules(raw_rules): <NEW_LINE> <INDENT> return [Rule(description=dsc, match=partial(match[0], *match[1:]), constraint=partial(constr[0], *constr[1:])) for (dsc, match, constr) in raw_rules]
compile validation rules in particular, turn matches and constraints into boolean predicates over entries (i.e., functions: Entry -> bool)
625941ecfb3f5b602dac3bae
def make_model_full(train_input, num_classes, weights_file=None): <NEW_LINE> <INDENT> model = Sequential() <NEW_LINE> if isinstance(train_input, tf.Tensor): <NEW_LINE> <INDENT> model.add(KL.InputLayer(input_tensor=train_input)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> model.add(KL.InputLayer(input_shape=train_inpu...
Return Cifar10 DL model with many layers. :param train_input: Either a tf.Tensor input placeholder/pipeline, or a tuple input shape.
625941ecfbf16365ca6f66e4
def _restore_mirrored(self, save_path): <NEW_LINE> <INDENT> with self.test_session(graph=ops.Graph()) as sess: <NEW_LINE> <INDENT> v, devices, mirrored = _make_mirrored() <NEW_LINE> self._assign_mirrored(devices, v, [7., 8.]) <NEW_LINE> saver = saver_lib.Saver(var_list=[mirrored]) <NEW_LINE> saver.restore(sess, save_pa...
Restore to variables with mirroring in a fresh graph.
625941eca17c0f6771cbe565
def fit_linear_model(self): <NEW_LINE> <INDENT> if self.data is not None: <NEW_LINE> <INDENT> data = self.data <NEW_LINE> model = models.LinearModel() <NEW_LINE> fit = model.fit(data.y, x=data.x, weights=1 / data.yerr) <NEW_LINE> self.text.setPlainText(fit.fit_report()) <NEW_LINE> x = np.linspace(data.x.min(), data.x.m...
Fit a linear model to the data.
625941ec3d592f4c4ed1d575
def saveOutputAndErrors(context, command, output, errors): <NEW_LINE> <INDENT> annot = IAnnotations(context) <NEW_LINE> now = datetime.now().strftime('%d/%m/%Y %H:%M:%S') <NEW_LINE> try: <NEW_LINE> <INDENT> cmd = command[0] <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> cmd = u'COMMAND?' <NEW_LINE> <DEDENT> ...
Save in annotations **``command``_OUTPUT** and **``command``_ERRORS** in a given context. ``output`` and ``errors`` come from the result of a ``subprocess.Popen`` method. :param context: any plone object :type context: object :param command: the command name used in ``Popen`` method :type command: string :param outpu...
625941ec66673b3332b925a7
def test_homepage_release(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.broswer.find_element_by_xpath('/html/body/div/ng-include[2]/aside/nav[2]/ul/li[1]/a').click() <NEW_LINE> sleep(2) <NEW_LINE> self.broswer.find_element_by_xpath('/html/body/div/div/div/div[1]/div[1]/div/div[3]').click() <NEW_LINE> sleep(2...
'点击首页中的今日生产稿件的查看,进入对应界面
625941ec30c21e258bdfa9b9
def canonical_order_atoms(self, molecule): <NEW_LINE> <INDENT> from rdkit import Chem <NEW_LINE> rdmol = self.to_rdkit(molecule) <NEW_LINE> atom_order = list(Chem.CanonicalRankAtoms(rdmol, breakTies=True)) <NEW_LINE> heavy_atoms = rdmol.GetNumHeavyAtoms() <NEW_LINE> hydrogens = rdmol.GetNumAtoms() - heavy_atoms <NEW_LI...
Canonical order the atoms in the molecule using the RDKit. Parameters ---------- molecule: openff.toolkit.topology.Molecule The input molecule Returns ------- molecule : openff.toolkit.topology.Molecule The input molecule, with canonically-indexed atoms and bonds.
625941ecd486a94d0b98e65d
def getFluent(self, fluentName): <NEW_LINE> <INDENT> if fluentName in self.__fluents: <NEW_LINE> <INDENT> return self.__fluents[fluentName] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None
Returns the core.Fluent object associated by the given fluent name or None if such a fluent hasn't been registered. :type fluentName: str :rtype: Fluent
625941eca8370b7717052db3
def simulated_annealing(pieces, steps=1000, temperature=1, rate=10): <NEW_LINE> <INDENT> total_same, total_different = count_all_attacks(pieces) <NEW_LINE> for i in range(steps): <NEW_LINE> <INDENT> piece_to_be_moved = random.choice(pieces) <NEW_LINE> color, piece_type, __, __ = piece_to_be_moved <NEW_LINE> new_locatio...
Solves the n-ything problem with simulated annealing.
625941ec07f4c71912b1199b
def handle_mouse_drag(self, event): <NEW_LINE> <INDENT> x=int(self.canvasx(event.x)) <NEW_LINE> if self.atdivider == 1: <NEW_LINE> <INDENT> self.table.delete('resizeline') <NEW_LINE> self.delete('resizeline') <NEW_LINE> self.table.create_line(x, 0, x, self.table.rowheight*self.table.rows, width=2, fill='gray', tag='res...
Handle column drag, will be either to move cols or resize
625941ec1b99ca400220afc9
def decode_kv_read(proto_kv_read): <NEW_LINE> <INDENT> kv_read = {} <NEW_LINE> kv_read['key'] = proto_kv_read.key <NEW_LINE> proto_version = proto_kv_read.version <NEW_LINE> if proto_version: <NEW_LINE> <INDENT> kv_read['version'] = {} <NEW_LINE> kv_read['version']['block_num'] = str(proto_version.block_num) <NEW_LINE>...
Decodes Key Value Read Args: proto_kv_read: Object of the key value with read contents Returns: deserialized key value read contents with block num and tx_num
625941ec21a7993f00bc820f
@app.route('/json/mempool/', methods=['GET']) <NEW_LINE> def get_json_mempool(): <NEW_LINE> <INDENT> mempool_data = node.info("mempool") <NEW_LINE> return json.dumps(mempool_data)
Get mempool data of the node in json
625941ec5fc7496912cc3e93
def get_completions(frame, act_tok): <NEW_LINE> <INDENT> return _pydev_completer.GenerateCompletionsAsXML(frame, act_tok)
fetch all completions, create xml for the same return the completions xml
625941ecd18da76e235329f3
@allure.title("Increase your holdings with a new wallet") <NEW_LINE> @pytest.mark.P3 <NEW_LINE> def test_AS_022(client_new_node): <NEW_LINE> <INDENT> address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 10 ** 18 * 10000000) <NEW_LINE> address1, _ = client_new_node.economic.account.g...
:param client_new_node_obj: :return:
625941ec1d351010ab856030
def getSum(self, a, b): <NEW_LINE> <INDENT> s, c = a^b, a&b <NEW_LINE> while c: <NEW_LINE> <INDENT> a, b = s, c_uint32(c<<1).value <NEW_LINE> s, c = a^b, a&b <NEW_LINE> <DEDENT> return c_int32(s).value
:type a: int :type b: int :rtype: int
625941ec8e05c05ec3eea88f
def configuration_test(self): <NEW_LINE> <INDENT> configuration = {u"applications": COMPLEX_APPLICATION_YAML, u"deployment": COMPLEX_DEPLOYMENT_YAML} <NEW_LINE> setting = self.assertResponseCode( b"POST", b"/configuration/_compose", configuration, OK ) <NEW_LINE> def configuration_set(_): <NEW_LINE> <INDENT> actual = s...
POSTing to ``/configuration/_compose`` in Flocker's custom configuration format changes the deployment configuration by parsing the given JSON in Flocker's custom configuration format and using it to replace the existing configuration.
625941ec7cff6e4e81117e9b
def crop_resize_image(image, size): <NEW_LINE> <INDENT> width, height = image.size <NEW_LINE> if width > height: <NEW_LINE> <INDENT> left = (width - height) / 2 <NEW_LINE> right = width - left <NEW_LINE> top = 0 <NEW_LINE> bottom = height <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> top = (height - width) / 2 <NEW_LIN...
Resize the input image. :param image: Original image which is a PIL object. :param size: Tuple of height and width to resize the image to. :return: Resized image which is a PIL object
625941ec67a9b606de4a83cd
def __init__(self, name, target_type=None, standard=None, redshift=None, keywords=None, moving=None, target_id=None): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.target_type = target_type <NEW_LINE> self.standard = standard <NEW_LINE> self.redshift = redshift <NEW_LINE> if keywords is None: <NEW_LINE> <INDENT>...
Initializes a Target instance Arguments: name : name of the target type : type of the target
625941ec7b25080760e3996c
def b2tob1(self, q): <NEW_LINE> <INDENT> q_scal = np.dot(self._b2tob1, q) <NEW_LINE> for io in self._open: <NEW_LINE> <INDENT> q_scal[:, 3 * io] = np.dot(self._o_b2tob1, q[:, 3 * io]) <NEW_LINE> q_scal[:, 3 * io + 1] = np.dot(self._o_b2tob1, q[:, 3 * io + 1]) <NEW_LINE> q_scal[:, 3 * io + 2] = np.dot(self._o_b2tob1, q[...
Transforms a matrix from one value of beads to another. Args: q: A matrix with nbeads2 rows, in the bead representation.
625941ec24f1403a92601078
def gcj02towgs84(self,lng,lat): <NEW_LINE> <INDENT> pi = math.pi <NEW_LINE> ee = 0.00669342162296594323 <NEW_LINE> a = 6378245.0 <NEW_LINE> if self.out_of_china(lng, lat): <NEW_LINE> <INDENT> return lng, lat <NEW_LINE> <DEDENT> dlat = self._transformlat(lng - 105.0, lat - 35.0) <NEW_LINE> dlng = self._transformlng(lng ...
GCJ02(火星坐标系)转GPS84 :param lng:火星坐标系的经度 :param lat:火星坐标系纬度 :return:
625941ec6e29344779a62b26
def verify_user(self, username, password): <NEW_LINE> <INDENT> stored_pw = self._get_password_hash(username) <NEW_LINE> if self.mutable: <NEW_LINE> <INDENT> user_data = self.user_data(username) <NEW_LINE> if user_data is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return bool(stored_pw and pwd_c...
Check the login credentials of a user For Mutable backends, pending users should fail to verify Parameters ---------- username : str password : str Returns ------- valid : bool True if user credentials are valid, false otherwise
625941ec7d847024c06be7d6
def run(self, conf, y_obs, y_obs_times, max_iter=2000, burning=500, jupyter=False): <NEW_LINE> <INDENT> from UQuant.mcmc import MCMC <NEW_LINE> self.epsilon = conf["epsilon"] <NEW_LINE> self.sigma_normal = conf["sigma_normal"] <NEW_LINE> self.initial_point_mcmc = conf["initial_point_mcmc"] <NEW_LINE> self.uni_prior_ran...
run_mcmc takes an epsilon and compute the y_obs and then run mcmc using those observations. Returns ------- samples: list
625941ec55399d3f05588bce
def test_courses(self): <NEW_LINE> <INDENT> self.assertEqual(list(self.catalog.courses()), [self.course])
Verify the method returns a QuerySet of courses contained in the catalog.
625941ec091ae3566866746c
def warning_updated(self): <NEW_LINE> <INDENT> if not self.current_tab.updated: <NEW_LINE> <INDENT> self._flip_updated()
Add a little star if the content of the tab changed, and switch the current_tab.updated attribute to True
625941ecf7d966606f6aa520
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> buff.write(_struct_q.pack(self.result)) <NEW_LINE> <DEDENT> except struct.error as se: self._check_types(se) <NEW_LINE> except TypeError as te: self._check_types(te)
serialize message into buffer @param buff: buffer @type buff: StringIO
625941ecfff4ab517eb2f955
def test_table_with_colalign(self): <NEW_LINE> <INDENT> actual_result = Table(['12', '3000', '5']) <NEW_LINE> expected_strings = ['<td colspan="100%">12</td>', '<td colspan="100%">3000</td>', '<td colspan="100%">5</td>'] <NEW_LINE> for s in expected_strings: <NEW_LINE> <INDENT> message = ('Did not find expected string ...
Table columns can be right justified
625941ec3539df3088e2e862
def interpolate(self, other: 'HexColor', t: float): <NEW_LINE> <INDENT> gamma = 2.2 <NEW_LINE> aaa, bbb = [ [channel ** gamma for channel in color.rgb] for color in [self, other] ] <NEW_LINE> ccc = [a * (1.0 - t) + t * b for a, b in zip(aaa, bbb)] <NEW_LINE> rgbResult = tuple(round(c ** (1/gamma)) for c in ccc) <NEW_LI...
>>> HexColor("F00").interpolate(HexColor("000"), t=0) 'FF0000' >>> HexColor("F00").interpolate(HexColor("000"), t=1) '000000' >>> HexColor("888").interpolate(HexColor("000"), t=0.5) '636363'
625941ecd10714528d6001ff
def __ensureChannelInDataSources(self, channel): <NEW_LINE> <INDENT> if not channel in self.dataSources: <NEW_LINE> <INDENT> self.dataSources[channel] = {}
Ensures that the buffer contains an entry for a given channel.
625941ec99cbb53fe67930fb
def __get_units__(kwargs, default_units): <NEW_LINE> <INDENT> if not kwargs.has_key("units"): <NEW_LINE> <INDENT> return default_units <NEW_LINE> <DEDENT> units = kwargs["units"] <NEW_LINE> return __standardize_units__(units, default_units)
This is a private helper function which scans a dictionary looking for the keyword I{units} and obtaining the value associated with that key. @param kwargs: A list of keyword arguments that this function scans @type kwargs: C{dict} @returns: The units for a given value @rtype: C{string}
625941ece5267d203edce1ac
def median(lst): <NEW_LINE> <INDENT> length = len(lst) <NEW_LINE> if (length == 0): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> elif (length % 2 == 1): <NEW_LINE> <INDENT> return float(lst[length/2]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return (lst[length/2] + lst[length/2 - 1])/2.0
return the median of a sorted list "lst", as a float
625941ece8904600ed9f244c
def _get_nets_arin(self, *args, **kwargs): <NEW_LINE> <INDENT> from warnings import warn <NEW_LINE> warn('Whois._get_nets_arin() has been deprecated and will be ' 'removed. You should now use Whois.get_nets_arin().') <NEW_LINE> return self.get_nets_arin(*args, **kwargs)
Deprecated. This will be removed in a future release.
625941ecf9cc0f698b140b0d
def test_waittimeout(self): <NEW_LINE> <INDENT> p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_waittimeout_10s_python.ini"], cwd=here) <NEW_LINE> p.run() <NEW_LINE> p.wait(timeout=5) <NEW_LINE> detected, output = proctest.check_for_process(self.proclaunch) <NEW_LINE> self.determine_status(det...
Process is started, then wait is called and times out. Process is still running and didn't timeout
625941ec01c39578d7e75352
def simulate(which,boundary,delta_t): <NEW_LINE> <INDENT> times = np.array([0.01,0.04,0.07]) <NEW_LINE> how_many_times = np.asarray(times/delta_t,dtype=int) <NEW_LINE> xnum = 51 <NEW_LINE> CFL = delta_t*(xnum+1)**2 <NEW_LINE> fig = plt.figure(figsize=(8,5)) <NEW_LINE> for i in range(3): <NEW_LINE> <INDENT> ival = get_i...
wrapper function for one plot. plots the different times in the so-called array for the scheme ´which´ and boundary ´boundary´. The time step has the size ´delta_t´.
625941ec1f037a2d8b946713
def __init__(self, name, props, fmt, args, arg_fmts, orig=None): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.properties = props <NEW_LINE> self.fmt = fmt <NEW_LINE> self.args = args <NEW_LINE> self.arg_fmts = arg_fmts <NEW_LINE> if orig is None: <NEW_LINE> <INDENT> self.original = weakref.ref(self) <NEW_LINE> ...
Parameters ---------- name : string Event name. props : list of str Property names. fmt : str, list of str Event printing format (or formats). args : Arguments Event arguments. arg_fmts : list of str Format strings for each argument. orig : Event or None Original Event before transformation.
625941ec5166f23b2e1a566f
def get_status(): <NEW_LINE> <INDENT> pass
Return a string describing the current state of the upload process.
625941ec8da39b475bd65491
@reserve_tools.elapsed_time <NEW_LINE> def get_cookie(cfg): <NEW_LINE> <INDENT> global http_req_num <NEW_LINE> session = requests.session() <NEW_LINE> response = session.get(cfg['first_url']) <NEW_LINE> cookie_sessionid = session.cookies.get(cfg['cookie_sessionid']) <NEW_LINE> http_req_num += 1 <NEW_LINE> cookies = { c...
cookieを取得する
625941ec507cdc57c63071fd
def train(model_name): <NEW_LINE> <INDENT> words = load_dataset() <NEW_LINE> data_size = len(words) <NEW_LINE> vocabulary_size = get_vocabulary_size(words, min_freq=3) <NEW_LINE> batch_size = 500 <NEW_LINE> embedding_size = 200 <NEW_LINE> skip_window = 5 <NEW_LINE> num_skips = 10 <NEW_LI...
训练词向量 Args: corpus_file: 文件内容已经经过分词。 得 我 就 在 车里 咪 一会 终于 知道 哪里 感觉 不 对 了 ... model_name: 模型名称,用于生成保存训练状态和词向量的文件名 Returns: 输出训练状态以及训练后的词向量文件
625941ec627d3e7fe0d69368
@pytest.fixture(scope="module") <NEW_LINE> def resource(service): <NEW_LINE> <INDENT> return AffiliationsResource(AffiliationsResourceConfig, service)
Affiliations resource object.
625941ec287bf620b61d3f77
def getPlayerScenceNpcQuestStatus(self): <NEW_LINE> <INDENT> statusList = [] <NEW_LINE> for npcID in self._npcList: <NEW_LINE> <INDENT> taskInfo = self.getQuestOnNpc(npcID) <NEW_LINE> task = taskInfo.get('ncp_task_item',None) <NEW_LINE> statusInfo = {} <NEW_LINE> statusInfo['npcID'] = npcID <NEW_LINE> statusInfo['statu...
获取场景中NPC的任务状态标识 @param npcList:
625941ec38b623060ff0b304
def is_orthonormal_cont(polys, lower, upper, rtol=0, atol=1e-08): <NEW_LINE> <INDENT> for i in range(len(polys)): <NEW_LINE> <INDENT> for j in range(i+1): <NEW_LINE> <INDENT> p1 = polys[i] <NEW_LINE> p2 = polys[j] <NEW_LINE> innerprod = integrate.quad(lambda x: p1(x)*p2(x), lower, upper)[0] <NEW_LINE> if not np.allclos...
check whether functions are orthonormal Parameters ---------- polys : list of polynomials or function Returns ------- is_orthonormal : bool is False if the innerproducts are not close to 0 or 1 Notes ----- this stops as soon as the first deviation from orthonormality is found. Examples -------- >>> from scipy.s...
625941ec30dc7b7665901e77
def Event_sort(self): <NEW_LINE> <INDENT> for i in range(len(self.event_list)): <NEW_LINE> <INDENT> min_pos = i <NEW_LINE> for j in range(i+1, len(self.event_list)): <NEW_LINE> <INDENT> if self.event_list[j].time < self.event_list[min_pos].time: <NEW_LINE> <INDENT> min_pos = j <NEW_LINE> <DEDENT> <DEDENT> temp = self.e...
イベント時間に従って並べ替え
625941ec76e4537e8c351b8d
def t330170_x4(text1=_, flag1=0, mode1=1): <NEW_LINE> <INDENT> assert t330170_x2() and CheckSpecificPersonTalkHasEnded(0) == 1 <NEW_LINE> TalkToPlayer(text1, -1, -1, flag1) <NEW_LINE> assert CheckSpecificPersonTalkHasEnded(0) == 1 <NEW_LINE> if not mode1: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <I...
State 0,4
625941ec0a50d4780f6673ad
def test_code_change_backward_break(self, trials): <NEW_LINE> <INDENT> code_change_adapter = CodeChange(CodeChange.BREAK) <NEW_LINE> adapted_trials = code_change_adapter.backward(trials) <NEW_LINE> assert len(adapted_trials) == 0
Test :meth:`kleio.core.evc.adapters.CodeChange.backward` with change type BREAK
625941ec8c0ade5d55d3eed6
def closeEvent(self, event): <NEW_LINE> <INDENT> self.disconnect_image_events() <NEW_LINE> self.remove_image_artists() <NEW_LINE> self.image_viewer.plugins.remove(self) <NEW_LINE> self.image_viewer.reset_image() <NEW_LINE> self.image_viewer.redraw() <NEW_LINE> self.close()
On close disconnect all artists and events from ImageViewer. Note that events must be connected using `self.connect_image_event` and artists must be appended to `self.artists`.
625941ec31939e2706e4d379
def build_walls(self): <NEW_LINE> <INDENT> self.map_builder.build_arena() <NEW_LINE> self.wall_list = self.play_window.get_object("wall_list")
calls the map builder agent to parse through the level file and create the map of the game
625941ec7047854f462a191a
def __init__(self, corpus, id2word=None, normalize=True): <NEW_LINE> <INDENT> self.normalize = normalize <NEW_LINE> self.n_docs = 0 <NEW_LINE> self.n_words = 0 <NEW_LINE> self.entr = {} <NEW_LINE> if corpus is not None: <NEW_LINE> <INDENT> self.initialize(corpus) <NEW_LINE> <DEDENT> self.id2word = id2word
`normalize` dictates whether the resulting vectors will be set to unit length.
625941ecad47b63b2c50a496
def isoccupied(self, p): <NEW_LINE> <INDENT> c, r = self.w2g(p) <NEW_LINE> try: <NEW_LINE> <INDENT> return self._grid[r, c] <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> return True
Test if coordinate is occupied :param p: world coordinate (x, y) :type p: array_like(2) :return: occupancy status of corresponding grid cell :rtype: bool The grid cell size and offset are used to convert ``p`` to an occupancy grid coordinate. The grid coordinate is rounded and cast to integer value. If the coordina...
625941ec7047854f462a191b
def list(self, session, filter_q=None, api_req=False): <NEW_LINE> <INDENT> project_list = self.auth.get_project_list(filter_q) <NEW_LINE> if not session["allow_show_user_project_role"]: <NEW_LINE> <INDENT> user = self.auth.get_user(session["username"]) <NEW_LINE> projects = [prm["project"] for prm in user["project_role...
Get a list of the topic that matches a filter :param session: contains "username", "admin", "force", "public", "project_id", "set_project" :param filter_q: filter of data to be applied :return: The list, it can be empty if no one match the filter.
625941ec099cdd3c635f116f
def strongly_connected_components(dg): <NEW_LINE> <INDENT> index = [0] <NEW_LINE> S = [] <NEW_LINE> indizes = {} <NEW_LINE> lowlinks = {} <NEW_LINE> scc = [] <NEW_LINE> def trajan(v): <NEW_LINE> <INDENT> indizes[v] = index[0] <NEW_LINE> lowlinks[v] = index[0] <NEW_LINE> index[0] += 1 <NEW_LINE> S.append(v) <NEW_LINE> f...
This algorithm is based upon a depth first search. It assigns a number to each visited node.
625941ec15baa723493c4490
def http_request(url, headers): <NEW_LINE> <INDENT> connection = httplib.HTTPConnection(urlparse(url).hostname) <NEW_LINE> connection.request(method='GET', url=url, body='', headers=headers) <NEW_LINE> response = connection.getresponse() <NEW_LINE> source = response.read().decode('utf-8') <NEW_LINE> connection.close() ...
Simple HTTP request function with custom headers.
625941ec7b180e01f3dc4d09
def check_bid_legality(self, player, bid): <NEW_LINE> <INDENT> if self.gs.game_mode != GAME_MODE.BID: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if bid == BID.PASS: <NEW_LINE> <INDENT> return 'pass' <NEW_LINE> <DEDENT> if bid < BID.PASS: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if bid > BID.CINCH:...
Check a proposed bid for legality against the current gs. Assumes that player is indeed the active player. Returns a string indicating the bid type, or False if illegal bid. player (Player): player object of player making bid (replace w/ pNum?) bid (int): integer [0-5] value of bid; BID.PASS=0, BID.CINCH=5
625941ecde87d2750b8602af
def main(num): <NEW_LINE> <INDENT> line = ceil(num/7) <NEW_LINE> for _ in range(line): <NEW_LINE> <INDENT> for j in range(num, num-7, -1): <NEW_LINE> <INDENT> if j < 1: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> print(j, end=" ") <NEW_LINE> <DEDENT> print() <NEW_LINE> num -= 7
main func
625941ec377c676e912726be
def getNameSpacePathExpression(package, source_ref): <NEW_LINE> <INDENT> reference_mode = Options.getFileReferenceMode() <NEW_LINE> if reference_mode == "original": <NEW_LINE> <INDENT> return makeConstantRefNode( constant=[package.getCompileTimeDirectory()], source_ref=source_ref, ) <NEW_LINE> <DEDENT> elif reference_m...
Create the __path__ expression for a package.
625941ecb5575c28eb68e51c
def sendRestRequest(self, method, path, parameters=None, data=None, files=None, json=None): <NEW_LINE> <INDENT> if not parameters: <NEW_LINE> <INDENT> parameters = {} <NEW_LINE> <DEDENT> assert method in self.METHODS <NEW_LINE> f = self.METHODS[method] <NEW_LINE> url = self.urlBase + path <NEW_LINE> result = f(url, par...
This method looks up the appropriate method, constructs a request URL from the base URL, path, and parameters, and then sends the request. If the method is unknown or if the path is not found, an exception is raised, otherwise a JSON object is returned with the Girder response. This is a convenience method to use when...
625941eca934411ee3751bac
def add_route(self, verb, path, delegate): <NEW_LINE> <INDENT> route = "{}:{}".format(verb, path) <NEW_LINE> self.add_full_route(route, delegate)
Add route given verb, path, delegate function. Args: verb (str): HTTP verb ex. GET, POST path (str): path delegate (func): function to call
625941ec8e71fb1e9831dcbe
def GetDataPointer(self, *args): <NEW_LINE> <INDENT> return _itkFixedArrayPython.itkFixedArrayUL4_GetDataPointer(self, *args)
GetDataPointer(self) -> unsigned long GetDataPointer(self) -> unsigned long
625941ec5510c4643540f8ee
def prepend(self, item): <NEW_LINE> <INDENT> node = Node(item) <NEW_LINE> if self.head is None: <NEW_LINE> <INDENT> self.head = node <NEW_LINE> self.tail = node <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> node.next = self.head <NEW_LINE> self.head = node <NEW_LINE> <DEDENT> self.size += 1
Insert the given item at the head of this linked list. Best and worth case running time: O(1) because we only change the first node and never loop through all nodes
625941ec23e79379d52eea74
def __init__(self): <NEW_LINE> <INDENT> self.swagger_types = { 'city': 'str', 'country': 'str', 'id': 'int', 'parent': 'Addresses', 'state': 'str', 'type': 'str', 'zip': 'str' } <NEW_LINE> self.attribute_map = { 'city': 'city', 'country': 'country', 'id': 'id', 'parent': 'parent', 'state': 'state', 'type': 'type', 'zip...
Address - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. :param dict attributeMap: The key is attribute name and the value is json key in definition.
625941ec283ffb24f3c55e13
def now_playing(self, artist, track, album=None, mbid=None, duration=None): <NEW_LINE> <INDENT> k = dict(artist=artist, track=track, sk=self.session_key) <NEW_LINE> if album is not None: <NEW_LINE> <INDENT> k['album'] = album <NEW_LINE> <DEDENT> if mbid is not None: <NEW_LINE> <INDENT> k['mbid'] = mbid <NEW_LINE> <DEDE...
Send a temporary "now playing" scrobble to last fm as the user associated with this session.
625941eccb5e8a47e48b7fb9
def create_raid(ns, devices, level, name=None): <NEW_LINE> <INDENT> devs = [common.str2device(ns, device) for device in devices] <NEW_LINE> args = { 'InExtents': devs, 'Level': level} <NEW_LINE> if name: <NEW_LINE> <INDENT> args['ElementName'] = name <NEW_LINE> <DEDENT> service = ns.LMI_StorageConfigurationService.firs...
Create new MD RAID device. :type devices: list of LMIInstance/CIM_StorageExtent or list of strings :param device: Devices to add to the RAID. :type level: int :param level: RAID level. :type name: string :param name: RAID name. :rtype: LMIInstance/LMI_MDRAIDStorageExtent
625941ec07d97122c4178daf
def avcodec_find_encoder_by_name(name): <NEW_LINE> <INDENT> func = _lib().avcodec_find_encoder_by_name <NEW_LINE> func.args = [ctypes.c_char_p] <NEW_LINE> func.restype = POINTER(AVCodec) <NEW_LINE> res = func(name) <NEW_LINE> if res: <NEW_LINE> <INDENT> return res.contents <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ...
Finds a registered encoder with the specified name. Returns an AVCodec object or None if no encoder was found.
625941ec99cbb53fe67930fc
def convert_vector_to_param_dict(self, vector): <NEW_LINE> <INDENT> ret_dict = {} <NEW_LINE> for key, val in self.param_index_dict.items(): <NEW_LINE> <INDENT> if isinstance(val, list): <NEW_LINE> <INDENT> ret_dict[key] = [] <NEW_LINE> for idx in val: <NEW_LINE> <INDENT> ret_dict[key].append(vector[idx]) <NEW_LINE> <DE...
Given vector, return a dict mapping each values to respective parameters :param vector: 1d np array of parameters :return: dict of parameters defined by self.param_index_dict
625941ece8904600ed9f244d
def merge_ranges(ranges, ss=100000): <NEW_LINE> <INDENT> ranges = ranges + [0, +ss] <NEW_LINE> ranges = iter(ranges) <NEW_LINE> current_start, current_stop = next(ranges) <NEW_LINE> for start, stop in ranges: <NEW_LINE> <INDENT> if start > current_stop: <NEW_LINE> <INDENT> yield current_start, current_stop <NEW_LINE> c...
Merges overlapping / adjacent ranges. 'ranges' must be sorted BEFORE running this function. Call with 'np.fromiter(merge_ranges(ranges), dtype='i8,i8')'.
625941eccad5886f8bd274f0
def set_existing(self, certificate_bytes): <NEW_LINE> <INDENT> self.existing_certificate_bytes = certificate_bytes <NEW_LINE> self.diff_after = self.diff_before = self._get_info(self.existing_certificate_bytes)
Set existing certificate bytes. None indicates that the key does not exist.
625941ecf9cc0f698b140b0e
def importFile(self, path, source_path): <NEW_LINE> <INDENT> self.post("/files/{path}".format(path=path), self._importFileCallback, body=pathlib.Path(source_path), timeout=None)
Imports a file to this node.
625941eceab8aa0e5d26e071
def t_ID(t): <NEW_LINE> <INDENT> t.type = reserved_map.get(t.value,"ID") <NEW_LINE> return t
[A-Za-z_]+[\w_]*
625941eca79ad161976cc65d
def test_add_attachment(self): <NEW_LINE> <INDENT> pass
Test case for add_attachment Add Alert Attachment # noqa: E501
625941ec099cdd3c635f1170
def __is_block_data_move(self): <NEW_LINE> <INDENT> block_data_move_instructions = ('movs', 'stos', 'lods') <NEW_LINE> isBlockDataMove = False <NEW_LINE> instruction = None <NEW_LINE> if self.pc is not None and self.faultDisasm: <NEW_LINE> <INDENT> for disasm in self.faultDisasm: <NEW_LINE> <INDENT> if disasm[0] == sel...
Private method to tell if the instruction pointed to by the program counter is a block data move instruction. Currently only works for x86 and amd64 architectures.
625941ecd268445f265b5387
@commandWrap <NEW_LINE> def SubdivProxy(*args, **kwargs): <NEW_LINE> <INDENT> return cmds.SubdivProxy(*args, **kwargs)
:rtype: list|str|DagNode|AttrObject|ArrayAttrObject|Components1Base
625941ec91af0d3eaac9bf35
def FastEnsembling(self, pp, factor, mass_threshold=0.2, suppression_field=14): <NEW_LINE> <INDENT> p = Pool(8) <NEW_LINE> simulated_fast = p.map(singleEnsemble, [(pp, factor, x, mass_threshold, suppression_field) for x in range(pp.shape[1])]) <NEW_LINE> p.close() <NEW_LINE> pp_ensembling = np.concatenate([x[0][np.newa...
pp: [fold, samples, channel, time_steps] :param pp: :return:
625941ecfb3f5b602dac3bb0
def removeDuplicates(self, nums): <NEW_LINE> <INDENT> if len(nums) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> slow = 0 <NEW_LINE> fast = 1 <NEW_LINE> while fast < len(nums): <NEW_LINE> <INDENT> if nums[slow] != nums[fast]: <NEW_LINE> <INDENT> slow += 1 <NEW_LINE> nums[slow] = nums[fast] <NEW_LINE> <DEDENT> ...
:type nums: List[int] :rtype: int
625941ec55399d3f05588bcf
def median(self, counts, data): <NEW_LINE> <INDENT> logger.debug('computing median') <NEW_LINE> R = self.ragged_size <NEW_LINE> N = data.shape[0] <NEW_LINE> assert data.shape == (N, R) <NEW_LINE> assert data.dtype == np.int8 <NEW_LINE> marginals = self.marginals(data) <NEW_LINE> V = len(self._ragged_index) - 1 <NEW_LIN...
Compute L1-loss-minimizing quantized marginals conditioned on data. Args: counts: A [V]-shaped numpy array of quantization resolutions. data: An [N, R]-shaped numpy array of row of conditioning data, as a ragged nummpy array of multinomial counts, where R = server.ragged_size. Returns: An ...
625941ecdd821e528d63b6bc
def inside(head): <NEW_LINE> <INDENT> return -290 < head.x < 320 and -290 < head.y < 320
Return True if head inside boundaries.
625941ec566aa707497f4a79
def populate_users(users): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> users_data = [] <NEW_LINE> for user in users: <NEW_LINE> <INDENT> u = guest_models.MySQLUser() <NEW_LINE> u.name = user.get('name', '') <NEW_LINE> u.password = user.get('password', '') <NEW_LINE> dbs = user.get('databases', '') <NEW_LINE> if dbs: <...
Create a serializable request containing users
625941ec956e5f7376d71383
def testNullableField(self): <NEW_LINE> <INDENT> object = FieldTest() <NEW_LINE> object.StringField = None <NEW_LINE> self.failUnless(object.StringField == None) <NEW_LINE> object.ObjectField = None <NEW_LINE> self.failUnless(object.ObjectField == None) <NEW_LINE> object.SpamField = None <NEW_LINE> self.failUnless(obje...
Test nullable fields.
625941ec3617ad0b5ed6840e
def WaterMark (inputPdfPath, waterMarkPath, pageList, outputPdfPath): <NEW_LINE> <INDENT> inputFile = open(inputPdfPath, "rb") <NEW_LINE> inFileReader = PyPDF2.PdfFileReader(inputFile) <NEW_LINE> waterMarkFile = open(waterMarkPath, "rb") <NEW_LINE> wmFileReader = PyPDF2.PdfFileReader(waterMarkFile) <NEW_LINE> pdfWriter...
Add WaterMark to the inputFile for the pages in the pageList. Use the watermark from the waterMarkPath, the watermark pdf should have only one page Store the output on the outputPdfPath :param inputPdfPath: String of the path of input :param waterMarkPath: String to the watermark path :param pageList: List of page nu...
625941eca934411ee3751bad
def test_create_instance_without_database(topology_st, page, browser_name, setup_page): <NEW_LINE> <INDENT> frame = check_frame_assignment(page, browser_name) <NEW_LINE> log.info('Click on Create New Instance button') <NEW_LINE> frame.click("#no-inst-create-btn") <NEW_LINE> frame.wait_for_selector('#createServerId') <N...
Test create instance without database :id: 7390c009-cb0d-406a-962a-4a1f0f02cfe6 :setup: Standalone instance :steps: 1. Click on Create New Instance button 2. Fill serverID 3. Fill password longer than eight characters 4. Fill passwordConfirm longer than eight character 5. Click on the Create I...
625941ecd6c5a10208144567
def drop_log_stats(self, ignore=('IGNORED',)): <NEW_LINE> <INDENT> return _drop_log_stats(self.drop_log, ignore)
Compute the channel stats based on a drop_log from Epochs. Parameters ---------- ignore : list The drop reasons to ignore. Returns ------- perc : float Total percentage of epochs dropped. See Also -------- plot_drop_log
625941ecd18da76e235329f4
def default_configfile(base_filename): <NEW_LINE> <INDENT> file_dir = os.path.join(os.environ.get('HOME', '~'), '.config', 'trepanpy') <NEW_LINE> file_dir = Mclifns.path_expanduser_abs(file_dir) <NEW_LINE> if not os.path.isdir(file_dir): <NEW_LINE> <INDENT> os.makedirs(file_dir, mode=0o755) <NEW_LINE> <DEDENT> return o...
Return fully expanded configuration filename location for base_filename. python2 and python3 debuggers share the smae directory: ~/.config/trepan.py
625941ec26238365f5f0f38d
def reset(self): <NEW_LINE> <INDENT> ret = libvirtmod.virNodeDeviceReset(self._o) <NEW_LINE> if ret == -1: raise libvirtError ('virNodeDeviceReset() failed') <NEW_LINE> return ret
Reset a previously dettached node device to the node before or after assigning it to a guest. The exact reset semantics depends on the hypervisor and device type but, for example, KVM will attempt to reset PCI devices with a Function Level Reset, Secondary Bus Reset or a Power Management D-State reset. If the reset w...
625941ec656771135c3ebd8d