code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__( self, *, location: str, tags: Optional[Dict[str, str]] = None, account_type: Optional[Union[str, "AccountType"]] = None, **kwargs ): <NEW_LINE> <INDENT> super(StorageAccountCreateParameters, self).__init__(**kwargs) <NEW_LINE> self.location = location <NEW_LINE> self.tags = tags <NEW_LINE> self.account_ty... | :keyword location: Required. The location of the resource. This will be one of the supported
and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region
of a resource cannot be changed once it is created, but if an identical geo region is specified
on update, the request will succe... | 625941e0a219f33f34628ce3 |
def process_node(layer, node_data): <NEW_LINE> <INDENT> input_tensors = [] <NEW_LINE> for input_data in nest.flatten(node_data): <NEW_LINE> <INDENT> input_data = input_data.as_list() <NEW_LINE> inbound_layer_name = input_data[0] <NEW_LINE> inbound_node_index = input_data[1] <NEW_LINE> inbound_tensor_index = input_data[... | Deserialize a node.
Arguments:
layer: layer instance.
node_data: Nested structure of `ListWrapper`.
Raises:
ValueError: In case of improperly formatted `node_data`. | 625941e0925a0f43d254a1f8 |
def __init__(self, ecuteps, nband, w_type="RPA", sc_mode="one_shot", hilbert=None, ecutwfn=None, inclvkb=2): <NEW_LINE> <INDENT> if w_type not in self._WTYPES: <NEW_LINE> <INDENT> raise ValueError("W_TYPE: %s is not supported" % w_type) <NEW_LINE> <DEDENT> if sc_mode not in self._SC_MODES: <NEW_LINE> <INDENT> raise Val... | Args:
ecuteps:
Cutoff energy for the screening (Ha units).
nband
Number of bands for the Green's function
w_type:
Screening type
sc_mode:
Self-consistency mode.
hilbert:
Instance of `HilbertTransform` defining the paramentes for the Hilber transform method.
... | 625941e05510c4643540f759 |
def find_package_root(fn, ignores): <NEW_LINE> <INDENT> if not isdir(fn): <NEW_LINE> <INDENT> fn = dirname(fn) <NEW_LINE> <DEDENT> while is_package_dir(fn): <NEW_LINE> <INDENT> assert fn <NEW_LINE> fn = dirname(fn) <NEW_LINE> <DEDENT> if fn and is_package_root(fn, ignores): <NEW_LINE> <INDENT> return fn | Search up the directory tree for a package root. | 625941e0167d2b6e31218f13 |
def default(self, obj): <NEW_LINE> <INDENT> if isinstance(obj, np.ndarray): <NEW_LINE> <INDENT> data_b64 = base64.b64encode(obj.data) <NEW_LINE> return dict(__ndarray__=data_b64, dtype=str(obj.dtype), shape=obj.shape) <NEW_LINE> <DEDENT> return json.JSONEncoder(self, obj) | if input object is a ndarray it will be converted into a
dict holding dtype, shape and the data base64 encoded | 625941e024f1403a92600ee1 |
def test_split_good_length(self): <NEW_LINE> <INDENT> for test_case in self.test_cases_good: <NEW_LINE> <INDENT> response = Url.split_url_into_words(test_case) <NEW_LINE> self.assertGreaterEqual(len(response), 0) | test if return more than one | 625941e050812a4eaa59c69c |
def test_three_before_after(cp, share, cptime): <NEW_LINE> <INDENT> cp.newCheckpoint(share, cptime, {"from": accounts[0]}) <NEW_LINE> cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]}) <NEW_LINE> cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]}) <NEW_LINE> share.mint(accounts[1], 100000, {"from": a... | three checkpoints - mint before and after | 625941e04527f215b584c7d1 |
def hasColors(self, caps): <NEW_LINE> <INDENT> if caps & onlp.onlp.ONLP_LED_CAPS.RED: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if caps & onlp.onlp.ONLP_LED_CAPS.RED_BLINKING: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if caps & onlp.onlp.ONLP_LED_CAPS.ORANGE: <NEW_LINE> <INDENT> return True <NEW_LIN... | True if this a color LED. | 625941e0aad79263cf390dc4 |
def list_fake_quantized_op_freqs(mod): <NEW_LINE> <INDENT> return _ffi_api.ExtractFakeQuantizedOps(mod) | Pass to extract fake quantized op names and the frequency that they appear
in fake quantized regions of an IRModule.
Parameters
----------
mod : tvm.IRModule
Returns
-------
ret : Dict[str, int]
Dict of fake quantized operator names to frequency | 625941e0462c4b4f79d1da4d |
def get_open_in_terminal_script(self, path): <NEW_LINE> <INDENT> terminal_emulator = self.preferences['terminal_emulator'] <NEW_LINE> if terminal_emulator in [ 'gnome-terminal', 'terminator', 'tilix', 'xfce-terminal' ]: <NEW_LINE> <INDENT> return RunScriptAction(terminal_emulator, ['--working-directory', path]) <NEW_LI... | Returns the script based on the type of terminal | 625941e01d351010ab855e99 |
def delete(self, id): <NEW_LINE> <INDENT> response = self._session.delete(self.build_url(id=id)) <NEW_LINE> return response | A method to delete an object.
:param guid: A string representing the alert channel GUID.
:return response json | 625941e07d847024c06be63d |
def testNtOffsetInMembrane(self): <NEW_LINE> <INDENT> offset = 5 <NEW_LINE> self.assertEqual( 26522 + offset, _FEATURES.referenceOffset('membrane', offset, aa=False)) | Test we get the correct genome offset given a nucleotide offset in the
membrane protein when we explicitly pass aa=False. | 625941e0187af65679ca549e |
def _fitness(self, i): <NEW_LINE> <INDENT> return self.problem.fitness(self.new_population[i, :], limit=self.fitness[i]) | Calculate the fitness for the i'th agent. | 625941e063b5f9789fde7464 |
def __del__(self): <NEW_LINE> <INDENT> pass | Destructor to clean the object and delete
| 625941e050485f2cf553d119 |
def __init__(self, dist, input, others, output, rv_mode=None): <NEW_LINE> <INDENT> dist = dist.coalesce((input,) + (sum(others, ()),) + (output,)) <NEW_LINE> constraints = [[0, 2], [1, 2]] <NEW_LINE> super(BROJAOptimizer, self).__init__(dist, marginals=constraints, rv_mode=rv_mode) <NEW_LINE> self._input = {0} <NEW_LIN... | Initialize the optimizer.
Parameters
----------
dist : Distribution
The distribution to base the optimization on.
input : iterable
Variables to treat as inputs.
others : iterable of iterables
The other input variables.
output : iterable
The output variable.
rv_mode : bool
Unused, provided for compa... | 625941e091f36d47f21ac874 |
def new_url(**kwargs): <NEW_LINE> <INDENT> url_base = "/axapi/v3/slb/ftp-proxy" <NEW_LINE> f_dict = {} <NEW_LINE> return url_base.format(**f_dict) | Return the URL for creating a resource | 625941e0a05bb46b383ecb9d |
def test_characterData(self): <NEW_LINE> <INDENT> element = domish.Element(("testns", "foo")) <NEW_LINE> element.addContent("somecontent") <NEW_LINE> text = str(element) <NEW_LINE> self.assertEqual("somecontent", text) <NEW_LINE> self.assertIsInstance(text, str) | Extract character data using L{str}. | 625941e099cbb53fe6792f64 |
def pert(value): <NEW_LINE> <INDENT> return value * (random.random()*.4 + 0.8) | pertubate a value | 625941e0e64d504609d74bbe |
def write_page(base_path: Path, content: dict) -> None: <NEW_LINE> <INDENT> path_page = filepath(base_path, content['url']) <NEW_LINE> path_page.parent.mkdir(parents=True, exist_ok=True) <NEW_LINE> path_page.write_text(render(content)) | Write a rendered content page. | 625941e0566aa707497f48e2 |
def cint(s): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return int(s) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return 0 | Converts a value to an int, coping with None and non-int values | 625941e09f2886367277ac09 |
def test_password_too_short(self): <NEW_LINE> <INDENT> payload = {'email': 'test@project.com', 'password': 'pw'} <NEW_LINE> res = self.client.post(CREATE_USER_URL, payload) <NEW_LINE> self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) <NEW_LINE> user_exists = get_user_model().objects.filter( email=payload['... | Test that the password must be moore than 5 characters | 625941e02ae34c7f2600d4af |
def center(self): <NEW_LINE> <INDENT> mid_12 = self.__mid_12() <NEW_LINE> mid_23 = self.__mid_23() <NEW_LINE> slop_12 = self.__slop_p_12() <NEW_LINE> slop_23 = self.__slop_p_23() <NEW_LINE> x = old_div((mid_23.y() - mid_12.y() + slop_12*mid_12.x() - slop_23*mid_23.x()), (slop_12 - slop_23)) <NEW_LINE> y = (x - mid_12.x... | To get the center of the arc
:return: the arc center | 625941e05166f23b2e1a54d7 |
def test_view_list_profiles_page(self): <NEW_LINE> <INDENT> c = Client() <NEW_LINE> response = c.get(reverse('profiles_list_profiles')) <NEW_LINE> self.assertTemplateUsed(response, 'profiles_people.html') | Get list profiles page. | 625941e0d164cc61757830cd |
def connect_to_dbus(self): <NEW_LINE> <INDENT> proxy_obj = self._bus.get_object("org.wicd.daemon", '/org/wicd/daemon') <NEW_LINE> daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') <NEW_LINE> proxy_obj = self._bus.get_object("org.wicd.daemon", '/org/wicd/daemon/wireless') <NEW_LINE> wireless = dbus.Interface(proxy_o... | Connects to wicd's dbus interfaces and loads them into a dict. | 625941e0bde94217f368316c |
@opcode <NEW_LINE> def MLS(cpu_context, instruction): <NEW_LINE> <INDENT> logger.debug("%s instruction not currently implemented.", instruction.mnem) | Multiply-subtract (vector form) | 625941e007d97122c4178c11 |
def get_probability_grammar(self): <NEW_LINE> <INDENT> word_expr = ( Word(alphanums + "-" + "_") + Suppress(Optional("|")) + Suppress(Optional(",")) ) <NEW_LINE> word_expr2 = Word( initChars=printables, excludeChars=[",", ")", " ", "("] ) + Suppress(Optional(",")) <NEW_LINE> num_expr = Word(nums + "-" + "+" + "e" + "E"... | A method that returns probability grammar | 625941e0090684286d50f068 |
def renderActionIcon( self, category, action_id, default=None, context=None ): <NEW_LINE> <INDENT> icon = self.queryActionIcon( category, action_id, default=default, context=context ) <NEW_LINE> if icon is not None: <NEW_LINE> <INDENT> portal=getToolByName(self, 'portal_url').getPortalObject() <NEW_LINE> return portal.... | Returns the actual object for the icon. If you
pass in a path elements in default it will attempt
to traverse to that path. Otherwise it will return
None | 625941e0fb3f5b602dac3a15 |
def calculate(self, s): <NEW_LINE> <INDENT> queue = collections.deque() <NEW_LINE> method = { "+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.div } <NEW_LINE> pri = { operator.add: 0, operator.sub: 0, operator.mul: 1, operator.div: 1 } <NEW_LINE> i = 0; n = 0 <NEW_LINE> while i < len(s): <NEW_LIN... | :type s: str
:rtype: int | 625941e0379a373c97cfaec5 |
def undoMutate(self): <NEW_LINE> <INDENT> self.points = self.oldPoints | Undoes the last mutate by restoring the old points. Necessary for
simulated annealing. | 625941e08c3a87329515873d |
def append(self, singlet, temp, chem_pot): <NEW_LINE> <INDENT> self.singlets.append(np.copy(singlet)) <NEW_LINE> self.temperatures.append(temp) <NEW_LINE> self.chem_pot.append(np.copy(chem_pot)) | Append a new entry
:param singlet: New singlet entry
:param temp: New temperature
:param chem_pot: New chemical potantial | 625941e0b545ff76a8914194 |
def test_reading_corrupted_fcs_file(self): <NEW_LINE> <INDENT> file_path = ADDITIONAL_FILE_MAPPING['corrupted_file'] <NEW_LINE> with self.assertRaises(ValueError): <NEW_LINE> <INDENT> parse_fcs(file_path) | Raise exception when reading a corrupted fcs file. | 625941e03eb6a72ae02ec864 |
def remove(self,id): <NEW_LINE> <INDENT> self.__participation_repository.delete_by_id(id) | Remove a participation that has a given id.
Args:
id(uint): the id of the participation to be removed
Returns:
None | 625941e0d10714528d600065 |
def setup_pbs_variant(self): <NEW_LINE> <INDENT> impl, ver = self.get_pbs_version() <NEW_LINE> self._pbs_impl = impl <NEW_LINE> if '~' in ver: <NEW_LINE> <INDENT> ver = ver[:ver.index('~')] <NEW_LINE> <DEDENT> self._pbs_version = [int(x) for x in ver.split('.')] <NEW_LINE> self.logger.info('PBS implementation: %s' % se... | determine PBS implementation / version and set internal behaviour accordingly | 625941e0f8510a7c17cf9a7d |
def _data_generator_wrapper(self, annotation_lines): <NEW_LINE> <INDENT> n = len(annotation_lines) <NEW_LINE> if n == 0 or self.batch_size <= 0: return None <NEW_LINE> return self._data_generator(annotation_lines) | For condition checking | 625941e0287bf620b61d3de0 |
def create_ve(self, **kwargs): <NEW_LINE> <INDENT> ve_name = kwargs.pop('ve_name', '') <NEW_LINE> rbridge_id = kwargs.pop('rbridge_id', '1') <NEW_LINE> enable = kwargs.pop('enable', True) <NEW_LINE> get = kwargs.pop('get', False) <NEW_LINE> callback = kwargs.pop('callback', self._callback) <NEW_LINE> ve_args = dict(nam... | Add Ve Interface .
Args:
ve_name: Ve name with which the Ve interface needs to be
created.
enable (bool): If vrf fowarding should be enabled
or disabled.Default:``True``.
get (bool) : Get config instead of editing config. (True, False)
rbridge_id (str): rbridge-id for device.
callback (... | 625941e0d486a94d0b98e4c5 |
def critical_crippling_stiffener(x): <NEW_LINE> <INDENT> alpha = 0.8 <NEW_LINE> n = 0.6 <NEW_LINE> yield_stress = p.ultimate_yield_strength_2099 <NEW_LINE> def stress_cc(K,b): <NEW_LINE> <INDENT> return K*(np.pi**2*p.E_compressive_2099*(sp.t_hat/b)**2/(12*(1-p.poisson_ratio_al2014**2))) <NEW_LINE> <DEDENT> t_sheet = sp... | Critical crippling stress for aluminium top stiffener in MPa | 625941e0fff4ab517eb2f7bc |
def output(data): <NEW_LINE> <INDENT> outfile = open("eng_plain_extracted.txt", "w", encoding="utf-8") <NEW_LINE> data_collection = collections.Counter(data) <NEW_LINE> for cmp_noun, value in data_collection.most_common(): <NEW_LINE> <INDENT> outfile.write(cmp_noun) <NEW_LINE> outfile.write("\t") <NEW_LINE> outfile.wri... | 処理結果を"eng_plain_extracted.txt"に出力 | 625941e0462c4b4f79d1da4e |
def feature_labels(self): <NEW_LINE> <INDENT> self._check_fitted() <NEW_LINE> return [b + " bond frac." for b in self.fitted_bonds_] | Returns the list of allowed bonds. Throws an error if the featurizer
has not been fit. | 625941e01f037a2d8b94657c |
def gcd(a, b): <NEW_LINE> <INDENT> return gcd(b, a % b) if b != 0 else a | Get greatest common divisor of given number a and b
:param a: the first given number
:type a: int
:param b: the second given number
:type b: int
:return: greatest common divisor
:rtype: int | 625941e00c0af96317bb8566 |
def __repr__(self): <NEW_LINE> <INDENT> return f"< Node (data={self.data}) >" | Represent the Node class in text format
:return: representation of the Node | 625941e04a966d76dd551391 |
def test00_init(self): <NEW_LINE> <INDENT> fld = forms.GeometryField() <NEW_LINE> for bad_default in ('blah', 3, 'FoO', None, 0): <NEW_LINE> <INDENT> self.assertRaises(ValidationError, fld.clean, bad_default) | Testing GeometryField initialization with defaults. | 625941e067a9b606de4a8236 |
def __init__(self, parameters=None): <NEW_LINE> <INDENT> if not parameters: <NEW_LINE> <INDENT> parameters = {} <NEW_LINE> <DEDENT> self.parameters = parameters | Standard constructor | 625941e08c0ade5d55d3ed3c |
def updateMonitor(self, event=None): <NEW_LINE> <INDENT> paramDict = self.cmaEngine.getStrategyParam(self.name) <NEW_LINE> if paramDict: <NEW_LINE> <INDENT> self.paramMonitor.updateData(paramDict) <NEW_LINE> <DEDENT> varDict = self.cmaEngine.getStrategyVar(self.name) <NEW_LINE> if varDict: <NEW_LINE> <INDENT> self.varM... | 显示策略最新状态 | 625941e00a50d4780f667214 |
def bias(self, games): <NEW_LINE> <INDENT> games = self.compute_rest_days(games) <NEW_LINE> rest_adv = self.rest_coeff * self.compare( games.rest_days_away, games.rest_days_home) <NEW_LINE> return rest_adv | Circumstantial bias factors which apply to a single game.
Args:
games (pd.DataFrame): dataframe of NBA game records
Returns:
pd.Series of game bias correction coefficients | 625941e016aa5153ce3627f7 |
def test_read_for_datasets_world_ok(self): <NEW_LINE> <INDENT> self.client._credentials = {} <NEW_LINE> for req in ["/rest/datasets", "/rest/datasets/1"]: <NEW_LINE> <INDENT> response = self.client.get(req) <NEW_LINE> self.assertEqual(response.status_code, status.HTTP_200_OK) | Reading datasets api should be permitted even without any authorization. | 625941e007f4c71912b11803 |
def min_max(lst): <NEW_LINE> <INDENT> return list([min(lst), max(lst)]) | на выходе список чисел
на выходе список из двух чисел: минимального и максимального | 625941e010dbd63aa1bd2f21 |
def get_pictures(self): <NEW_LINE> <INDENT> return self.pictures.on_site().order_by('picturenote__position') | Return all pictures attached to note which are available on current
site, ordered by PictureNote.position. | 625941e0c432627299f04fc8 |
def test_detect_01_test_platform_not_windows(monkeypatch): <NEW_LINE> <INDENT> uname_list = [ "macware", "filler", "filler", "2.0", "RISC III", ] <NEW_LINE> def uname_data(): <NEW_LINE> <INDENT> return uname_list <NEW_LINE> <DEDENT> monkeypatch.setattr(platform, 'uname', uname_data) <NEW_LINE> tested_detect = mdetect.M... | Test that we're pulling back the right data | 625941e056ac1b37e6264548 |
def _get_key(self, key): <NEW_LINE> <INDENT> key = "{%s}%s" % (self.ns, key) <NEW_LINE> key = self.shorten_key(key.encode("utf-8")) <NEW_LINE> return key | Gets a key (binary string) that contains the namespace | 625941e0ab23a570cc250504 |
def parse_file(filename): <NEW_LINE> <INDENT> with open(filename, "r") as f: <NEW_LINE> <INDENT> is_phrase = True <NEW_LINE> total_phrase = [] <NEW_LINE> while is_phrase: <NEW_LINE> <INDENT> phrase = [] <NEW_LINE> concepts = [] <NEW_LINE> line = f.readline() <NEW_LINE> while line: <NEW_LINE> <INDENT> if line == "\n": <... | Parse a given filename and generate a list of sentences.
:param filename: given filename path
:return: a list of sentences | 625941e0fb3f5b602dac3a16 |
def __call__(self, params): <NEW_LINE> <INDENT> m = np.asarray(params[0])[..., None] <NEW_LINE> x = np.arange(self.size) <NEW_LINE> vec = x * np.log(m) <NEW_LINE> vec += gammaln(self.r + x) <NEW_LINE> vec -= gammaln(self.r) <NEW_LINE> vec += self.r * np.log(self.r) <NEW_LINE> vec -= np.log(factorial(x)) <NEW_LINE> vec ... | gammaln(r + x) - gammaln(r) - ln x! +
x ln(m) + r ln(r) - (x + r) * ln(r + m)) | 625941e04c3428357757c6a5 |
def isfragment(self): <NEW_LINE> <INDENT> return self.__isfragment | Checks whether a http fragment. | 625941e0d7e4931a7ee9e29e |
def test_top_of_world_snow(self): <NEW_LINE> <INDENT> self.c.set_block((0, 127, 0), bravo.blocks.blocks["stone"].slot) <NEW_LINE> self.hook.transform(self.c) | Blocks at the top of the world should not cause exceptions when snow
is placed on them. | 625941e0d164cc61757830ce |
def build_fDNT(dnt_delete): <NEW_LINE> <INDENT> date = datetime.datetime.now().strftime(dnt_datetime_format) <NEW_LINE> dnt = ET.Element('delivery') <NEW_LINE> dnt.set('PushingEntity','CopernicusMarine-InSitu-Global') <NEW_LINE> dnt.set('date', date) <NEW_LINE> dnt.set('product',PRODUCT_ID) <NEW_LINE> dataset = ET.SubE... | Generates delivery note for NetCDF folder clean up | 625941e063d6d428bbe4486f |
def mask_centroids(self, inside=None, outside=None, use_existing=True): <NEW_LINE> <INDENT> if inside is None and outside is None: <NEW_LINE> <INDENT> raise ValueError("must provide at least one of `inside` or `outside`") <NEW_LINE> <DEDENT> if inside is not None: <NEW_LINE> <INDENT> poly = validate.simple_polygon_gdf(... | Create mask for the cells of the ModelGrid with a polygon.
Parameters
----------
inside, outside : GeoDataFrame, optional
GeoDataFrames of Polygons or MultiPolygons inside or outside of
which nodes will be masked, respectively.
use_existing : bool (default = True)
When True, the newly computed mask is comb... | 625941e06fece00bbac2dac1 |
def f_decorator(func): <NEW_LINE> <INDENT> def inner(f, *args, **kwargs): <NEW_LINE> <INDENT> initial_pos = f.tell() <NEW_LINE> f.seek(0) <NEW_LINE> ret = func(f, *args, **kwargs) <NEW_LINE> f.seek(initial_pos) <NEW_LINE> return ret <NEW_LINE> <DEDENT> return inner | Make sure decorated function doesn't alter file position. | 625941e021bff66bcd684cce |
def tests_dir(): <NEW_LINE> <INDENT> cwd = os.getcwd() <NEW_LINE> basename = os.path.basename(cwd) <NEW_LINE> if basename == 'tests': <NEW_LINE> <INDENT> return cwd <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tests_dir = os.path.join(cwd, 'tests') <NEW_LINE> if os.path.exists(tests_dir): <NEW_LINE> <INDENT> return te... | Return None is no tests dir. | 625941e03617ad0b5ed68275 |
def stable(models, dates, variogram, t_cg, detection_bands): <NEW_LINE> <INDENT> check_vals = [] <NEW_LINE> for idx in detection_bands: <NEW_LINE> <INDENT> rmse_norm = max(variogram[idx], models[idx].rmse) <NEW_LINE> slope = models[idx].fitted_model.coef_[0] * (dates[-1] - dates[0]) <NEW_LINE> check_val = (abs(slope) +... | Determine if we have a stable model to start building with
Args:
models: list of current representative/fitted models
variogram: 1-d array of variogram values to compare against for the
normalization factor
dates: array of ordinal date values
t_cg: change threshold
detection_bands: index lo... | 625941e08e7ae83300e4b34d |
def get_committer_name(env=None): <NEW_LINE> <INDENT> if env is None: <NEW_LINE> <INDENT> env = os.environ <NEW_LINE> <DEDENT> if "GENTOO_COMMITTER_NAME" in env and "GENTOO_COMMITTER_EMAIL" in env: <NEW_LINE> <INDENT> user = "%s <%s>" % (env["GENTOO_COMMITTER_NAME"], env["GENTOO_COMMITTER_EMAIL"]) <NEW_LINE> <DEDENT> e... | Generate a committer string like echangelog does. | 625941e02ae34c7f2600d4b0 |
def edge_list_to_adjacency(edges): <NEW_LINE> <INDENT> adjacency = dict([(n, []) for n in edge_list_to_nodes(edges)]) <NEW_LINE> for edge in edges: <NEW_LINE> <INDENT> adjacency[edge[0]].append(edge[1]) <NEW_LINE> <DEDENT> return adjacency | Create adjacency dictionary based on a list of edges
:param edges: edges to create adjacency for
:type edges: :py:list
:rtype: :py:dict | 625941e04428ac0f6e5bab74 |
@modelbuilder("SALDO compound model", language=["swe"]) <NEW_LINE> def build_saldo_comp(out: ModelOutput = ModelOutput("saldo/saldo.compound.pickle"), saldom: Model = Model("saldo/saldom.xml")): <NEW_LINE> <INDENT> xml_lexicon = read_lmf(saldom.path) <NEW_LINE> save_to_picklefile(out.path, xml_lexicon) | Extract compound info from saldom.xml and save as a pickle file. | 625941e0796e427e537b0947 |
def Write(self, request, global_params=None): <NEW_LINE> <INDENT> config = self.GetMethodConfig('Write') <NEW_LINE> return self._RunMethod( config, request, global_params=global_params) | Writes log entries to Stackdriver Logging. This API method is the only way to send log entries to Stackdriver Logging. This method is used, directly or indirectly, by the Stackdriver Logging agent (fluentd) and all logging libraries configured to use Stackdriver Logging. A single request may contain log entries for a m... | 625941e082261d6c526ab824 |
def findMode(self, root): <NEW_LINE> <INDENT> if not root: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> self.maxAmount, self.pre, self.curFreq, self.res = 1, None, 1, [] <NEW_LINE> self.cur = None <NEW_LINE> self.dfs(root) <NEW_LINE> if self.curFreq > self.maxAmount: <NEW_LINE> <INDENT> return [self.cur] <NEW_LINE... | :type root: TreeNode
:rtype: List[int] | 625941e03317a56b86939fcf |
def test_task_nostate_cachelocations_updated(plugin, tmpdir): <NEW_LINE> <INDENT> cache_dir = tmpdir.mkdir("test_task_nostate") <NEW_LINE> cache_dir1 = tmpdir.mkdir("test_task_nostate1") <NEW_LINE> cache_dir2 = tmpdir.mkdir("test_task_nostate2") <NEW_LINE> nn = fun_addtwo(name="NA", a=3, cache_dir=cache_dir) <NEW_LINE>... | Two identical tasks with provided cache_dir;
the second task has cache_locations in init,
that is later overwritten in Submitter.__call__;
the cache_locations passed to call doesn't exist so the second task should run again | 625941e0e5267d203edce018 |
def main(): <NEW_LINE> <INDENT> input_dir = Path(sys.argv[1]) <NEW_LINE> frequency = Counter() <NEW_LINE> for path in sorted(input_dir.glob('*/wiki_*')): <NEW_LINE> <INDENT> logging.info(f'Processing{path}...') <NEW_LINE> with open(path) as file: <NEW_LINE> <INDENT> frequency += count_words(file) <NEW_LINE> <DEDENT> fo... | コマンドライン引数で指定したディレクトリ内のファイルを読み込んで、頻出単語を表示する | 625941e0442bda511e8be793 |
def check_memo(): <NEW_LINE> <INDENT> fr_month = ( "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre") <NEW_LINE> date = datetime.datetime.now() <NEW_LINE> mois = fr_month[date.month - 1] <NEW_LINE> actualDate = f'{date.day} {mois} à {date.hour}h' <NE... | fonction va regarder dans un fichier texte et qui parcour tous les
dictionnaires et compare la date du mémo ave la date actuelle pour voir si il doit speak le mémo
:return: | 625941e097e22403b379d31a |
def read_data(data): <NEW_LINE> <INDENT> global missionTime, softwareState,tiltX,tiltY,tiltZ,altitude,pressure,temp,voltage,teamID,packetCount, GPSTime,GPSLat,GPSLong,GPSSats,GPSAlt <NEW_LINE> global packetsDropped,packetReceivedRate <NEW_LINE> try: <NEW_LINE> <INDENT> teamID.append(data["dio-0"]) <NEW_LINE> ... | The Xbee module calls this method whenever it receives
data. It then sends the data as a single argument to
this method. | 625941e026068e7796caf063 |
def _3dby8toRGB ( indata ): <NEW_LINE> <INDENT> rgbdata = np.zeros ( indata.shape[0:2], dtype=np.uint32) <NEW_LINE> rgbdata = np.uint32(0xFF000000) + np.left_shift(np.uint32(indata[:,:,0]),16) + np.left_shift(np.uint32(indata[:,:,1]),8) + np.uint32(indata[:,:,2]) <NEW_LINE> rgbdata = np.left_shift(np.uint32(indata[:,:... | Convert a numpy array of 3d, 8-bit data to 32bit RGB | 625941e0097d151d1a2231d7 |
def test_encode_ping_frame(self): <NEW_LINE> <INDENT> frames = Frames() <NEW_LINE> expected_result = [b'\x89\x00'] <NEW_LINE> result = frames.encode_frame(Opcode.PING_FRAME) <NEW_LINE> self.assertEqual(result, expected_result) | Test for encoding ping frame | 625941e0be383301e01b57fe |
def add_dynamic_group(self, hosts, groupname, groupvars=None): <NEW_LINE> <INDENT> self.inventory.add_group(groupname) <NEW_LINE> my_group = Group(name=groupname) <NEW_LINE> if groupvars: <NEW_LINE> <INDENT> for key, value in groupvars.iteritems(): <NEW_LINE> <INDENT> my_group.set_variable(key, value) <NEW_LINE> <DEDEN... | add hosts to a group | 625941e05e10d32532c5f2a5 |
def get_rpi_revision(): <NEW_LINE> <INDENT> for line in open("/proc/cpuinfo"): <NEW_LINE> <INDENT> if "Revision" in line: <NEW_LINE> <INDENT> return re.sub('Revision\t: ([a-z0-9]+)\n', r'\1', line) | Returns the version number from the revision line. | 625941e0a17c0f6771cbe3cf |
def update(self): <NEW_LINE> <INDENT> if sys.platform == 'win32': <NEW_LINE> <INDENT> _ping_cmd = ['ping', '-n 1', '-w', '1000', self._host] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> _ping_cmd = ['ping', '-n', '-q', '-c1', '-W1', self._host] <NEW_LINE> <DEDENT> ping = subprocess.Popen(_ping_cmd, stdout=subprocess.P... | Update state of device. | 625941e066656f66f7cbc52c |
def load_exr_data(filename, preprocess=False, concat=False, target=False): <NEW_LINE> <INDENT> infile = OpenEXR.InputFile(filename) <NEW_LINE> color = get_layer(infile, 'Color') <NEW_LINE> normal = get_layer(infile, 'Normal') <NEW_LINE> albedo = get_layer(infile, 'Albedo') <NEW_LINE> depth = get_layer(infile, 'Depth') ... | Loads a multilayer OpenEXR file and returns a list of all features loaded as numpy arrays.
You can use np.concatenate(x, 2) to create a 3D array of size [width, height, 14] | 625941e044b2445a33932413 |
@register.filter <NEW_LINE> def filters_json(value, arg): <NEW_LINE> <INDENT> def _human_key(key): <NEW_LINE> <INDENT> parts = re.split('(\d*\.\d+|\d+)', key) <NEW_LINE> return tuple((e.swapcase() if i % 2 == 0 else float(e)) for i, e in enumerate(parts)) <NEW_LINE> <DEDENT> if arg == "county": <NEW_LINE> <INDENT> stat... | Returns Array with extra values removed based on species | 625941e026238365f5f0f1f2 |
def build_dict_from_items(self, *dicts, **items): <NEW_LINE> <INDENT> dict_list = list(dicts) <NEW_LINE> dict_list.append(items) <NEW_LINE> result = {} <NEW_LINE> for d in dict_list: <NEW_LINE> <INDENT> for key, value in d.items(): <NEW_LINE> <INDENT> camel_key = self._convert_lower_camel_case(key) <NEW_LINE> if value ... | A method to build a dictionary based on inputs, pruning items that are None.
:raises KeyError: In case there is a duplicate key name in the dictionary.
:returns: A single dict built from the input. | 625941e0a79ad161976cc4c5 |
def test_connection(self): <NEW_LINE> <INDENT> return {'session': self.session, 'error': self.error} | Test connection to Envialia webservices | 625941e0a8ecb033257d344b |
def when_hurricane(self): <NEW_LINE> <INDENT> return weatherutils.filter_by_status(self._forecast.get_weathers(), "hurricane", weather_code_registry) | Returns a sublist of the *Weather* list in the forecast, containing
only items having hurricane as weather condition.
:returns: a list of *Weather* objects | 625941e05fcc89381b1e1a40 |
def linking_predicates_descendants_expansion(self, linking_predicates): <NEW_LINE> <INDENT> retval = set(linking_predicates) <NEW_LINE> for lp in linking_predicates: <NEW_LINE> <INDENT> if lp in self._linking_predicates: <NEW_LINE> <INDENT> retval |= self._linking_predicates[lp]["descendants"] <NEW_LINE> <DEDENT> <DEDE... | Expands a set of linking predicates by adding their descendants
:param linking_predicates: the initial seed set of linking predicates
:return: a set containing the seed linking predicates and their descendants | 625941e030bbd722463cc147 |
def isloop(self): <NEW_LINE> <INDENT> return False | Method that returns if the node is a loop node.
Returns:
bool: True if it is a loop node, False else. | 625941e0187af65679ca549f |
def logloss_fobj(preds, train_data): <NEW_LINE> <INDENT> y = train_data.get_label() <NEW_LINE> p = 1.0 / (1.0 + np.exp(-preds)) <NEW_LINE> grad = p - y <NEW_LINE> hess = p * (1.0 - p) <NEW_LINE> return grad, hess | 二分类交叉熵损失函数的一阶导和二阶导
L(y, p) = -(ylogp + (1-y)log(1-p))
L' = p - y
L'' = p(1 - p) | 625941e0046cf37aa974d0c4 |
def editAttribute(self, node, index, newName=None, newIndex=None): <NEW_LINE> <INDENT> if not node in self.scene().nodes.values(): <NEW_LINE> <INDENT> print('Node object does not exist !') <NEW_LINE> print('Attribute creation aborted !') <NEW_LINE> return <NEW_LINE> <DEDENT> if newName != None: <NEW_LINE> <INDENT> if n... | Edit the specified attribute.
:type node: class.
:param node: The node instance that you want to delete.
:type index: int.
:param index: The index of the attribute in the node.
:type newName: str.
:param newName: The new name for the given attribute.
:type newIndex: int.
:param newIndex: The index for the given... | 625941e01f5feb6acb0c4ec9 |
@pytest.mark.parametrize( ('tstart', 'tstep', 'trange', 'geocentric', 'targets', 'id_type'), [ (2456117.641933589, 20.0, 600, 0, ['30101'], ['smallbody']), (2456184.7528431923, 20.0, 600, 0, ['30102'], ['smallbody']), (2456142.5, 20.0, 60, 0, ['30101', '30102'], ['smallbody', 'smallbody']), ]) <NEW_LINE> @pytest.mark.p... | Test that putting input from Horizons in gives Horizons consistent output. | 625941e0656771135c3ebbf2 |
def subdivide_ico(n): <NEW_LINE> <INDENT> verts = base_icosahedron() <NEW_LINE> bary = get_barymat(n) <NEW_LINE> tensor = np.tensordot(verts, bary, axes=[(0,), (-1,)]) <NEW_LINE> newverts = tensor.swapaxes(1, 2).reshape(-1, 3) <NEW_LINE> numtriangles = newverts.shape[0] <NEW_LINE> if numtriangles > 1e6: <NEW_LINE> <IND... | Compute the triangulation of the sphere by refining each face of the
icosahedron to an nth order barycentric triangle. There are two key issues
that this routine addresses :
1) calculate the triangles (unique by construction)
2) remove non-unique nodes and edges
:param n: Level of division of the Icosahedron
:param ic... | 625941e023849d37ff7b340c |
def get_max_pairwise_product(numbers: List[int]): <NEW_LINE> <INDENT> max_number = max(numbers) <NEW_LINE> numbers.remove(max_number) <NEW_LINE> second_max_number = max(numbers) <NEW_LINE> max_product = max_number * second_max_number <NEW_LINE> return max_product | return the largest pairwise product of two
numbers from a list of integers | 625941e0baa26c4b54cb149c |
def get_download_link_to_file(self, path_to_file): <NEW_LINE> <INDENT> url = self._base_url + "/resources/download" <NEW_LINE> payload = {'path': path_to_file} <NEW_LINE> r = requests.get(url, headers=self.base_headers, params=payload) <NEW_LINE> self._check_code(r) <NEW_LINE> return r.json() | :param path_to_file: path to file
:return: download link to file | 625941e0435de62698dfdfcd |
def apply_transform(self, input_columns, cache=None): <NEW_LINE> <INDENT> if cache is None: <NEW_LINE> <INDENT> cache = {} <NEW_LINE> <DEDENT> if len(input_columns) != self.input_valency: <NEW_LINE> <INDENT> raise ValueError("Expected %s input Columns but received %s." % (self.input_valency, len(input_columns))) <NEW_L... | Apply this `Transform` to the provided `Column`s, producing 'Tensor's.
Args:
input_columns: None, a `Column`, or a list of input `Column`s, acting as
positional arguments.
cache: a dict from Column reprs to Tensors.
Returns:
A namedtuple of the output Tensors.
Raises:
ValueError: `input_columns` does no... | 625941e05fc7496912cc3cfe |
def get_next_frame(self, timeout=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> frame_type, frame = self._default_listener.get(timeout) <NEW_LINE> <DEDENT> except Empty: <NEW_LINE> <INDENT> raise NoFrameReceivedError() <NEW_LINE> <DEDENT> return frame_type, frame | Get the next frame type and frame from the device.
Args:
timeout (number or None): If not-None, a positive number of seconds
to wait for a frame before raising a
:py:class:`.NoFrameReceivedError` exception.
Returns:
A :py:class:`.FrameType`, :py:class:`.Frame` tuple representing the
type o... | 625941e021bff66bcd684ccf |
def _ScanEncryptedVolume(self, scan_context, scan_node, options): <NEW_LINE> <INDENT> super(StorageMediaToolVolumeScanner, self)._ScanEncryptedVolume( scan_context, scan_node, options) <NEW_LINE> if not scan_context.IsLockedScanNode(scan_node.path_spec): <NEW_LINE> <INDENT> credential_type, credential_data = scan_node.... | Scans an encrypted volume scan node for volume and file systems.
Args:
scan_context (SourceScannerContext): source scanner context.
scan_node (SourceScanNode): volume scan node.
options (VolumeScannerOptions): volume scanner options.
Raises:
dfvfs.ScannerError: if the format of or within the source is not
... | 625941e07b25080760e397d7 |
def save(self): <NEW_LINE> <INDENT> db.session.add(self) <NEW_LINE> db.session.commit() | Persist Item into the database
:return: | 625941e0a4f1c619b28b03b1 |
def track_to_dict(self, t, albumartist, album, mtime): <NEW_LINE> <INDENT> artist = ', '.join(i['name'] for i in t['artists']) <NEW_LINE> track = float('{}.{}'.format(t['disc_number'], t['track_number'])) <NEW_LINE> title = t['name'] <NEW_LINE> uri = t['uri'] <NEW_LINE> mtime = mtime <NEW_LINE> return {'artist': artist... | use spotify track results to return agnostic track dict
uses details from parent album | 625941e03c8af77a43ae3b23 |
def draw(): <NEW_LINE> <INDENT> choose_cells() <NEW_LINE> draw_cells() | Draw function. | 625941e067a9b606de4a8237 |
def export(): <NEW_LINE> <INDENT> output_fileName = '_output/' + 'obs_type.xlsx' <NEW_LINE> writer = pd.ExcelWriter(output_fileName, engine='xlsxwriter') <NEW_LINE> file.to_excel(writer, sheet_name='0') <NEW_LINE> writer.save() | Exports the cleaned data to a new excel workbook | 625941e029b78933be1e5a27 |
def stderr(message, end="\n"): <NEW_LINE> <INDENT> symbol = colored("[ERR]","red") <NEW_LINE> currenttime = colored("[{}]".format(time.strftime("%H:%M:%S")),"green") <NEW_LINE> print("{}{}{}".format(symbol, currenttime,message),end=end) | 输出一个错误给用户
:param message:
:param end:
:return: | 625941e08e71fb1e9831db28 |
def xml_node_to_json(xml_node): <NEW_LINE> <INDENT> if((len(xml_node.childNodes) == 1) and (xml_node.childNodes[0].nodeType == xml_node.TEXT_NODE)): <NEW_LINE> <INDENT> txt_node = xml_node.childNodes[0] <NEW_LINE> txt_value = json_value(txt_node, txt_node.data) <NEW_LINE> if(len(xml_node.attributes) == 0): <NEW_LINE> <... | Returns a json node generated from the given xml element. | 625941e0fbf16365ca6f654a |
def draw_rect_border(x, y, width, height, color): <NEW_LINE> <INDENT> __rect(x,y,width,height,color) | Draws a rectangle with a border
:param x: the x coordinate of the lower-left corner of the rectangle
:param y: the y coordinate of the lower-left corner of the rectangle
:param width: the width of the rectangle
:param height: the height of the rectangle
:param color: RGB color of the border [R,G,B] scaled between [0... | 625941e060cbc95b062c68c3 |
def evaluation(X_selected, n_clusters, y): <NEW_LINE> <INDENT> k_means = KMeans(n_clusters=n_clusters, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances=True, verbose=0, random_state=None, copy_x=True, n_jobs=1) <NEW_LINE> k_means.fit(X_selected) <NEW_LINE> y_predict = k_means.labels_ <NEW_LIN... | This function calculates ARI, ACC and NMI of clustering results
Input
-----
X_selected: {numpy array}, shape (n_samples, n_selected_features}
input data on the selected features
n_clusters: {int}
number of clusters
y: {numpy array}, shape (n_samples,)
true labels
Output
------
nmi: {float}
... | 625941e08c3a87329515873e |
def test_remove_by_index(self): <NEW_LINE> <INDENT> list1 = LinkedList() <NEW_LINE> list1.remove_by_index(10) <NEW_LINE> nums = 10 <NEW_LINE> list1, reference_arr = generate_filled_list(LinkedList, nums) <NEW_LINE> list1.remove_by_index(100) <NEW_LINE> list_arr = list(list1) <NEW_LINE> self.assertEqual(list_arr, refere... | test remove_by_index() | 625941e0bde94217f368316d |
def local_test(): <NEW_LINE> <INDENT> require('project') <NEW_LINE> with cd(os.path.join("..", env.project)): <NEW_LINE> <INDENT> local("python " + env.test_cmd, capture=False) | run the django tests on the local machine | 625941e08e05c05ec3eea6f7 |
def perform(): <NEW_LINE> <INDENT> inf = sys.stdin <NEW_LINE> outf = sys.stdout <NEW_LINE> if flag_infile: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> inf = open(flag_infile, "r") <NEW_LINE> <DEDENT> except IOError as e: <NEW_LINE> <INDENT> u.error("unable to open input file %s: " "%s" % (flag_infile, e.strerror)) <NE... | Main driver routine. | 625941e04f88993c3716c3e4 |
def testPageLoads(self): <NEW_LINE> <INDENT> user = profile_utils.seedNDBUser() <NEW_LINE> profile_utils.loginNDB(user) <NEW_LINE> profile_utils.seedNDBProfile(self.program.key(), user=user) <NEW_LINE> response = self.get(_getOrgProfileCreateUrl(self.program)) <NEW_LINE> self.assertResponseOK(response) | Tests that page loads properly. | 625941e063b5f9789fde7466 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.