code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_head(self) : <NEW_LINE> <INDENT> return int(self.full_label[HEAD]) - 1 | get head idx in sentence | 625941ee6aa9bd52df0372f5 |
def main(): <NEW_LINE> <INDENT> if os.getenv('SERVER_NAME'): <NEW_LINE> <INDENT> print("Content-type: text/html\n\n") <NEW_LINE> print(response(cgi.FieldStorage())) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> import webbrowser <NEW_LINE> import cgitb <NEW_LINE> cgitb.enable() <NEW_LINE> if sys.version_info[0] == 2: <... | Start web browser or print response. | 625941ee3346ee7daa2b32be |
def version(): <NEW_LINE> <INDENT> version = settings.VERSION <NEW_LINE> services = 1 <NEW_LINE> timestamp = int(time.time()) <NEW_LINE> source_address = b'\x00'*26 <NEW_LINE> destination_address = b'\x00'*26 <NEW_LINE> nonce = random.getrandbits(64) <NEW_LINE> sub_version_num = b'\x00' <NEW_LINE> start_height = 0 <NEW... | Advertize version, this message is mandatory and must be the first message.
The remote node will respond with its own version, additionally further communication
will only be possible if the remote peer responds with a "verack". | 625941ee8da39b475bd654c8 |
def get_img_ids(img_files, return_channel = False): <NEW_LINE> <INDENT> channel_re = re.compile('^w\d+[A-Za-z]*[ .]') <NEW_LINE> img_ids = [] <NEW_LINE> channels = [] <NEW_LINE> for img in img_files: <NEW_LINE> <INDENT> print('_______________________________________________________') <NEW_LINE> print(' generating i... | Extracts image filenames lacking wavelength identifiers. | 625941ee4f6381625f114f88 |
def p_product(self, arg): <NEW_LINE> <INDENT> (_0, fields, _1) = arg <NEW_LINE> fields.reverse() <NEW_LINE> return Product(fields) | product ::= ( fields ) | 625941eea17c0f6771cbe59c |
def read_data_shape(self): <NEW_LINE> <INDENT> return self.get_data_shape('data') | Expose shape read on field data' | 625941ee3eb6a72ae02eca3a |
def get_full_name(self): <NEW_LINE> <INDENT> if self._full_name is None: <NEW_LINE> <INDENT> raise NotLoggedIn() <NEW_LINE> <DEDENT> return self._full_name | Returns the users full name | 625941ee5fc7496912cc3ecb |
def train(self, mains, meter, epochs=1, batch_size=128, start=None, end=None, **load_kwargs): <NEW_LINE> <INDENT> main_power_series = mains.power_series(**load_kwargs) <NEW_LINE> meter_power_series = meter.power_series(**load_kwargs) <NEW_LINE> run = True <NEW_LINE> mainchunk = next(main_power_series) <NEW_LINE> meterc... | Train
Parameters
----------
mains : a nilmtk.ElecMeter object for the aggregate data
meter : a nilmtk.ElecMeter object for the meter data
epochs : number of epochs to train
batch_size : size of batch used for training
**load_kwargs : keyword arguments passed to `meter.power_series()` | 625941eebd1bec0571d90b7c |
def generate_url_google_maps(self, complete_address, zip_code): <NEW_LINE> <INDENT> _base_gm_url = "https://maps.google.com/?q=%s,%s" <NEW_LINE> _google_url = _base_gm_url % (complete_address, zip_code) <NEW_LINE> return _google_url.replace(' ', '+') | Return a Google Maps Url Address | 625941ee99fddb7c1c9de8db |
def setOfWords2Vec(vocabList , inputSet): <NEW_LINE> <INDENT> returnVec = [0]*len(vocabList) <NEW_LINE> for word in inputSet: <NEW_LINE> <INDENT> if word in vocabList: <NEW_LINE> <INDENT> returnVec[vocabList.index(word)] = 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print ("the word : %s is not in my Vocabulary") %... | input one line | 625941ee9f2886367277add6 |
def copy(self, deep=True): <NEW_LINE> <INDENT> data = self._data <NEW_LINE> if deep: <NEW_LINE> <INDENT> data = data.copy() <NEW_LINE> <DEDENT> return GeoDataFrame(data)._propogate_attributes(self) | Make a copy of this GeoDataFrame object
Parameters
----------
deep : boolean, default True
Make a deep copy, i.e. also copy data
Returns
-------
copy : GeoDataFrame | 625941ee4c3428357757c872 |
def cleanTempMakefile(paths: Paths): <NEW_LINE> <INDENT> makefile = mkf.Makefile() <NEW_LINE> try: <NEW_LINE> <INDENT> with open(paths.tmpMakefile, 'r') as makefileHandler: <NEW_LINE> <INDENT> data = makefileHandler.readlines() <NEW_LINE> <DEDENT> data = makefile.searchAndCleanData(data, makefile.mkfStr.cSources) <NEW_... | Clean default generated Makefile data (sources, includes, names, ...). | 625941ee5510c4643540f924 |
def get_swagger_view(title=None, url=None, patterns=None, urlconf=None): <NEW_LINE> <INDENT> class SwaggerSchemaView(APIView): <NEW_LINE> <INDENT> _ignore_model_permissions = True <NEW_LINE> exclude_from_schema = True <NEW_LINE> permission_classes = [AllowAny] <NEW_LINE> renderer_classes = [ CoreJSONRenderer, renderers... | Returns schema view which renders Swagger/OpenAPI. | 625941ee32920d7e50b28722 |
def build_all_caches(self): <NEW_LINE> <INDENT> print("Building/updating station cache...") <NEW_LINE> self.comm.stations.file_count <NEW_LINE> for event in self.comm.events.list(): <NEW_LINE> <INDENT> print("Building/updating data cache for event '%s'..." % event) <NEW_LINE> try: <NEW_LINE> <INDENT> self.comm.waveform... | Command to build/update all caches. | 625941eed18da76e23532a2b |
def get_item(self, i): <NEW_LINE> <INDENT> if self._rows == 1 and self._columns > 1: <NEW_LINE> <INDENT> return self.get_val(0, i) <NEW_LINE> <DEDENT> elif self._rows > 1 and self._columns == 1: <NEW_LINE> <INDENT> return self.get_val(i, 0) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise MatrixDimensionError | (OneDimensionalMatrix, int) -> float
Return the i'th item in this matrix | 625941ee24f1403a926010af |
def _read_config_files(self, config_files): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> f_read = self._config.read(config_files) <NEW_LINE> <DEDENT> except configparser.Error as e: <NEW_LINE> <INDENT> msg = 'Problem parsing config file(s): {}' <NEW_LINE> raise ConfigError(msg.format(e)) <NEW_LINE> <DEDENT> problem_fil... | Read a list of config files | 625941eebaa26c4b54cb1668 |
def calculate_azimuth(self, exact=True): <NEW_LINE> <INDENT> x, y = np.gradient(self._data, abs(self._metadata['affine_transformation'][1]), abs(self._metadata['affine_transformation'][5]), edge_order=1,axis=None) if 'affine_transformation' in self._metadata else np.gradient(self._data) <NEW_LINE> aspect = np.degrees(... | Calculate azimuth from self data of DEM image. | 625941ee67a9b606de4a8404 |
def feature_match(self, specification): <NEW_LINE> <INDENT> if isinstance(specification,str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.features[specification[1:]]!=specification[0]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DE... | Return true if segment matches specification, false otherwise.
Specification can be a single feature value '+feature' or a list of
feature values ['+feature1','-feature2'] | 625941eebd1bec0571d90b7d |
def method_grad_bb(rgb, loss): <NEW_LINE> <INDENT> x = proj(rgb) <NEW_LINE> last_g, last_x = None, None <NEW_LINE> i = 0 <NEW_LINE> while last_x is None or np.mean(abs(x - last_x)) >= 1e-4: <NEW_LINE> <INDENT> if i >= 200: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> g = grad(loss, x) <NEW_LINE> if last_x is not None:... | Projected gradient descent with Barzilai-Borwein step size. | 625941ee91f36d47f21aca46 |
def test_activation(self): <NEW_LINE> <INDENT> self.failUnlessEqual(RegistrationProfile.activate_user( self.sample_user.activation_key).pk, self.sample_user.pk) <NEW_LINE> self.failUnless(User.objects.get(pk=self.sample_user.pk).is_active) <NEW_LINE> self.failUnlessEqual( RegistrationProfile.objects.get( user=self.samp... | Test that user activation actually activates the user and
properly resets the activation key, and fails for an
already-active or expired user, or an invalid key. | 625941ee6e29344779a62b5e |
def release_date(self): <NEW_LINE> <INDENT> try: return self.info.find('div', class_ = 'subtext').text.strip().split('\n')[-1] <NEW_LINE> except: return 'N/A' | The release date is processed here...
If the info is missing, 'N/A' will be output instead. | 625941ee31939e2706e4d3b0 |
def plotGeneration(self): <NEW_LINE> <INDENT> to_plot = self.__fitnesses <NEW_LINE> plt.plot(to_plot, 'g^') <NEW_LINE> plt.ylabel('fitness') <NEW_LINE> plt.xlabel('individual') <NEW_LINE> plt.show() <NEW_LINE> self.__fitnesses = [] | Plot average fitnesses after one run
:return: void | 625941eeb830903b967e9e53 |
def make_sound(self): <NEW_LINE> <INDENT> return self.sound.upper() * 2 | Return the sound the animal makes three times | 625941eedc8b845886cb5a85 |
def factor(n): <NEW_LINE> <INDENT> for x in range(2,math.floor(math.sqrt(n)+1)): <NEW_LINE> <INDENT> if n % x == 0: <NEW_LINE> <INDENT> print(n,'eq',x,'*', n//x) <NEW_LINE> n=n//x <NEW_LINE> factor(n) | print the factors of n | 625941ee7c178a314d6ef9b6 |
def update(self): <NEW_LINE> <INDENT> self.map_part_id_mid_secid_eosid = {} <NEW_LINE> for i in range(len(self.partID_label)): <NEW_LINE> <INDENT> self.map_part_id_mid_secid_eosid.update({self.partID_label[i].get():[int(self.partShell_label[i].get()), int(self.partMat_label[i].get()), int(self.partEOS_label[i].get())]}... | :return: | 625941eedd821e528d63b6f2 |
def get_match(match_id): <NEW_LINE> <INDENT> base_url = urls.GET_MATCHE.replace("{match_id}", str(match_id)) <NEW_LINE> full_url = __build_url(base_url) <NEW_LINE> try: <NEW_LINE> <INDENT> data = request.urlopen(full_url).read() <NEW_LINE> data_json = json.loads(data.decode('utf-8')) <NEW_LINE> <DEDENT> except: <NEW_LI... | Match data | 625941ee94891a1f4081bffa |
def set_telefone(self, novo_telefone: int) -> None: <NEW_LINE> <INDENT> if type(novo_telefone) is not int: <NEW_LINE> <INDENT> raise TypeError <NEW_LINE> <DEDENT> self.__telefone = novo_telefone | Mutador do atributo telefone, caso não receba um número,
gera um TypeError | 625941ee96565a6dacc8fc17 |
def ex_list_customer_images(self, location=None): <NEW_LINE> <INDENT> params = {} <NEW_LINE> if location is not None: <NEW_LINE> <INDENT> params['datacenterId'] = location.id <NEW_LINE> <DEDENT> return self._to_base_images( self.connection.request_with_orgId_api_2( 'image/customerImage', params=params) .object, 'custom... | Return a list of customer imported images
:param location: The target location
:type location: :class:`NodeLocation`
:rtype: ``list`` of :class:`NodeImage` | 625941ee6e29344779a62b5f |
def get_hour_angle_sunrise(self): <NEW_LINE> <INDENT> d = radians(self.declination) <NEW_LINE> lat = radians(self.lat) <NEW_LINE> self.hour_angle_sunrise = degrees(arccos((cos(radians(90.833)) / (cos(lat) * cos(d)) - tan(lat) * tan(d)))) <NEW_LINE> return self.hour_angle_sunrise | calculates the hour hangle of sunrise | 625941eeac7a0e7691ed4610 |
def put(self): <NEW_LINE> <INDENT> request = transforms.loads(self.request.get('request')) <NEW_LINE> key = request.get('key') <NEW_LINE> if not self.assert_xsrf_token_or_fail( request, 'announcement-put', {'key': key}): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not AnnouncementsRights.can_edit(self): <NEW_LINE... | Handles REST PUT verb with JSON payload. | 625941ee1b99ca400220b002 |
def info(self): <NEW_LINE> <INDENT> print(str(self)) | Print summary info. | 625941ee63d6d428bbe44a3f |
def get_sndiod_flags(): <NEW_LINE> <INDENT> raw = subprocess.check_output("rcctl get sndiod".split()) <NEW_LINE> flags = None <NEW_LINE> devices = None <NEW_LINE> for line in (x.strip() for x in raw.decode('utf8').split("\n")): <NEW_LINE> <INDENT> if "sndiod_flags" in line: <NEW_LINE> <INDENT> flags = '='.join(line.spl... | get_sndiod_flags
Get the currently configured sndiod flags via rcctl.
This function returns a tuple, the first element being a list of currently
configured devices (-f), and the second element being all other flags as a
string. | 625941ee1d351010ab856069 |
def __init__(self, mType, iofile): <NEW_LINE> <INDENT> self.T = mType <NEW_LINE> self.run = False <NEW_LINE> try : <NEW_LINE> <INDENT> self.s = open ( iofile, "r") <NEW_LINE> <DEDENT> except OSError as e: <NEW_LINE> <INDENT> raise Exception ("Unable to create mock! {}".format(str(e))) <NEW_LINE> <DEDENT> self._EUI = "0... | Constructor | 625941eed268445f265b53bd |
@takes(unicode) <NEW_LINE> @returns(str) <NEW_LINE> def translify(in_string): <NEW_LINE> <INDENT> translit = in_string <NEW_LINE> for symb_in, symb_out in TRANSTABLE: <NEW_LINE> <INDENT> translit = translit.replace(symb_in, symb_out) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> translit = str(translit) <NEW_LINE> <DEDE... | Translify russian text
@param in_string: input string
@type in_string: C{unicode}
@return: transliterated string
@rtype: C{str}
@raise L{pytils.err.InputParameterError}: input parameters' check failed
(in_string is not C{unicode})
@raise ValueError: when string doesn't transliterate completely | 625941eebde94217f368333a |
def getUnstablePct(self): <NEW_LINE> <INDENT> total = self.success + self.unstable + self.fail <NEW_LINE> return (float(self.unstable) / total) if total != 0 else 0 | generated source for method getUnstablePct | 625941ee097d151d1a2233a5 |
def initializeUniformly(self, gameState): <NEW_LINE> <INDENT> self.particlelist = [] <NEW_LINE> num = self.numParticles <NEW_LINE> while num>0: <NEW_LINE> <INDENT> for p in self.legalPositions: <NEW_LINE> <INDENT> if num > 0: <NEW_LINE> <INDENT> self.particlelist.append(p) <NEW_LINE> num = num-1 <NEW_LINE> <DEDENT> els... | Initializes a list of particles. Use self.numParticles for the number of particles | 625941ee6fece00bbac2dc93 |
def mensaje(self, mensaje_string): <NEW_LINE> <INDENT> cuerpo_mensaje = MIMEText(mensaje_string.decode(_CODIFICACION), 'plain', _CODIFICACION) <NEW_LINE> self._mensaje.attach(cuerpo_mensaje) <NEW_LINE> return self | Considera el mensaje a enviar desde un string Python | 625941eecc0a2c11143dd3e0 |
def upload_resource(assessor_obj, resource, resource_path): <NEW_LINE> <INDENT> if resource == 'SNAPSHOTS': <NEW_LINE> <INDENT> upload_snapshots(assessor_obj, resource_path) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rfiles_list = os.listdir(resource_path) <NEW_LINE> if not rfiles_list: <NEW_LINE> <INDENT> LOGGER.wa... | Upload a resource folder to an assessor
:param assessor_obj: pyxnat assessor Eobject
:param resource: resource to upload
:param resource_path: resource path on the station
:return: None | 625941ee99cbb53fe6793133 |
def translate(input_filepaths, output_format, output_dir): <NEW_LINE> <INDENT> if output_format not in OUTPUTTERS: <NEW_LINE> <INDENT> raise ValueError(f"Unknown output format '{output_format}'") <NEW_LINE> <DEDENT> all_metrics = parser.parse_metrics(input_filepaths) <NEW_LINE> found_error = False <NEW_LINE> for error ... | Translate the files in `input_filepaths` to the given `output_format` and
put the results in `output_dir`. | 625941ee21a7993f00bc8248 |
def test_delete_business(self): <NEW_LINE> <INDENT> url = reverse('delete_business', args=(self.business.pk,)) <NEW_LINE> response = self.client.get(url) <NEW_LINE> self.assertEquals(response.status_code, 200) <NEW_LINE> self.assertEquals(response.context['object'], self.business) <NEW_LINE> self.assertEquals(timepiece... | A superuser should be able to access the delete page | 625941ee283ffb24f3c55e4a |
def _generate_initial_gml_db(self): <NEW_LINE> <INDENT> axes_map = OrderedDict() <NEW_LINE> for axis, grid_axis in self.coverage.get_insert_axes().iteritems(): <NEW_LINE> <INDENT> if axis.coefficient is not None: <NEW_LINE> <INDENT> axis.coefficient = [axis.coefficient[0]] <NEW_LINE> <DEDENT> axes_map[axis] = GridAxis(... | Generates the initial slice in gml for importing using the database method and returns the gml for it
:rtype: File | 625941eefb3f5b602dac3be7 |
def writeList(self, reg, list): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.bus.write_i2c_block_data(self.address, reg, list) <NEW_LINE> <DEDENT> except IOError: <NEW_LINE> <INDENT> return self.errMsg() | Writes an array of bytes using I2C format | 625941ee67a9b606de4a8405 |
def X(self, Z): <NEW_LINE> <INDENT> return 0.4 + 0.6 * (1 - 0.96 * (np.sin(Z))**2)**(-0.5) | Note thatn Z must be <= pi/2, i.e. above the horizon! | 625941ee5e10d32532c5f473 |
def create_container_root(image_name, image_dir, container_id, container_dir): <NEW_LINE> <INDENT> image_path = _get_image_path(image_name, image_dir) <NEW_LINE> container_root = _get_container_path(container_id, container_dir, 'rootfs') <NEW_LINE> assert os.path.exists(image_path), "unable to locate image %s" % image_... | Create a container root by extracting an image into a new directory
Usage:
new_root = create_container_root(
image_name, image_dir, container_id, container_dir)
@param image_name: the image name to extract
@param image_dir: the directory to lookup image tarballs in
@param container_id: the unique container id
@para... | 625941ee498bea3a759b9ffc |
def run(self): <NEW_LINE> <INDENT> check_input_and_output_categories(self.input_data) <NEW_LINE> model_solution = self._create_solution() <NEW_LINE> self._create_lp() <NEW_LINE> for count, dmu_code in enumerate(self.input_data.DMU_codes): <NEW_LINE> <INDENT> self.run_for_one_DMU(dmu_code, model_solution) <NEW_LINE> sel... | Solves a given problem.
| 625941eecb5e8a47e48b7ff0 |
@utils.arg('iservicegroup', metavar='<iservicegroup id>', nargs='+', help="ID of iservicegroup") <NEW_LINE> def donot_servicegroup_delete(cc, args): <NEW_LINE> <INDENT> for c in args.iservicegroup: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> cc.smapiClient.iservicegroup.delete(c) <NEW_LINE> <DEDENT> except exc.HTTPNot... | Delete a servicegroup. | 625941ee56b00c62f0f14bab |
def read_distillate_model(distillate_filename): <NEW_LINE> <INDENT> return get_distillate_model(read_distillate(distillate_filename)) | Reads a distillation result file as LowDimensionalModel. | 625941eef548e778e58cdace |
def get_related_synsets(self,relation): <NEW_LINE> <INDENT> results = [] <NEW_LINE> for relation_candidate in self._raw_synset.internalLinks: <NEW_LINE> <INDENT> if relation_candidate.name == relation: <NEW_LINE> <INDENT> linked_synset = synset(_get_key_from_raw_synset(relation_candidate.target_concept)) <NEW_LINE> rel... | Retrieves all the synsets which are related by given relation.
Parameters
----------
relation : str
Name of the relation via which the sought synsets are linked.
Returns
-------
list of Synsets
Synsets which are related via `relation`. | 625941eea8ecb033257d3619 |
def __init__(self, parent=None, width=7, height=7, dpi=60): <NEW_LINE> <INDENT> figure = Figure(figsize=(width, height), dpi=dpi) <NEW_LINE> self.axes = figure.add_subplot(111) <NEW_LINE> FigureCanvas.__init__(self, figure) <NEW_LINE> self.setParent(parent) <NEW_LINE> FigureCanvas.setSizePolicy(self, QSizePolicy.Expand... | Constructor for GraphCanvas.
:param parent: Parent widget
:param width: Width of matplotlib graph
:param height: Height of matplotlib graph
:param dpi: DPI (Dots Per Inch) of graph | 625941ee44b2445a339325e0 |
def xrate(card, trans, fee, date, amount): <NEW_LINE> <INDENT> if card not in CURRENCIES: <NEW_LINE> <INDENT> raise VisaxratedException('Card currency %s not available.' % card) <NEW_LINE> <DEDENT> if trans not in CURRENCIES: <NEW_LINE> <INDENT> raise VisaxratedException('Transaction currency %s not available.' % trans... | Returns the exchenge rate (amount) from Visa. | 625941ee5fcc89381b1e1c12 |
def inner(*args, **kwargs): <NEW_LINE> <INDENT> if login(user_dict): <NEW_LINE> <INDENT> ret = f(*args, **kwargs) <NEW_LINE> return ret <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('Login Failed.') | 访问函数之前的操作, 功能 | 625941eecdde0d52a9e53586 |
def testFailedIFRLookup(self): <NEW_LINE> <INDENT> self.assertRaises(CannotGetComponentExImpl, BaciHelper.addProperty, self.victim, "Foo") | Raise CannotGetComponentExImpl if it cannot get the property type | 625941ee30dc7b7665901eae |
def read_enabled(orig_val): <NEW_LINE> <INDENT> val = orig_val.strip().lower() <NEW_LINE> return val == "enable" | :param orig_val: A string with either 'enable' or 'disable'. May
be surrounded by whitespace, and case doesn't
matter
:returns: True for 'enabled' and False for 'disabled' | 625941eec4546d3d9de72f87 |
def save_df2table(table_name: str, df: pd.DataFrame, fields: list): <NEW_LINE> <INDENT> st.info(f'Appending rows from dataframe to table {table_name}') <NEW_LINE> ok = save_db_table(table_name, df, fields) <NEW_LINE> if ok: <NEW_LINE> <INDENT> st.info(f'Dataframe was appended to table {table_name}') <NEW_LINE> <DEDENT>... | Saves selected columns of a pandas dataframe to a database table | 625941eea79ad161976cc694 |
def idxLo2Hi(item): <NEW_LINE> <INDENT> start, end = item['start'], item['end'] <NEW_LINE> if end < start: <NEW_LINE> <INDENT> start, end = end, start <NEW_LINE> <DEDENT> return start, end | sometimes start and end are reversed see rs214083637 in
ENSMUSE00000339485 whereby start is 15881352 and end is 15881351
despite strand being 1 | 625941ee96565a6dacc8fc18 |
def pop(self, *keys): <NEW_LINE> <INDENT> for key in keys: self.set(key) | Pops the specified keys. | 625941ee2eb69b55b151ce06 |
def isIgnored(self, info): <NEW_LINE> <INDENT> sysfs_path = udev.device_get_sysfs_path(info) <NEW_LINE> name = udev.device_get_name(info) <NEW_LINE> if not sysfs_path: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if udev.device_is_md(info) and udev.device_get_md_level(info) == "container": <NEW_LINE> <... | Return True if info is a device we should ignore.
:param info: udevdb device entry
:type info: dict
:returns: whether the device will be ignored
:rtype: bool | 625941ee851cf427c661aa58 |
def _acquire_loop(self): <NEW_LINE> <INDENT> dev = self._device <NEW_LINE> try: <NEW_LINE> <INDENT> dev.streamStop() <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> error = None <NEW_LINE> while not self.data_stop.is_set(): <NEW_LINE> <INDENT> if not self.data_request.wait(0.01): <NEW... | Target for data acquisition thread. | 625941ee187af65679ca566e |
def visit(self, navigate=True): <NEW_LINE> <INDENT> if navigate: <NEW_LINE> <INDENT> self.navigate() <NEW_LINE> <DEDENT> self.wait_for_page_to_load(self.get_page_load_condition()) <NEW_LINE> return self | Navigate to the page's URL and wait for it to load.
@type navigate: bool
@param navigate: Wether to navigate to the page's URL or not | 625941eeff9c53063f47c73f |
def UpdateLayers(self): <NEW_LINE> <INDENT> pass | Update the layers present in the LayerManager.
Gets layers of current slide and displays them. | 625941ee596a89723608a007 |
def sched_entry_task(self, job): <NEW_LINE> <INDENT> label_pi = 0 <NEW_LINE> label_est = 0 <NEW_LINE> label_eft = 0 <NEW_LINE> min_o_eft = self.M <NEW_LINE> for pi in range(self.q): <NEW_LINE> <INDENT> eft = self.computation_costs[job - 1][pi] <NEW_LINE> oct_ = self.oct_table[job][pi] <NEW_LINE> o_eft = eft + oct_ <NEW... | entry task | 625941ee5166f23b2e1a56a8 |
def build_portals(self, elfDict, attackDict): <NEW_LINE> <INDENT> flanking_elves = self.aggressive.outside_aggressive_buildportals(self.game, elfDict, attackDict) <NEW_LINE> return flanking_elves | build portals at the designated flanking points using aggressive
:param elfDict: usable elfs
:param attackDict: portals used to attack
:return: elfs being used | 625941ee4428ac0f6e5bad46 |
def new_block(self, proof, previous_hash=None): <NEW_LINE> <INDENT> if len(self.chain) > 0: <NEW_LINE> <INDENT> block_string = json.dumps(self.last_block, sort_keys=True) <NEW_LINE> guess = f'{block_string}{proof}'.encode() <NEW_LINE> current_hash = hashlib.sha256(guess).hexdigest() <NEW_LINE> <DEDENT> else: <NEW_LINE>... | Create a new Block in the Blockchain
A block should have:
* Index
* Timestamp
* List of current transactions
* The proof used to mine this block
* The hash of the previous block
:param proof: <int> The proof given by the Proof of Work algorithm
:param previous_hash: (Optional) <str> Hash of previous Block
:return: <d... | 625941eec432627299f05199 |
def show_loss(self,loss_all,faloss_all): <NEW_LINE> <INDENT> nums = range(len(loss_all)) <NEW_LINE> plt.plot(nums, loss_all, label='front') <NEW_LINE> plt.plot(nums, faloss_all, label='rear') <NEW_LINE> plt.xlabel('# of epoch') <NEW_LINE> plt.ylabel('loss') <NEW_LINE> plt.title('loss experiment') <NEW_LINE> plt.legend(... | show figure for rmse and epoch | 625941eec4546d3d9de72f88 |
def get_hr_all(self,df=False): <NEW_LINE> <INDENT> if self.start_datetime: <NEW_LINE> <INDENT> athlete_id=self.whoop_id <NEW_LINE> start_date=parser.isoparse(self.start_datetime).replace(tzinfo=None) <NEW_LINE> end_time='T23:59:59.999Z' <NEW_LINE> start_time='T00:00:00.000Z' <NEW_LINE> intervals=rrule.rrule(freq=WEEKLY... | This function will pull every heart rate measurement recorded for the life of WHOOP membership.
The default return for this function is a list of lists, where each "row" contains the date, time, and hr value.
The measurements are spaced out every ~6 seconds on average.
To return a dataframe, set df=True. This will tak... | 625941eed4950a0f3b08c896 |
def respawn(self): <NEW_LINE> <INDENT> self.x, self.y = self.__level.random_inner_point() | reset enemy's position to random inner point | 625941eed8ef3951e3243a8c |
def __get_ebook_infodata(self, r): <NEW_LINE> <INDENT> logger.info("Retrieving complete information for '{}'".format(self.book_title)) <NEW_LINE> r = self.session.get(self.cfg.freelearning_url, timeout=10) <NEW_LINE> result_html = BeautifulSoup(r.text, 'html.parser') <NEW_LINE> last_grabbed_book = result_html.find('div... | Log grabbed book information to log file
:param r: the previous response got when book has been successfully added to user library
:return: the data ready to be written to the log file | 625941eeab23a570cc2506d6 |
def AddVersion(self, version): <NEW_LINE> <INDENT> num = version.version_number <NEW_LINE> if num not in self.__versions: <NEW_LINE> <INDENT> self.__versions[num] = version <NEW_LINE> return True <NEW_LINE> <DEDENT> return False | Adds given version and returns True if successful.
@param version: version to add
@type version: L{KeyVersion}
@return: True if version was successfully added (i.e. no previous version
had the same version number), False otherwise.
@rtype: boolean | 625941eef9cc0f698b140b45 |
def test_unicodeType(self): <NEW_LINE> <INDENT> self.assertRaises(TypeError, HDocument, uri=b'notunicode') | Almost everything in hypy must be unicode | 625941ee30dc7b7665901eaf |
def echange(liste,i,j): <NEW_LINE> <INDENT> liste[i], liste[j] = liste[j], liste[i] | Echange les éléments aux rangs i et j de la liste.
Args:
liste (list): Liste à modifier.
i (int): Indice du premier élément.
j (int): Indice du deuxième élément. | 625941ee16aa5153ce3629c7 |
def height_adjusted(img, vertices, ratio=0.2): <NEW_LINE> <INDENT> h_ratio = 1 + ratio * (np.random.rand() * 2 - 1) <NEW_LINE> old_h = img.height <NEW_LINE> new_h = int(np.around(old_h * h_ratio)) <NEW_LINE> img = img.resize((img.width, new_h), Image.BILINEAR) <NEW_LINE> new_vertices = vertices.copy() <NEW_LINE> if ver... | adjust height of image to augmented data
| 625941ee0a50d4780f6673e6 |
def initialize(context): <NEW_LINE> <INDENT> context.target_leverage = 1.0 <NEW_LINE> context.etfs = { symbol('AMZN'): 0.2, symbol('AAPL'): 0.2, symbol('FB'): 0.2, symbol('NFLXL'): 0.2, symbol('GOOG'): 0.2, } <NEW_LINE> set_commission(commission.PerShare(cost=0.0, min_trade_cost=0.0)) <NEW_LINE> schedule_function(rebal... | Called once at the start of the algorithm. | 625941eea4f1c619b28b057b |
def time_stats(df): <NEW_LINE> <INDENT> print('\nCalculating The Most Frequent Times of Travel...\n') <NEW_LINE> start_time = time.time() <NEW_LINE> most_common_month = df['month'].mode()[0] <NEW_LINE> print("The most common month is: ",most_common_month) <NEW_LINE> most_common_day_of_week = df['day_of_week'].mode()[0]... | Displays statistics on the most frequent times of travel. | 625941eed53ae8145f87a7b4 |
def update_summoners(summoners=None, region=None): <NEW_LINE> <INDENT> ids = [] <NEW_LINE> for summoner in summoners: <NEW_LINE> <INDENT> ids.append(summoner.summoner_id) <NEW_LINE> <DEDENT> query_list = [] <NEW_LINE> for chunk in chunks(ids, 40): <NEW_LINE> <INDENT> query_list.append(chunk) <NEW_LINE> <DEDENT> print("... | Accepts an iterable of Summoner objects and fully updates their fields. | 625941ee099cdd3c635f11a7 |
def do_json(self, command, data=None, params=None, include_engine=True): <NEW_LINE> <INDENT> if params is None: <NEW_LINE> <INDENT> params = {} <NEW_LINE> <DEDENT> params['project'] = self.project_id <NEW_LINE> if include_engine: <NEW_LINE> <INDENT> if data is None: <NEW_LINE> <INDENT> data = {} <NEW_LINE> <DEDENT> dat... | Issue a command to the server, parse & return decoded JSON. | 625941ee10dbd63aa1bd30f1 |
def test_info(): <NEW_LINE> <INDENT> raw = read_raw_fif(raw_fname) <NEW_LINE> event_id, tmin, tmax = 1, -0.2, 0.5 <NEW_LINE> events = read_events(event_name) <NEW_LINE> event_id = int(events[0, 2]) <NEW_LINE> epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None) <NEW_LINE> evoked = epochs.average() <NEW_LI... | Test info object. | 625941ee8a349b6b435e86c2 |
def set_xlim(self,xlim,axis_num=0): <NEW_LINE> <INDENT> row = axis_num//self.ncols <NEW_LINE> col = axis_num%self.ncols <NEW_LINE> self.xlims[row][col]=xlim | Set the xlims of the axes indexed row major wise starting from 0.
Effect will be visible only after update.
Setting either limit to None will make that limit update automatically. | 625941ee167d2b6e312190e4 |
def test_guess_medium() -> None: <NEW_LINE> <INDENT> db = connect_to_db() <NEW_LINE> num_media = 5 <NEW_LINE> [create_test_medium(db, str(i)) for i in range(num_media)] <NEW_LINE> db.query("update media set url = 'http://media-' || media_id ||'.com'") <NEW_LINE> guess_medium(db, 'foo') <NEW_LINE> media = db.query("sele... | Test guess_medium(). | 625941ee293b9510aa2c37e0 |
def __init__( self, *, azure_defender: Optional["ManagedClusterSecurityProfileAzureDefender"] = None, **kwargs ): <NEW_LINE> <INDENT> super(ManagedClusterSecurityProfile, self).__init__(**kwargs) <NEW_LINE> self.azure_defender = azure_defender | :keyword azure_defender: Azure Defender settings for the security profile.
:paramtype azure_defender:
~azure.mgmt.containerservice.v2021_09_01.models.ManagedClusterSecurityProfileAzureDefender | 625941ee21bff66bcd684e9d |
def __init__(self, group, weight=2, eps=1e-20, delta=1e-2, tp=[2,3,5]): <NEW_LINE> <INDENT> if isinstance(group, integer_types + (Integer,)): <NEW_LINE> <INDENT> group = Gamma0(Integer(group)) <NEW_LINE> <DEDENT> self._group = group <NEW_LINE> self._weight = Integer(weight) <NEW_LINE> self._tp = tp <NEW_LINE> if self.... | Create a new space of numerical eigenforms.
EXAMPLES::
sage: numerical_eigenforms(61) # indirect doctest
Numerical Hecke eigenvalues for Congruence Subgroup Gamma0(61) of weight 2 | 625941eee1aae11d1e74a20c |
def __init__(self, message, query): <NEW_LINE> <INDENT> Error.__init__(self, message) <NEW_LINE> self.query = query | Init the error with the query | 625941eefbf16365ca6f671f |
def experiment_list(infile, check_format=True): <NEW_LINE> <INDENT> from dxtbx.model.experiment_list import ExperimentListFactory <NEW_LINE> if infile and hasattr(infile, "__fspath__"): <NEW_LINE> <INDENT> infile = ( infile.__fspath__() ) <NEW_LINE> <DEDENT> return ExperimentListFactory.from_serialized_format( infile, ... | Load an experiment list from a serialized format. | 625941eea219f33f34628eb1 |
def free(self, con, err=None): <NEW_LINE> <INDENT> return super(PyMySQLPool, self).free((con, err)) | Args:
con(SharedConnection):
err
Returns:
bool | 625941ee30bbd722463cc318 |
def test_warn_consec_badpixels(): <NEW_LINE> <INDENT> with pytest.raises(ValueError): <NEW_LINE> <INDENT> pb.warn_consec_badpixels([[1, 10], [1, 11]]) <NEW_LINE> <DEDENT> assert pb.warn_consec_badpixels([[1, 7], [2, 7], [3, 8]]) is None | Test warn consecutive throws and error. | 625941ee8e05c05ec3eea8c8 |
@pytest.mark.optionalhook <NEW_LINE> def pytest_html_results_table_row(report,cells): <NEW_LINE> <INDENT> cells.insert(1,html.td(report.description)) <NEW_LINE> cells.insert(2,html.td(report.nodeid)) <NEW_LINE> cells.pop(2) | Description列添加详情和Test_nodeid列添加详情,删除原有的Test列 | 625941ee63d6d428bbe44a40 |
def annotate_with_number_of_deliveries(self): <NEW_LINE> <INDENT> return self.annotate(number_of_deliveries=models.Count('deadlines__deliveries')) | See :meth:`.AssignmentGroupManager.annotate_with_number_of_deliveries`. | 625941ee21a7993f00bc8249 |
def turnOffMotors(): <NEW_LINE> <INDENT> left_motor.run(Adafruit_MotorHAT.RELEASE) <NEW_LINE> right_motor.run(Adafruit_MotorHAT.RELEASE) | Shutdown motors and unset handlers.
Called on exit to ensure the robot is stopped. | 625941ee63b5f9789fde7635 |
def output(self) -> OutputMode: <NEW_LINE> <INDENT> return OutputMode(int(self.s[5])) | Returns the output mode. | 625941eed10714528d600239 |
def test5756Wrapped(self): <NEW_LINE> <INDENT> new_group = self.new_group() <NEW_LINE> new_client, new_user = self.new_client_and_user(new_group) <NEW_LINE> share = new_client.sf.getShareService() <NEW_LINE> query = new_client.sf.getQueryService() <NEW_LINE> update = new_client.sf.getUpdateService() <NEW_LINE> image = ... | Accessing deleted image in share seems to have changed.
This tests what happens using BlitzGateway wrappers. | 625941ee046cf37aa974d291 |
def most_and_least_common_type(treats): <NEW_LINE> <INDENT> types = {} <NEW_LINE> for treat in treats: <NEW_LINE> <INDENT> types[treat['type']] = types.get(treat['type'], 0) + 1 <NEW_LINE> <DEDENT> most_count = most_type = None <NEW_LINE> least_count = least_type = None <NEW_LINE> for treat_type, count in types.items()... | Given list of treats, return most and least common treat types.
Return most and least common treat types in tuple of format (most, least).
>>> treats = [
... {'type': 'dessert'},
... {'type': 'dessert'},
... {'type': 'appetizer'},
... {'type': 'dessert'},
... {'type': 'app... | 625941ee5f7d997b87174fec |
def initialize_model(model_file, model_name='Model', comm=None): <NEW_LINE> <INDENT> rank, size = get_rank_size(comm) <NEW_LINE> print_once('Initializing the %s.\n' % model_name, comm=comm) <NEW_LINE> print_once('-------------------------\n', comm=comm) <NEW_LINE> for i in range(size): <NEW_LINE> <INDENT> if rank == i:... | Initialize the ``model_file`` which should be a proper python module. | 625941ee55399d3f05588c07 |
def get_first_filter_process(data, kws, specific_words): <NEW_LINE> <INDENT> original_event = {} <NEW_LINE> for i in data: <NEW_LINE> <INDENT> for k, v in i.items(): <NEW_LINE> <INDENT> tmp = [] <NEW_LINE> for item in v: <NEW_LINE> <INDENT> mm = "".join(item[:3]) <NEW_LINE> for ikw in kws: <NEW_LINE> <INDENT> if ikw in... | data:已经抽取出来的数据
kws:key_words
specific_words:一些需要召回的特定的关键词 | 625941ee60cbc95b062c6a93 |
def select(self, elem=None, **kwargs): <NEW_LINE> <INDENT> if "option_" in kwargs.keys(): <NEW_LINE> <INDENT> value = kwargs["option_"] <NEW_LINE> kwargs.pop('option_') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ParamIsMissed('You missed "option_" param.') <NEW_LINE> <DEDENT> selenium_elem = self._change_to_se... | !
Method that select value from dropdown. Need "option_" as one of
kwargs to select specific option.
Args:
elem - object of element.Element class;
kwargs - params to search.
Raise exception:
ParamIsMissed: if missed option "option_" while calling method. | 625941ee07f4c71912b119d4 |
def get_count(self): <NEW_LINE> <INDENT> if (not self.freezed and self.sql!=str() and "insert into " not in self.sql.lower() and "update " not in self.sql.lower()): <NEW_LINE> <INDENT> self._tables = SqlParser.get_tables(self.sql) <NEW_LINE> self._columns = self.get_columns(self.sql) <NEW_LINE> self._where = SqlParser.... | Cuenta los registros. Como es necesario pasar antes por get_tables y get_columns y get_where...
TODO: Implementar "JOIN" | 625941eedc8b845886cb5a86 |
def _get_record(self, target_request_id): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> header_data = self.socket.recv(FCGI_HEADER_LENGTH) <NEW_LINE> version, type, request_id, content_length, padding_length = struct.unpack(FCGI_HEADER_STRUCT, header_data) <NEW_LINE> contents = self.socket.recv(content_length) <N... | Retrieves a record from the socket
:type target_request_id: int
:param target_request_id: The target request id of the record.
:rtype: Tuple
:return: The record tuple. | 625941ee97e22403b379d4eb |
def addArcFilled(picture, startX, startY, width, height, start, angle, color=black): <NEW_LINE> <INDENT> pass | picture: the picture you want to draw the arc on
startX: the x-coordinate of the center of the arc
startY: the y-coordinate of the center of the arc width: the width of the arc
height: the height of the arc
start: the start angle of the arc in degrees
angle: the angle of the arc relative to start in degrees
color: the ... | 625941ee8e7ae83300e4b51e |
def score(self, observations): <NEW_LINE> <INDENT> observations = numpy.asarray(observations) <NEW_LINE> alpha_t = self.pi * self.B[:, observations[0]] <NEW_LINE> for index in xrange(1, len(observations)): <NEW_LINE> <INDENT> alpha_tn = numpy.dot(alpha_t, self.A) * self.B[:, observations[index]] <NEW_LINE> alpha_t = al... | Compute the log probability under the model.
Parameters
----------
observations: array_like, shape(n, n_features=1)
Sequence of n_feature-dimensional data points.
Each row corresponds to a single data point.
Current support n_features = 1
Returns
-------
logprob: float
Log likehood of the `observations`. | 625941ee507cdc57c6307237 |
def select(self): <NEW_LINE> <INDENT> variate = random.random() * sum(self.workers) <NEW_LINE> cum = 0.0 <NEW_LINE> count = 0 <NEW_LINE> for county in self.counties: <NEW_LINE> <INDENT> cum += self.workers[count] <NEW_LINE> if variate < cum: <NEW_LINE> <INDENT> self.workers[count] -= 1 <NEW_LINE> return county <NEW_LIN... | Randomly select a work county from the list of commutable counties.
Returns:
county (str): A county FIPS code. | 625941ee9b70327d1c4e1327 |
def calcOverallPR(self,playerID): <NEW_LINE> <INDENT> a = API() <NEW_LINE> d = Data() <NEW_LINE> u = Util() <NEW_LINE> eDmg = 0 <NEW_LINE> eWin = 0 <NEW_LINE> eKil = 0 <NEW_LINE> aDmg = 0 <NEW_LINE> aWin = 0 <NEW_LINE> aKil = 0 <NEW_LINE> btot = 0 <NEW_LINE> data = a.getPlayerShipStats(playerID) <NEW_LINE> for shipdata... | Parameters:
playerID: WG player ID
Returns:
PR value of player (float) | 625941ee3539df3088e2e89b |
def test_process_exception(self): <NEW_LINE> <INDENT> self.assertIsInstance(DispatchErrorMiddleware().process_exception( None, DispatchError('error')), HttpResponse) | Test process exception method.
| 625941ee85dfad0860c3b3ac |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.