code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def do_motion_notify_event(self, event): <NEW_LINE> <INDENT> if event.state == Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.BUTTON1_MASK: <NEW_LINE> <INDENT> rect = self.get_allocation() <NEW_LINE> x, y = (self.borde, self.borde) <NEW_LINE> w, h = (rect.width-(self.borde*2), rect.height-(self.borde*2)) <NEW_LINE> even... | Cuando el usuario se desplaza por la barra de progreso. | 625941dd9b70327d1c4e10ec |
def testStandardError(self): <NEW_LINE> <INDENT> c = ExternalCommand(['darcs', 'ciao']) <NEW_LINE> out, err = c.execute("ciao", stdout=PIPE, stderr=PIPE) <NEW_LINE> self.assert_("darcs failed" in err.read()) | Verify that ExternalCommand redirects stderr. | 625941dde1aae11d1e749fd0 |
def specifications(self, user, sort=None, quantity=None, filter=None, need_people=True, need_branches=True, need_workitems=False): <NEW_LINE> <INDENT> base_clauses = [Specification.productID == self.id] <NEW_LINE> return search_specifications( self, base_clauses, user, sort, quantity, filter, need_people=need_people, n... | See `IHasSpecifications`. | 625941dd0a50d4780f6671ab |
def testDirectoryTraversal(self): <NEW_LINE> <INDENT> response = self._get('/..' * 30 + '/etc/passwd') <NEW_LINE> self.assertEqual(response.status, 400) | Attempt a directory traversal attack. | 625941ddc432627299f04f5e |
def consulta(self): <NEW_LINE> <INDENT> if self.inicio is not None: <NEW_LINE> <INDENT> elem = self.inicio.dado <NEW_LINE> return elem <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return "A fila está vazia!" | retorna o inicio sem remover | 625941dd3317a56b86939f68 |
def tail(self, n=5): <NEW_LINE> <INDENT> if self.empty: <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if self._length is not None: <NEW_LINE> <INDENT> length = self._length <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> length = self._lazy_len().weld_expr <NEW_LINE> <DEDENT> return Index(... | Return Index with the last n values.
Parameters
----------
n : int
Number of values.
Returns
-------
Series
Index containing the last n values.
Examples
--------
>>> ind = bl.Index(np.arange(3, dtype=np.float64))
>>> print(ind.tail(2).evaluate())
[1. 2.] | 625941dd925a0f43d254a190 |
def shift_points_along_viewing_rays(pts, distance): <NEW_LINE> <INDENT> if pts.ndim != 2 or pts.shape[0] != 3: <NEW_LINE> <INDENT> raise ValueError('Input coordinates must be of shape 3xN.') <NEW_LINE> <DEDENT> pts = pts.astype(np.float64) <NEW_LINE> num_pts = pts.shape[1] <NEW_LINE> if isinstance(distance, numbers.Num... | Shifts points along the viewing rays in a pinhole camera model. Usually
used with 3xN pts: x and y coordinates will be computed, such that
z=distance; distance can be a scalar or a 1xN array | 625941dd7d847024c06be5d5 |
@tf_export('igamma') <NEW_LINE> def igamma(a, x, 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( "Igamma", a=a, x=x, name=name) <NEW_LINE> _result = _op.outputs[:] <NEW_LINE> _inputs_fl... | Compute the lower regularized incomplete Gamma function `Q(a, x)`.
The lower regularized incomplete Gamma function is defined as:
\\(P(a, x) = gamma(a, x) / Gamma(a) = 1 - Q(a, x)\\)
where
\\(gamma(a, x) = int_{0}^{x} t^{a-1} exp(-t) dt\\)
is the lower incomplete Gamma function.
Note, above `Q(a, x)` ... | 625941dd55399d3f055889cc |
def hpfeedsend(self, eformat): <NEW_LINE> <INDENT> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) <NEW_LINE> sock.settimeout(2) <NEW_LINE> result = sock.connect_ex((self.ECFG["host"], int(self.ECFG["port"]))) <NEW_LINE> sock.close() <NEW_LINE> if result != 0: <NEW_LINE> <INDENT> self.logger.warning(f"HPFEEDS ... | workaround if hpfeeds broker is offline as otherwise hpfeeds lib will loop connection attempt | 625941dd6aa9bd52df0370bc |
def get( self, resource_group_name, circuit_name, peering_name, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}' <NEW_LINE> path_format... | Gets the specified authorization from the specified express route
circuit.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param circuit_name: The name of the express route circuit.
:type circuit_name: str
:param peering_name: The name of the peering.
:type peering_name: str... | 625941dd01c39578d7e75152 |
def get_auth_stdin(refresh_token_filename): <NEW_LINE> <INDENT> refresh_token_cache = RefreshTokenCache(refresh_token_filename) <NEW_LINE> return get_auth(CredentialsPrompt(), refresh_token_cache) | Wrapper for get_auth that prompts the user on stdin. | 625941dd16aa5153ce36278e |
def initializeModule(libc): <NEW_LINE> <INDENT> for function in ("inotify_add_watch", "inotify_init", "inotify_rm_watch"): <NEW_LINE> <INDENT> if getattr(libc, function, None) is None: <NEW_LINE> <INDENT> raise ImportError("libc6 2.4 or higher needed") <NEW_LINE> <DEDENT> <DEDENT> libc.inotify_init.argtypes = [] <NEW_L... | Initialize the module, checking if the expected APIs exist and setting the
argtypes and restype for C{inotify_init}, C{inotify_add_watch}, and
C{inotify_rm_watch}. | 625941dd442bda511e8be72b |
def get_form_vals(self, dynamic_fields, domains, cfg_step): <NEW_LINE> <INDENT> vals = {} <NEW_LINE> dynamic_fields = dynamic_fields.copy() <NEW_LINE> step_val_ids = cfg_step and cfg_step.attribute_line_ids.mapped('value_ids').ids or self.product_tmpl_id.attribute_line_ids.mapped('value_ids').ids ... | Generate a dictionary to return new values via onchange method.
Domains hold the values available, this method enforces these values
if a selection exists in the view that is not available anymore.
Also, if there are values blanked out by this, then try and see if
there is an available default.
:param dynamic_fields: ... | 625941dde64d504609d74b56 |
def get_configuration_info(self): <NEW_LINE> <INDENT> pass <NEW_LINE> algo_info = "Algorithmus - {}\n".format(self.name) <NEW_LINE> algo_info += "\n" <NEW_LINE> algo_info += "Parameter\n" <NEW_LINE> for parameter_key in self.parameters: <NEW_LINE> <INDENT> algo_info += "{}: {} \n".format(parameter_key, self.parameters[... | This function returns information about selected algorithm and selected parameters
:return: (str) Returns selected algorithm and selected parameters as string | 625941dddd821e528d63b4be |
def __init__(self, db, collection): <NEW_LINE> <INDENT> self._db = db <NEW_LINE> self._collection = collection <NEW_LINE> self._conn = MONGO_CONN <NEW_LINE> self._cursor = self._conn[db][collection] | Initialize. | 625941dd435de62698dfdf64 |
def configure_exposure_and_trigger(cam: PySpin.CameraPtr): <NEW_LINE> <INDENT> cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) <NEW_LINE> cam.ExposureTime.SetValue(5000) <NEW_LINE> cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) <NEW_LINE> cam.TriggerSource.SetValue(PySpin.TriggerSource_Counter0Start) <NEW_LINE> ca... | Set exposure to manual mode, 5 ms
Set trigger to ON and source to Counter0Start
Set trigger overlay to READOUT | 625941dd82261d6c526ab7ba |
def key_repr(key): <NEW_LINE> <INDENT> if isinstance(key, basestring): <NEW_LINE> <INDENT> return key <NEW_LINE> <DEDENT> return "<%s>" % type(key).__name__ | Return a more terse object for debugging. | 625941ddb5575c28eb68e31a |
def set_radius(self, new_radius): <NEW_LINE> <INDENT> self.radius = float(new_radius) <NEW_LINE> self._initialize_geometry() | Setter for radius; will re-initialize the object. | 625941dd5fcc89381b1e19d7 |
def __is_json(test_json): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> json.loads(test_json) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Checks if a string is a valid json object | 625941dd71ff763f4b5499a8 |
def title_for_html(self, req: "CamcopsRequest", anonymise: bool = False) -> str: <NEW_LINE> <INDENT> if anonymise: <NEW_LINE> <INDENT> patient = "?" <NEW_LINE> <DEDENT> elif self.patient: <NEW_LINE> <INDENT> patient = self.patient.prettystr(req) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> _ = req.gettext <NEW_LINE> p... | Returns the plain text used for the HTML ``<title>`` block (by
``task.mako``), and also for the PDF title for PDF exports.
Should be plain text only.
Args:
req: a :class:`camcops_server.cc_modules.cc_request.CamcopsRequest`
anonymise: hide patient identifying details? | 625941dd44b2445a339323ab |
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self <NEW_LINE> buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) <NEW_LINE> _x = self.header.frame_id <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x.... | serialize message into buffer
:param buff: buffer, ``StringIO`` | 625941dd2ae34c7f2600d448 |
def _build_licenses_tab(self, widget): <NEW_LINE> <INDENT> from a2widget import a2licenses_widget_ui <NEW_LINE> a2uic.check_module(a2licenses_widget_ui) <NEW_LINE> ui = a2licenses_widget_ui.Ui_Form() <NEW_LINE> ui.setupUi(self.ui.a2settings_tab) <NEW_LINE> text = ui.a2license_text.text() <NEW_LINE> for tag, version in ... | Build the licenses tab on demand. | 625941ddcc40096d61595c66 |
def read_file(self, filename, block_size=64): <NEW_LINE> <INDENT> self.send_command(b"file.close()") <NEW_LINE> self.send_command(b"=file.list()[" + lua_string(filename) + b"]") <NEW_LINE> try: <NEW_LINE> <INDENT> size = int(self.read_line()) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise IOError("Fil... | Read file from the device's flash.
Parameters
----------
filename : str
File to read from device.
block_size : int
The number of bytes to read at a time.
Returns
-------
The contents of the file as a bytes. | 625941dd38b623060ff0b104 |
def process_plot_function_inputs(x_param, y_stat, restrict_to_other_params): <NEW_LINE> <INDENT> if (not isinstance(x_param, tuple) or not 2 <= len(x_param) <= 3 or not all(isinstance(v, str) for v in x_param)): <NEW_LINE> <INDENT> raise PlottingException("Error : The function expects a parameter `x_param` as a tuple (... | Checks and pre-processes inputs to a plotting function.
Args:
x_param (tuple): a tuple of strings, containing the name of the
parameter to put in abscissa of the graph, accompanied with label of
the axis, plus optionally a label for the file name
y_stat (tuple): similarl to `x_param`, but for ... | 625941dd5510c4643540f6f4 |
def associate_project_with_quality_profile(self, project, name, language): <NEW_LINE> <INDENT> params = {'qualityProfile': name, 'language': language, 'project': project} <NEW_LINE> self.sonarqube._make_call('post', API_QUALITYPROFILES_ADD_PROJECT, **params) | Associate a project with a quality profile.
:param project:
:param name:
:param language:
:return: | 625941ddbe8e80087fb20f56 |
def maximum_specific_humidity(self): <NEW_LINE> <INDENT> w0sat = HAPropsSI('W', 'T', self.temperature+273.15, 'R', 1.0, 'P', self.pressure*1e5) <NEW_LINE> return w0sat | Maximum value of the humidity content for a given air, corresponding to
a 100% relative humidity. | 625941ddfbf16365ca6f64e0 |
def no_whitespace(text): <NEW_LINE> <INDENT> x = [] <NEW_LINE> for line in text: <NEW_LINE> <INDENT> no_space = line.strip() <NEW_LINE> x.insert(0, no_space) <NEW_LINE> <DEDENT> return x | Gets the spreadsheet's header column named 'english_version' and remove whitespace"
Parameters
----------
text : str
The texts retrieved from the spreadsheet
Returns
-------
list
a list of strings that contains no ending and starting whitespace | 625941ddac7a0e7691ed43de |
def getConfiguration(c): <NEW_LINE> <INDENT> newtimeout = c.config.getInt("http_timeout") <NEW_LINE> if newtimeout is not None: <NEW_LINE> <INDENT> config.http_timeout = newtimeout / 1000.0 <NEW_LINE> <DEDENT> newport = c.config.getInt("http_port") <NEW_LINE> if newport: <NEW_LINE> <INDENT> config.http_port = newport <... | Called when the user opens a new file. | 625941dd67a9b606de4a81ce |
def getAllChilds(self): <NEW_LINE> <INDENT> return self.getNormalChilds() + self.getVirtualChilds() | Get virtual and normal childs of this node | 625941dd097d151d1a22316f |
def test_list_webhooks_succeeds(self): <NEW_LINE> <INDENT> policy_list = self.successResultOf(self.group.list_policies()) <NEW_LINE> uuid = policy_list.keys()[0] <NEW_LINE> webhooks = { '10': self.sample_webhook_data, '11': self.sample_webhook_data } <NEW_LINE> self.group.webhooks = {uuid: webhooks} <NEW_LINE> result =... | If there are webhooks for a particular policy, listing webhooks returns
a dictionary for all of them | 625941ddb7558d58953c5226 |
def dotget(obj, expr, optional=False): <NEW_LINE> <INDENT> context = obj <NEW_LINE> for token in expr.split("."): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> context = context[token] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> if optional: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> raise <NEW_LIN... | `.`으로 연결된 객체접근 표현식을 parsing, 반복하여 반환하는 유틸리티 함수입니다.
Args:
expr (str): 문자열 형태의 연속된 객체접근 표현식입니다.
optional (bool, optional): 자바스크립트의 `optional chaining`과 같이,
해당 속성이 객체에 존재하지 않을 경우에도 에러를 발생시키지 않습니다.
Returns:
`eval(expr)`을 실행한 것과 같은 결과를 보여줍니다. | 625941dd26068e7796caeffa |
def see(counter, value): <NEW_LINE> <INDENT> counter['total'] += 1 <NEW_LINE> if str(value) not in counter: <NEW_LINE> <INDENT> counter[str(value)] = 1 <NEW_LINE> <DEDENT> elif str(value) in counter: <NEW_LINE> <INDENT> counter[str(value)] += 1 <NEW_LINE> <DEDENT> return | Purpose:
Records the observation of the given value in the counter.
Pre-conditions:
:param counter: a reference to a counter data structure
:param value: any immutable data value.
Return:
None | 625941ddd58c6744b4257f75 |
def test_dtd(self): <NEW_LINE> <INDENT> with open(path.join(path.dirname(__file__), '..', 'tei_reader', 'transform', 'tei-content.dtd'), encoding='utf-8') as f: <NEW_LINE> <INDENT> dtd = ET.DTD(f) <NEW_LINE> <DEDENT> for transformed in (ET.parse(xml) for xml in get_files('out.xml')): <NEW_LINE> <INDENT> if not dtd.vali... | Check that the test output matches the DTD. | 625941dd15fb5d323cde0e2b |
def __init__( self, transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None, ): <NEW_LINE> <INDENT> if client_config is not None: <NEW_LINE> <INDENT> warnings.warn( "The `client_config` argument is deprecated.", PendingDeprecationWarning, stacklevel=2, ) <NEW_LINE> <DED... | Constructor.
Args:
transport (Union[~.ImageAnnotatorGrpcTransport,
Callable[[~.Credentials, type], ~.ImageAnnotatorGrpcTransport]): A transport
instance, responsible for actually making the API calls.
The default transport uses the gRPC protocol.
This argument may also be a call... | 625941dd7047854f462a171d |
def filename_to_drs(self, filename): <NEW_LINE> <INDENT> if self._is_ignored(filename): <NEW_LINE> <INDENT> raise TranslationError() <NEW_LINE> <DEDENT> m = re.match(r'(?P<variable>.*?)_(?P<domain>.*?)_(?P<gcm_model>.*?)_(?P<experiment>.*?)_(?P<ensemble>.*?)_(?P<institute>.*?)-(?P<rcm_model>.*?)_(?P<rcm_version>.*?)_(?... | Return a DRS instance deduced from a filename. | 625941dde8904600ed9f2248 |
def _handle_post_api_template(handler, path_match, data): <NEW_LINE> <INDENT> template_string = data.get('template', '') <NEW_LINE> try: <NEW_LINE> <INDENT> rendered = template.render(handler.server.hass, template_string) <NEW_LINE> handler.send_response(HTTP_OK) <NEW_LINE> handler.send_header(HTTP_HEADER_CONTENT_TYPE,... | Log user out. | 625941dd96565a6dacc8f9e2 |
def __len__(self): <NEW_LINE> <INDENT> return len(self.img_infos) | Total number of samples of data. | 625941dda17c0f6771cbe367 |
def merge(base, other): <NEW_LINE> <INDENT> _if_filename_register_autoreload(other) <NEW_LINE> for section, value_map in reprconf.Parser.load(other).items(): <NEW_LINE> <INDENT> if not isinstance(value_map, dict): <NEW_LINE> <INDENT> raise ValueError( 'Application config must include section headers, but the ' "config ... | Merge one app config (from a dict, file, or filename) into another.
If the given config is a filename, it will be appended to
the list of files to monitor for "autoreload" changes. | 625941dd851cf427c661a824 |
def _load_viewable(self, values): <NEW_LINE> <INDENT> instance = self._viewable() <NEW_LINE> instance._store = self._store <NEW_LINE> identifiers = [] <NEW_LINE> for attr, value in zip(self._viewable.cls_attributes, values): <NEW_LINE> <INDENT> if isinstance(value, Identifier): <NEW_LINE> <INDENT> identifiers.append(va... | Converts the result of this result set into an instance of the
configured viewable. | 625941ddd7e4931a7ee9e236 |
def test_parse_int_list_accepted_all(self): <NEW_LINE> <INDENT> request = MagicMock(Request) <NEW_LINE> request.query_params = QueryDict('', mutable=True) <NEW_LINE> request.query_params.setlist('test', ['1', '2']) <NEW_LINE> self.assertListEqual(rest_util.parse_int_list(request, 'test', accepted_values=[1, 2]), [1, 2]... | Tests parsing a list of int parameters where all values are acceptable. | 625941ddb57a9660fec33ba0 |
def get_invalid_data(data): <NEW_LINE> <INDENT> return data[np.where(data[:,2]==1)] | Return only invalid data. Value of third column is equal to 1 if data
record is invalid. | 625941dd187af65679ca5437 |
def constant(self, mua=1e-10, mus=1e-10, g=1e-10): <NEW_LINE> <INDENT> return (MolecularCompositionGenerator().append(Molecule(name="constant_mua_mus_g", absorption_spectrum= AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(mua), volume_fraction=1.0, scattering_spectrum= ScatteringSpectrumLibrary. CONSTANT_SCATT... | TODO | 625941dd92d797404e3044a3 |
def getDihedrals(self): <NEW_LINE> <INDENT> if self._dihedrals is not None: <NEW_LINE> <INDENT> acsi = self._acsi <NEW_LINE> return np.array([Dihedral(self, dihedral, acsi) for dihedral in self._dihedrals]) <NEW_LINE> <DEDENT> return None | Returns dihedrals. Use :meth:`setDihedrals` for setting dihedrals. | 625941dd4f6381625f114d53 |
def GetExtent(vDataSet): <NEW_LINE> <INDENT> return [vDataSet.GetExtendMinX(),vDataSet.GetExtendMaxX(), vDataSet.GetExtendMinY(),vDataSet.GetExtendMaxY(), vDataSet.GetExtendMinZ(),vDataSet.GetExtendMaxZ()] | Get the X,Y,Z extents of a dataset | 625941ddb830903b967e9c20 |
def get_completed_exploration_ids(user_id, collection_id): <NEW_LINE> <INDENT> progress_model = user_models.CollectionProgressModel.get( user_id, collection_id) <NEW_LINE> return progress_model.completed_explorations if progress_model else [] | Returns a list of explorations the user has completed within the context
of the provided collection.
Args:
user_id: str. ID of the given user.
collection_id: str. ID of the collection.
Returns:
list(Exploration). A list of explorations that the user with the given
user id has completed within the cont... | 625941dd8a349b6b435e848a |
def is_a_rule_keyword(self) -> bool: <NEW_LINE> <INDENT> return self.value >= 15 and self.value != self.TEXT | Returns True if the token is a rule structure keyword such as
RULE, COMMENT, CONDITIONS, etc | 625941dd63d6d428bbe44807 |
def createNode(nodes, parent): <NEW_LINE> <INDENT> n = Node() <NEW_LINE> n.path,n.name,n.order,n.shape,n.color,n.bottom_label,n.side_label,n.dash,n.arrow, n.jump, n.action_order, n.left_edge_label, n.right_edge_label = getValues(nodes) <NEW_LINE> if parent != None: <NEW_LINE> <INDENT> parent.children.append(n) <NEW_LIN... | Creates a node and set up all the attributes
Parameters:
(list) List of dictionaries each representing one node
Returns:
n (Node) Root node | 625941ddcc0a2c11143dd1a9 |
def _init_gitmenu(self): <NEW_LINE> <INDENT> plugin_path = os.path.dirname(__file__) <NEW_LINE> self._actions = Gtk.ActionGroup("AddiksGitMenuActions") <NEW_LINE> for actionName, title, shortcut, callbackName in ACTIONS: <NEW_LINE> <INDENT> action = Gio.SimpleAction(name=actionName) <NEW_LINE> callback = None <NEW_LINE... | Will build the git-menu in the gedit-menu. | 625941dd5fdd1c0f98dc054c |
def testInstance(self): <NEW_LINE> <INDENT> self.assertTrue(QgsRendererV2Registry.instance()) <NEW_LINE> self.assertTrue('singleSymbol' in QgsRendererV2Registry.instance().renderersList()) <NEW_LINE> self.assertFalse('test' in QgsRendererV2Registry.instance().renderersList()) <NEW_LINE> self.assertTrue(QgsRendererV2Reg... | test retrieving global instance | 625941dda05bb46b383ecb37 |
def real_sxp(self): <NEW_LINE> <INDENT> return self.vector(R.real_elt) | Print double vector, type 14 | 625941dd4d74a7450ccd44db |
def test_without_args_and_kwargs(self): <NEW_LINE> <INDENT> op = Operation("Define") <NEW_LINE> self.assertEqual(op.args, ()) <NEW_LINE> self.assertEqual(op.kwargs, {}) | Test case to check accuracy of
all arguments with no arguments
at all in the input. | 625941dd3346ee7daa2b3085 |
def __init__(self, name, obj_fun, var_set=None, obj_set=None, con_set=None, use_groups=False, *args, **kwargs): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.obj_fun = obj_fun <NEW_LINE> self.use_groups = use_groups <NEW_LINE> if var_set is None: <NEW_LINE> <INDENT> self._variables = {} <NEW_LINE> <DEDENT> else:... | Optimization Problem Class Initialization
**Arguments:**
- name -> STR: Solution name
- opt_func -> FUNC: Objective function
**Keyword arguments:**
- var_set -> INST: Variable set, *Default* = None
- obj_set -> INST: Objective set, *Default* = None
- con_set -> INST: Constraints set, *Default* = None
- use_groups -... | 625941ddb7558d58953c5227 |
def getlibrary(): <NEW_LINE> <INDENT> library = G.get_all_songs() <NEW_LINE> return library | get all songs from library | 625941dd85dfad0860c3b174 |
@pytest.mark.parametrize('args', [['-h'], ['--help']]) <NEW_LINE> def test_tree_help(runner, args): <NEW_LINE> <INDENT> result = runner.invoke(main.tree, args) <NEW_LINE> check_result(0, TREE_HELP, result) | Show the tree command usage help. | 625941dd711fe17d8254267c |
def match_alphabet(self, pattern): <NEW_LINE> <INDENT> s = {} <NEW_LINE> for char in pattern: <NEW_LINE> <INDENT> s[char] = 0 <NEW_LINE> <DEDENT> for i in range(len(pattern)): <NEW_LINE> <INDENT> s[pattern[i]] |= 1 << (len(pattern) - i - 1) <NEW_LINE> <DEDENT> return s | Initialise the alphabet for the Bitap algorithm.
:param pattern: The text to encode.
:returns: Hash of character locations. | 625941dd7d43ff24873a2fba |
@app.route('/edit') <NEW_LINE> def edit(): <NEW_LINE> <INDENT> return render_template( 'edit.html', title='Edit Item or Category', year=datetime.now().year, ) | Renders the edit page. | 625941dd10dbd63aa1bd2eba |
def get_network_pii_pii_keys(self, options=dict()): <NEW_LINE> <INDENT> self.validate_parameters(network_id=options.get("network_id")) <NEW_LINE> _url_path = '/networks/{networkId}/pii/piiKeys' <NEW_LINE> _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'networkId': options.get('network_id', None)... | Does a GET request to /networks/{networkId}/pii/piiKeys.
List the keys required to access Personally Identifiable Information
(PII) for a given identifier. Exactly one identifier will be accepted.
If the organization contains org-wide Systems Manager users matching
the key provided then there will be an entry with the... | 625941dd283ffb24f3c55c16 |
def move(self, name, parent_reference=None): <NEW_LINE> <INDENT> result = ClientResult(self.context) <NEW_LINE> qry = ServiceOperationQuery(self, "move", None, { "name": name, "parentReference": parent_reference }, None, result ) <NEW_LINE> self.context.add_query(qry) <NEW_LINE> def _construct_request(request): <NEW_LI... | To move a DriveItem to a new parent item, your app requests to update the parentReference of the DriveItem
to move.
:type name: str
:type parent_reference: office365.onedrive.listitems.item_reference.ItemReference | 625941dd3d592f4c4ed1d37f |
def close_file(self, index: int, is_force: bool = False): <NEW_LINE> <INDENT> raise NotImplementedError() | 关闭打开的文件
@param {int} index - 要关闭的文件对象对应的处理线程索引
@param {bool} is_force=False - 指示是否强制关闭 | 625941dd442bda511e8be72c |
def _datasource_ex(self, resource, query=None, client_projection=None, client_sort=None): <NEW_LINE> <INDENT> datasource, filter_, projection_, sort_ = self._datasource(resource) <NEW_LINE> if client_sort: <NEW_LINE> <INDENT> sort = client_sort <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sort = sort_ if sort_ and con... | Returns both db collection and exact query (base filter included)
to which an API resource refers to.
.. versionchanged:: 0.5
Let client projection work when 'allow_unknown' is active (#497).
.. versionchanged:: 0.4
Always return required/auto fields (issue 282.)
.. versionchanged:: 0.3
Field exclusion supp... | 625941dd2eb69b55b151cbcb |
def setup_build_options(args, host_type=None): <NEW_LINE> <INDENT> fbcode_builder_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) <NEW_LINE> scratch_dir = args.scratch_path <NEW_LINE> if not scratch_dir: <NEW_LINE> <INDENT> if "SANDCASTLE" in os.environ: <NEW_LINE> <INDENT> if "DISK_TEMP" not in os.en... | Create a BuildOptions object based on the arguments | 625941dd32920d7e50b284ea |
def find_subtree(torrent, path): <NEW_LINE> <INDENT> tree = torrent['files'][torrent['name']] <NEW_LINE> if tree.nodetype == 'leaf': <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for i,part in enumerate(path): <NEW_LINE> <INDENT> if part: <NEW_LINE> <INDENT> subtree = tree.get(part) <NEW... | `torrent` must be a Torrent instance and `path` must be a sequence of nested
directory names in the tree `torrent['files']`
Empty strings in `path` are ignored (like `ls foo//bar///baz` also works).
If `torrent` is a single-file torrent or any item in `path[:-1]` points to a
leaf or doesn't exist, return None. Other... | 625941ddd4950a0f3b08c663 |
def post(self, request): <NEW_LINE> <INDENT> serializer = self.get_serializer(data=request.data) <NEW_LINE> serializer.is_valid(raise_exception=True) <NEW_LINE> user = serializer.save() <NEW_LINE> jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER <NEW_LINE> jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER <NEW... | 绑定用户到openid
GenericAPIView | 625941dd293b9510aa2c35ab |
def group_text_reply(self, msg): <NEW_LINE> <INDENT> content = msg.text <NEW_LINE> username = msg.actualNickName <NEW_LINE> try: <NEW_LINE> <INDENT> group_name = msg.User.NickName <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> message = {} <NEW_LINE> message["payload... | 将群消息发往scratch | 625941dd462c4b4f79d1d9e8 |
def __repr__(self): <NEW_LINE> <INDENT> if self._isiconic: <NEW_LINE> <INDENT> return object.__repr__(self)+ ": '{}'".format(self._funcs) <NEW_LINE> <DEDENT> if self._deps is None: <NEW_LINE> <INDENT> return object.__repr__(self) <NEW_LINE> <DEDENT> return object.__repr__(self)+ ": '{}'".format(self._deps) | Print representation | 625941dd0fa83653e46572d1 |
def p_wire_name_and_opt_assign_SEQ(p): <NEW_LINE> <INDENT> make_seq_rr(p) | wire_name_and_opt_assign_SEQ : wire_name_and_opt_assign
| wire_name_and_opt_assign ',' wire_name_and_opt_assign_SEQ | 625941dd15baa723493c428f |
def rename(path): <NEW_LINE> <INDENT> FileList = os.listdir(path) <NEW_LINE> for files in FileList: <NEW_LINE> <INDENT> oldDirPath = os.path.join(path, files) <NEW_LINE> if os.path.isdir(oldDirPath): <NEW_LINE> <INDENT> rename(oldDirPath) <NEW_LINE> continue <NEW_LINE> <DEDENT> fileName = os.path.splitext(files)[0] <NE... | modify the file names excluding directories | 625941ddd53ae8145f87a583 |
def get_value(self): <NEW_LINE> <INDENT> df = self.dataModel.get_data() <NEW_LINE> if self.is_series: <NEW_LINE> <INDENT> return df.iloc[:, 0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return df | Return modified Dataframe -- this is *not* a copy | 625941dd711fe17d8254267d |
def CamelCaseToUnderscores(name): <NEW_LINE> <INDENT> return re_camelcase_to_underscores.sub(r'_\1', name).lower() | Convert CamelCase to pythonic_underscores | 625941dda4f1c619b28b034b |
def get_move(self, board, color, move_num=None, time_remaining=None, time_opponent=None): <NEW_LINE> <INDENT> moves = board.get_legal_moves(color) <NEW_LINE> return random.choice(moves) | Select a random move from the list of legal moves. | 625941ddbf627c535bc134e7 |
def account_confirm(self, hashstr): <NEW_LINE> <INDENT> from ..photoalbum.models import Album <NEW_LINE> confirm = SignupConfirm.query.get(self.id) <NEW_LINE> if confirm is None or confirm.hashstr != hashstr: <NEW_LINE> <INDENT> return False; <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> confirm.accepted = True <NEW_LI... | 帐号确认
1.初始化用户书架
2.初始化“用户活跃度”表
3.初始化默认相册
4.写入“注册”事件 | 625941dd498bea3a759b9dc7 |
def test_advance_show0(self): <NEW_LINE> <INDENT> cli = self.create() <NEW_LINE> captureOutput = io.StringIO() <NEW_LINE> sys.stdout = captureOutput <NEW_LINE> cli.onecmd("create Amenity") <NEW_LINE> sys.stdout = sys.__stdout__ <NEW_LINE> string1 = captureOutput.getvalue() <NEW_LINE> sys.stdout.flush() <NEW_LINE> captu... | Testing show function by advance"
| 625941dde1aae11d1e749fd2 |
def transcript_iterator(gff_iterator, strict=True): <NEW_LINE> <INDENT> last = None <NEW_LINE> matches = [] <NEW_LINE> found = set() <NEW_LINE> for gff in gff_iterator: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> this = gff.transcript_id + gff.gene_id <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> cont... | iterate over the contents of a gtf file.
return a list of entries with the same transcript id.
Any features without a transcript_id will be ignored.
The entries for the same transcript have to be consecutive
in the file. If *strict* is set an AssertionError will be
raised if that is not true. | 625941dd15fb5d323cde0e2c |
def test_refresh_entity(self): <NEW_LINE> <INDENT> node = MockNode() <NEW_LINE> value = MockValue(data=False, node=node, command_class=const.COMMAND_CLASS_SENSOR_BINARY) <NEW_LINE> power_value = MockValue(data=50, node=node, command_class=const.COMMAND_CLASS_METER) <NEW_LINE> values = MockEntityValues(primary=value, po... | Test zwave refresh_entity service. | 625941ddaad79263cf390d5e |
def GetNumberOfMSOrdersFromScanNum(self, scanNumber): <NEW_LINE> <INDENT> result = c_long() <NEW_LINE> error = self.source.GetNumberOfMSOrdersFromScanNum( c_long(scanNumber), byref(result)) <NEW_LINE> if error: <NEW_LINE> <INDENT> raise IOError("GetNumberOfMSOrdersFromScanNum error :", error) <NEW_LINE> <DEDENT> return... | This function gets the number of MS reaction data items in the scan event for the scan
specified by scanNumber and the transition specified by MSOrder from the scan event
structure in the raw file. | 625941ddad47b63b2c50a297 |
def filter_hr_history(self, lead_number=None): <NEW_LINE> <INDENT> import scipy.signal <NEW_LINE> return scipy.signal.medfilt(self.heart_rate[lead_number][1], (195,)) | Filter the input array
:return: Filtered array | 625941dd23849d37ff7b33a6 |
def binary_search_recursive(lst, value, left, right): <NEW_LINE> <INDENT> if right < left: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> middle = (left+right)//2 <NEW_LINE> if lst[middle] == value: <NEW_LINE> <INDENT> return middle <NEW_LINE> <DEDENT> if lst[middle] > value: <NEW_LINE> <INDENT> return binary_search... | (list, object, int, int) -> int
Return the index of the first occurrence of value in lst, or return
-1 if value is not in lst.
>>> binary_search_recursive([1, 2, 3], 1, 0, 2)
0
>>> binary_search_recursive([1, 2, 3], 2, 0, 2)
1
>>> binary_search_recursive([1, 2, 3], 3, 0, 2)
2
>>> binary_search_recursive([1, 2, 3], 0,... | 625941dd94891a1f4081bdc3 |
def id_generator(size=25, chars=string.ascii_lowercase + string.digits): <NEW_LINE> <INDENT> identifier = ''.join(random.choice(chars) for _ in range(size)) <NEW_LINE> return identifier | generate item or service id
:param size:
:param chars:
:return: | 625941dd4e4d5625662d46ed |
def clean_data(data): <NEW_LINE> <INDENT> entries_to_remove = [ 'TOTAL', 'LAY KENNETH L', 'SHAPIRO RICHARD S', 'KAMINSKI WINCENTY J', 'GLISAN JR BEN F', 'KEAN STEVEN J' ] <NEW_LINE> for entry in entries_to_remove: <NEW_LINE> <INDENT> data.pop(entry, None) <NEW_LINE> <DEDENT> data['BHATNAGAR SANJAY'] = {'bonus': 'NaN', ... | Correct known data errors in initial data dictionary | 625941dd21bff66bcd684c68 |
def _get(self, path, params=None, headers=None): <NEW_LINE> <INDENT> if params is None: <NEW_LINE> <INDENT> params = {} <NEW_LINE> <DEDENT> if headers is None: <NEW_LINE> <INDENT> headers={} <NEW_LINE> <DEDENT> url = self.emoncmsbaseurl + path <NEW_LINE> params['apikey']= self.rwapikey <NEW_LINE> try: <NEW_LINE> <INDEN... | Make a GET HTTP request | 625941dd3cc13d1c6d3c7692 |
def registerEncodedIdPrefix(self, prefix, format): <NEW_LINE> <INDENT> return self._get_mini_repository().registerEncodedIdPrefix(prefix, format) | Registers a single encoded prefix.
See: http://franz.com/agraph/support/documentation/v4/encoded-ids.html | 625941dd6e29344779a62928 |
def test_int_equal_lists(): <NEW_LINE> <INDENT> diff = [] <NEW_LINE> list_a = [1, 2, 3, 4] <NEW_LINE> list_b = [3, 2, 1, 4] <NEW_LINE> diff.extend(_get_list_simple_diff(list_a, list_b)) <NEW_LINE> assert not diff | No differences (order doesn't matter) | 625941dd26068e7796caeffb |
def ShowAutoCompleteList(self): <NEW_LINE> <INDENT> if _hasJedi and self.getFileType() == 'Python': <NEW_LINE> <INDENT> self.coder.SetStatusText( 'Retrieving code completions, please wait ...', 0) <NEW_LINE> compList = [i.name for i in jedi.Script( self.getTextUptoCaret(), path=self.filename if os.path.isabs(self.filen... | Show autocomplete list at the current caret position. | 625941ddfb3f5b602dac39af |
def ns_to_timespec(self, nsec): <NEW_LINE> <INDENT> ts = self.timespec() <NEW_LINE> if not nsec: <NEW_LINE> <INDENT> ts.tv_sec = 0 <NEW_LINE> ts.tv_nsec = 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ts.tv_sec, rem = divmod(nsec, timespec.NSEC_PER_SEC) <NEW_LINE> if rem < 0: <NEW_LINE> <INDENT> ts.tv_sec -= 1 <NEW_L... | Transforms nanoseconds to a timespec. | 625941dd56b00c62f0f14974 |
def getAlarmState(self): <NEW_LINE> <INDENT> return {"state": self.settings['settings']['alarmState']} | Returns the status of the alert for the UI | 625941dde1aae11d1e749fd3 |
def main(): <NEW_LINE> <INDENT> n=int(input("How many numbers do you want to insert? n= ")) <NEW_LINE> lst=[] <NEW_LINE> while n > 0 : <NEW_LINE> <INDENT> lst.append(int(input("Introduce new number:"))) <NEW_LINE> n-=1 <NEW_LINE> <DEDENT> backList=[0,0,0,0,0,0,0,0,0,0] <NEW_LINE> saveLst=[] <NEW_LINE> back(0,lst,backLi... | reads and writes and calls the function back to compute all the posibilities
:return: | 625941ddd268445f265b5187 |
def test_invalid_minutes(self): <NEW_LINE> <INDENT> with assert_raises(ValueError): <NEW_LINE> <INDENT> get_scheduled_distributions(0) <NEW_LINE> <DEDENT> with assert_raises(ValueError): <NEW_LINE> <INDENT> get_scheduled_distributions(-1) <NEW_LINE> <DEDENT> with assert_raises(ValueError): <NEW_LINE> <INDENT> get_sched... | Test scheduled invalid | 625941dd24f1403a92600e7c |
def fix_posts(): <NEW_LINE> <INDENT> fix_post_list = [] <NEW_LINE> post_id_list = subprocess.check_output('wp post list --field=ID', shell=True).split('\n') <NEW_LINE> writer_usernames = subprocess.check_output('wp user list --field=user_login', shell=True).split('\n') <NEW_LINE> writer_names = subprocess.check_output(... | Usage: reassign posts from broken author usernames with ands to their respective authors | 625941dd0fa83653e46572d2 |
def __init__(self, fut, file_obj, parent=None, tid=None): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self._tid = tid <NEW_LINE> if isinstance(file_obj, str) and not isinstance(file_obj, File): <NEW_LINE> <INDENT> self.file_obj = File(file_obj) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.file_obj = file_ob... | Construct the DataFuture object.
If the file_obj is a string convert to a File.
Args:
- fut (AppFuture) : AppFuture that this DataFuture will track
- file_obj (string/File obj) : Something representing file(s)
Kwargs:
- parent ()
- tid (task_id) : Task id that this DataFuture tracks | 625941ddfff4ab517eb2f756 |
def create_open_file_button(self): <NEW_LINE> <INDENT> self.open_file_button = Button(self, text='Open File', command = self.open_file) <NEW_LINE> self.open_file_button.grid(column=1, row=1, sticky="nesw") | Create button to get filepath for analysis | 625941dd7d847024c06be5d8 |
def get_book_id(self): <NEW_LINE> <INDENT> return | Gets the ``Book`` ``Id`` associated with this session.
:return: the ``Book Id`` associated with this session
:rtype: ``osid.id.Id``
*compliance: mandatory -- This method must be implemented.* | 625941dd9c8ee82313fbba8f |
def show(self, fmt=None, app=None, direction=DIRECTION_ASCENDING): <NEW_LINE> <INDENT> if fmt is not None: <NEW_LINE> <INDENT> format, ext = common.findFormat(fmt) <NEW_LINE> if format in ['scala']: <NEW_LINE> <INDENT> returnedFilePath = self.write(format, direction=direction) <NEW_LINE> environLocal.launch(format, ret... | Show the scale in a format. Here, prepare scala format if requested.
| 625941dd6e29344779a62929 |
def test_create_delete_volume_sparse_backing_file(self): <NEW_LINE> <INDENT> CONF.gpfs_sparse_volumes = True <NEW_LINE> vol = self._create_volume(size=1) <NEW_LINE> volume_id = vol['id'] <NEW_LINE> self.assertTrue(os.path.exists(self.volumes_path)) <NEW_LINE> self.volume.create_volume(self.context, volume_id) <NEW_LINE... | create and delete vol with default sparse creation method | 625941ddfff4ab517eb2f757 |
def _load(self, station: str, year: int) -> pd.DataFrame: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> url = f'{self.BASE_URL}&stationID={station["national_id"]}&Year={str(year)}' <NEW_LINE> df = pd.read_csv(url, parse_dates={'time': [4]}) <NEW_LINE> df = df.rename(self.PARAMETERS, axis=1) <NEW_LINE> df = df[df.columns... | Load dataset into DataFrame | 625941dd24f1403a92600e7d |
def check_aliens_bottom(settings, stats, screen, sb, ship, aliens, bullets): <NEW_LINE> <INDENT> screen_rect = screen.get_rect() <NEW_LINE> for alien in aliens.sprites(): <NEW_LINE> <INDENT> if alien.rect.bottom >= screen_rect.bottom: <NEW_LINE> <INDENT> ship_hit(settings, stats, screen, sb, ship, aliens, bullets) <NEW... | Check if any aliens are at the bottom of the screen | 625941ddcc40096d61595c68 |
def get(self, session=None, group=None, unit=None, **kwargs): <NEW_LINE> <INDENT> dirname = self.session_d[session] <NEW_LINE> call_kwargs = self.kk_kwargs.copy() <NEW_LINE> call_kwargs.update(kwargs) <NEW_LINE> spikes = from_KK(dirname, **call_kwargs) <NEW_LINE> sub = utility.panda_pick_data(spikes, group=group, unit=... | Returns spike times for specified session * unit
Extra keywords override object defaults (eg group_multiplier, fs,
memoization...)
Current behavior is to always load and save memoized versions for
best speed. This might change ... | 625941dd7b25080760e39771 |
def define_uri(auto=False): <NEW_LINE> <INDENT> return RDFPredicate(is_uri=True, auto_uri=auto) | helper method that created a URI predicate | 625941dd50812a4eaa59c638 |
def OnCellClicked(self, cell, x, y, event): <NEW_LINE> <INDENT> self.linked = False <NEW_LINE> wx.html.HtmlWindow.base_OnCellClicked(self, cell, x, y, event) | Called whenever the splash screen is clicked. If a link was
clicked, then that link will be opened. Otherwise, we close the
splash screen. | 625941ddbde94217f3683107 |
def mark_dirty(self, new_value: bool=True): <NEW_LINE> <INDENT> self._is_dirty = new_value <NEW_LINE> if self._is_dirty: <NEW_LINE> <INDENT> self.on_marked_dirty() | .
Todo:
* May be able to remove this.(Used for Undo function. Not used) | 625941dd26238365f5f0f18b |
def findMaxConsecutiveOnes(self, nums): <NEW_LINE> <INDENT> max_len = 0 <NEW_LINE> last_zero = -1 <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> if nums[i] == 0: <NEW_LINE> <INDENT> cur_len = i - last_zero - 1 <NEW_LINE> last_zero = i <NEW_LINE> if cur_len > max_len: <NEW_LINE> <INDENT> max_len = cur_len <NE... | :type nums: List[int]
:rtype: int | 625941ddd486a94d0b98e460 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.