code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def getToken(self): <NEW_LINE> <INDENT> raise NotImplementedError | it's the service to get the access token | 625941e1462c4b4f79d1da73 |
def p_argument_list_recursive(p): <NEW_LINE> <INDENT> p[0] = p[1] <NEW_LINE> p[0].append(p[3]) | ArgumentList : ArgumentList COMMA Expr | 625941e1460517430c394520 |
def get_rit(self): <NEW_LINE> <INDENT> output = self._request('j') <NEW_LINE> if not isinstance(output, basestring): <NEW_LINE> <INDENT> logger.error("Expected unicode string while getting RIT, " "got {}".format(type(output))) <NEW_LINE> raise ValueError <NEW_LINE> <DEDENT> return output | Wrapper around _request. It configures the command for getting
RIT. | 625941e166673b3332b92435 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.unpack(str[start:end]) <NEW_LINE> pattern = '<%si'%length <NEW_LINE> start = end <NEW_LINE> end += struct.calcsize(pattern) <NEW_LINE> self.ranges = struct.unpack(... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941e1b7558d58953c52b1 |
def boundary(self): <NEW_LINE> <INDENT> if self._dimension != 2: <NEW_LINE> <INDENT> raise NotImplementedError("The method boundary is currently " "implemented " "only for dimension 2") <NEW_LINE> <DEDENT> from collections import defaultdict <NEW_LINE> horizontal = defaultdict(int) <NEW_LINE> vertical = defaultdict(int... | Return the boundary of a 2d polyomino.
INPUT:
- ``self`` - a 2d polyomino
OUTPUT:
- list of edges (an edge is a pair of adjacent 2d coordinates)
EXAMPLES::
sage: from sage.combinat.tiling import Polyomino
sage: p = Polyomino([(0,0), (1,0), (0,1), (1,1)])
sage: sorted(p.boundary())
[((-0.5, -0.5), ... | 625941e1046cf37aa974d0e8 |
def SetPadding(self, padding): <NEW_LINE> <INDENT> self._nPadding = padding.GetWidth() | Sets the amount of space around each page's icon and label, in pixels.
:param `padding`: the amount of space around each page's icon and label,
in pixels.
:note: Only the horizontal padding is considered. | 625941e1851cf427c661a8b0 |
def test_recurse(self): <NEW_LINE> <INDENT> name = os.path.join(integration.TMP, 'recurse_dir') <NEW_LINE> ret = self.run_state('file.recurse', name=name, source='salt://grail') <NEW_LINE> self.assertTrue(os.path.isfile(os.path.join(name, '36', 'scene'))) <NEW_LINE> result = ret[next(iter(ret))]['result'] <NEW_LINE> se... | file.recurse | 625941e123849d37ff7b3431 |
def do_GET(self): <NEW_LINE> <INDENT> cmd = self.path[1:] <NEW_LINE> cmd_list = cmd.split('/') <NEW_LINE> s = self.command_handler.do_command(cmd_list) <NEW_LINE> if (s is None) or (len(s) == 0): <NEW_LINE> <INDENT> err_statement = ("do_GET: NoneType was returned " + str(cmd_list)) <NEW_LINE> logging.info(err_statement... | Scratch2 only sends HTTP GET commands. This method processes them.
It differentiates between a "normal" command request and a request
to send policy information to keep Flash happy on Scratch.
(This may change when Scratch is converted to HTML 5 | 625941e1ac7a0e7691ed446a |
def _toolbarData(self): <NEW_LINE> <INDENT> icons = BaseIcons <NEW_LINE> return self._getToolbarData((("rendermap", icons["render"], self.parent.OnRender), ("pointer", icons["pointer"], self.parent.OnPointer, wx.ITEM_CHECK), ("query", swipeIcons["query"], self.parent.OnQuery, wx.ITEM_CHECK), ("pan", icons["pan"], self.... | Returns toolbar data (name, icon, handler) | 625941e1b545ff76a89141b9 |
def build_config(transforms, config): <NEW_LINE> <INDENT> return reduce(lambda c, fn: fn(c), transforms, config) | Reduces a dictionary through functions to modify the dictionary | 625941e12c8b7c6e89b35b62 |
def create_superuser(self, email, name, password): <NEW_LINE> <INDENT> user = self.create_user(email, name, password) <NEW_LINE> user.is_superuser = True <NEW_LINE> user.is_staff = True <NEW_LINE> user.save(using = self._db) <NEW_LINE> return user | Creat and save a new superuser with given details | 625941e1498bea3a759b9e52 |
def setHelpEnabled(self, page, value): <NEW_LINE> <INDENT> KWizard.setHelpEnabled(self, page.parent(), value) | Sets functionality of help button | 625941e15fc7496912cc3d22 |
def __init__(self, K, dist, feature_name="ORB", output_folder='output'): <NEW_LINE> <INDENT> self.K = K <NEW_LINE> self.K_inv = np.linalg.inv(K) <NEW_LINE> self.d = dist <NEW_LINE> self.output_folder = output_folder <NEW_LINE> self.img1 = Image() <NEW_LINE> self.img2 = Image() <NEW_LINE> self.R = np.ones((3, 3)) <NEW_L... | Constructor
This method initializes the scene reconstruction algorithm.
:param K: 3x3 intrinsic camera matrix
:param dist: vector of distortion coefficients | 625941e1377c676e9127254b |
def receive_robustness_value(self): <NEW_LINE> <INDENT> message = self.receive_message() <NEW_LINE> if message.command == SimulationMessageInterface.ROBUSTNESS: <NEW_LINE> <INDENT> rob = message.object <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rob = None <NEW_LINE> <DEDENT> return rob | Receives computed robustness value from Webots. | 625941e1711fe17d82542707 |
def main(): <NEW_LINE> <INDENT> global ENABLE_USER_SITE <NEW_LINE> orig_path = sys.path[:] <NEW_LINE> if orig_path != sys.path: <NEW_LINE> <INDENT> abs_paths() <NEW_LINE> <DEDENT> if ENABLE_USER_SITE is None: <NEW_LINE> <INDENT> ENABLE_USER_SITE = check_enableusersite() <NEW_LINE> <DEDENT> setquit() <NEW_LINE> setcopyr... | Add standard site-specific directories to the module search path.
This function is called automatically when this module is imported,
unless the python interpreter was started with the -S flag. | 625941e115fb5d323cde0eb8 |
@pytest.fixture <NEW_LINE> def context(): <NEW_LINE> <INDENT> return { "full_name": "Lisa Simpson", "email": "smartgirl63_\@yahoo.com", "github_username": "none", "repo_name": "Lisa_Lionheart", "package_name": "lisa", "application_name": "saxophone", "application_title": "Saxophone", "project_short_description": "Learn... | Test template creation with these parameters. | 625941e1be383301e01b5823 |
def full_display(plateau): <NEW_LINE> <INDENT> couleurs = { 0 : {0 : ["white", "on_white"], 1 : ["white", "on_blue"], 2 : ["white", "on_red"]}, 1 : ["grey", "on_white"], "ligne" : [colored, " ", "grey", "on_grey"] } <NEW_LINE> trait = couleurs["ligne"][0](couleurs["ligne"][1],couleurs["ligne"][2],couleurs["ligne"][3]) ... | Affiche le plateau en couleurs | 625941e1009cb60464c63753 |
def test_step_upload(config, test_user, test_file): <NEW_LINE> <INDENT> if config['inbox_s3']: <NEW_LINE> <INDENT> verify_s3_inbox_ssl = False <NEW_LINE> if config['inbox_s3_public'] and config['inbox_s3_ssl']: <NEW_LINE> <INDENT> verify_s3_inbox_ssl = True <NEW_LINE> <DEDENT> elif config['inbox_s3_ssl']: <NEW_LINE> <I... | Do the first step of the test, send file to inbox. | 625941e1a219f33f34628d09 |
def mysql_database_exists(username, password, host, db_name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> conn = mysql.connector.connect(user=username, password=password, host=host) <NEW_LINE> cursor = conn.cursor() <NEW_LINE> <DEDENT> except mysql.connector.Error as e: <NEW_LINE> <INDENT> _print_mysql_connection_erro... | Determine if a MySQL database exists.
Args:
:param username: The MySQL database user name.
:type username: String
:param password: The MySQL database password.
:type password: String
:param host: The MySQL database host.
:type host: String
:param db_name: The name of the MySQL database.
:type db_name: String
Returns:... | 625941e1a05bb46b383ecbc3 |
def destroy(self): <NEW_LINE> <INDENT> return self.get_data("droplets/%s" % self.id, type=DELETE) | Destroy the droplet
Optional Args:
return_dict - bool : Return a dict when True (default),
otherwise return an Action.
Returns dict or Action | 625941e121a7993f00bc809a |
def test_accessible(self): <NEW_LINE> <INDENT> survey = Survey.objects.get(id=2) <NEW_LINE> responses = Response.objects.filter(survey=survey) <NEW_LINE> response = responses.all()[0] <NEW_LINE> urls = [ reverse("survey-list"), reverse("survey-detail", kwargs={"id": 2}), reverse("survey-completed", kwargs={"id": 2}), r... | If need_logged_user=False user do not need to authenticate. | 625941e13eb6a72ae02ec88a |
def shutdown(self): <NEW_LINE> <INDENT> if self.driver is not None: <NEW_LINE> <INDENT> self.driver.quit() <NEW_LINE> self.driver = None <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Stops connection to cleverbot | 625941e1236d856c2ad44b83 |
@require_login <NEW_LINE> def log_search(request): <NEW_LINE> <INDENT> keyword = request.GET.get('keyword') <NEW_LINE> login_types = {'S': 'SSH', 'T': 'TELNET'} <NEW_LINE> dept = get_session_user_info(request)[5] <NEW_LINE> post_all = WEB_Logs.objects.filter(Q(name__contains=keyword) | Q(header__contains=keyword)).dist... | 搜索监控 | 625941e1507cdc57c6307087 |
def __init__(self, seq=()): <NEW_LINE> <INDENT> self._data = dict(seq) <NEW_LINE> self._key_locks = ThreadSafeDefaultdict(Lock) | Constructor.
:param seq: initial metadata items | 625941e1b545ff76a89141ba |
def assembly_name(self,args): <NEW_LINE> <INDENT> return self.name | Get the name of the op-code based on the arguments.
'args' may be modified, to change the arguments printed. | 625941e1b57a9660fec33c2d |
def _apply_equivalences(self, unit, other, equivalencies): <NEW_LINE> <INDENT> def make_converter(scale1, func, scale2): <NEW_LINE> <INDENT> def convert(v): <NEW_LINE> <INDENT> return func(_condition_arg(v) * scale1) * scale2 <NEW_LINE> <DEDENT> return convert <NEW_LINE> <DEDENT> orig_unit = unit <NEW_LINE> orig_other ... | Internal function (used from `get_converter`) to apply
equivalence pairs. | 625941e130bbd722463cc16c |
def __init__(self, id=None, url=None, name=None, slug=None, aggregate_count=None): <NEW_LINE> <INDENT> self._id = None <NEW_LINE> self._url = None <NEW_LINE> self._name = None <NEW_LINE> self._slug = None <NEW_LINE> self._aggregate_count = None <NEW_LINE> self.discriminator = None <NEW_LINE> if id is not None: <NEW_LIN... | NestedRIR - a model defined in Swagger | 625941e12c8b7c6e89b35b63 |
def apply_data(self, data: dict): <NEW_LINE> <INDENT> self._name = data["name"] <NEW_LINE> self._location_id = data["locationId"] <NEW_LINE> self._latitude = data.get("latitude", None) <NEW_LINE> self._longitude = data.get("longitude", None) <NEW_LINE> self._region_radius = data.get("regionRadius", None) <NEW_LINE> sel... | Apply the given data structure to the location. | 625941e1d7e4931a7ee9e2c3 |
def appendComments(self, comments): <NEW_LINE> <INDENT> self.comments.extend(comments) <NEW_LINE> for cmt in comments: <NEW_LINE> <INDENT> if cmt.interActiveType == EInteractiveType.Upvote: <NEW_LINE> <INDENT> self.upvoteUserSet.add(cmt.userId) | :type comments: list[TUserPostComment]
:return: | 625941e156b00c62f0f14a00 |
def parse_authorization_header(header): <NEW_LINE> <INDENT> if not header: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> auth_type, auth_info = header.split(None, 1) <NEW_LINE> auth_type = auth_type.lower() <NEW_LINE> <DEDENT> except ValueError as e: <NEW_LINE> <INDENT> print(e) <NEW_LINE> ret... | Parse authorization header and build Authorization object
| 625941e17c178a314d6ef80a |
def complement(s): <NEW_LINE> <INDENT> t = {"0": "1", "1": "0"} <NEW_LINE> return "".join(t[c] for c in s) | >>> complement('01100')
'10011' | 625941e1566aa707497f4908 |
def lookup_by_objref(objref): <NEW_LINE> <INDENT> obj = pydoc.locate(objref.name) <NEW_LINE> if obj is None: <NEW_LINE> <INDENT> if objref.module is None: <NEW_LINE> <INDENT> raise ImportError('Unable to import "%s"' % (objref.name)) <NEW_LINE> <DEDENT> path = '.'.join([objref.module, objref.name]) <NEW_LINE> obj = pyd... | Imports an object by an ObjRef object.
If ObjRef object also contains module attribute, it will also attempt to relative import from it
when absolute import was not successful. | 625941e1627d3e7fe0d691f6 |
def modify_resource(self, object_type, payload, object_name=None): <NEW_LINE> <INDENT> target_uri = self._build_uri(object_type, object_name) <NEW_LINE> message, status_code = self.request(target_uri, PUT, request_object=payload) <NEW_LINE> operation = 'modify %(res)s resource' % {'res': object_type} <NEW_LINE> self.ch... | Modify a resource.
:param object_type: the object type (e.g. volumes)
:param payload: the payload
:param object_name: the object name (e.g. name of volume)
:returns: message -- string (server response), status_code -- int | 625941e199fddb7c1c9de734 |
def fitCCPhi(self, ePhi=0.001, lam=1000., mpar=(0, 0, 1), taupar=(0, 1e-5, 100), cpar=(0.3, 0, 1)): <NEW_LINE> <INDENT> if taupar[0] == 0: <NEW_LINE> <INDENT> taupar = (1.0 / self.f[np.argmax(self.phi)] / 2.0 / pi, taupar[1], taupar[2]) <NEW_LINE> print("taupar", taupar) <NEW_LINE> <DEDENT> if mpar[0] == 0: <NEW_LINE> ... | fit a Cole-Cole term to phase only
Parameters
----------
ePhi : float
absolute error of phase angle
lam : float
regularization parameter
mpar, taupar, cpar : list[3]
inversion parameters (starting value, lower bound, upper bound)
for Cole-Cole parameters (m, tau, c) and EM relaxation time (em) | 625941e1c432627299f04fed |
def setGravity(self, direction): <NEW_LINE> <INDENT> self.gravity_direction = direction <NEW_LINE> for s in self.sprites(): <NEW_LINE> <INDENT> s.gravity_direction = direction | Set the gravity direction for the team
@param direction: An integer representing a value. Use enums.Direction. | 625941e123e79379d52ee904 |
def __init__(self, video_dir, label_dir): <NEW_LINE> <INDENT> self.video_dir = video_dir <NEW_LINE> self.filename = os.listdir(video_dir) <NEW_LINE> self.labels = np.loadtxt(label_dir) | Args:
video_dir (string): Directory with all the videos.
label_dir (string): Path to the label data. | 625941e11b99ca400220ae57 |
def _meteofinder(meteo_dir, meteo_bookends, mon, year, mon_dict, meteoyearfunc): <NEW_LINE> <INDENT> orig_dir = os.getcwd() <NEW_LINE> meteofiles = [] <NEW_LINE> file_number = -1 <NEW_LINE> prv, nxt, now = _monyearstrings(mon, year, mon_dict, meteoyearfunc) <NEW_LINE> try: <NEW_LINE> <INDENT> os.chdir(meteo_dir) <NEW_L... | Get list of meteorology files.
Creates list of files in storage location ``meteo_dir`` that belong
to the given month and year, plus the necessary files from previous
and the next months (``meteo_bookends``).
For successful meteofinding, separate different meteorology types into
different folders and name weekly or s... | 625941e18e7ae83300e4b372 |
def relative_representation(df, header_list, min_threshold=100): <NEW_LINE> <INDENT> df_relative_rep = pd.DataFrame({'Column value': [], 'Number of entries': [ ], 'Relative representation %': [], 'Column header': []}) <NEW_LINE> for header in header_list: <NEW_LINE> <INDENT> df_unique = unique_values(df, header) <NEW_L... | Helper function that outputs a summary table of categorical values where their relative prevelance is less than a given threshold (min_threshold)
Arguments:
-----------
df : pd.dataframe, dataframe to be passed as input
header_list : list, list of columns headers to be passed in as input
min_threshold : float, the min... | 625941e13346ee7daa2b3113 |
def translate(self, message, plural_message=None, count=None, **kwargs): <NEW_LINE> <INDENT> if plural_message is not None: <NEW_LINE> <INDENT> assert count is not None <NEW_LINE> message = self.translations.ungettext( message, plural_message, count) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> message = self.translat... | Translates message and returns new message as str
:param str message: original message
:param str plural_message: plural format of the message
:param int count: number proper plural message for generation
:param kwargs: named placeholders for message templating
:return str: translated message | 625941e15510c4643540f780 |
def __init__(self, problem_name, domain, initial_state=None): <NEW_LINE> <INDENT> self.problem_name = problem_name <NEW_LINE> self.domain = domain <NEW_LINE> if initial_state: <NEW_LINE> <INDENT> self.setInitialState(initial_state) <NEW_LINE> <DEDENT> self.exclude_goals = [] | Constructor
:Parameters:
domain : DomainDefinition
the domain to work inside
problem_name : string
arbritatry name of problem
initial_state : SymbolicState
initial state, should not contain parameterised clauses | 625941e15fc7496912cc3d23 |
def test_default(self): <NEW_LINE> <INDENT> f = File(self.mktemp(), 'w') <NEW_LINE> self.assertEqual(f.libver, ('earliest', self.latest)) <NEW_LINE> f.close() | Opening with no libver arg | 625941e15fdd1c0f98dc05d9 |
def _wait_for_lun_or_snap_copy(self, src_vol_id, dest_vdev_id=None, dest_obj_id=None): <NEW_LINE> <INDENT> wait_id = None <NEW_LINE> wait_func = None <NEW_LINE> if dest_vdev_id: <NEW_LINE> <INDENT> wait_id = dest_vdev_id <NEW_LINE> wait_func = self.vmem_mg.snapshot.get_snapshot_copy_status <NEW_LINE> <DEDENT> elif dest... | Poll to see when a lun or snap copy to a lun is complete.
:param src_vol_id: cinder volume ID of source volume
:param dest_vdev_id: virtual device ID of destination, for snap copy
:param dest_obj_id: lun object ID of destination, for lun copy
:returns: True if successful, False otherwise | 625941e131939e2706e4d209 |
def getHaltonSeq(dimensions=int, length=int): <NEW_LINE> <INDENT> sequencer = ghalton.Halton(dimensions) <NEW_LINE> return sequencer.get(length) | returns an array Halton sequence of quasi random number
:param dimensions: number of dimensions of matrix (columsn)
:param length: number of sequences returned (rows)
:return: | 625941e126068e7796caf089 |
def test_annotations(self): <NEW_LINE> <INDENT> cfunc = njit(variable_name_reuse) <NEW_LINE> a = np.linspace(0, 1, 10) <NEW_LINE> cfunc(a, a, a, a) <NEW_LINE> buf = utils.StringIO() <NEW_LINE> cfunc.inspect_types(buf) <NEW_LINE> res = buf.getvalue() <NEW_LINE> self.assertIn("# u.1 = ", res) <NEW_LINE> self.assertIn("... | Type annotation of array expressions with disambiguated
variable names (issue #1466). | 625941e14c3428357757c6cb |
def drop_adapt(adapt_probs, classifier, train_dataset, num_drop=500): <NEW_LINE> <INDENT> assert len(adapt_probs) == len(classifier.rem_classes) <NEW_LINE> assert num_drop < len(adapt_probs) <NEW_LINE> top_cls = adapt_probs.argsort()[::-1][:-num_drop] <NEW_LINE> top_cls_orig_label = classifier.get_orig_labels(top_cls) ... | Drop least probable classes from training dataset from aggregated probs
returns train_dataset and classifier | 625941e1fff4ab517eb2f7e3 |
def get_touchpad_config_file_path(): <NEW_LINE> <INDENT> return os.path.join(get_configuration_directory(), 'touchpad-config.json') | Get the path to the file which stores the touchpad configuration. | 625941e1fbf16365ca6f656f |
def addView(self, widget, name, focused=True, unfocus_on_refresh=False, **kwargs): <NEW_LINE> <INDENT> widget.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding ) <NEW_LINE> widget._unfocus_on_refresh = unfocus_on_refresh <NEW_LINE> widget.vm = self <NEW_LINE> widget.name = name <NEW_LINE> t = super(ViewManage... | Add a view to this view manager.
Adds the specified widget to the ViewManager under a named tab.
:param widget: The widget to add as a view.
:type widget: object inherited from QWidget or views.BaseView
:param name: The name of the widget, will be shown on the tab and used as a data-redirector selector.
:type name: s... | 625941e1796e427e537b096d |
def send_messages(self, msgs): <NEW_LINE> <INDENT> for topic, msgs in itertools.groupby(msgs, lambda x: x[0]): <NEW_LINE> <INDENT> self.queue.put((topic, list(msgs))) | Group messages by topic and send each group as one chunk.
This can save a lot of time for bulk changes since there will be only
one connection per group. | 625941e1cc40096d61595cf4 |
def sliding_window(data, labels, window_sz, n_hop, n_start=0, show_status=False): <NEW_LINE> <INDENT> flag = 0 <NEW_LINE> for sample in range(data.shape[0]): <NEW_LINE> <INDENT> tmp = np.array( [data[sample, i:i + window_sz, :] for i in np.arange(n_start, data.shape[1] - window_sz + n_hop, n_hop)]) <NEW_LINE> tmp_lab =... | input: (array) data : matrix to be processed
(int) window_sz : nb of samples to be used in the window
(int) n_hop : size of jump between windows
output:(array) new_data : output matrix of size (None, window_sz, feature_dim) | 625941e155399d3f05588a5b |
def p_ifBlock(p): <NEW_LINE> <INDENT> p[0] = FuncNode('if', p[3], p[5], p[6]) | ifBlock : IF L_PAR megaExp R_PAR body optionalElse | 625941e1851cf427c661a8b1 |
def plotdata(pref="qtiplot"): <NEW_LINE> <INDENT> global history <NEW_LINE> if pref=="qtiplot": <NEW_LINE> <INDENT> for dat in history: <NEW_LINE> <INDENT> tmpfile=tempfile.NamedTemporaryFile(prefix="tmpExpEYES") <NEW_LINE> name=tmpfile.name <NEW_LINE> tmpfile.close() <NEW_LINE> d = shelve.open(name,"c") <NEW_LINE> d["... | sends the data to a plotter/analyser with many features
@param pref the preferred program, defaults to qtiplot | 625941e197e22403b379d340 |
def rm_node(self, rmkey): <NEW_LINE> <INDENT> ptr = self.head <NEW_LINE> if ptr: <NEW_LINE> <INDENT> if ptr.data == rmkey: <NEW_LINE> <INDENT> self.head = ptr.next <NEW_LINE> <DEDENT> <DEDENT> while ptr: <NEW_LINE> <INDENT> if ptr.data == rmkey: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> prev = ptr <NEW_LINE> ptr = ... | 刪除值是 rmkey 的節點 | 625941e1f8510a7c17cf9aa4 |
def isDerivVar(x): <NEW_LINE> <INDENT> return hasattr(x,'value') and hasattr(x,'deriv') | Returns 1 if |x| is a DerivVar object. | 625941e1fbf16365ca6f6570 |
def get_consistent_resource(self): <NEW_LINE> <INDENT> http_client = HttpClient() <NEW_LINE> response, _ = http_client.get( routes.url(routes.REFUND_RESOURCE, resource_id=self.id, payment_id=self.payment_id) ) <NEW_LINE> return Refund(**response) | :return a refund that you can trust.
:rtype Refund | 625941e1cc0a2c11143dd237 |
def set_UserRegion(self, value): <NEW_LINE> <INDENT> super(DeleteQueueInputSet, self)._set_input('UserRegion', value) | Set the value of the UserRegion input for this Choreo. ((optional, string) The AWS region that corresponds to the SQS endpoint you wish to access. The default region is "us-east-1". See description below for valid values.) | 625941e18da39b475bd6531d |
def detect_RF_collision_of_satellite_over_groundstations(ground_stations, satellites, main_sat, date_time_range, frequency_range=30000, time_period=False): <NEW_LINE> <INDENT> all_rf_collisions = {} <NEW_LINE> id = 1 <NEW_LINE> for ground_station in ground_stations: <NEW_LINE> <INDENT> rf_collisions = [] <NEW_LINE> for... | Detects RF collisions that main satellite will have with
other satellites over every ground station
:param ground_station: List of `GroundStation`s
:return: ditcionary contaning all collisions
:rtype: dictionary | 625941e1442bda511e8be7b8 |
def _ParseResult(self, response_data, io_set_public): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result = json.loads(response_data) <NEW_LINE> msg = result.get('msg', 'No message found') <NEW_LINE> if not result.get('hasAnswer', False): <NEW_LINE> <INDENT> return 'Rejected: ' + msg <NEW_LINE> <DEDENT> elif not io_set... | Extract the result from the server response data.
Args:
response_data: The response body obtained from the server, which is
formatted like a python dictionary.
io_set_public: Boolean indicating whether the answer is public or not.
Returns:
The returned message from the server, or the string 'No message foun... | 625941e13cc13d1c6d3c771e |
def run_eval_epoch(self, iterator, track_stats, val_or_test): <NEW_LINE> <INDENT> self.eval() <NEW_LINE> all_y = [] <NEW_LINE> all_y_pred = [] <NEW_LINE> with torch.no_grad(): <NEW_LINE> <INDENT> for i, batch in enumerate(iterator): <NEW_LINE> <INDENT> text = batch.text <NEW_LINE> bio = batch.bio <NEW_LINE> tag_scores ... | Run the model in eval mode with val or test iterator and read_in performance | 625941e17d847024c06be664 |
def clone(self): <NEW_LINE> <INDENT> return Version(text_type(self)) | Return a new copy of this Version object.
Useful when you need to generate a new object that can be mutated
separately from the original. | 625941e1711fe17d82542708 |
def main(): <NEW_LINE> <INDENT> log('Installing dsound') <NEW_LINE> util.protontricks('dsound') | dsound is needed for audio
| 625941e1a79ad161976cc4ea |
def finish_prereq(self, prereq: TPrerequisite, tasks: Tuple[TTask, ...]) -> None: <NEW_LINE> <INDENT> if len(self._tasks) == 0: <NEW_LINE> <INDENT> raise ValidationError("Cannot finish a task until set_last_completion() is called") <NEW_LINE> <DEDENT> for task in tasks: <NEW_LINE> <INDENT> task_id = self._id_of(task) <... | For every task in tasks, mark the given prerequisite as completed | 625941e1a79ad161976cc4eb |
def test_section_apply_to(): <NEW_LINE> <INDENT> section_file = Section() <NEW_LINE> section_file.read = utils.mock_read(SECTION_STR) <NEW_LINE> assert section_file.apply_to(FILE_WITH_SECTION_STR) == FILE_WITH_SECTION_STR <NEW_LINE> assert section_file.apply_to(FILE_WITHOUT_SECTION_STR) == FILE_WITHOUT_SECTION_STR + '\... | Test Section apply_to method. | 625941e16fb2d068a760f448 |
def __init__(self, x, y, ppl, level_restrict=True): <NEW_LINE> <INDENT> self.x = x.copy() <NEW_LINE> self.y = y.copy() <NEW_LINE> self.points_per_leaf = ppl <NEW_LINE> xmin = self.x.min() <NEW_LINE> xmax = self.x.max() <NEW_LINE> ymin = self.y.min() <NEW_LINE> ymax = self.y.min() <NEW_LINE> mmin = int(np.floor(np.min([... | x: array of points x
y: array of points y
ppl: maximum points per leaf | 625941e1bd1bec0571d909d4 |
def omdictnew(keys_iterable): <NEW_LINE> <INDENT> return dictzip(keys_iterable, map(deepcopy, steady([]))) | Returns a new one-to-many dictionary whose keys are
produced from the keys_iterable. Values of the return-ed
dict are empty list-s. | 625941e1507cdc57c6307088 |
def polcap_factory(policy, name): <NEW_LINE> <INDENT> if isinstance(name, PolicyCapability): <NEW_LINE> <INDENT> assert name.policy == policy <NEW_LINE> return name <NEW_LINE> <DEDENT> elif isinstance(name, qpol.qpol_polcap_t): <NEW_LINE> <INDENT> return PolicyCapability(policy, name) <NEW_LINE> <DEDENT> else: <NEW_LIN... | Factory function for creating policy capability objects. | 625941e19c8ee82313fbbb1b |
def change_password(request, user_id): <NEW_LINE> <INDENT> if not can_edit_user(request.user, user_id): <NEW_LINE> <INDENT> raise PermissionDenied <NEW_LINE> <DEDENT> if request.user.id == int(user_id): <NEW_LINE> <INDENT> Form = PasswordChangeForm <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> Form = SetPasswordForm <N... | Change the password of the user with the given user_id. Checks for
permission to change users. | 625941e1be383301e01b5824 |
def is_sku(s): <NEW_LINE> <INDENT> skuLen = os.getenv("SKULEN") <NEW_LINE> s=s.replace(" ", "") <NEW_LINE> print(s) <NEW_LINE> if(len(s) >skuLen): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> float(s) <NEW_LINE> print("returning valid sku") <NEW_LINE> return True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDEN... | Returns True is string is a number. | 625941e1379a373c97cfaeec |
def reader(closeWindow): <NEW_LINE> <INDENT> global backData, keypad, RFID <NEW_LINE> breakOut = False <NEW_LINE> GPIO.output(ledRed, True) <NEW_LINE> GPIO.output(ledGreen, True) <NEW_LINE> while True: <NEW_LINE> <INDENT> (status,TagType) = RFID.MFRC522_Request(RFID.PICC_REQIDL) <NEW_LINE> (status,backData) = RFID.MFRC... | In this function we try to read rfid cards. At the end it returns the data it got. | 625941e1a4f1c619b28b03d6 |
def unapply_all(self, force=False): <NEW_LINE> <INDENT> self._check(force) <NEW_LINE> for patch in reversed(self.db.applied_patches()): <NEW_LINE> <INDENT> self._unapply_patch(patch) <NEW_LINE> <DEDENT> self.db.save() <NEW_LINE> self.unapplied(self.db.top_patch()) | Unapply all patches | 625941e1baa26c4b54cb14c1 |
def load_dataset(file_name): <NEW_LINE> <INDENT> data=[] <NEW_LINE> with open(file_name) as data_file: <NEW_LINE> <INDENT> for line in data_file: <NEW_LINE> <INDENT> line_list=line.strip().split(",") <NEW_LINE> data.append([]) <NEW_LINE> data[-1].append(float(1)) <NEW_LINE> data[-1].append(float(line_list[0])) <NEW_LIN... | Read data line wise from the input file
create attribute array with appending 1 (for bias implementation)
looks like =[x1, x2, 1]
:param file_name:
:return: np array of attribute and labels | 625941e1bf627c535bc13575 |
def pascal(row, column): <NEW_LINE> <INDENT> if row < 0 or column < 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif row == 0 and column == 0: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return pascal(row - 1, column) + pascal(row - 1, column - 1) | Calculates value in pascal triangle at row and column. | 625941e1d4950a0f3b08c6ef |
@sig(H/ (H/ "a" >> "b" >> "c") >> "b" >> "a" >> "c") <NEW_LINE> def flip(f, b, a): <NEW_LINE> <INDENT> return f(a, b) | flip :: (a -> b -> c) -> b -> a -> c
flip(f) takes its (first) two arguments in the reverse order of f. | 625941e1e76e3b2f99f3abab |
def create_embedding_matrix(word_index, embedding_dict): <NEW_LINE> <INDENT> embedding_matrix = np.zeros((len(word_index) + 1, 300)) <NEW_LINE> for word, i in word_index.items(): <NEW_LINE> <INDENT> word = "the" <NEW_LINE> i = 1 <NEW_LINE> if word in embedding_dict: <NEW_LINE> <INDENT> print(f"{i}, {word}") <NEW_LINE> ... | This function creates the embedding matrix
Args:
word_index: a dictionary with word:index_value
embedding_dict: a dictionary with word:embedding_vector
return: a numpy array with embedding vectors for all known words | 625941e1167d2b6e31218f3a |
def getRootData(self) -> 'np.ndarray': <NEW_LINE> <INDENT> if (isinstance(self.trainSource, TableSource)): <NEW_LINE> <INDENT> return self.trainSource.getRootData(self.key) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Get the root data of this @DataPreprocessing.ColumnsNode object in case this belongs to a @TableSource object. --- UPDATED (Dexter) 20190129
Returns
------------------------------
`np.ndarray<np.ndarray<float|int|str>>` - The root data | 625941e130dc7b7665901d08 |
def compute_norms_1D_polynomials(jacobi_params, deg_max): <NEW_LINE> <INDENT> dim = jacobi_params.size // 2 <NEW_LINE> square_norms = np.zeros((deg_max + 1, dim)) <NEW_LINE> n = np.arange(1, deg_max + 1)[:, None] <NEW_LINE> arcsine = np.all(jacobi_params == -0.5, axis=1) <NEW_LINE> if any(arcsine): <NEW_LINE> <INDENT> ... | Compute the square norms :math:`\|P_{k}^{(a_i,b_i)}\|^2` of each (univariate) orthogoanl Jacobi polynomial for :math:`k=0` to ``deg_max`` and :math:`a_i, b_i =` ``jacobi_params[i, :]``
Recall that the Jacobi polynomials :math:`\left( P_{k}^{(a_i,b_i)} \right)` are `orthogonal <http://en.wikipedia.org/wiki/Jacobi_polyno... | 625941e1ab23a570cc25052b |
def loadSSheetFile(self, filename): <NEW_LINE> <INDENT> if self.spriteSheets.__contains__(filename): <NEW_LINE> <INDENT> return self.spriteSheets[filename] <NEW_LINE> <DEDENT> from quark.properties import sprite_sheet_folder <NEW_LINE> data = self.loadFile(sprite_sheet_folder + filename) <NEW_LINE> if data != None: <NE... | filename: .json file | 625941e17b180e01f3dc4b9c |
def test_issue_6(self): <NEW_LINE> <INDENT> kwargs = self.databases[0].copy() <NEW_LINE> kwargs["database"] = "mysql" <NEW_LINE> conn = pymysql.connect(**kwargs) <NEW_LINE> c = conn.cursor() <NEW_LINE> c.execute("select * from user") <NEW_LINE> conn.close() | exception: TypeError: ord() expected a character, but string of length 0 found | 625941e1baa26c4b54cb14c2 |
def get_light_state(self, light): <NEW_LINE> <INDENT> if not self.latest_lights: <NEW_LINE> <INDENT> self.prev_light_loc = None <NEW_LINE> return False <NEW_LINE> <DEDENT> cv_image = self.bridge.imgmsg_to_cv2(self.camera_image, "rgb8") <NEW_LINE> if self.enable_location_zoom: <NEW_LINE> <INDENT> crop_width = 1.0 <NEW_L... | Determines the current color of the traffic light
Args:
light (TrafficLight): light to classify
Returns:
int: ID of traffic light color (specified in styx_msgs/TrafficLight) | 625941e11f5feb6acb0c4ef0 |
def login_user(username,password): <NEW_LINE> <INDENT> check_user = User.user_exist(username) <NEW_LINE> return check_user | function that checks whether a user exist and then login the user in. | 625941e1d99f1b3c44c6792e |
def run(self): <NEW_LINE> <INDENT> if self.mainWindow: <NEW_LINE> <INDENT> self.mainWindow.show() <NEW_LINE> <DEDENT> if not self.app0: <NEW_LINE> <INDENT> self.app.exec_() | Show window and enter event loop.
| 625941e1167d2b6e31218f3b |
def test_12_secs(self): <NEW_LINE> <INDENT> assert title_screen.alpha_value(12) == 127 | Should be 128 when halfway to 16 seconds (at 12 seconds) | 625941e1aad79263cf390dec |
@pytest.mark.django_db <NEW_LINE> def test_blog_pagination(rf, site): <NEW_LINE> <INDENT> BlogSettings.objects.create( site=site, page_number=1 ) <NEW_LINE> root_page = get_root_page() <NEW_LINE> blog = mommy.prepare_recipe('tests.recipes.blog') <NEW_LINE> posts = mommy.prepare_recipe('tests.recipes.post', _quantity=3)... | Alice is a user that wants to read our blog. She opens the
/blog/ webpage, but the administrator has set the pagination
to one. Because of that, Alice sees 3 paginator pages with one
article for each page.
- the ``BlogSettings`` pagination is set to one post for
each page
- the Blog page contains three po... | 625941e166673b3332b92437 |
def generator(self): <NEW_LINE> <INDENT> for key in self.storage.keys(): <NEW_LINE> <INDENT> yield key | Local storage generator. | 625941e1bde94217f3683193 |
def polls_get_with_http_info(self, **kwargs): <NEW_LINE> <INDENT> all_params = ['cursor', 'tags', 'question', 'sort'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout') <NEW_LIN... | Polls
A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question when they enter Polls, and they don't necessarily enter ev... | 625941e14a966d76dd5513b8 |
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> buff.write(_get_struct_B().pack(self.attach)) <NEW_LINE> <DEDENT> except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) <NEW_LINE> except TypeError... | serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module | 625941e13317a56b86939ff6 |
def disconnect_api(): <NEW_LINE> <INDENT> global _api <NEW_LINE> if _api: <NEW_LINE> <INDENT> _api.disconnect() <NEW_LINE> _api = None | Gracefully shutdown the API. | 625941e1956e5f7376d71212 |
def get_files(): <NEW_LINE> <INDENT> Tk().withdraw() <NEW_LINE> fullpaths = askopenfilename(multiple=1, filetypes=[('XRDML','.xrdml'),('CSV','.csv'),('All files','.*')]) <NEW_LINE> if len(fullpaths): <NEW_LINE> <INDENT> print('User opened:', *fullpaths, sep='\n') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('No ... | Open a dialog and return a set of files to parse. | 625941e1cb5e8a47e48b7e4b |
def updateDistributionsFromSentences(text, wordCasingLookup, uniDist, backwardBiDist, forwardBiDist, trigramDist): <NEW_LINE> <INDENT> for sentence in text: <NEW_LINE> <INDENT> if not checkSentenceSanity(sentence): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> for tokenIdx in xrange(1, len(sentence)): <NEW_LINE> <IN... | Updates the NLTK Frequency Distributions based on a list of sentences.
text: Array of sentences.
Each sentence must be an array of Tokens. | 625941e1cad5886f8bd2737f |
def analyze(self, wanted): <NEW_LINE> <INDENT> if not isinstance(wanted, entity_query.Query): <NEW_LINE> <INDENT> wanted = entity_query.Query(wanted) <NEW_LINE> <DEDENT> cache_key = wanted.source <NEW_LINE> analysis = self._cached_query_analyses.get(cache_key, None) <NEW_LINE> if analysis: <NEW_LINE> <INDENT> analysis_... | Finds collectors and indexing suggestions for the query.
Returns a dict of:
- collectors: list of collectors to run
- lookups: list of attributes to consider indexing for
- dependencies: list of SimpleDependency instances to include
- exclusions: list of SimpleDependency instances to exclude | 625941e107d97122c4178c39 |
def query_length(query): <NEW_LINE> <INDENT> return int(query['q. end']) - int(query['q. start']) + 1 | Returns the length of a query from blastp search.
Key inputs:
query --- a dict based on output of single alignment from blastp search | 625941e115fb5d323cde0eba |
def throw_pexpect_error(func): <NEW_LINE> <INDENT> @functools.wraps(func) <NEW_LINE> def wrapper(*args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return func(*args, **kwargs) <NEW_LINE> <DEDENT> except pexpect.TIMEOUT as e: <NEW_LINE> <INDENT> raise PexpectErrorTimeout(e) <NEW_LINE> <DEDENT> <DEDENT> retu... | If a pexpect.TIMEOUT occurs throw boardfarm.PexpectError error. | 625941e1090684286d50f090 |
@bpy.app.handlers.persistent <NEW_LINE> def _toss_garbage(scene): <NEW_LINE> <INDENT> bpy_data = bpy.data <NEW_LINE> tex = bpy_data.textures.get("LIGHTMAPGEN_PREVIEW") <NEW_LINE> if tex is not None: <NEW_LINE> <INDENT> bpy_data.textures.remove(tex) <NEW_LINE> <DEDENT> for i in bpy_data.images: <NEW_LINE> <INDENT> if i.... | Removes all LIGHTMAPGEN and autocolor garbage before saving | 625941e160cbc95b062c68e9 |
def GetPythonPackageRootForFilename(filename): <NEW_LINE> <INDENT> absolutePathToFilename = os.path.abspath(filename) <NEW_LINE> currentPath = absolutePathToFilename <NEW_LINE> lastDirectory = None <NEW_LINE> while True: <NEW_LINE> <INDENT> directory = os.path.dirname(currentPath) <NEW_LINE> if not IsPythonDirectory(di... | Returns the Python Package Root that the filename is in or None | 625941e199fddb7c1c9de735 |
def tpr(imap, ref_imap): <NEW_LINE> <INDENT> tp = ((imap == 1) & (ref_imap == 1)).sum().sum() <NEW_LINE> p = ref_imap.sum().sum() <NEW_LINE> return(tp/p) | True positive rate | 625941e17d43ff24873a3049 |
def doTEBD(self,*args,**kwargs): <NEW_LINE> <INDENT> return self.__doTEBD__(*args,**kwargs) | see __doTEBD__ | 625941e176d4e153a657eed8 |
def _update_heave(self): <NEW_LINE> <INDENT> if self.button_rb: <NEW_LINE> <INDENT> self.heave = CONTROL_NORM_MAX <NEW_LINE> <DEDENT> elif self.button_lb: <NEW_LINE> <INDENT> self.heave = CONTROL_NORM_MIN <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.heave = CONTROL_NORM_IDLE | Heave is determined by the buttons RB and LB. | 625941e1aad79263cf390ded |
def log_out(self): <NEW_LINE> <INDENT> self.logout() | Log out alias function | 625941e1be7bc26dc91cd99f |
def title_command(willie, trigger): <NEW_LINE> <INDENT> if not trigger.group(2): <NEW_LINE> <INDENT> if trigger.sender not in willie.memory['last_seen_url']: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> matched = check_callbacks(willie, trigger, willie.memory['last_seen_url'][trigger.sender], True) <NEW_LINE> if matc... | Show the title or URL information for the given URL, or the last URL seen
in this channel. | 625941e176e4537e8c351a1b |
@users.view_util.login_or_local_required <NEW_LINE> @cache_page(settings.FAST_PAGE_CACHE_TIMEOUT) <NEW_LINE> @cache_control(private=True) <NEW_LINE> @users.view_util.monitor <NEW_LINE> @vary_on_cookie <NEW_LINE> def pv_monitor(request, instrument): <NEW_LINE> <INDENT> instrument_id = get_object_or_404(Instrument, name=... | Display the list of latest PV values
@param request: HTTP request object
@param instrument: instrument name | 625941e13d592f4c4ed1d40a |
def make_marker_text(lonlat_tuples_list): <NEW_LINE> <INDENT> used_color_map = session.get('used_color_map', {}) <NEW_LINE> marker_text_list = [] <NEW_LINE> name = 'pin-m' <NEW_LINE> for index, lonlat_tuple in enumerate(lonlat_tuples_list): <NEW_LINE> <INDENT> label = "building" <NEW_LINE> zpid, lon, lat = lonlat_tuple... | Parse and join the strings that go in the mapbox api call | 625941e115fb5d323cde0ebb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.