code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super().__init__(*args, **kwargs) <NEW_LINE> placeholders = { 'full_name': 'Full Name', 'email': 'Email Address', 'phone_number': 'Phone Number', 'street_address1': 'Street Address 1', 'street_address2': 'Street Address 2', 'town_or_city': 'Town Or City', 'postco... | Add placeholders and classes, remove-auto-generated labels and set autofocus on first field | 625941d72c8b7c6e89b35a14 |
@commands('factoid list') <NEW_LINE> @example('.factoid list #mychannel') <NEW_LINE> @require_privmsg() <NEW_LINE> def listnames(bot, trigger): <NEW_LINE> <INDENT> channel = trigger.group(3) <NEW_LINE> if not channel or not channel in bot.channels: <NEW_LINE> <INDENT> bot.reply("Invalid channel specified: {}. Valid cha... | Lists all factoid and alias names.
e.g. $prefixfactoid list #mychannel
Only usable in a private message. | 625941d730c21e258bdfa6f2 |
def test_multiple_targets(self): <NEW_LINE> <INDENT> self.invoke(['amd64', 'i386']) <NEW_LINE> self.assert_file_exists(self.get_built_file(target='amd64')) <NEW_LINE> self.assert_file_exists(self.get_built_file(target='i386')) | Test that passing multiple targets works. | 625941d7fbf16365ca6f641a |
def _setup_functions_captures(self): <NEW_LINE> <INDENT> concrete_functions = sorted(self._proto.concrete_functions.items()) <NEW_LINE> for name, proto in concrete_functions: <NEW_LINE> <INDENT> concrete_function = self._concrete_functions[name] <NEW_LINE> bound_inputs = [ self._get_tensor_from_node(node_id, name) for ... | Setup captures and variables in restored functions. | 625941d71f037a2d8b946452 |
def try_methods(): <NEW_LINE> <INDENT> elle = rg.SimpleTurtle() <NEW_LINE> elle.pen = rg.Pen('brown', 5) <NEW_LINE> elle.forward(150) <NEW_LINE> elle.left(90) <NEW_LINE> elle.forward(50) <NEW_LINE> elle.backward(100) | Constructs a SimpleTurtle and sets its pen to a new rg.Pen
that is 'brown' with thickness 5.
Then makes the SimpleTurtle move as follows (in the order listed):
-- forward 150 units
-- left 90 degrees
-- forward 50 units
-- backward 100 units | 625941d799cbb53fe6792e3a |
def test_unnamaed_to_sig_without_vpo_raises(self): <NEW_LINE> <INDENT> sig = inspect.Signature() <NEW_LINE> with pytest.raises(TypeError) as excinfo: <NEW_LINE> <INDENT> sort_arguments(sig, unnamed=(1,)) <NEW_LINE> <DEDENT> assert excinfo.value.args[0] == 'Cannot sort var-positional arguments' | Ensure a signature without a var-positional parameter raises when a
var-positional argument is supplied | 625941d7a05bb46b383eca75 |
def test_branch_creation(self): <NEW_LINE> <INDENT> self.client.login(username=self.admin.username, password=self.password) <NEW_LINE> response = self.client.post(self.branch_add_url, data=self.empty_form) <NEW_LINE> self.assertTemplateUsed('admin/change_form.html') <NEW_LINE> self.assertContains(response, 'This field ... | Test valid and invalid branch form submission from admin. | 625941d75f7d997b87174ced |
def _get_scheduler(get=None, collection=None) -> Optional[str]: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> import dask <NEW_LINE> <DEDENT> except ImportError: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> actual_get = dask.base.get_scheduler(get, collection) <NEW_LINE> try: <NEW_LINE> <INDENT> from dask.distrib... | Determine the dask scheduler that is being used.
None is returned if no dask scheduler is active.
See also
--------
dask.base.get_scheduler | 625941d7dc8b845886cb578a |
def action(self, line, eof=False): <NEW_LINE> <INDENT> if eof: <NEW_LINE> <INDENT> self._current.left.add_prod(self._current) <NEW_LINE> return <NEW_LINE> <DEDENT> indent = self.indention(line) <NEW_LINE> if self._indent is None: <NEW_LINE> <INDENT> self._indent = indent <NEW_LINE> <DEDENT> if indent < self._indent: <N... | Get inline python code. Uses `self._indent` to keep
track. Switches back do `parser` on unindents. | 625941d7498bea3a759b9d03 |
def get_friends(twitter, screen_name): <NEW_LINE> <INDENT> friends = [] <NEW_LINE> friends_request = robust_request(twitter, 'friends/ids',{'screen_name':screen_name, 'count': 5000}, max_tries=5) <NEW_LINE> friends = sorted([i for i in friends_request]) <NEW_LINE> return friends | Return a list of Twitter IDs for users that this person follows, up to 5000.
See https://dev.twitter.com/rest/reference/get/friends/ids
Note, because of rate limits, it's best to test this method for one candidate before trying
on all candidates.
Args:
twitter.......The TwitterAPI object
screen_name... a stri... | 625941d7f9cc0f698b14084e |
def find_edge_with_param(self,param): <NEW_LINE> <INDENT> retVal = None <NEW_LINE> nodes_range = range(len(self.edges)) <NEW_LINE> for i in nodes_range: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> retVal = self.edges[i][param] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> <DEDENT> if ret... | Same as find_node_with_param, but it is used for links
| 625941d7be8e80087fb20e94 |
def interrupt_kernel(self, kernel_id): <NEW_LINE> <INDENT> comp_id = self._kernels[kernel_id]["comp_id"] <NEW_LINE> reply = self._sender.send_msg({"type": "interrupt_kernel", "content": {"kernel_id": kernel_id}}, comp_id) <NEW_LINE> if reply["type"] == "success": <NEW_LINE> <INDENT> logger.info("Kernel %s interrupted."... | Interrupts a given kernel.
:arg str kernel_id: the id of the kernel you want interrupted | 625941d76aa9bd52df036ff9 |
def test_post_exists_does_nothing(mocker): <NEW_LINE> <INDENT> mocker.patch('praw.Reddit', new_callable=PrawMock) <NEW_LINE> mocker.patch('jobs.models.Post.exists', side_effect=lambda: True) <NEW_LINE> source = Source.objects.get(code='reddit') <NEW_LINE> harvester = Harvester(source) <NEW_LINE> jobs = list(harvester.h... | Test the reddit harvester stops on duplicates. | 625941d785dfad0860c3b0b0 |
def rotate(x, y, a): <NEW_LINE> <INDENT> return x * np.cos(a) + y * np.sin(a), -x * np.sin(a) + y * np.cos(a) | Rotate vector (x, y) by an angle a. | 625941d75fcc89381b1e1915 |
def transform(self, X, Y=None, copy=True): <NEW_LINE> <INDENT> check_is_fitted(self) <NEW_LINE> X = check_array(X, copy=copy, dtype=FLOAT_DTYPES) <NEW_LINE> X -= self.x_mean_ <NEW_LINE> X /= self.x_std_ <NEW_LINE> x_scores = np.dot(X, self.x_rotations_) <NEW_LINE> if Y is not None: <NEW_LINE> <INDENT> Y = check_array(Y... | Apply the dimension reduction learned on the train data.
Parameters
----------
X : array-like of shape (n_samples, n_features)
Training vectors, where n_samples is the number of samples and
n_features is the number of predictors.
Y : array-like of shape (n_samples, n_targets), default=None
Target vectors,... | 625941d7e5267d203edcdeef |
def test02_unary_math_operators(self): <NEW_LINE> <INDENT> import cppyy <NEW_LINE> number = cppyy.gbl.number <NEW_LINE> n = number(20) <NEW_LINE> n += number(10) <NEW_LINE> n -= number(10) <NEW_LINE> n *= number(10) <NEW_LINE> n /= number(2) <NEW_LINE> assert n == number(100) <NEW_LINE> nn = -n; <NEW_LINE> assert nn =... | Test overloading of unary math operators | 625941d78a43f66fc4b542b7 |
def post_setup_load_handlers(): <NEW_LINE> <INDENT> config.registry.palantir_handlers = load_handlers(config.settings) | Load handlers as a callback | 625941d73317a56b86939ea8 |
def get_reg_name(address: int) -> str: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return regs[address] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return "INVALID" | Get the register name by address. | 625941d7d7e4931a7ee9e172 |
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <... | Returns the model properties as a dict | 625941d7099cdd3c635f0eaf |
def search_grab_focus(self): <NEW_LINE> <INDENT> self.__search_entry.grab_focus() | Grab focus on search entry | 625941d7eab8aa0e5d26ddad |
def _dispatch(self): <NEW_LINE> <INDENT> if self.tokens: <NEW_LINE> <INDENT> if self.args: <NEW_LINE> <INDENT> rv = dispatch.dispatch(self.command, *self.args, backend=self.backend, daemon=self.daemon, join=self.join) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rv = dispatch.dispatch(self.command, backend=self.backen... | 分发命令 | 625941d721bff66bcd684ba5 |
def p_doWhMark3(p): <NEW_LINE> <INDENT> TAC.emit('ifgoto',p[-2]['place'],'eq 0', p[-7][2]) <NEW_LINE> TAC.emit('goto',p[-7][1],'','') <NEW_LINE> TAC.emit('label',p[-7][2],'','') | doWhMark3 : | 625941d707f4c71912b116d8 |
def move(paramTADretA, dx, dy): <NEW_LINE> <INDENT> paramTADretA[0] += dx <NEW_LINE> paramTADretA[1] += dy <NEW_LINE> paramTADretA[2] += dx <NEW_LINE> paramTADretA[3] += dy | Desloca, no plano, o retângulo (sua origem) de dx na coordenada x e
dy na coordenada y. | 625941d7627d3e7fe0d690a6 |
def test_get_pdp_list(): <NEW_LINE> <INDENT> full_pipe = 1 <NEW_LINE> df_1 = 2 <NEW_LINE> feat = ['a', 'b'] <NEW_LINE> with pytest.raises(TypeError): <NEW_LINE> <INDENT> pdp = tml.get_pdp(full_pipe, feat, df_1) | Test the function raises a TypeError if a list is in the input | 625941d731939e2706e4d0bc |
def test_invalid_credentials(self): <NEW_LINE> <INDENT> self.user = {"username": "testuserother", "password": "testpassword"} <NEW_LINE> response = self.app.post("/auth/login/", data=self.user) <NEW_LINE> self.assertEqual(response.status_code, 403) <NEW_LINE> output = json.loads(response.data.decode('utf-8')) <NEW_LINE... | Test that users cannot login with invalid credentials | 625941d7a8370b7717052af3 |
def PostprocessDetachDisk(disk_name, local_path): <NEW_LINE> <INDENT> if local_path: <NEW_LINE> <INDENT> path = local_path <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> path = '/dev/disk/by-id/google-{0:s}'.format(disk_name) <NEW_LINE> <DEDENT> if not IsBlockDevice(path): <NEW_LINE> <INDENT> log.info('Disk {0:s} alread... | Detaches Google Cloud Disk from an instance.
Args:
disk_name(str): The name of the Cloud Disk to dettach.
local_path(str): The local path to the block device to detach. | 625941d76fb2d068a760f2f4 |
def apply_name_map(self, cat_map={}, proc_map={}): <NEW_LINE> <INDENT> tmp = {} <NEW_LINE> for key, histo in self._histograms.items(): <NEW_LINE> <INDENT> fit_name, cat_name, proc_name = key <NEW_LINE> new_cat_name = cat_map.get(cat_name, cat_name) <NEW_LINE> new_proc_name = proc_map.get(proc_name, proc_name) <NEW_LINE... | Renaming method to change category and/or process naming convention | 625941d756ac1b37e6264421 |
def check_python_version(): <NEW_LINE> <INDENT> if version_info.major < 3 or (version_info.minor < 5 and version_info.major == 3): <NEW_LINE> <INDENT> s = "\nError: Python version not supported.\n" " Must use at least Python 3.5." <NEW_LINE> raise Exception(s) | Check the python version to ensure it is correct. PonyGE uses Python 3.
:return: Nothing | 625941d7d18da76e2353272c |
def main(switch_ip, switch_os): <NEW_LINE> <INDENT> f1 = open('up_ethernet.yaml', 'w') <NEW_LINE> f2 = open('up_portchannel.yaml', 'w') <NEW_LINE> driver = get_network_driver(switch_os) <NEW_LINE> device = driver(switch_ip, secrets.sw_user, secrets.sw_pwd) <NEW_LINE> device.open() <NEW_LINE> interface_list = device.get... | main function | 625941d766673b3332b922e6 |
def is_dead(self): <NEW_LINE> <INDENT> if self.health <= 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | (Gladiator) is dead when health reaches 0 | 625941d7fff4ab517eb2f691 |
def __init__(self, params, data, desc=''): <NEW_LINE> <INDENT> wx.Dialog.__init__(self, None, -1, "Specify parameters") <NEW_LINE> text = self.MakeStaticBoxSizer('Function', [desc]) <NEW_LINE> labels = [] <NEW_LINE> entries = [] <NEW_LINE> for name, validator, default in params: <NEW_LINE> <INDENT> labels.append(wx.Sta... | params is a list of (name, validator, defaults) tuples. | 625941d744b2445a339322e9 |
def testUpdateDispatchJobsParam(self): <NEW_LINE> <INDENT> model = samsara.models.update_dispatch_jobs_param.UpdateDispatchJobsParam() | Test UpdateDispatchJobsParam | 625941d74e4d5625662d462a |
def __init__(self, iface): <NEW_LINE> <INDENT> self.iface = iface <NEW_LINE> self.settings = QgridderSettings() <NEW_LINE> self.dlg_new = QGridderDialogNew(self.iface, self.settings) <NEW_LINE> self.dlg_refinement = QGridderDialogRefinement(self.iface, self.settings) <NEW_LINE> self.dlg_check3D = QGridderDialogCheck3D... | Description
-----------
Initialize Qgridder plugin | 625941d7b57a9660fec33adb |
def example_3_doubled(): <NEW_LINE> <INDENT> g = gen.multiple_priorities(io.load_generalized_from_file("assets/strong parity/example_3.txt"),2) <NEW_LINE> (a,c) = gp.generalized_parity_solver(g) <NEW_LINE> return op.are_lists_equal(a , [2, 1, 3, 4]) and op.are_lists_equal(c , [6, 7, 5]) | Solves a simple example. | 625941d75510c4643540f634 |
def place_buy_order(self, trader_id, price, stocks): <NEW_LINE> <INDENT> offer = BuyOrder(trader_id, price, stocks) <NEW_LINE> self.buy_orders.append(offer) <NEW_LINE> logging.info("New Offer registered! " + str(offer)) | Places an order to buy a stock.
:param trader_id: ID of the trader that wants to buy a stock.
:param price: Proposed price of one stock.
:param stocks: Number of the stocks that the trader wants to buy. | 625941d7bf627c535bc13424 |
def startGuess(self, data): <NEW_LINE> <INDENT> return 0*self.Ahfunc(data) | starting guess for deconvolution - can be overridden in derived classes
but the data itself is usually a pretty good guess. | 625941d76fb2d068a760f2f5 |
def create_message(from_addr, to_addr, subject, body, mime=None, attach_file=None): <NEW_LINE> <INDENT> msg = MIMEMultipart() <NEW_LINE> msg["From"] = from_addr <NEW_LINE> msg["To"] = to_addr <NEW_LINE> msg["Date"] = formatdate() <NEW_LINE> msg["Subject"] = subject <NEW_LINE> body = MIMEText(body) <NEW_LINE> msg.attach... | メッセージを作成する
@:param from_addr 差出人
@:param to_addr 宛先
@:param subject 件名
@:param body 本文
@:param mime MIME
@:param attach_file 添付ファイル
@:return メッセージ | 625941d73317a56b86939ea9 |
def _process_key_event (self, key): <NEW_LINE> <INDENT> if self._editor.is_empty() and (self._match_hotkey(key, IBus.KEY_Shift_L, IBus.ModifierType.SHIFT_MASK | IBus.ModifierType.RELEASE_MASK)): <NEW_LINE> <INDENT> self.set_input_mode(int(not self._input_mode)) <NEW_LINE> return True <NEW_LINE> <DEDENT> if self._match_... | Internal method to process key event | 625941d70a50d4780f6670e8 |
def __init__(self, parent = None): <NEW_LINE> <INDENT> QMainWindow.__init__(self, parent) <NEW_LINE> self.setupUi(self) <NEW_LINE> self.selectedItem = '' <NEW_LINE> self.items = [ u'均价', u'总市值', u'流通股本', u'总股本', ... | Constructor | 625941d7187af65679ca5374 |
def SubscribeKeyAll(self, func): <NEW_LINE> <INDENT> self.SubscribeKeyDown(func) <NEW_LINE> self.SubscribeKeyUp(func) <NEW_LINE> self.SubscribeKeyChar(func) | Registers the given function as the callback for all keyboard events.
Use the KeyAll property as a shortcut.
@param func: Callback function
@type func: callable | 625941d7d10714528d5fff3a |
def relabel_nodes(self, mapping): <NEW_LINE> <INDENT> unique_names = set(mapping.values()) <NEW_LINE> if len(unique_names) != len(self.nodes()): <NEW_LINE> <INDENT> raise ReGraphError( "Attempt to relabel nodes failed: the IDs are not unique!") <NEW_LINE> <DEDENT> temp_names = {} <NEW_LINE> for key, value in mapping.it... | Relabel graph nodes inplace given a mapping.
Similar to networkx.relabel.relabel_nodes:
https://networkx.github.io/documentation/development/_modules/networkx/relabel.html
Parameters
----------
mapping: dict
A dictionary with keys being old node ids and their values
being new id's of the respective nodes.
Ra... | 625941d7fbf16365ca6f641b |
def plot_scatter_matrix(self, hue: str=None) -> None: <NEW_LINE> <INDENT> if hue not in self.df.columns: <NEW_LINE> <INDENT> warnings.warn("{} is not found in dataframe's columns, ignoring hue...".format(hue)) <NEW_LINE> hue = None <NEW_LINE> <DEDENT> if hue: <NEW_LINE> <INDENT> sns.pairplot(self.df[self.num_cols]) <NE... | hue: str
indicating hue for plot
generate pair plots for numerical variables | 625941d7e1aae11d1e749f0e |
@contextmanager <NEW_LINE> def assert_directory_contents(path, changed=True): <NEW_LINE> <INDENT> old = dirhash(str(path), 'sha512') <NEW_LINE> yield <NEW_LINE> new = dirhash(str(path), 'sha512') <NEW_LINE> if changed: <NEW_LINE> <INDENT> assert old != new <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> assert old == new | Assert directory contents change or remain the same.
Contents are compared deeply, i.e. recursively and file contents are considered as well.
Parameters
----------
path : Path
Path to directory
changed : bool
If True, directory contents must change, else contents must remain the same. | 625941d73346ee7daa2b2fc2 |
def easter(year, method=EASTER_WESTERN): <NEW_LINE> <INDENT> if not (1 <= method <= 3): <NEW_LINE> <INDENT> raise ValueError("invalid method") <NEW_LINE> <DEDENT> y = year <NEW_LINE> g = y % 19 <NEW_LINE> e = 0 <NEW_LINE> if method < 3: <NEW_LINE> <INDENT> i = (19*g + 15) % 30 <NEW_LINE> j = (y + y//4 + i) % 7 <NEW_LIN... | This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, editor.
This algorithm implements three different Easter
calculation me... | 625941d7925a0f43d254a0cd |
def conversion_control_structure(rates, from_string, to_string): <NEW_LINE> <INDENT> if from_string == to_string: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> elif is_in_rates_forward_or_backward(rates, from_string, to_string): <NEW_LINE> <INDENT> return convert_forward_or_backward(rates, from_string, to_string) <N... | Determines which sort of currency conversion is needed based on input | 625941d738b623060ff0b042 |
def def_end_token(self, end_token_label): <NEW_LINE> <INDENT> tok = self.def_token(end_token_label, None) <NEW_LINE> self.end_token_label = end_token_label <NEW_LINE> self.end_token_subclass = tok <NEW_LINE> return tok | Define the end-token. The `def_begin_end_tokens` method should usually
be called instead. | 625941d7d99f1b3c44c677e0 |
def set_duration(self): <NEW_LINE> <INDENT> started_string = self.current_step["started"] <NEW_LINE> finished_string = self.current_step["finished"] <NEW_LINE> if not (started_string and finished_string): <NEW_LINE> <INDENT> self.current_step["duration"] = None <NEW_LINE> return <NEW_LINE> <DEDENT> start_time = self.pa... | Sets duration for the step in seconds. | 625941d78da39b475bd651ca |
def jabber_cmd_jchat(data, buffer, args): <NEW_LINE> <INDENT> if args: <NEW_LINE> <INDENT> context = jabber_search_context(buffer) <NEW_LINE> if context["server"]: <NEW_LINE> <INDENT> buddy = context["server"].search_buddy_list(args, by='alias') <NEW_LINE> if not buddy: <NEW_LINE> <INDENT> buddy = context["server"].add... | Command '/jchat'. | 625941d7a219f33f34628bbc |
def gcirc(ra1deg, dec1deg, ra2deg, dec2deg, getangle=False): <NEW_LINE> <INDENT> ra1 = np.array(ra1deg, dtype="f8", ndmin=1) <NEW_LINE> dec1 = np.array(dec1deg, dtype="f8", ndmin=1) <NEW_LINE> ra2 = np.array(ra2deg, dtype="f8", ndmin=1) <NEW_LINE> dec2 = np.array(dec2deg, dtype="f8", ndmin=1) <NEW_LINE> deg2rad(ra1, ra... | This is currently very inflexible: degrees in, radians out | 625941d75fcc89381b1e1916 |
def time_series_range(x): <NEW_LINE> <INDENT> return time_series_maximum(x) - time_series_minimum(x) | Calculates the range value of the time series x.
:param x: the time series to calculate the feature of
:type x: pandas.Series
:return: the value of this feature
:return type: float | 625941d7be383301e01b56d8 |
def evaluate_state(self): <NEW_LINE> <INDENT> query_clauses = [_empty] * len(self.clauses) <NEW_LINE> values = [] <NEW_LINE> for state in self.orm.state: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> query_clauses[self.clauses.index(state.clause)] = state.string <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <IND... | :see::meth:SELECT.evaluate_state | 625941d71d351010ab855d70 |
def get_max(self): <NEW_LINE> <INDENT> assert self.count > 0 <NEW_LINE> return self.data[1] | 获取最大堆中的堆顶元素 | 625941d7d6c5a102081442a1 |
def on_change_partner(self, cr, uid, ids, partner_id): <NEW_LINE> <INDENT> if not partner_id: <NEW_LINE> <INDENT> return {'value' : {'email_to' : False, 'address_id': False}} <NEW_LINE> <DEDENT> addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact']) <NEW_LINE> data = {'address_id': addr['co... | This function fills address information based on partner/user selected
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Mail’s IDs
@param user: Changed User id
@param partner: Changed Partner id | 625941d7fff4ab517eb2f692 |
def tensor_array_scatter(handle, indices, value, flow_in, name=None): <NEW_LINE> <INDENT> _ctx = _context._context <NEW_LINE> if _ctx is None or not _ctx._eager_context.is_eager: <NEW_LINE> <INDENT> _, _, _op = _op_def_lib._apply_op_helper( "TensorArrayScatter", handle=handle, indices=indices, value=value, flow_in=flow... | TODO: add doc.
Args:
handle: A `Tensor` of type mutable `string`.
indices: A `Tensor` of type `int32`.
value: A `Tensor`.
flow_in: A `Tensor` of type `float32`.
name: A name for the operation (optional).
Returns:
A `Tensor` of type `float32`. | 625941d73cc13d1c6d3c75cf |
def __init__(self): <NEW_LINE> <INDENT> this = _x64dbgapi64.new_XREF_RECORD() <NEW_LINE> try: self.this.append(this) <NEW_LINE> except: self.this = this | __init__(XREF_RECORD self) -> XREF_RECORD | 625941d7377c676e912723fd |
def round_step(x, prec=2, base=0.05): <NEW_LINE> <INDENT> return round(base * round(float(x) / base), prec) | Return a number rounded to the nearest base. | 625941d710dbd63aa1bd2df8 |
def test_ppc_7450(self): <NEW_LINE> <INDENT> self.vm.set_console() <NEW_LINE> self.vm.launch() <NEW_LINE> wait_for_console_pattern(self, '>> OpenBIOS') <NEW_LINE> wait_for_console_pattern(self, '>> CPU type PowerPC,G4') | :avocado: tags=cpu:7450 | 625941d763b5f9789fde733b |
def setUp(self): <NEW_LINE> <INDENT> self.doSetUp('hdr_dep_check', target='...') | setup method. | 625941d7d268445f265b50c4 |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super().__init__(*args, **kwargs) <NEW_LINE> self.order_fields([ 'token', 'export_wf']) | Modify the fields with the adequate information. | 625941d756b00c62f0f148b0 |
def clones (module, N) : <NEW_LINE> <INDENT> return nn.ModuleList ([copy.deepcopy(module) for _ in range (N)]) | 复制module n次 | 625941d7ab23a570cc2503d9 |
def test_from_path(self) -> None: <NEW_LINE> <INDENT> with FileSource.from_path("tests/embedding/syntax.pyhp", compiler) as source: <NEW_LINE> <INDENT> spec = source.spec <NEW_LINE> stat = os.fstat(source.fd.fileno()) <NEW_LINE> <DEDENT> self.assertEqual((stat.st_ino, stat.st_dev), os.stat("tests/embedding/syntax.pyhp"... | test FileSource.from_path | 625941d77cff6e4e81117bdb |
def __init__(self, brushinfo=None, painting_only=False, cache_dir=None, cache_size=DEFAULT_CACHE_SIZE, max_undo_stack_size=DEFAULT_UNDO_STACK_SIZE): <NEW_LINE> <INDENT> object.__init__(self) <NEW_LINE> if not brushinfo: <NEW_LINE> <INDENT> brushinfo = brush.BrushInfo() <NEW_LINE> brushinfo.load_defaults() <NEW_LINE> <D... | Initialize
:param brushinfo: the lib.brush.BrushInfo instance to use
:param painting_only: only use painting layers
:param cache_dir: use an existing cache dir
:param cache_size: size of the layer render cache
If painting_only is true, then no tempdir will be created by the
document when it is initialized or cleared.... | 625941d78c3a873295158612 |
def assert_stat_op_api(opname, float_frame, float_string_frame, has_numeric_only=False): <NEW_LINE> <INDENT> getattr(float_string_frame, opname)(axis=0) <NEW_LINE> getattr(float_string_frame, opname)(axis=1) <NEW_LINE> if has_numeric_only: <NEW_LINE> <INDENT> getattr(float_string_frame, opname)(axis=0, numeric_only=Tru... | Check that API for operator opname works as advertised on frame
Parameters
----------
opname : string
Name of the operator to test on frame
float_frame : DataFrame
DataFrame with columns of type float
float_string_frame : DataFrame
DataFrame with both float and string columns
has_numeric_only : bool, defau... | 625941d726238365f5f0f0c6 |
@keyword('get_list_count') <NEW_LINE> def get_list_count(view): <NEW_LINE> <INDENT> return var_cache['proxy'].get_list_count(view) | get listView's count
version 1
:param view:
:return: | 625941d7f7d966606f6aa25c |
def handle_error(err): <NEW_LINE> <INDENT> logging.exception(err) <NEW_LINE> message = '' <NEW_LINE> if hasattr(err, 'data') and err.data['message']: <NEW_LINE> <INDENT> message = err.data['message'] <NEW_LINE> <DEDENT> elif hasattr(err, 'message') and err.message: <NEW_LINE> <INDENT> message = err.message <NEW_LINE> <... | This error handler logs exception and then makes response with most
appropriate error message and error code
Args:
err (Exception): the raised Exception object | 625941d70383005118ecf837 |
def write_correlation_samples(writer, correlation_terms, correlation_samples, channel_count): <NEW_LINE> <INDENT> assert(len(correlation_terms) == len(correlation_samples)) <NEW_LINE> if channel_count == 2: <NEW_LINE> <INDENT> for (term, samples) in zip(correlation_terms, correlation_samples): <NEW_LINE> <INDENT> if (1... | correlation_terms[p] are correlation term ints for each pass
correlation_samples[p][c][s] are lists of correlation sample ints
for each pass and channel in descending order
writes the samples to sub block data in the proper order/format | 625941d7596a897236089d14 |
def _check_num_states(self, num_states): <NEW_LINE> <INDENT> self._num_states += num_states <NEW_LINE> if self._max_num_states is not None: <NEW_LINE> <INDENT> if self._num_states > self._max_num_states: <NEW_LINE> <INDENT> raise RuntimeError("Too many states detected while running dynamic " "programming: got %d states... | Track the number of states. | 625941d7dd821e528d63b3fd |
def apply_single_function(ds_dict, *, source_dataset_name, dataset_name, serialized_function, added_descr_txt, drop_extra, **opts): <NEW_LINE> <INDENT> new_ds = {} <NEW_LINE> logger.debug(f"Loading {source_dataset_name}...") <NEW_LINE> ds = ds_dict.get(source_dataset_name) <NEW_LINE> new_metadata = ds.metadata.copy() <... | Parameters
----------
ds_dict:
input datasets.
source_dataset_name:
name of the dataset that the new dataset will be derived from
dataset_name:
name of the new dataset_catalog
added_descr_txt: Default None
new description text to be appended to the metadata descr
serialized_function:
function (seria... | 625941d7ad47b63b2c50a1d5 |
def to_instance(self, no_copy: bool = False) -> T: <NEW_LINE> <INDENT> if self.is_valid is True: <NEW_LINE> <INDENT> init_function = cast(Callable, getattr(self._class_type, 'from_qonfig', None)) <NEW_LINE> if init_function is None: <NEW_LINE> <INDENT> raise NotQonfigurableError() <NEW_LINE> <DEDENT> if no_copy or self... | Return Instance of class configured in the Qonfig.
Args:
no_copy: Don't copy elements in Qonfig on instance creation
(Use when a reference to an object should be passed
instead of a copy of the object)
Returns:
instance (T): Instance of the python class configured by Qonfig
Raises:
... | 625941d7091ae356686671b1 |
def match(self, view, force_match=True, clone_view=False): <NEW_LINE> <INDENT> if view is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> view.settings().set("bracket_highlighter.busy", True) <NEW_LINE> if clone_view: <NEW_LINE> <INDENT> view.settings().set("bracket_highlighter.clone", view.id()) <NEW_LINE> <DEDEN... | Preform matching brackets surround the selection(s). | 625941d77d43ff24873a2ef6 |
def test_combination_of_column_and_cell_exclusion_proper_candidate_is_found(self): <NEW_LINE> <INDENT> candidate_cells = _RegionCandidateCells(topmost_row = 6, leftmost_column = 0, value = 2) <NEW_LINE> exclusion_result = candidate_cells.apply_and_exclude_cell_value(row = 6, column = 0, value = 1) <NEW_LINE> self.asser... | +-------+-------+-------+
| | | |
| 2 | | |
| | | |
+-------+-------+-------+
| | | |
| | | |
| 2 | | |
+-------+-------+-------+
| 1 | | |
| C | | |
| 4 | | |
+-------... | 625941d75fdd1c0f98dc0489 |
def normalize(x): <NEW_LINE> <INDENT> target = (x-x.min())/(x.max()-x.min()) <NEW_LINE> return target | Normalize a list of sample image data in the range of 0 to 1
: x: List of image data. The image shape is (32, 32, 3)
: return: Numpy array of normalize data | 625941d726238365f5f0f0c7 |
def resolve(self): <NEW_LINE> <INDENT> self._url = HealthcheckUrl( path=self._reverse(), querystring=self.querystring ) <NEW_LINE> self._defaultName = self._create_name() <NEW_LINE> self.key = self.key if self.key else self._create_key() | Because the route cannot be reversed into a URL at the same time its defined, we delay route resolution
until we are ready to submit the healthchecks to the API. | 625941d7a79ad161976cc39b |
def __init__(self): <NEW_LINE> <INDENT> super(YTS, self).__init__('YTS', 'https://yts.to/api/v2/list_movies.json') | Initialises the provider with the YTS url | 625941d716aa5153ce3626cd |
def get_num_steps(trial_swing_indices): <NEW_LINE> <INDENT> return len(trial_swing_indices["lf_sensor"][0]) + len(trial_swing_indices["rf_sensor"][0]) | Gets the number of steps (across both feet) in a single trial. As given by the trial_swing_indices.
:param trial_swing_indices: The swing indices of the trial. A dictionary mapping from sensor name (lf_sensor or
rf_sensor) to the foot_swing_indices - a 2d numpy array with shape
... | 625941d7283ffb24f3c55b55 |
def generate_form(self, buyer, order, amount, url=None): <NEW_LINE> <INDENT> data = { 'merchant_id': self.MERCHANT_ID, 'merchant_key': self.MERCHANT_KEY, 'return_url': f'{url}?action=return', 'cancel_url': f'{url}?action=cancel', 'notify_url': f'{url}?action=notify', 'name_first': buyer['first_name'], 'name_last': buye... | Generate payment form. | 625941d7be383301e01b56d9 |
def _derivative_(self, *args, **kwds): <NEW_LINE> <INDENT> x = args[0] <NEW_LINE> return -csch(x)*coth(x) | EXAMPLES::
sage: bool(diff(csch(x), x) == diff(1/sinh(x), x))
True
sage: diff(csch(x), x)
-coth(x)*csch(x) | 625941d7379a373c97cfad9c |
def ingest_Jan_2017(): <NEW_LINE> <INDENT> i = 1 <NEW_LINE> while i < 31: <NEW_LINE> <INDENT> if i < 10: <NEW_LINE> <INDENT> os.system('wget -c http://files.pushshift.io/reddit/staging/RC_2017-01-0%s.gz'%i) <NEW_LINE> os.system('gzip -d RC_2017-01-0%s'%i) <NEW_LINE> os.system('aws s3 cp RC_2017-01-0%s s3://historical-r... | Takes all reddit comments from January 2017
& pushes it to s3 | 625941d77b25080760e396ae |
def get_renderer(self, page): <NEW_LINE> <INDENT> if page[:-4] == '.xml': <NEW_LINE> <INDENT> return 'xml' <NEW_LINE> <DEDENT> return 'xhtml' | Returns genshi renderer type for chosen page. | 625941d70383005118ecf838 |
def create_lambda_to_dummy_called_intrinsic(parameter_name, parameter_type=tf.int32): <NEW_LINE> <INDENT> call = create_dummy_called_intrinsic( parameter_name=parameter_name, parameter_type=parameter_type) <NEW_LINE> return building_blocks.Lambda(parameter_name, parameter_type, call) | Returns a lambda to call a dummy intrinsic.
Lambda(x)
|
Call
/ \
intrinsic Ref(x)
Args:
parameter_name: The name of the parameter.
parameter_type: The type of the parameter. | 625941d77d847024c06be514 |
def add_all(self, sequence, minscore): <NEW_LINE> <INDENT> heap = self.heap <NEW_LINE> docs = self.docs <NEW_LINE> capacity = self.capacity <NEW_LINE> subtotal = 0 <NEW_LINE> for docnum, score in sequence: <NEW_LINE> <INDENT> if score < minscore: continue <NEW_LINE> docs.set(docnum) <NEW_LINE> subtotal += 1 <NEW_LINE> ... | Adds a sequence of (item, score) pairs.
| 625941d73617ad0b5ed6814c |
def rename(self, shop): <NEW_LINE> <INDENT> if not isinstance(shop, type(self.get_rename_obj())): <NEW_LINE> <INDENT> raise TypeError( "Get shop from get_rename_obj and call with that") <NEW_LINE> <DEDENT> return self.service2.rename(shop) | Rename shop
Warning: this might change some urls in the shop and confuse
search engines etc.
renameshop = sp.get_rename_obj()
renameshop.Alias = "ExistingAlias"
renameshop.NewAlias = "NewAlias"
sp.rename(renamshop)
returns None if the operation was successfull | 625941d7fbf16365ca6f641c |
def eval(self): <NEW_LINE> <INDENT> correct = 0 <NEW_LINE> total = self._analogy_questions.shape[0] <NEW_LINE> start = 0 <NEW_LINE> while start < total: <NEW_LINE> <INDENT> limit = start + 2500 <NEW_LINE> sub = self._analogy_questions[start:limit, :] <NEW_LINE> idx = self._predict(sub) <NEW_LINE> start = limit <NEW_LIN... | Evaluate analogy questions and reports accuracy. | 625941d7b5575c28eb68e258 |
def compute_cost_with_regularization(AL, Y, caches, lambd): <NEW_LINE> <INDENT> m = Y.shape[1] <NEW_LINE> sum_W=0 <NEW_LINE> for i in caches: <NEW_LINE> <INDENT> sum_W+= np.sum(np.square(i[0][1])) <NEW_LINE> <DEDENT> cross_entropy_cost = compute_cost(AL, Y) <NEW_LINE> L2_regularization_cost = lambd / (2 * m) * (sum_W) ... | Implement the cost function with L2 regularization. .
Arguments:
AL -- post-activation, output of forward propagation, of shape (output size, number of examples)
Y -- "true" labels vector, of shape (output size, number of examples)
parameters -- python dictionary containing parameters of the model
Returns:
cost - val... | 625941d763d6d428bbe44746 |
def acl_changed(module, cmd): <NEW_LINE> <INDENT> if platform.system().lower() == 'freebsd': <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> cmd = cmd[:] <NEW_LINE> cmd.insert(1, '--test') <NEW_LINE> lines = run_acl(module, cmd) <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> if not line.endswith('*,*'): <NEW_LIN... | Returns true if the provided command affects the existing ACLs, false otherwise. | 625941d72c8b7c6e89b35a16 |
def train(self, input_data): <NEW_LINE> <INDENT> def min_func(params): <NEW_LINE> <INDENT> self.params.arr1d = params <NEW_LINE> self._feed_forward(input_data) <NEW_LINE> self._backprop(input_data) <NEW_LINE> value = self._cost_func(input_data) <NEW_LINE> grad = self._params_grad.arr1d <NEW_LINE> return value, grad <NE... | Train parameters of the SparseAutoencoder with input data.
Parameters
----------
input_data : Input training data. | 625941d750812a4eaa59c576 |
def get_error_message(self): <NEW_LINE> <INDENT> with self.lock: <NEW_LINE> <INDENT> assert self.has_error() <NEW_LINE> return self.error_message | Fetche an error message.
:return: an error message
:rtype: str | 625941d7a934411ee37518ea |
def SetSmoothingFilter(self, *args): <NEW_LINE> <INDENT> return _itkBayesianClassifierImageFilterPython.itkBayesianClassifierImageFilterVIF2USDD_SetSmoothingFilter(self, *args) | SetSmoothingFilter(self, itkImageToImageFilterID2ID2 arg0) | 625941d7bd1bec0571d90886 |
def test_cycle_detection(self): <NEW_LINE> <INDENT> a_scheduler = Scheduler() <NEW_LINE> a_scheduler.add_a_prerequisite(task='A', prerequisite='B') <NEW_LINE> a_scheduler.add_a_prerequisite(task='B', prerequisite='C') <NEW_LINE> a_scheduler.add_a_prerequisite(task='C', prerequisite='A') <NEW_LINE> with self.assertRaise... | Test public methods on a task set, which forms a cycle. | 625941d7498bea3a759b9d05 |
def draw_line(self, x0, y0, x1, y1, c, pattern=0xffff): <NEW_LINE> <INDENT> x0, y0 = self.screen.mode.cutoff_coord(x0, y0) <NEW_LINE> x1, y1 = self.screen.mode.cutoff_coord(x1, y1) <NEW_LINE> if y1 <= y0: <NEW_LINE> <INDENT> x1, y1, x0, y0 = x0, y0, x1, y1 <NEW_LINE> <DEDENT> dx, dy = abs(x1-x0), abs(y1-y0) <NEW_LINE> ... | Draw a line between the given physical points. | 625941d7e76e3b2f99f3aa5e |
def _get_list(self, **filter) -> 'RPC response': <NEW_LINE> <INDENT> model_objects = self._model.query.filter_by(**filter) <NEW_LINE> return self.__serialize_many(model_objects) | List model objects | 625941d7a8ecb033257d3322 |
def Keywords(lang_id=0): <NEW_LINE> <INDENT> return [(5, XML_KEYWORDS + u" " + SGML_KEYWORDS)] | Returns Specified Keywords List
@param lang_id: used to select specific subset of keywords | 625941d70c0af96317bb843f |
def __vcsRegisteredState_wc(self, name): <NEW_LINE> <INDENT> dname, fname = self.splitPath(name) <NEW_LINE> if fname == '.': <NEW_LINE> <INDENT> if os.path.isdir(os.path.join(dname, self.adminDir)): <NEW_LINE> <INDENT> return self.canBeCommitted <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.canBeAdded <NEW_... | Private method used to get the registered state of a file in the vcs.
This is the variant for subversion installations using the old working
copy meta-data format.
@param name filename to check (string)
@return a combination of canBeCommited and canBeAdded | 625941d799fddb7c1c9de5e7 |
def mkwc(self): <NEW_LINE> <INDENT> self.wcname = tempfile.mkdtemp("wc") | creates the working copy directory | 625941d782261d6c526ab6f8 |
def quantity_constructor(loader, node): <NEW_LINE> <INDENT> from yaml.nodes import ScalarNode <NEW_LINE> scalar = loader.construct_scalar(node) <NEW_LINE> value_str, unit_str = scalar.split(None,1) <NEW_LINE> vnode = ScalarNode('tag:yaml.org,2002:float', value_str) <NEW_LINE> value = loader.construct_yaml_float(vnode) ... | A YAML loader for quantities | 625941d7956e5f7376d710c2 |
def testDeleteSimple(self): <NEW_LINE> <INDENT> response = self.client.get(VpopAdvTest.urlDelete.format(w)) <NEW_LINE> status = self.check(response, "status") <NEW_LINE> self.assertEqual(str(status), "OK") | Tests key deletion by simply verifying that the call suceeds and
returns an positive status code and message. | 625941d7287bf620b61d3cb9 |
def set_active(self): <NEW_LINE> <INDENT> set_active_slide(self.sid) | Appoint this item as the active slide. | 625941d785dfad0860c3b0b2 |
def needs_host(func): <NEW_LINE> <INDENT> from fabric.state import env <NEW_LINE> @wraps(func) <NEW_LINE> def host_prompting_wrapper(*args, **kwargs): <NEW_LINE> <INDENT> while not env.get('host_string', False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> input = raw_input <NEW_LINE> <DEDENT> except NameError: <NEW_LI... | Prompt user for value of ``env.host_string`` when ``env.host_string`` is
empty.
This decorator is basically a safety net for silly users who forgot to
specify the host/host list in one way or another. It should be used to wrap
operations which require a network connection.
Due to how we execute commands per-host in `... | 625941d7d4950a0f3b08c5a3 |
def put(self, id, object): <NEW_LINE> <INDENT> raise Exception("not-implemented") | Put an object into the cache.
@param id: The object id.
@type id: str
@param object: The object to add.
@type object: any | 625941d75fdd1c0f98dc048a |
def ppc(self, nsims=1000, T=np.mean): <NEW_LINE> <INDENT> if self.latent_variables.estimation_method not in ['BBVI', 'M-H']: <NEW_LINE> <INDENT> raise Exception("No latent variables estimated!") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> lv_draws = self.draw_latent_variables(nsims=nsims) <NEW_LINE> mus = [] <NEW_LIN... | Computes posterior predictive p-value
Parameters
----------
nsims : int (default : 1000)
How many draws for the PPC
T : function
A discrepancy measure - e.g. np.mean, np.std, np.max
Returns
----------
- float (posterior predictive p-value) | 625941d78a43f66fc4b542b9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.