code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__(self, side): <NEW_LINE> <INDENT> self.side = side | Constructor for shape objects
Takes a side as argument | 625941f74527f215b584cac4 |
def Stop(self): <NEW_LINE> <INDENT> return super(IAnimationProgressor, self).Stop() | Method IAnimationProgressor.Stop | 625941f724f1403a926011d4 |
def convert_cpi(): <NEW_LINE> <INDENT> data_xls = pd.read_excel('../data_sets/cpi_1974-2016.xls') <NEW_LINE> data_xls.to_csv('../data_sets/cpi_1974-2016.csv', encoding='utf-8') <NEW_LINE> food_dict = dict() <NEW_LINE> with open('../data_sets/cpi_1974-2016.csv') as data_csv: <NEW_LINE> <INDENT> reader = csv.reader(data_... | Converts the consumer price index dataset or the producer price index dataset into a csv then to a dictionary.
:return: Returns a dictionary of food items and price changes by year | 625941f7435de62698dfe2c1 |
def get_data(url, proxy_address): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> page_content = get_html(url, proxy_address) <NEW_LINE> if page_content: <NEW_LINE> <INDENT> if page_content.status_code == 200: <NEW_LINE> <INDENT> question_id = url.split('/')[-1] <NEW_LINE> ret = page_content.text <NEW_LINE> data = parse_h... | 获取重定向后的url,获取其html, 解析html,入库redis
:param url:
:param proxy_address:
:return: | 625941f763f4b57ef0001779 |
def _draw_proj_checkbox(event, params, draw_current_state=True): <NEW_LINE> <INDENT> from matplotlib import widgets <NEW_LINE> projs = params['projs'] <NEW_LINE> labels = [p['desc'] for p in projs] <NEW_LINE> actives = ([p['active'] for p in projs] if draw_current_state else params.get('proj_bools', [params['apply_proj... | Toggle options (projectors) dialog. | 625941f73d592f4c4ed1d6ce |
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host, controller=DefaultController, link=Link, intf=Intf, build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8', inNamespace=False, autoSetMacs=False, autoStaticArp=False, autoPinCpus=False, listenPort=None, waitConnected=False ): <NEW_LINE> <INDENT> se... | Create Mininet object.
topo: Topo (topology) object or None
switch: default Switch class
host: default Host class/constructor
controller: default Controller class/constructor
link: default Link class/constructor
intf: default Intf class/constructor
ipBase: base IP address for hosts,
build: build now from topo?
xterms: ... | 625941f7956e5f7376d714de |
def initSchemaTableActions(self): <NEW_LINE> <INDENT> for tableName, qtAction in self.tableNameToDescriptionQtAction.items(): <NEW_LINE> <INDENT> self.removeAction(qtAction) <NEW_LINE> <DEDENT> self.tableNameToDescriptionQtAction = {} <NEW_LINE> for table in self.schema.tables: <NEW_LINE> <INDENT> qtActionLabel = 'Show... | Initialize the QT actions associated to the the relational tables (right click menu related) | 625941f73346ee7daa2b33e6 |
def loadRemoteData(self, name): <NEW_LINE> <INDENT> data = super(SaltKeep, self).loadRemoteData(name) <NEW_LINE> if not data: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> mid = data['role'] <NEW_LINE> statae = raeting.ACCEPTANCES.keys() <NEW_LINE> for status in statae: <NEW_LINE> <INDENT> keydata = self.saltRaet... | Load and Return the data from the remote file | 625941f78a43f66fc4b546d1 |
def __call__(self, d): <NEW_LINE> <INDENT> t = term(self) <NEW_LINE> for v in d: <NEW_LINE> <INDENT> if v in t.degree: <NEW_LINE> <INDENT> t *= d[v] ** t.degree[v] <NEW_LINE> del t.degree[v] <NEW_LINE> <DEDENT> <DEDENT> if isinstance(self.coef, int) and all(isinstance(e, int) for e in d.values()) and all(abs(e) == 1 fo... | evaluate term at values specified in dictionary,
e.g. dict = {'x':3, 'y': 4} avaluates the polynomial at x=3, y=4. | 625941f7e5267d203edce308 |
def show_data_dir_info(self, ddir, histfile=''): <NEW_LINE> <INDENT> status, droot = self.find_data_root(ddir, hvar=0) <NEW_LINE> if status: <NEW_LINE> <INDENT> print('data dir : missing %s' % ddir) <NEW_LINE> return 1 <NEW_LINE> <DEDENT> dhome = droot.replace(self.home_dir, '$HOME') <NEW_LINE> print('data dir : found ... | try to locate and display the given data directory
if histfile, display the top line
return 0 if found, else 1 | 625941f7287bf620b61d40d3 |
def BubbleSortGraph(n): <NEW_LINE> <INDENT> if n < 1: <NEW_LINE> <INDENT> raise ValueError( "Invalid number of symbols to permute, n should be >= 1") <NEW_LINE> <DEDENT> if n == 1: <NEW_LINE> <INDENT> from sage.graphs.generators.basic import CompleteGraph <NEW_LINE> return Graph(CompleteGraph(n), name="Bubble sort") <N... | Returns the bubble sort graph `B(n)`.
The vertices of the bubble sort graph are the set of permutations
on `n` symbols. Two vertices are adjacent if one can be obtained
from the other by swapping the labels in the `i`-th and `(i+1)`-th
positions for `1 \leq i \leq n-1`. In total, `B(n)` has order
`n!`. Swapping two la... | 625941f7796e427e537b0c3f |
def _json_encode(self, fingerprints, typedic): <NEW_LINE> <INDENT> fingerprints_encoded = {} <NEW_LINE> for key, val in fingerprints.items(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> newkey = "_".join(map(str, list(key))) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> newkey = str(key) <NEW_LINE> <DEDENT... | json does not accept tuples nor integers as dict keys,
so in order to write the fingerprints to atoms.info, we need
to convert them to strings | 625941f7507cdc57c630735f |
def __str_full__(self, subcol_headers): <NEW_LINE> <INDENT> col_width = self[0].col_width <NEW_LINE> out = '-' * col_width + '\n' <NEW_LINE> if self.table_header: <NEW_LINE> <INDENT> out += '{0:^{1}}'.format(format_(self.table_header, col_width), col_width) + '\n' <NEW_LINE> <DEDENT> for col in self: <NEW_LINE> <INDENT... | Prints DataTable when `compact_view` is `False`. | 625941f75510c4643540fa47 |
def nextPermutation(self, nums: List[int]) -> None: <NEW_LINE> <INDENT> n = len(nums) <NEW_LINE> firstIndex = -1 <NEW_LINE> for i in range(n-2,-1,-1): <NEW_LINE> <INDENT> if nums[i] < nums[i+1]: <NEW_LINE> <INDENT> firstIndex = i <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> if -1 == firstIndex: <NEW_LINE> <INDENT> sel... | Do not return anything, modify nums in-place instead. | 625941f77d43ff24873a331a |
def get_word(self, item): <NEW_LINE> <INDENT> word_s = hit_to_string(item, self.width) <NEW_LINE> c = self.dbh.cursor() <NEW_LINE> c.execute("SELECT * FROM words WHERE philo_id=? LIMIT 1;", (word_s,)) <NEW_LINE> return c.fetchone() | Retrieve word from words table | 625941f7ab23a570cc2507fc |
def groupAnagrams(self, strs): <NEW_LINE> <INDENT> dic = {} <NEW_LINE> for items in strs: <NEW_LINE> <INDENT> sortedItems = ''.join(sorted(items)) <NEW_LINE> if sortedItems in dic: <NEW_LINE> <INDENT> dic.get(sortedItems).append(items) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dic[sortedItems] = [items] <NEW_LINE> ... | :type strs: List[str]
:rtype: List[List[str]] | 625941f75166f23b2e1a57cd |
def p_section(self, p): <NEW_LINE> <INDENT> p[0] = (p[1], p[3] if len(p) != 5 else p[4]) | section : AREA EOL area
| MOBILES EOL mobiles
| OBJECTS EOL objects
| ROOMS EOL rooms
| RESETS EOL comments resets
| SHOPS EOL shops
| SPECIALS EOL comments specials | 625941f7cc40096d61595fc1 |
def _ioprio_set(io_class, io_priority): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> io_class = IO_CLASS_ENUM[io_class] <NEW_LINE> io_priority = int(io_priority) <NEW_LINE> _posix_syscall(NR_ioprio_set(), IOPRIO_WHO_PROCESS, os.getpid(), IOPRIO_PRIO_VALUE(io_class, io_priority)) <NEW_LINE> <DEDENT> except (KeyError, Va... | ioprio_set for this process
:param io_class: the I/O class component, can be
IOPRIO_CLASS_RT, IOPRIO_CLASS_BE,
or IOPRIO_CLASS_IDLE
:param io_priority: priority value in the I/O class | 625941f7e76e3b2f99f3ae74 |
def __rmul__(self, other): <NEW_LINE> <INDENT> return self.__mul__(other) | Reverse multipy function, adds support for format: 2 * bar
where bar is a Matrix object | 625941f76aa9bd52df03741c |
def example(self, random=None): <NEW_LINE> <INDENT> random = random or Random() <NEW_LINE> for _ in hrange(100): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> template = self.draw_and_produce(random) <NEW_LINE> with BuildContext(): <NEW_LINE> <INDENT> return self.reify(template) <NEW_LINE> <DEDENT> <DEDENT> except (BadT... | Provide an example of the sort of value that this strategy
generates. This is biased to be slightly simpler than is typical for
values from this strategy, for clarity purposes.
This method shouldn't be taken too seriously. It's here for interactive
exploration of the API, not for any sort of real testing.
This method... | 625941f707f4c71912b11af9 |
def main(): <NEW_LINE> <INDENT> img1 = pv3.Image(pv3.IMG_DRIVEWAY) <NEW_LINE> img1.annotate_text( "sample annotation", (200, 200), color=pv3.RGB_CYAN, bg_color=pv3.RGB_BLACK, font_scale=2, ) <NEW_LINE> img2 = pv3.Image(pv3.IMG_PRIUS) <NEW_LINE> img3 = pv3.Image(pv3.IMG_SLEEPYCAT) <NEW_LINE> img_list = [img1, img2, img3... | Demonstrates several annotation methods of the Image class | 625941f738b623060ff0b460 |
def show_main(self, enabled=True): <NEW_LINE> <INDENT> if not enabled: <NEW_LINE> <INDENT> self.mainwin.disable() <NEW_LINE> <DEDENT> self.update_name() <NEW_LINE> self.guess_odir() <NEW_LINE> self.update_ofile() <NEW_LINE> self.mainwin.show() | Shows the main window. | 625941f7cdde0d52a9e536ad |
def _create_embeddings(self): <NEW_LINE> <INDENT> (encoder_embedding, decoder_embedding ) = utils.create_encoder_and_decoder_embeddings( src_vocab_size=self._src_vocab_size, tgt_vocab_size=self._tgt_vocab_size, src_embed_size=self._num_units, tgt_embed_size=self._num_units, share_vocab=self._share_vocab) <NEW_LINE> ret... | Returns the embeddings for encoder (source) and decoder (target).
The gradients will be backpropagated to the embeddings at training time.
Returns:
encoder_embedding: float tensor with shape [src_vocab_size, num_units]
containing the embeddings of symbols in source vocabulary.
decoder_embedding: float tenso... | 625941f785dfad0860c3b4d1 |
@register.filter <NEW_LINE> def show_user(email, arg=None, autoescape=None, memcache_results=None): <NEW_LINE> <INDENT> if isinstance(email, users.User): <NEW_LINE> <INDENT> email = email.email() <NEW_LINE> <DEDENT> if not arg: <NEW_LINE> <INDENT> user = users.get_current_user() <NEW_LINE> if user is not None and email... | Render a link to the user's dashboard, with text being the nickname. | 625941f7a4f1c619b28b069c |
def db_access(self): <NEW_LINE> <INDENT> db_choice = self.representation.choose_database() <NEW_LINE> if db_choice == "up": <NEW_LINE> <INDENT> self.database = UniprotBuilder() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.database = UniprotBuilder() <NEW_LINE> <DEDENT> db_options = self.representation.db_options(... | :return: | 625941f7099cdd3c635f12cc |
def actions(self, state): <NEW_LINE> <INDENT> possible_actions = list() <NEW_LINE> index_blank_square = self.find_blank_square(state) <NEW_LINE> if index_blank_square(0) == 0: <NEW_LINE> <INDENT> possible_actions += ['DOWN'] <NEW_LINE> <DEDENT> elif index_blank_square(0) == 1: <NEW_LINE> <INDENT> possible_actions += ['... | Return the actions that can be executed in the given state.
The result would be a list, since there are only four possible actions
in any given state of the environment. | 625941f7d8ef3951e3243bb2 |
@user_passes_test(is_secret, login_url='accueil') <NEW_LINE> def ajaxcolloscopeeffacer(request, numero_semaine, id_creneau): <NEW_LINE> <INDENT> if not Config.objects.get_config().modif_secret_col: <NEW_LINE> <INDENT> return HttpResponseForbidden("Accès non autorisé") <NEW_LINE> <DEDENT> semaine=get_object_or_404(Semai... | Efface la colle sur le créneau dont l'id est id_creneau et la semaine dont le numéro est numero_semaine
puis renvoie la chaine de caractères "efface" | 625941f7a8370b7717052f11 |
def isOp(s): <NEW_LINE> <INDENT> return getOp(s) != None | takes a string to see if it is a op | 625941f7b830903b967e9f77 |
def send( self, exchange: str, routing_key: str, body: Union[str, bytes], properties: pika.spec.BasicProperties = None, mandatory: bool = True, transaction_id: Optional[int] = None, ) -> Future[None]: <NEW_LINE> <INDENT> if not self._connection: <NEW_LINE> <INDENT> raise RuntimeError("Cannot send on unstarted connectio... | Send a message. Thread-safe. | 625941f7d6c5a102081446c4 |
@setHook(HOOK_STARTUP) <NEW_LINE> def startupEvent(): <NEW_LINE> <INDENT> setPinDir(redLEDPin, True) <NEW_LINE> setPinDir(greenLEDPin, True) | This is hooked into the HOOK_STARTUP event | 625941f7ab23a570cc2507fd |
def island(matrix): <NEW_LINE> <INDENT> if (not matrix) or len(matrix) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> number_of_islands = 0 <NEW_LINE> l = [True] * len(matrix[0]) <NEW_LINE> for i in range(len(matrix)): <NEW_LINE> <INDENT> ind = True <NEW_LINE> for j in range(len(matrix[0])): <NEW_LINE> <INDENT>... | given a two by two matrix, get the number of islands in it, an island is a series of 1's connected in a
row or a column | 625941f730dc7b7665901fd3 |
def test_make_location(self): <NEW_LINE> <INDENT> loc = self.human.makeLocation(CoordName=1) <NEW_LINE> self.assertEquals(len(loc), 248956422) | should correctly make a location for an entire chromosome | 625941f757b8e32f52483b14 |
def test_set_role(self): <NEW_LINE> <INDENT> username = "salt_test" <NEW_LINE> role = "vdc-admin" <NEW_LINE> with patch("salt.modules.nxos.config", autospec=True, return_value=set_role): <NEW_LINE> <INDENT> result = nxos_module.set_role(username, role) <NEW_LINE> self.assertEqual(result, set_role) | UT: nxos module:save_running_config method | 625941f73c8af77a43ae3e1d |
def pairwise(): <NEW_LINE> <INDENT> def pairwise_transducer(reducer): <NEW_LINE> <INDENT> return Pairwise(reducer) <NEW_LINE> <DEDENT> return pairwise_transducer | Create a transducer which produces successive pairs | 625941f7cc0a2c11143dd506 |
def predict(data_path): <NEW_LINE> <INDENT> print('Making predictions for test set ...') <NEW_LINE> test_file = os.path.join(data_path,'users','coded_ids_labels_test.csv') <NEW_LINE> test_df = pd.read_csv(test_file) <NEW_LINE> train_set, test_set = get_train_and_test_set(data_path) <NEW_LINE> train = train_set[5] <NEW_... | Choose
1. the best model (Gradient Boosting Classfier)
2. the best feature group (feature group 6)
to fit the model and make predictions for test set | 625941f77c178a314d6efae0 |
def get_stats_topic(masteruri, wait=True): <NEW_LINE> <INDENT> return _get_topic(masteruri, 'LinkStatesStamped', wait) | Search in publishers of ROS master for a topic with type LinkStatesStamped and
returns his name, if it runs on the local host. Returns empty list if no topic
was found and `wait` is ``False``.
:param masteruri: the URI of the ROS master
:type masteruri: str
:param wait: check every second for the topic
:type wait: ... | 625941f730c21e258bdfab19 |
def is_adherent(self): <NEW_LINE> <INDENT> end = self.end_adhesion() <NEW_LINE> if not end: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif end < timezone.now(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True | Methods, calculate and returns if the user has a valid membership by testing
if end_adherent is after now or not.
Parameters:
self (user instance): user to return infos
Returns:
is_adherent (boolean) : True is user has a valid membership. | 625941f7be7bc26dc91cdc68 |
def process(self, data): <NEW_LINE> <INDENT> json = JSONDecoder().decode(data.decode('utf-8')) <NEW_LINE> try: <NEW_LINE> <INDENT> hash_id = check_not_none(json['id']) <NEW_LINE> session = check_not_none(json['session']) <NEW_LINE> status = self.__cloud.is_session(session) <NEW_LINE> if status or (not status and self._... | The thread that runs and gets the status of the session | 625941f7d486a94d0b98e7bb |
def live(self): <NEW_LINE> <INDENT> return self.shop.api.livevariant([self.id]) | The live data to this variant. | 625941f7e64d504609d74eb4 |
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None): <NEW_LINE> <INDENT> if not region: <NEW_LINE> <INDENT> region = RegionInfo(self, self.DefaultRegionName, ... | Init method to create a new connection to EC2.
B{Note:} The host argument is overridden by the host specified in the boto configuration file. | 625941f791af0d3eaac9c092 |
def handle_expired_client_cert(self, e): <NEW_LINE> <INDENT> exit_code = ExceptionHandler.handle_expired_client_cert(self, e) <NEW_LINE> desc = _('Use the login command to authenticate with the server and ' 'download a new session certificate.') <NEW_LINE> self.prompt.render_paragraph(desc) <NEW_LINE> return exit_code | Handles the exception raised when the client certificate has expired.
:param e: The Exception that was raised
:type e: pulp.bindings.exceptions.ClientCertificateExpiredException
:return: The exit code to be used.
:rtype: int | 625941f766656f66f7cbc821 |
def loss(self, X, y=None, reg=0.0): <NEW_LINE> <INDENT> W1, b1 = self.params['W1'], self.params['b1'] <NEW_LINE> W2, b2 = self.params['W2'], self.params['b2'] <NEW_LINE> N, D = X.shape <NEW_LINE> scores = None <NEW_LINE> layer1 = np.dot(X,W1) + b1 <NEW_LINE> activation = np.vectorize(lambda x: x * (x > 0)) <NEW_LINE> l... | Compute the loss and gradients for a two layer fully connected neural
network.
Inputs:
- X: Input data of shape (N, D). Each X[i] is a training sample.
- y: Vector of training labels. y[i] is the label for X[i], and each y[i] is
an integer in the range 0 <= y[i] < C. This parameter is optional; if it
is not passed... | 625941f7d6c5a102081446c5 |
def get_number_aliens_x(ai_settings, alien_width): <NEW_LINE> <INDENT> available_space_x = ai_settings.screen_width - 2 * alien_width <NEW_LINE> number_aliens_x = int(available_space_x / (2 * alien_width)) <NEW_LINE> return number_aliens_x | 计算每行可容纳多少机器人 | 625941f7dc8b845886cb5bab |
def scrub_response(response): <NEW_LINE> <INDENT> headers = response["headers"] <NEW_LINE> for header in [ "CF-Cache-Status", "CF-RAY", "Cache-Control", "Connection", "Date", "Expect-CT", "NEL", "Report-To", "Server", "Transfer-Encoding", "cf-request-id", "Set-Cookie", ]: <NEW_LINE> <INDENT> headers.pop(header, None) <... | Drop irrelevant headers. | 625941f70fa83653e465762b |
def m_analysis(dat): <NEW_LINE> <INDENT> sleep_cost=0 <NEW_LINE> for i in range(len(dat)-2): <NEW_LINE> <INDENT> if(dat[i][3]==0 and dat[i+1][3]==1 and dat[i+2][3]==2): <NEW_LINE> <INDENT> sleep_cost=dat[i+1][2]-dat[i][2] <NEW_LINE> <DEDENT> <DEDENT> return round(sleep_cost/60,2) | 计算每天的所需特征,比如:目前计算的是入睡时间(分钟) | 625941f7aad79263cf3910c0 |
def test_chain_positive_1(self): <NEW_LINE> <INDENT> string = "123" <NEW_LINE> state = epp.State(string) <NEW_LINE> parser = epp.chain( [ epp.literal("1"), epp.literal("2"), epp.literal("3") ], combine=False) <NEW_LINE> output = epp.parse(None, state, parser) <NEW_LINE> self.assertIsNotNone(output) <NEW_LINE> value, af... | Test 'chain' parser generator, positive check #1. | 625941f7d268445f265b54e4 |
def open(self): <NEW_LINE> <INDENT> self.handler.add_observer(self) | Open websocket | 625941f763b5f9789fde775b |
def create_inbox(self, request): <NEW_LINE> <INDENT> body = { "name": request.get_name(), "serviceClass": request.get_service_class(), } <NEW_LINE> if request.get_description() is not None: <NEW_LINE> <INDENT> body["description"] = request.get_description() <NEW_LINE> <DEDENT> if request.get_auto_delete() is not None: ... | 受信ボックスを新規作成します<br>
<br>
:param request: リクエストパラメータ
:type request: gs2_inbox_client.control.CreateInboxRequest.CreateInboxRequest
:return: 結果
:rtype: gs2_inbox_client.control.CreateInboxResult.CreateInboxResult | 625941f74e4d5625662d4a42 |
def set_semantic_domain(self, semantic_domain, language=None): <NEW_LINE> <INDENT> self.create_and_add_subject_field().set_semanticDomain(semantic_domain, language) <NEW_LINE> return self | ! @brief Create a SubjectField instance and set its semantic domain and language.
Attributes 'semanticDomain' and 'language' are owned by SubjectField.
@param semantic_domain The semantic domain to set.
@param language Language used to describe the semantic domain.
@return Sense instance. | 625941f7236d856c2ad44e59 |
def pad(self, width, side="left", fillchar=" "): <NEW_LINE> <INDENT> width = int(width) <NEW_LINE> fillchar = self._obj.dtype.type(fillchar) <NEW_LINE> if len(fillchar) != 1: <NEW_LINE> <INDENT> raise TypeError("fillchar must be a character, not str") <NEW_LINE> <DEDENT> if side == "left": <NEW_LINE> <INDENT> f = lambd... | Pad strings in the array up to width.
Parameters
----------
width : int
Minimum width of resulting string; additional characters will be
filled with character defined in `fillchar`.
side : {'left', 'right', 'both'}, default 'left'
Side from which to fill resulting string.
fillchar : str, default ' '
Ad... | 625941f7b545ff76a891448a |
def geometric_features(self): <NEW_LINE> <INDENT> d = {'start': self.shapes['line start'].geometric_features()['start'], 'end': self.shapes['piston']['line'].geometric_features()['start'], 'bar_length': self.bar_length, 'piston_pos': self.piston_pos, 'width': self.width, 'dashpot_length': self.dashpot_length, } <NEW_LI... | Recorded geometric features:
==================== =============================================
Attribute Description
==================== =============================================
start Start point of dashpot.
end End point of dashpot.
bar_length Length of firs... | 625941f75e10d32532c5f599 |
def is_try_to_follow_find_path(self): <NEW_LINE> <INDENT> return choice([True, False]) | If we chasing and then get a path that doesn't lead to our target do we follow it?
Expected to be overridden in child classes
:return: | 625941f7ec188e330fd5ae05 |
def softmax_loss_vectorized(W, X, y, reg): <NEW_LINE> <INDENT> num_classes = W.shape[1] <NEW_LINE> num_train = X.shape[0] <NEW_LINE> loss = 0.0 <NEW_LINE> dW = np.zeros_like(W) <NEW_LINE> probs = np.zeros((num_train, num_classes)) <NEW_LINE> probs = X.dot(W) <NEW_LINE> probs = np.exp(probs) <NEW_LINE> probs /= np.sum(p... | Softmax loss function, vectorized version.
Inputs and outputs are the same as softmax_loss_naive. | 625941f773bcbd0ca4b2c6ea |
def __prepare(self, x, y): <NEW_LINE> <INDENT> self.train_x = np.asmatrix(x) <NEW_LINE> self.train_y = np.asarray(y) <NEW_LINE> self.count, self.dimension = np.shape(self.train_x) <NEW_LINE> self.w = np.zeros((1, self.dimension)) <NEW_LINE> self.alpha = np.zeros(self.count) <NEW_LINE> self.error_list = np.zeros(self.co... | x: count by dimension matrix
y: 1 by count vector/list | 625941f760cbc95b062c6bb8 |
def mkdir(self): <NEW_LINE> <INDENT> self._root_dir.mkdir(parents=True, exist_ok=True) <NEW_LINE> self._temp_dir.mkdir(parents=True, exist_ok=True) <NEW_LINE> self._download_dir.mkdir(parents=True, exist_ok=True) <NEW_LINE> self._savestate_dir.mkdir(parents=True, exist_ok=True) | Create all base directories. | 625941f760cbc95b062c6bb9 |
def __init__(self, version=None, title=None, url=None, description=None, image_type=None): <NEW_LINE> <INDENT> self.__discriminator_value = "PrintImageRequest" <NEW_LINE> self.object_type = self.__discriminator_value <NEW_LINE> super(PrintImageRequest, self).__init__(object_type=self.__discriminator_value, version=vers... | Payload Request object for PrintImage
:param version: version of the request
:type version: (optional) str
:param title: title of the image
:type title: (optional) str
:param url: url of the image
:type url: (optional) str
:param description: description of the image
:type description: (optional) str
:param image_type... | 625941f7cad5886f8bd2764d |
def init(): <NEW_LINE> <INDENT> pass | __NATIVE__
PmReturn_t retval = PM_RET_OK;
static struct uip_eth_addr sTempAddr;
unsigned long ulUser0, ulUser1;
unsigned long ulTemp;
lib_printf("Reading the MAC address from the user registers.\n");
ROM_FlashUserGet(&ulUser0, &ulUser1);
if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
{
//
// We shoul... | 625941f755399d3f05588d2e |
def _write_map(self) -> None: <NEW_LINE> <INDENT> if not self._map: <NEW_LINE> <INDENT> self._map = { "stata_data": 0, "map": self.handles.handle.tell(), "variable_types": 0, "varnames": 0, "sortlist": 0, "formats": 0, "value_label_names": 0, "variable_labels": 0, "characteristics": 0, "data": 0, "strls": 0, "value_lab... | Called twice during file write. The first populates the values in
the map with 0s. The second call writes the final map locations when
all blocks have been written. | 625941f73eb6a72ae02ecb65 |
def _Version(): <NEW_LINE> <INDENT> print('<repo not installed>') <NEW_LINE> print('repo launcher version %s' % ('.'.join(str(x) for x in VERSION),)) <NEW_LINE> print(' (from %s)' % (__file__,)) <NEW_LINE> print('git %s' % (ParseGitVersion().full,)) <NEW_LINE> print('Python %s' % sys.version) <NEW_LINE> uname = p... | Show version information. | 625941f7d486a94d0b98e7bc |
def post_legacy_authorizations_id_password_with_http_info(self, auth_id, password_reset_body, **kwargs): <NEW_LINE> <INDENT> local_var_params, path_params, query_params, header_params, body_params = self._post_legacy_authorizations_id_password_prepare(auth_id, password_reset_body, **kwargs) <NEW_LINE> return... | Set a legacy authorization password.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_legacy_authorizations_id_password_with_http_info(auth_id, password_reset_body, async_req=True)
>>> result = thread.get()
:param async_req... | 625941f750812a4eaa59c98f |
def test_bucketlist_can_be_deleted(self): <NEW_LINE> <INDENT> res = self.client().post('/bucketlists', data={'name': 'Time travel'}) <NEW_LINE> self.assertEqual(res.status_code, 201) <NEW_LINE> self.assertIn('Time travel', str(res.data)) <NEW_LINE> data = json.loads(res.data.decode('utf-8').replace("'", "\"")) <NEW_LIN... | Test the API that given an id a bucketlist can be deleted. (DELETE request). | 625941f730bbd722463cc43f |
def main(): <NEW_LINE> <INDENT> serial_ports = [] <NEW_LINE> serial_ports, input_text = setup_system(serial_ports) <NEW_LINE> if input_text != "Exit": <NEW_LINE> <INDENT> run_system(serial_ports) | Loop of the program. Provides tui to interact with the ceiling sculpture
| 625941f7e76e3b2f99f3ae75 |
def is_known_field(self, field_name): <NEW_LINE> <INDENT> return True | Without schema, any field is considered as known. | 625941f74428ac0f6e5bae6e |
def getbranchesurl(idbranch, *args, **kwargs): <NEW_LINE> <INDENT> getparams = [] <NEW_LINE> if kwargs: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if kwargs["fullDetails"] == True: <NEW_LINE> <INDENT> getparams.append("fullDetails=true") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> getparams.append("fullDetails=fals... | Request Branches URL.
If idbranch is set, you'll get a response adequate for a MambuBranch object.
If not set, you'll get a response adequate for a MambuBranches object.
See mambubranch module and pydoc for further information.
Currently implemented filter parameters:
* fullDetails
* limit
* offset
See Mambu officia... | 625941f757b8e32f52483b15 |
def get_exit_time(self): <NEW_LINE> <INDENT> if self.is_alive(): <NEW_LINE> <INDENT> ExitTime = win32.GetSystemTimeAsFileTime() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if win32.PROCESS_ALL_ACCESS == win32.PROCESS_ALL_ACCESS_VISTA: <NEW_LINE> <INDENT> dwAccess = win32.PROCESS_QUERY_LIMITED_INFORMATION <NEW_LINE> <... | Determines when has this process finished running.
If the process is still alive, the current time is returned instead.
@rtype: win32.SYSTEMTIME
@return: Process exit time. | 625941f7bde94217f3683460 |
def test_GIT_BRANCH(self): <NEW_LINE> <INDENT> self.assertEqual(self._module.br_name, Syntax.GIT_BRANCH()) | test Syntax.GIT_BRANCH | 625941f7e1aae11d1e74a333 |
def yourcmd(somearg, x=None, verbose : bool = False, *args, foo=None, **kwargs): <NEW_LINE> <INDENT> return (somearg, x, verbose, args, foo, kwargs) | Your own command.
:param somearg: It's some string argument that this function will return | 625941f7498bea3a759ba122 |
def render(self): <NEW_LINE> <INDENT> self._camera_.update() <NEW_LINE> self._scenario_.render(*self._camera_.position) <NEW_LINE> for game_object in self._game_objects_.values(): <NEW_LINE> <INDENT> game_object.render(*self._camera_.position) <NEW_LINE> <DEDENT> for decoration in list(self._decorations_.values()): <NE... | Draw a frame | 625941f77b25080760e39aca |
@app.route('/add_device', methods=['POST', 'GET']) <NEW_LINE> def add_device(): <NEW_LINE> <INDENT> if not session.get('logged_in'): <NEW_LINE> <INDENT> return redirect(url_for('login')) <NEW_LINE> <DEDENT> if request.method == 'POST': <NEW_LINE> <INDENT> db = get_db() <NEW_LINE> db.execute('insert into devices (asset_... | Add a single device | 625941f7851cf427c661ab7e |
def results(self): <NEW_LINE> <INDENT> return self.queryset.paginate(self.page, self.page_size()) | Paginate queryset and return results | 625941f7eab8aa0e5d26e1d0 |
def test_ingredients(capsys): <NEW_LINE> <INDENT> assert ingredients.ingredients(10) == None <NEW_LINE> captured = capsys.readouterr() <NEW_LINE> assert "1.0 cups arepa flour" in captured.out <NEW_LINE> assert "1.0 cups cheese" in captured.out <NEW_LINE> assert "0.25 cups water" in captured.out | We use the capsys argument to capture printing to stdout. | 625941f75fc7496912cc3ff3 |
def n_to_rots(sampling_n): <NEW_LINE> <INDENT> return 10*(sampling_n+5*sampling_n**3) | The number of rotations when the sampling parameter n is used | 625941f7d99f1b3c44c67bf7 |
def test_successful_pause(self): <NEW_LINE> <INDENT> task = ScanTask.objects.create( source=self.source, scan_type=ScanTask.SCAN_TYPE_CONNECT, status=ScanTask.PENDING) <NEW_LINE> task.pause() <NEW_LINE> task.save() <NEW_LINE> self.assertEqual(messages.ST_STATUS_MSG_PAUSED, task.status_message) <NEW_LINE> self.assertEqu... | Create a scan task and pause it. | 625941f723e79379d52eebd0 |
def _div_(self, other): <NEW_LINE> <INDENT> from sage.tensor.modules.format_utilities import format_mul_txt, format_mul_latex <NEW_LINE> if other._is_zero: <NEW_LINE> <INDENT> raise ZeroDivisionError("division of a scalar field by zero") <NEW_LINE> <DEDENT> if sel... | Scalar field division.
INPUT:
- ``other`` -- a scalar field (in the same algebra as self)
OUPUT:
- the scalar field resulting from the division of ``self`` by
``other``
TESTS::
sage: M = Manifold(2, 'M', structure='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
... | 625941f74c3428357757c999 |
def generate_node_mappings(self, roles): <NEW_LINE> <INDENT> with open(self.node_mappings_file_path, "w") as outfile: <NEW_LINE> <INDENT> for i in range(0, len(roles)): <NEW_LINE> <INDENT> mininet_host_name = roles[i][0] <NEW_LINE> port_mapping = roles[i][1] <NEW_LINE> for mapping in port_mapping: <NEW_LINE> <INDENT> e... | Generate a dictionary which maps application_id to a hostname, ip and port. Stores this in /tmp
:param roles: list of tuples (host_name, [application_id, listen_port])
:return: None | 625941f76fece00bbac2ddbc |
def jwt_auth(): <NEW_LINE> <INDENT> def wrapper(fn): <NEW_LINE> <INDENT> @wraps(fn) <NEW_LINE> def decorator(*args, **kwargs): <NEW_LINE> <INDENT> return fn(*args, **kwargs) <NEW_LINE> <DEDENT> return decorator <NEW_LINE> <DEDENT> return wrapper | View decorator that requires a valid JWT token to be present in the request | 625941f74527f215b584cac6 |
def dimension(self): <NEW_LINE> <INDENT> return self._dim | Return the dimension of the manifold.
EXAMPLE::
sage: M = Manifold(2, 'M')
sage: M.dimension()
2
A shortcut is ``dim()``::
sage: M.dim()
2
The Sage global function ``dim`` can also be used::
sage: dim(M)
2 | 625941f7d53ae8145f87a8d7 |
def setLegendVisible(self, visible: bool) -> None: <NEW_LINE> <INDENT> self.__legendVisible = visible <NEW_LINE> legends = [ self.heatmap_colormap_legend, self.bottom_legend_container ] <NEW_LINE> apply_all(filter(None, legends), lambda item: item.setVisible(visible)) | Set colormap legend visible state. | 625941f78c3a873295158a39 |
def year_list(self): <NEW_LINE> <INDENT> return list(self.data_frame[self.year_var_name].unique()) | A function that returns a list of the years present in the dataframe
Returns: list
A list of years | 625941f73d592f4c4ed1d6d0 |
def update(self, state, action, nextState, reward): <NEW_LINE> <INDENT> sample = reward + self.discount * self.computeValueFromQValues(nextState) <NEW_LINE> qv = self.getQValue(state, action) <NEW_LINE> qv = (1 - self.alpha) * qv + self.alpha * sample <NEW_LINE> state_action_pair = str(state) + " " + str(action) <NEW_L... | The parent class calls this to observe a
state = action => nextState and reward transition.
You should do your Q-Value update here
NOTE: You should never call this function,
it will be called on your behalf | 625941f763f4b57ef000177b |
def get_section_display_name(course_id): <NEW_LINE> <INDENT> course = modulestore().get_course(course_id, depth=4) <NEW_LINE> section_display_name = [""] * len(course.get_children()) <NEW_LINE> i = 0 <NEW_LINE> for section in course.get_children(): <NEW_LINE> <INDENT> section_display_name[i] = own_metadata(section).get... | Returns an array of the display names for each section in the course.
`course_id` the course ID for the course interested in
The ith string in the array is the display name of the ith section in the course. | 625941f7d7e4931a7ee9e595 |
def hash_object_to_id(s, only_last=0): <NEW_LINE> <INDENT> supported_types = (str, int, dict, float, list, set, bool) <NEW_LINE> stringable_types = (str, int, float, bool, list) <NEW_LINE> try: <NEW_LINE> <INDENT> assert type(s) in supported_types <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT>... | Given an object s, first the function transforms it to a string and then it
hashes it. Unordered types like sets and dictionaries are first sorted. | 625941f750812a4eaa59c990 |
def get_area(z): <NEW_LINE> <INDENT> if z < -3.4 or z > 3.4: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> if z < 0: <NEW_LINE> <INDENT> z = (-1 * z) <NEW_LINE> area = 1-z_table[int(z*100)] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> area = z_table[int(z*100)] <NEW_LINE> <DEDENT> return ar... | Parameter: the z-score whose proportion is needed to be calculated (valid upto 2 decimal places).
Returns: area under normal curve for x <= z. | 625941f767a9b606de4a852b |
def __new__(self, source, geo=None): <NEW_LINE> <INDENT> fissionSource.__init__(self) <NEW_LINE> pdf = source <NEW_LINE> if isinstance(source, fissionBank.fissionBank): <NEW_LINE> <INDENT> pdf = scipy.zeros(self.geo.bins) <NEW_LINE> <DEDENT> self.geo = copy.deepcopy(geo) <NEW_LINE> return pdf.view(self) | source: A source, either a fissionBank object or a scipy.ndarray object
geo: Geometry object optional if source is already a fissionSource
object | 625941f73317a56b8693a2bd |
def test_board_does_not_let_a_move_into_occupied_space(self): <NEW_LINE> <INDENT> game = TicTac() <NEW_LINE> game.player_one.make_move(1, 1) <NEW_LINE> with pytest.raises(InvalidMoveError): <NEW_LINE> <INDENT> game.player_two.make_move(1, 1) | If a player tries to make a move into a space already occupied by
another player, a error will be raised. | 625941f7a05bb46b383ece90 |
def logout(client): <NEW_LINE> <INDENT> if isinstance(client, Client): <NEW_LINE> <INDENT> if client.conn: <NEW_LINE> <INDENT> client.conn.close() | Close the connection to the server | 625941f73d592f4c4ed1d6d1 |
def query(self, url, method="GET", params=dict(), headers=dict()): <NEW_LINE> <INDENT> access_token = self._get_at_from_session() <NEW_LINE> oauth = OAuth1( self.consumer_key, client_secret=self.secret_key, resource_owner_key=access_token['oauth_token'], resource_owner_secret=access_token['oauth_token_secret'], signatu... | Request a API endpoint at ``url`` with ``params`` being either the
POST or GET data. | 625941f7adb09d7d5db6ce01 |
def clear_app_cache(self): <NEW_LINE> <INDENT> self.old_app_models, cache.app_models = cache.app_models, {} | Clears the contents of AppCache to a blank state, so new models
from the ORM can be added. | 625941f7287bf620b61d40d5 |
def searchMatrix(self, matrix, target): <NEW_LINE> <INDENT> if len(matrix) == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> row, col = 0, len(matrix[0]) - 1 <NEW_LINE> while(row <= len(matrix) - 1 and col >= 0): <NEW_LINE> <INDENT> if matrix[row][col] == target: <NEW_LINE> <INDENT> return True <NEW_LINE> <DED... | :type matrix: List[List[int]]
:type target: int
:rtype: bool | 625941f7b57a9660fec33f04 |
def spec_to_nice_name(ns, nodespec, suffix=''): <NEW_LINE> <INDENT> name_suffix = str(nodespec.function.__name__) <NEW_LINE> if suffix: <NEW_LINE> <INDENT> name_suffix += '_' + suffix <NEW_LINE> <DEDENT> name = get_nice_name(ns, nodespec.nsspec[:-1], name_suffix) <NEW_LINE> return name | Get a nice name from a ResourceExecutor node spec | 625941f74e4d5625662d4a43 |
def get_ehrenfest(self): <NEW_LINE> <INDENT> if self.is_ehrenfest: <NEW_LINE> <INDENT> np.abs(self.wavefunction, out=self.density) <NEW_LINE> self.density *= self.density <NEW_LINE> self.density /= self.density.sum() <NEW_LINE> self.x1_average.append(self.get_x1_average(self.density)) <NEW_LINE> self.x2_average.append(... | Calculate observables entering the Ehrenfest theorems at time (t) | 625941f7796e427e537b0c41 |
def test_compose_message(): <NEW_LINE> <INDENT> message = b'message' <NEW_LINE> topic = b'test topic' <NEW_LINE> for serializer in AgentAddressSerializer.SERIALIZER_SIMPLE: <NEW_LINE> <INDENT> serializer = AgentAddressSerializer(serializer) <NEW_LINE> assert compose_message(message, topic, serializer) == top... | Test correct message composing. | 625941f77d43ff24873a331b |
def getDeviceRecords(session, timeKey): <NEW_LINE> <INDENT> url = 'http://192.168.1.1/cgi?1&5' <NEW_LINE> session.headers.update({'Referer': 'http://192.168.1.1/mainFrame.htm'}) <NEW_LINE> data ='[STAT_CFG#0,0,0,0,0,0#0,0,0,0,0,0]0,0\r\n[STAT_ENTRY#0,0,0,0,0,0#0,0,0,0,0,0]1,0\r\n' <NEW_LINE> try: <NEW_LINE> <INDENT> r ... | Poll the router for the current device statistics
These records need to be compared to a previous set to calculate the
Delta | 625941f716aa5153ce362aef |
def _get_caller_details(self, last_to_last_frame): <NEW_LINE> <INDENT> return { 'name': last_to_last_frame.f_code.co_name, 'filename': last_to_last_frame.f_code.co_filename, 'line_no': last_to_last_frame.f_lineno } | Get the name of the file that called the logger. | 625941f77d43ff24873a331c |
def test_clean3(self): <NEW_LINE> <INDENT> tree = html.fromstring(HTML3) <NEW_LINE> clean(tree) <NEW_LINE> self.assertEqual(CLEAN3, tostring(tree, method='html').decode()) | Test apply the default clean to HTML document. | 625941f7f9cc0f698b140c6b |
def __init__(self, recievers, payload): <NEW_LINE> <INDENT> self.recievers = recievers <NEW_LINE> self.payload = payload | Arguments:
if recievers is an integer, it is expected to be ALL or OTHERS
if it is a string, it's considered a name of a client
if it is another iterable, it should be a list of strings which are
considered to be client names
payload should be one of the Request classes. | 625941f74e696a04525c9ac4 |
def ReadControlMode(self, msgstr): <NEW_LINE> <INDENT> control = ds.control_mode <NEW_LINE> self.request.send(bytes(str(control), 'utf-8')) <NEW_LINE> pass | :param msgstr:
:return: | 625941f73eb6a72ae02ecb66 |
def __init__(self, api_key, max_results=50): <NEW_LINE> <INDENT> self.api = youtube_api.YoutubeAPI(api_key) <NEW_LINE> self.MAX_RESULTS = max_results | Initializes with YouTube v3 API key and max_results (0-50) as of December 2016
:param api_key: YouTube v3 ApiKey
:param max_results: YouTube max_results | 625941f7d18da76e23532b55 |
def _annotate_person_name(api_client, text_annotation_request: dict) -> dict: <NEW_LINE> <INDENT> api_instance = text_person_name_annotation_api.TextPersonNameAnnotationApi(api_client) <NEW_LINE> annotations = api_instance.create_text_person_name_annotations( text_person_name_annotation_request=text_annotation_request ... | Annotate notes with date
Args:
host: Data node host IP
text_annotation_request: Text person name annotation request
Yields:
Annotated notes
Examples:
>>> example_request = {
>>> "note": {
>>> "identifier": "note-1",
>>> "type": "loinc:LP29684-5",
>>> "patient_i... | 625941f7f7d966606f6aa682 |
def get_all_item_containers(self, page_content): <NEW_LINE> <INDENT> regex_results = re.findall(full_page_regex_pattern, page_content, re.I) <NEW_LINE> if len(regex_results) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return regex_results | Function checks for item_containers in html code.
:param page_content: full html page from poe.trade
:return: item_containers in list on None if none found | 625941f73539df3088e2e9c1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.