code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def white_bright(message): <NEW_LINE> <INDENT> return Fore.WHITE + Style.BRIGHT + message + Style.RESET_ALL
This method works exactly the way green_bright() work with different color.
625941cdf7d966606f6aa114
def has_legacy_landmarksxy(self): <NEW_LINE> <INDENT> logger.debug("checking legacy landmarksXY") <NEW_LINE> retval = (any(key == "landmarksXY" for alignments in self.data.values() for alignment in alignments for key in alignment)) <NEW_LINE> logger.debug("legacy landmarksXY: %s", retval) <NEW_LINE> return retval
check for legacy landmarksXY keys
625941cddd821e528d63b2b9
def IsInside(self, *args): <NEW_LINE> <INDENT> return _itkPolygonGroupSpatialObjectPython.itkPolygonGroupSpatialObject2_IsInside(self, *args)
IsInside(self, itkPointD2 point, unsigned int depth = 0, char name = 0l) -> bool IsInside(self, itkPointD2 point, unsigned int depth = 0) -> bool IsInside(self, itkPointD2 point) -> bool
625941cd31939e2706e4cf7a
def flush(self): <NEW_LINE> <INDENT> if self.debug: <NEW_LINE> <INDENT> sys.stderr.write("%s: FLUSH INPUT (%i bytes waiting)\n" %( self.__class__.__name__, self.ser.inWaiting() )) <NEW_LINE> <DEDENT> self.ser.flushInput()
Flush input buffers.
625941cd4428ac0f6e5ba902
def validate(self, form): <NEW_LINE> <INDENT> s3db = current.s3db <NEW_LINE> config = self._config <NEW_LINE> if self.record_id: <NEW_LINE> <INDENT> onvalidation = config("update_onvalidation", config("onvalidation", None)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> onvalidation = config("create_onvalidation", confi...
Run the onvalidation callbacks for the master table and all subtables in the form, and store any errors in the form. Args: form: the form
625941cdd164cc6175782e5e
def get_allObjects_js(self): <NEW_LINE> <INDENT> parameters_json = self.get_parameters(); <NEW_LINE> data_json = self.get_data(); <NEW_LINE> tile2datamap_json = self.get_tile2datamap(); <NEW_LINE> filtermenu_json = self.get_filtermenu(); <NEW_LINE> alldata_O = ''; <NEW_LINE> if parameters_json: alldata_O+= 'var ' + 'pa...
return all container data in string format
625941cde76e3b2f99f3a91b
def biomass_plot(axes, data, label): <NEW_LINE> <INDENT> bm_cdict = {v: k for k, v in enumerate(np.unique(data.biomass))} <NEW_LINE> bm_cvals = [bm_cdict[c] for c in data.biomass] <NEW_LINE> axes.scatter( data.x, data.y, c = bm_cvals, cmap = 'nipy_spectral', s = 1 ) <NEW_LINE> axes.set_xlabel('UMAP_1') <NEW_LINE> axes....
Make a scatterplot of the UMAP results where each point is colored according to the biomass reaction used by the associated network
625941cdec188e330fd5a8af
def testRuleAttributes(self): <NEW_LINE> <INDENT> pass
Test RuleAttributes
625941cde8904600ed9f203d
def setup_drmaa_job_template(self, drmaa_session, job_name, job_memory, job_threads, working_directory, **kwargs): <NEW_LINE> <INDENT> if not job_memory: <NEW_LINE> <INDENT> raise ValueError("Job memory must be specified when running" "DRMAA jobs") <NEW_LINE> <DEDENT> jt = drmaa_session.createJobTemplate() <NEW_LINE> j...
Sets up a Drmma job template. Currently SGE, SLURM, Torque and PBSPro are supported
625941cd283ffb24f3c55a11
def forward(self, input, hidden, result, cps=1.0, gen=0.0, batch=1): <NEW_LINE> <INDENT> hidden0=hidden[0][0].view(1, batch, self.hidden_size) <NEW_LINE> c0 = hidden[0][1].view(1, batch, self.hidden_size) <NEW_LINE> hout, (hidden1,c1) = self.lstm(input.view(-1, batch, self.input_size), (hidden0,c0)) <NEW_LINE> output =...
:param input: :param hidden: [(lstm h0, c0),(errpipe),context] :param result: :return:
625941cdd58c6744b4257d70
def test_merge(self): <NEW_LINE> <INDENT> self.mock_the_dialog(test_entire_mode=True) <NEW_LINE> self.impact_merge_dialog.prepare_input() <NEW_LINE> self.impact_merge_dialog.validate_all_layers() <NEW_LINE> self.impact_merge_dialog.merge() <NEW_LINE> report_list = glob( os.path.join( self.impact_merge_dialog.out_dir, '...
Test merge function.
625941cd2c8b7c6e89b358d1
def pause_writing(self) -> None: <NEW_LINE> <INDENT> pass
Called when the write buffer becomes full This method is called when the channel's write buffer becomes full and no more data can be sent until the remote system adjusts its window. While data can still be buffered locally, applications may wish to stop producing new data until the write buffer has drained.
625941cd55399d3f055887c4
def load_peaklist(self, event): <NEW_LINE> <INDENT> dialog = RelaxFileDialog(parent=self, message='Select the %s peak list file'%self.label, style=wx.FD_OPEN|wx.FD_MULTIPLE) <NEW_LINE> if status.show_gui and dialog.ShowModal() != wx.ID_OK: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> files = dialog.get_file() <NEW_LI...
Function to load peak lists to data grid. @param event: The wx event. @type event: wx event
625941cd21bff66bcd684a63
def get_word_diagnostic(word_count_dictionary, equals_count=constants.markers.Invalid): <NEW_LINE> <INDENT> if word_count_dictionary and equals_count is constants.markers.Invalid: <NEW_LINE> <INDENT> paragraph_number_details_list = get_first_minimum_value_deep( word_count_dictionary ) <NEW_LINE> filename_for_paragraph_...
Create a full diagnostic based on the dictionary of (paragraph, word counts).
625941cdd18da76e235325e6
def push(self, item): <NEW_LINE> <INDENT> assert self.active is True <NEW_LINE> c_item = ffi.new("char[]", pickle.dumps(item)) <NEW_LINE> ret = self.sm.write(self.sm, c_item, len(c_item)) <NEW_LINE> return ret
Push a string item onto the persistent queue
625941cd091ae3566866706e
def writeStaticDescription( output, suite ): <NEW_LINE> <INDENT> output.write( 'CxxTest::StaticSuiteDescription %s' % suite['dobject'] ) <NEW_LINE> if not noStaticInit: <NEW_LINE> <INDENT> output.write( '( %s, %s, "%s", %s, %s )' % (suite['cfile'], suite['line'], suite['name'], suite['object'], suite['tlist']) ) <NEW_L...
Write SuiteDescription for a static suite
625941cd5e10d32532c5f037
def fromRawData(self): <NEW_LINE> <INDENT> return str()
static str QByteArray.fromRawData()
625941cd460517430c394295
def list_series_with_gaps(data_mgr, config): <NEW_LINE> <INDENT> cur = data_mgr.query("SELECT rowid, * FROM Series ORDER BY name") <NEW_LINE> entries = cur.fetchall() <NEW_LINE> series_list = [entry_to_series(entry) for entry in entries] <NEW_LINE> series_with_gaps = [] <NEW_LINE> for series in series_list: <NEW_LINE> ...
list_series_with_gaps() Retrieves and prints the list of all series in the database for which there is a gap (the set of all volumes is not continuous) Arguments: data_mgr - DatabaseManager object with active connection to database config - Config object with current config settings loaded.
625941cd2ae34c7f2600d241
def set_profile(self,profile_name): <NEW_LINE> <INDENT> if profile_name in [ "delete", "None", "~", ""] or profile_name is None: <NEW_LINE> <INDENT> self.profile = "" <NEW_LINE> return True <NEW_LINE> <DEDENT> self.image = "" <NEW_LINE> p = self.config.profiles().find(name=profile_name) <NEW_LINE> if p is not None: <NE...
Set the system to use a certain named profile. The profile must have already been loaded into the Profiles collection.
625941cdff9c53063f47c304
@pt.fixture() <NEW_LINE> def websocket_props() -> WebSocketProps: <NEW_LINE> <INDENT> return WebSocketProps()
Reserve a websocket host and port.
625941cd627d3e7fe0d68f60
def point_plane_distance(q, p, n): <NEW_LINE> <INDENT> return (q - p).dot(n) / (n.dot(n))
q is the point to be projected, p and n define the plane
625941cd187af65679ca522f
def _fetch_captcha(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._check_file(self.captcha_fetcher_method_from_outer_class()) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> self.log.error(e.message) <NEW_LINE> raise Exception(u'> ERROR: File cant read...')
Read captcha from url.
625941cdd6c5a1020814415b
def powershell_instructions(self): <NEW_LINE> <INDENT> if self.department_user.dir_sync_enabled: <NEW_LINE> <INDENT> if not self.department_user.ad_guid: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> if self.ad_field == 'Manager': <NEW_LINE> <INDENT> instructions = '$manager = Get-ADUser -Identity {}\nSet-ADUser -I...
Returns a PowerShell command to update the relevant Active Directory.
625941cdcc0a2c11143dcfa1
def K2C(K): <NEW_LINE> <INDENT> return _np.asanyarray(K) - zero_Celsius
Convert Kelvin to Celsius Parameters ---------- K : array_like Kelvin temperature(s) to be converted. Returns ------- C : float or array of floats Equivalent Celsius temperature(s). Notes ----- Computes ``C = K - zero_Celsius`` where `zero_Celsius` = 273.15, i.e., (the absolute value of) temperature "absolut...
625941cd8c0ade5d55d3eacb
def __init__(self,layers,active_function=[logistic],active_function_der=[logistic_derivative],learn_rate=0.9): <NEW_LINE> <INDENT> self.weights = [np.random.randn(x,y) for x,y in zip(layers[1:],layers[:-1])]; <NEW_LINE> self.biases = [np.random.randn(x,1) for x in layers[1:]]; <NEW_LINE> self.size = len(layers); <NEW_L...
初始化神经网络 layer中存放每层的神经元数量,layer的长度即为网络的层数 active_function 为每一层指定一个激活函数,若长度为1则表示所有层使用同一个激活函数 active_function_der 激活函数的导数 learn_rate 学习速率
625941cd16aa5153ce362589
def p_Variation(self, p): <NEW_LINE> <INDENT> pass
Variation : VARIATION ObjectName SyntaxPart WriteSyntaxPart VariationAccessPart CreationPart DefValPart DESCRIPTION Text
625941cd2eb69b55b151c9bf
def __init__(self, device): <NEW_LINE> <INDENT> import flux_led <NEW_LINE> self._name = device['name'] <NEW_LINE> self._ipaddr = device['ipaddr'] <NEW_LINE> self._mode = device[ATTR_MODE] <NEW_LINE> self.is_valid = True <NEW_LINE> self._bulb = None <NEW_LINE> try: <NEW_LINE> <INDENT> self._bulb = flux_led.WifiLedBulb(s...
Initialize the light.
625941cd097d151d1a222f6a
def test_radiobutton_dialog_element(appliance, request): <NEW_LINE> <INDENT> element_data = { 'element_information': { 'ele_label': fauxfactory.gen_alphanumeric(15, start="ele_label_"), 'ele_name': fauxfactory.gen_alphanumeric(15, start="ele_name_"), 'ele_desc': fauxfactory.gen_alphanumeric(15, start="ele_desc_"), 'cho...
Polarion: assignee: nansari casecomponent: Services caseimportance: low initialEstimate: 1/4h tags: service
625941cdab23a570cc250293
def _Validate(self, config): <NEW_LINE> <INDENT> config = re.sub(PROGUARD_COMMENTS_PATTERN, '', config) <NEW_LINE> args = config.split('-') <NEW_LINE> invalid_configs = [] <NEW_LINE> for arg in args: <NEW_LINE> <INDENT> arg = arg.strip() <NEW_LINE> if not arg or self._ValidateArg(arg): <NEW_LINE> <INDENT> continue <NEW...
Checks the config for illegal arguments.
625941cd656771135c3eb97f
def __init__(self, address="http://sf-daqsync-02:%d/" % config.DEFAULT_API_PORT): <NEW_LINE> <INDENT> self.api_address_format = address.rstrip("/") + config.API_PREFIX + "%s" <NEW_LINE> self.address = address
:param address: Address of the cam API, e.g. http://localhost:10000
625941cd2ae34c7f2600d242
def print_header(): <NEW_LINE> <INDENT> name_and_version = settings.get_name_and_version() <NEW_LINE> print() <NEW_LINE> print(name_and_version) <NEW_LINE> print('=' * len(name_and_version))
Print application name and version on command line. :rtype: None
625941cd96565a6dacc8f7dc
def mySettings(): <NEW_LINE> <INDENT> settings = {} <NEW_LINE> settings['markets'] = ['CASH', 'F_AD', 'F_AE', 'F_AH', 'F_AX', 'F_BC', 'F_BG', 'F_BO', 'F_BP', 'F_C', 'F_CA', 'F_CC', 'F_CD', 'F_CF', 'F_CL', 'F_CT', 'F_DL', 'F_DM', 'F_DT', 'F_DX', 'F_DZ', 'F_EB', 'F_EC', 'F_ED', 'F_ES', 'F_F', 'F_FB', 'F_FC', 'F_FL', 'F...
Define your trading system settings here
625941cdd6c5a1020814415c
def password(self, mobile): <NEW_LINE> <INDENT> pass
Parameters: - mobile
625941cd4e696a04525c955c
def test_loader(self): <NEW_LINE> <INDENT> self.assertTrue('invenio.celery.tasks.invenio_version' in self.celery_app.tasks)
Test if `workers.py` files are correctly registered.
625941cd046cf37aa974ce58
def hoard(self, count=1): <NEW_LINE> <INDENT> for item in [bag_of_hoarding.HoardItem() for i in range(int(count))]: <NEW_LINE> <INDENT> print(str(item))
Retrieve 1 or more random items from Whisper's Bag of Hoarding.
625941cd8da39b475bd65085
def test_href_to_each_place_eating(self): <NEW_LINE> <INDENT> for each_place in ("home", "school", "sangfor"): <NEW_LINE> <INDENT> response = self.client.get(self.unique_url) <NEW_LINE> self.assertContains(response, "{}{}".format(self.unique_url, each_place), msg_prefix="[-] 缺少指向 {} 的链接".format(each_place))
测试首页有链接到各个地方吃饭计划表的按钮
625941cda8ecb033257d31de
def _postprocess_sparql_result(self, sparql_result): <NEW_LINE> <INDENT> csv_lines = sparql_result.splitlines() <NEW_LINE> csv_lines.insert(1, SparqlCEHelper._create_type_mapping_line(sparql_result)) <NEW_LINE> return "\n".join(csv_lines)
Subclass implementation for Christiane's outlier detection algorithm. Adds an additional line for identifiers to the sparql-result for Christiane's outier detection algorithm. :param sparql_result: Sparql-result in csv-format :return: str the input for Christianes outlier detection algorithm Raises...
625941cd090684286d50edf6
def save(self, filename): <NEW_LINE> <INDENT> if filename[-4:] != ".pkl": <NEW_LINE> <INDENT> filename = filename + ".pkl" <NEW_LINE> <DEDENT> with open(filename, 'wb') as f: <NEW_LINE> <INDENT> pickle.dump(self, f)
Saves the instance object to a file in pickle format filename is the file to which the object should be saved If filename does not have the extension .pkl, add it
625941cdcb5e8a47e48b7bbb
def findMaxLength(self, nums): <NEW_LINE> <INDENT> dic=dict() <NEW_LINE> count=0 <NEW_LINE> m=0 <NEW_LINE> dic[0]=-1 <NEW_LINE> for i,v in enumerate(nums): <NEW_LINE> <INDENT> if v==0: <NEW_LINE> <INDENT> count-=1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> count+=1 <NEW_LINE> <DEDENT> if count in dic: <NEW_LINE> <IN...
:type nums: List[int] :rtype: int
625941cd67a9b606de4a7fca
def bernoulli_pow(odd, p, a=0.5, q=None): <NEW_LINE> <INDENT> if q is None: <NEW_LINE> <INDENT> q = 1 - p <NEW_LINE> <DEDENT> P = np.power(p, 1 / a) <NEW_LINE> Q = np.power(q, 1 / a) <NEW_LINE> return 1 / (1 + Q * odd / (P * np.power(odd - 1, 1 / a) - Q))
Solution for the power case: utility function: u(x) = (x^(1-a) - 1) / (1 - a)
625941cd3317a56b86939d69
def load_annotations(directory): <NEW_LINE> <INDENT> annotations_files = os.listdir(directory) <NEW_LINE> annotations_files.sort() <NEW_LINE> print("\nLoading annotations into memory...") <NEW_LINE> roots = [ET.parse(os.path.join(directory, ann_file)).getroot() for ann_file in tqdm(annotations_files)] <NEW_LINE> return...
Given VOC annotations directory, load all annotations Parameters ---------- dir: directory of xml annotation files Return ------ roots: list of all annotation roots
625941cd97e22403b379d0aa
def getExitCode(self): <NEW_LINE> <INDENT> return self.__exit_code
Return exit code
625941cdbde94217f3682f02
def search_file(filename, search_path): <NEW_LINE> <INDENT> for path in search_path.split(':'): <NEW_LINE> <INDENT> candidate = os.path.join(path, filename) <NEW_LINE> if os.path.exists(candidate): <NEW_LINE> <INDENT> return os.path.abspath(candidate) <NEW_LINE> <DEDENT> <DEDENT> return None
Given a search path, find file with requested name
625941cd1f5feb6acb0c4c61
def pkgsplit(mypkg, silent=1, eapi=None): <NEW_LINE> <INDENT> catpsplit = catpkgsplit(mypkg, eapi=eapi) <NEW_LINE> if catpsplit is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> cat, pn, ver, rev = catpsplit <NEW_LINE> if cat is _missing_cat and "/" not in mypkg: <NEW_LINE> <INDENT> return (pn, ver, rev) <NE...
@param mypkg: either a pv or cpv @return: 1. None if input is invalid. 2. (pn, ver, rev) if input is pv 3. (cp, ver, rev) if input is a cpv
625941cd56ac1b37e62642e0
def test_mul_casting_reversed(self): <NEW_LINE> <INDENT> self.assert_( 3 * Q(1, 2) == Q(3, 2) ) <NEW_LINE> self.assert_( P(-1, 1) * R(P(2), P(1, 1)) == R(P(-2, 2), P(1, 1)) )
Multiplication: automatic casting of left factor
625941cd91af0d3eaac9bb2a
def test_no_formatting(self): <NEW_LINE> <INDENT> app = flask.Flask(__name__) <NEW_LINE> babel.Babel(app) <NEW_LINE> with app.test_request_context(): <NEW_LINE> <INDENT> assert gettext(u'Test %s') == u'Test %s' <NEW_LINE> assert gettext(u'Test %(name)s', name=u'test') == u'Test test' <NEW_LINE> assert gettext(u'Test %s...
Ensure we don't format strings unless a variable is passed.
625941cd99fddb7c1c9de4a2
def totalize_result(result_df,byQuery=False): <NEW_LINE> <INDENT> def format_count(count_df): <NEW_LINE> <INDENT> count_df=count_df.fillna(0) <NEW_LINE> category_lst=get_category() <NEW_LINE> count_df[category_lst]=count_df[category_lst].astype(int) <NEW_LINE> count_df=count_df[["thres"]+category_lst] <NEW_LINE> return...
totalize #query for each category
625941cd5510c4643540f4f5
def __len__(self): <NEW_LINE> <INDENT> return len(self._data)
Length
625941cd32920d7e50b282e1
def main(): <NEW_LINE> <INDENT> page_size = 1000 <NEW_LINE> creds = None <NEW_LINE> if os.path.exists('../vault/token.pickle'): <NEW_LINE> <INDENT> with open('../vault/token.pickle', 'rb') as token: <NEW_LINE> <INDENT> creds = pickle.load(token) <NEW_LINE> <DEDENT> <DEDENT> if not creds or not creds.valid: <NEW_LINE> <...
Shows basic usage of the Drive v3 API. Prints the names and ids of all files the user has access to, in passes Assumes all files can be managed in single session
625941cd57b8e32f524835ac
def execDevReplay(code: str, pattern: str) -> str: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> out = Popen(['devreplay', '--fix', code, pattern], stdin=PIPE, stdout=PIPE) <NEW_LINE> stdout, _ = out.communicate() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> s = stdout.decode('utf-8') <N...
Return fixed source code `code` is path of the prefixed source code file `pattern` is path of devreplay pattern file
625941cd009cb60464c634c2
def exec_command(self, cmd): <NEW_LINE> <INDENT> ssh = self._get_ssh_connection() <NEW_LINE> transport = ssh.get_transport() <NEW_LINE> channel = transport.open_session() <NEW_LINE> channel.fileno() <NEW_LINE> channel.exec_command(cmd) <NEW_LINE> channel.shutdown_write() <NEW_LINE> out_data = [] <NEW_LINE> err_data = [...
Execute the specified command on the server. Note that this method is reading whole command outputs to memory, thus shouldn't be used for large outputs. :returns: data read from standard output of the command. :raises: SSHExecCommandFailed if command returns nonzero status. The exception contains command sta...
625941cd4c3428357757c439
def open(self, device_id): <NEW_LINE> <INDENT> if self.opened: <NEW_LINE> <INDENT> raise Exception("A joystick is already opened") <NEW_LINE> <DEDENT> self.device_id = device_id <NEW_LINE> self.jsfile = open("/dev/input/js{}".format(self.device_id), "r") <NEW_LINE> fcntl.fcntl(self.jsfile.fileno(), fcntl.F_SETFL, os.O_...
Open the joystick device. The device_id is given by available_devices
625941cd23849d37ff7b31a0
def event(value): <NEW_LINE> <INDENT> def add_attribute(function): <NEW_LINE> <INDENT> function.event = value <NEW_LINE> return function <NEW_LINE> <DEDENT> return add_attribute
Decorator. Equivalent to func.event = value. This is one of a number of events, such as 'JOIN', 'PART', 'QUIT', etc. (More details can be found in RFC 1459.) When the Skrizz bot is sent one of these events, the function will execute. Note that functions with an event must also be given a rule to match (though it may b...
625941cd3eb6a72ae02ec5ee
def getRowStart(self, pos): <NEW_LINE> <INDENT> return int(math.floor(pos/9) * 9)
Gets the left most (row beginning) position for a given pos Returns: int
625941cdf9cc0f698b14070d
def RunCommand(self): <NEW_LINE> <INDENT> self.continue_on_error = False <NEW_LINE> if self.sub_opts: <NEW_LINE> <INDENT> for o, unused_a in self.sub_opts: <NEW_LINE> <INDENT> if o == '-f': <NEW_LINE> <INDENT> self.continue_on_error = True <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> did_some_work = False <NEW_LINE> some_fail...
Command entry point for the rb command.
625941cde5267d203edcddae
def clear(self): <NEW_LINE> <INDENT> self.env_modifications = []
Clears the current list of modifications
625941cd3346ee7daa2b2e7d
def store_lds(width=None, cumheight=None, spass=0, lds=None, R=None, thread=None, offset_lds=None, lstride=None, **kwargs): <NEW_LINE> <INDENT> stmts = StatementList() <NEW_LINE> for w in range(width): <NEW_LINE> <INDENT> idx = offset_lds + B(B(thread / cumheight) * (width * cumheight) + thread % cumheight + w * cumhei...
Store registers 'R' to LDS 'X'.
625941cd4a966d76dd551121
def setUp(self): <NEW_LINE> <INDENT> self.flag_verbose = args.verbose
Toggle verbose using the command line.
625941cd097d151d1a222f6b
def __init__(self, x, y): <NEW_LINE> <INDENT> if type(y) not in (int, float, Decimal): <NEW_LINE> <INDENT> raise OperatorError("supported operand only in types int,float" " for Div Operator of Money") <NEW_LINE> <DEDENT> y = Decimal(y) <NEW_LINE> self.x, self.y = x, y
@param Expression x @param int,float y
625941cd9c8ee82313fbb887
def judge_no_crawler(supervise_path): <NEW_LINE> <INDENT> filepath = supervise_path + get_now_date() <NEW_LINE> file_size = os.path.getsize(filepath) <NEW_LINE> if file_size == 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
判断制定目录下,制定文件大小为0 :return: 返回真
625941cd498bea3a759b9bc0
def calculate_LCR(model, x_train: list, index: int, model_mutants: list, num_class: int = 10): <NEW_LINE> <INDENT> L = [] <NEW_LINE> for c in range(num_class): <NEW_LINE> <INDENT> L.append(index[c]) <NEW_LINE> <DEDENT> L = np.concatenate(L, axis = 0) <NEW_LINE> model.load_weights('cifar10resnet_weights.h5') <NEW_LINE> ...
Function: calculate the label change rate of a model using its mutants Inputs: a model, its mutants and a training set to evaluate prediction stability Outputs: LCR corresponding to each prediction
625941cdbe7bc26dc91cd711
def getRowReadTime(self): <NEW_LINE> <INDENT> return self._getSomethingSimple(self.at.getFloat, Features.RowReadTime)
Gets the current value of RowReadTime. Returns ------- float The current value of RowReadTime.
625941cd442bda511e8be529
def display_cputype(self): <NEW_LINE> <INDENT> if self.cputype == CPU_TYPE_POWERPC: <NEW_LINE> <INDENT> return "ppc" <NEW_LINE> <DEDENT> elif self.cputype == CPU_TYPE_POWERPC64: <NEW_LINE> <INDENT> return "ppc64" <NEW_LINE> <DEDENT> elif self.cputype == CPU_TYPE_I386: <NEW_LINE> <INDENT> return "i386" <NEW_LINE> <DEDEN...
Return the string to display based on its cputype number.
625941cd435de62698dfdd5e
def test_preferred_origin(self, catalogs=None): <NEW_LINE> <INDENT> for cat in catalogs or make_diverse_catalog_list(): <NEW_LINE> <INDENT> preferred_origin = cat[0].preferred_origin() <NEW_LINE> assert preferred_origin is not None <NEW_LINE> assert preferred_origin is cat[0].origins[-1]
Test preferred_origin is set and event scoped.
625941cdf8510a7c17cf980e
def check_dih_type(self): <NEW_LINE> <INDENT> warning_message = "***Warning: Odd dihedral-type-parameter found. Check if parameter is o.k." <NEW_LINE> if self.prm_k > 1: <NEW_LINE> <INDENT> print(warning_message) <NEW_LINE> <DEDENT> if int(self.prm_d) not in (180, 0): <NEW_LINE> <INDENT> print(warning_message)
Check if something is odd with the force-field parameters (currently only eV-units are supported).
625941cd63d6d428bbe44601
def fetch_feed(webcast_url): <NEW_LINE> <INDENT> yt_url = get_yt_url(webcast_url) <NEW_LINE> try: <NEW_LINE> <INDENT> response = urllib2.urlopen(yt_url) <NEW_LINE> <DEDENT> except urllib2.HTTPError as e: <NEW_LINE> <INDENT> print("Failed to fetch Atom feed; error was:") <NEW_LINE> print(e) <NEW_LINE> return False <NEW_...
Returns the feedparser representation of the Atom feed.
625941cd5166f23b2e1a526a
def quota_update_for_user(context, user_id, project_id, resource, limit): <NEW_LINE> <INDENT> return IMPL.quota_update_for_user(context, user_id, project_id, resource, limit)
Update a quota or raise if it does not exist.
625941cd462c4b4f79d1d7e2
def testAddReport(self): <NEW_LINE> <INDENT> title = 'A report' <NEW_LINE> id = self.survey.addReport(title=title) <NEW_LINE> report = self.survey._getOb(id, None) <NEW_LINE> self.assertNotEqual(report, None) <NEW_LINE> self.assert_(isinstance(report, SurveyReport)) <NEW_LINE> self.assertEqual(report.getLocalAttribute(...
Add report
625941cde1aae11d1e749dc9
def Connect(self, host, type='http', timeout=30 ): <NEW_LINE> <INDENT> if type == 'http': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.httpclient = httplib.HTTPConnection(host, 80, timeout) <NEW_LINE> return const.OPERATE_SUCCESS <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return const.OPERATE_FAILURE <NEW_LIN...
@summary:连接http服务器,支持以http和https两种方式进行连接。 @param host:网址或者IP地址。 @param timeout:连接超时时间。 @param type:连接类型,http或https。 @return:操作成功则返回1,否则返回-1。
625941cdd268445f265b4f7f
def test_create_support_system_dataclass_matrix(self): <NEW_LINE> <INDENT> support_system_dataclass_matrix = SupportSystemDataclassMatrix() <NEW_LINE> query_string = [('account_id_session', 789), ('token', 'token_example')] <NEW_LINE> response = self.client.open('/projects/{project_id}/matrices/supportsystemdataclass'....
Test case for create_support_system_dataclass_matrix Create new support system X dataclass matrix
625941cd627d3e7fe0d68f61
def test_case2(self): <NEW_LINE> <INDENT> urls = url + "/v1/pc/communication/sysMsgPush/createSysMsg/" <NEW_LINE> headers = { "Authorization": a_token } <NEW_LINE> data = { 'content': '', 'title': '', } <NEW_LINE> r = requests.post(urls, data=data, headers=headers) <NEW_LINE> di = json.loads(r.text) <NEW_LINE> assert d...
创建系统消息失败——不填写内容
625941cdf548e778e58cd68f
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self.response_string <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x.encode('utf-8') <NEW_LINE> length = len(_x) <NEW_LINE> <DEDENT> buff.write(struct.pack('<I%ss'%length, leng...
serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module
625941cd956e5f7376d70f7f
def on_config_update(self, key, op, data): <NEW_LINE> <INDENT> if key != SERVER_KEY: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> cfg_data = _update_entry(dflt_cfg_ser, data) <NEW_LINE> if self.cfg_server == cfg_data: <NEW_LINE> <INDENT> log_debug("No change in server config") <NEW_LINE> return <NEW_LINE> <DEDENT> lo...
On config update
625941cdc432627299f04d57
def set_max_space(self, new_space): <NEW_LINE> <INDENT> if isinstance(new_space, int): <NEW_LINE> <INDENT> if new_space == 0: <NEW_LINE> <INDENT> raise ValueError("the space cant be 0") <NEW_LINE> <DEDENT> if new_space < 0: <NEW_LINE> <INDENT> raise ValueError("the space cant be a negative") <NEW_LINE> <DEDENT> if new_...
| set new max space for the parking lot :param new_space: the new max space
625941cd1b99ca400220abc3
def update_client(self, client_id, client_name): <NEW_LINE> <INDENT> with self.DbConCursor() as dbc: <NEW_LINE> <INDENT> dbc.execute("UPDATE clients SET clientName = ? WHERE clientId = ?", ([client_name, client_id]))
Update client name :param client_id: :param client_name: :return: void
625941cd26068e7796caedf0
def decodeInvoker(self, invoker): <NEW_LINE> <INDENT> assert isinstance(invoker, Invoker), 'Invalid invoker %s' % invoker <NEW_LINE> children, ordered = {}, {} <NEW_LINE> for inp in invoker.inputs: <NEW_LINE> <INDENT> assert isinstance(inp, Input) <NEW_LINE> typeInp = inp.type <NEW_LINE> assert isinstance(typeInp, Type...
Create a decode exploit for the invoker. @param invoker: Invoker The invoker to create a parameters decoder for. @return: callable(**data) -> boolean The exploit that provides the invoker decoding.
625941cdb57a9660fec33995
def get(self, param, default=None): <NEW_LINE> <INDENT> info = self.info() <NEW_LINE> try: <NEW_LINE> <INDENT> return info[param] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return default
Returns a property of this instance
625941cdab23a570cc250294
def cmdLineParse(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser( description='log ratio') <NEW_LINE> parser.add_argument('-mdir', dest='mdir', type=str, required=True, help = 'master directory containing the bursts') <NEW_LINE> parser.add_argument('-sdir', dest='sdir', type=str, required=True, help = 'slave di...
Command line parser.
625941cd442bda511e8be52a
def initialize_facebook(url: str, username: str, password: str) -> 'WebDriver': <NEW_LINE> <INDENT> browser = webdriver.Firefox() <NEW_LINE> browser.get('http://www.facebook.com') <NEW_LINE> user = browser.find_element_by_id(ID['email']) <NEW_LINE> pass_ = browser.find_element_by_id(ID['pass']) <NEW_LINE> user.send_key...
Returns a Selenium WebDriver after initializing it through Firefox, logging in on Facebook with username and password, and heading to url.
625941cd4e4d5625662d44e9
def on_channel_open(self, channel): <NEW_LINE> <INDENT> LOGGER.info('[RabbitMqClient] Channel opened : %s ' % channel) <NEW_LINE> self._status = 2 <NEW_LINE> self._channel = channel <NEW_LINE> self.add_on_channel_close_callback() <NEW_LINE> self.setup_exchange()
This method is invoked by pika when the channel has been opened. The channel object is passed in so we can make use of it. Since the channel is now open, we'll declare the exchange to use. :param channel: The channel object :type channel: pika.channel.Channel
625941cdac7a0e7691ed41de
def get_allowed(self): <NEW_LINE> <INDENT> allowed_json = self._get_account_info_or_raise('allowed') <NEW_LINE> if allowed_json is None: <NEW_LINE> <INDENT> return self.DEFAULT_ALLOWED <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return json.loads(allowed_json)
Return 'allowed' dictionary info. The 'allowed' column was not in the original schema, so it may be NULL. :rtype: dict
625941cd7b180e01f3dc490e
def _initpumps(self, setup_pumps): <NEW_LINE> <INDENT> if setup_pumps is None: <NEW_LINE> <INDENT> if not self.pumps: <NEW_LINE> <INDENT> self.pump_sizer.Remove(0) <NEW_LINE> <DEDENT> setup_pumps = [('Sheath', 'VICI M50', 'COM3', ['629.88', '13.381'], {}, {}), ('Outlet', 'VICI M50', 'COM4', ['626.36', '10.109'], {}, {}...
This is a convenience function for initalizing pumps on startup, if you already know what pumps you want to add. You can comment it out in the ``__init__`` if you want to not load any pumps on startup. If you want to add pumps here, add them to the ``setup_pumps`` list. Each entry should be an iterable with the follow...
625941cd099cdd3c635f0d6c
def CalculateDiags(self, square): <NEW_LINE> <INDENT> def upright(square): <NEW_LINE> <INDENT> n, m = square <NEW_LINE> A = [] <NEW_LINE> def testend(a, b): <NEW_LINE> <INDENT> if (a == 7 or b == 7): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False <NEW_LINE> <DEDENT> while not testend(n, m): <NEW_LINE>...
Calculates diagonals expanding outwards from a square. Accepts tuple for the square position. Returns List of 4 Lists There are 1,2,3 or 4 diagonals depending on where the square is. [[1],[2],[3],[4]] -> 1. Up and towards the right. 2. Down and towards the right. 3. Up and towards the left. 4. Down an...
625941cdbaa26c4b54cb1231
def ftpSyncFinished(self): <NEW_LINE> <INDENT> if self.proc.exitStatus() == 0: <NEW_LINE> <INDENT> self.dlg.ui.outLog.append(QApplication.translate("lizmap", "log.sync.completed")) <NEW_LINE> self.dlg.ui.outState.setText(QApplication.translate("lizmap", "log.outState.completed")) <NEW_LINE> <DEDENT> else: <NEW_LINE> <I...
Loaded when the sync process has finished its job.
625941cd26238365f5f0ef80
def __len__(self): <NEW_LINE> <INDENT> return len(self._token_to_idx)
返回字典的长度
625941cda8370b77170529b1
def capture_warning(msg): <NEW_LINE> <INDENT> warnings.append(msg)
A fake implementation of Coverage._warn, to capture warnings.
625941cd6e29344779a62724
def tomat(N, ifc, tmpdir="/tmp"): <NEW_LINE> <INDENT> norbt = ifc.norbt <NEW_LINE> new = full.matrix((norbt, norbt)) <NEW_LINE> lwop = len(N) // 2 <NEW_LINE> for ij, (i, j) in enumerate(jwop(ifc)): <NEW_LINE> <INDENT> new[i, j] = N[ij] <NEW_LINE> new[j, i] = N[ij + lwop] <NEW_LINE> <DEDENT> return new
Vector to matrix
625941cd0a50d4780f666fa4
def compute_mu_for_component(graph, component_index, source_index, root, vertices_in_component): <NEW_LINE> <INDENT> mu_for_component = root.children[0] <NEW_LINE> for index in range(source_index): <NEW_LINE> <INDENT> if (mu_for_component == root.children[index] and is_component_connected(graph, component_index, index,...
Compute the mu value for component INPUT: - ``graph`` -- Graph whose MD tree needs to be computed - ``component_index`` -- index of the component - ``source_index`` -- index of the source in the forest - ``root`` -- the forest which needs to be assembled into a MD tree - ``vertices_in_component`` -- dictionary wh...
625941cd6e29344779a62723
def make_env(scenario_name, benchmark=False): <NEW_LINE> <INDENT> from multiagent.environment import MultiAgentEnv <NEW_LINE> import multiagent.scenarios as scenarios <NEW_LINE> scenario = scenarios.load(scenario_name + ".py").Scenario() <NEW_LINE> world = scenario.make_world() <NEW_LINE> world.dim_c = 0 <NEW_LINE> if ...
Creates a MultiAgentEnv object as env. This can be used similar to a gym environment by calling env.reset() and env.step(). Use env.render() to view the environment on the screen. Input: scenario_name : name of the scenario from ./scenarios/ to be Returns (without the .py extension) ...
625941cd711fe17d8254247d
def volumeChangeLoad(h, topo): <NEW_LINE> <INDENT> if h > 0: <NEW_LINE> <INDENT> hw = (h - np.maximum(0, topo)) * (h > topo) <NEW_LINE> <DEDENT> elif h < 0: <NEW_LINE> <INDENT> hw = (np.maximum(topo, h)) * (topo < 0) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> hw = 0*topo <NEW_LINE> <DEDENT> return hw
Compute ocean depth changes for a topographic shift h, consistent with sloping topographies. Parameters ---------- h : float The topographic shift. topo : np.ndarray The topography to shift. (Altered topography is T - h) Returns ------- hw : np.ndarray An array with shape topo.shape whose maximum magnitud...
625941cd26068e7796caedf1
@only_plone_4 <NEW_LINE> def select(*objects, **kwargs): <NEW_LINE> <INDENT> browser = kwargs.pop('browser', default_browser) <NEW_LINE> assert not kwargs, 'Invalid keyword arguments: {!r}'.format(kwargs) <NEW_LINE> select_rows([row_by_object(obj, browser=browser) for obj in objects])
Selects the checkboxes on one or more rows by objects. :param objects: List of Plone objects to select. :type objects: list of Plone objects :param browser: A browser instance. (Default: global browser) :type browser: :py:class:`ftw.testbrowser.core.Browser`
625941cd6aa9bd52df036eb6
def fuel_required(mass: int) -> int: <NEW_LINE> <INDENT> return int(mass / 3) - 2
Calculate the fuel required given mass of module to be launched.
625941cd45492302aab5e3d5
def helm_extra_vars( version=None, config_yaml=None, env_vars=None, preserve=None, verbose=False ): <NEW_LINE> <INDENT> extra_vars_string = "" <NEW_LINE> if version: <NEW_LINE> <INDENT> extra_vars_string += " --version {}".format(version) <NEW_LINE> <DEDENT> if config_yaml: <NEW_LINE> <INDENT> if isinstance(config_yaml...
Centralise obtaining extra variables for our helm_install and/or helm_upgrade Args: version (str): Which Chart version do we wish to install? config_yaml (str, Iterable): Values file(s) to override defaults. env_vars (Iterable): Environmental variables we wish to store in Helm. preserve (Iterable): Set...
625941cd1d351010ab855c2d
def pos(self, axes=None): <NEW_LINE> <INDENT> axis_list = self._check_axislist(axes) <NEW_LINE> self._check_loaded(axis_list) <NEW_LINE> self._check_sync(axis_list) <NEW_LINE> cmd = "?PARPOS" <NEW_LINE> cmds = {} <NEW_LINE> pars = [] <NEW_LINE> for axis in axis_list: <NEW_LINE> <INDENT> system = axis.system() <NEW_LIN...
Returns the current position on the trajectory. The position is a parameter value.
625941cd4428ac0f6e5ba904
def __init__(self, client, options, fetch_function): <NEW_LINE> <INDENT> super(_DefaultQueryExecutionContext, self).__init__(client, options) <NEW_LINE> self._fetch_function = fetch_function
:param CosmosClient client: :param dict options: The request options for the request. :param method fetch_function: Will be invoked for retrieving each page Example of `fetch_function`: >>> def result_fn(result): >>> return result['Databases']
625941cdd486a94d0b98e257
def __delitem__(self, key): <NEW_LINE> <INDENT> del self._data[key]
Delete a field in the dataset.
625941cdbf627c535bc132e1
def get_entity_loaded_propnames(entity): <NEW_LINE> <INDENT> ins = inspect(entity) <NEW_LINE> keynames = get_entity_propnames(ins) <NEW_LINE> if not ins.transient: <NEW_LINE> <INDENT> keynames -= ins.unloaded <NEW_LINE> <DEDENT> if ins.expired: <NEW_LINE> <INDENT> keynames |= ins.expired_attributes <NEW_LINE> <DEDENT> ...
Get entity property names that are loaded (e.g. won't produce new queries) :param entity: Entity :type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta :returns: Set of entity property names :rtype: set
625941cddc8b845886cb5647
def testFinished(self): <NEW_LINE> <INDENT> self.remainingCount -= 1 <NEW_LINE> self.runCount += 1 <NEW_LINE> self.progressCounterRunCount.setText(str(self.runCount)) <NEW_LINE> self.progressCounterRemCount.setText(str(self.remainingCount)) <NEW_LINE> if self.errorCount: <NEW_LINE> <INDENT> self.__setProgressColor("red...
Public method called if a test has finished. <b>Note</b>: It is also called if it has already failed or errored.
625941cd30c21e258bdfa5af
def insert_data(cursor): <NEW_LINE> <INDENT> lessons = ( (1, 'Python standard library'), (2, 'Bootstrap project'), (3, 'WSGI & DB-API'), ) <NEW_LINE> cursor.executemany('INSERT INTO lessons VALUES (?, ?);', lessons) <NEW_LINE> students = ( (1, 'Alexandr Kobzar', 'maodzedun@gmail.com'), (2, 'Ivan Tolkach', 'ivan@tolkach...
Insert initial data.
625941cdeab8aa0e5d26dc6a
def test_has__edit_rec_perms(self): <NEW_LINE> <INDENT> perms = [x.codename for x in self.user.user_permissions.all()] <NEW_LINE> self.assertIn('change_recipe', perms)
Test that user has permission to edit a recipe.
625941cd50485f2cf553ceac