code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_ellp(): <NEW_LINE> <INDENT> f = Fuselage() <NEW_LINE> fs = FlightState() <NEW_LINE> faero = f.flight_model(f, fs) <NEW_LINE> f.substitutions[f.Vol] = 1.33 <NEW_LINE> m = Model(f.W*faero.Cd, [f, fs, faero]) <NEW_LINE> m.solve() | elliptical fuselage test | 625941be4f6381625f11495a |
def font_color(self): <NEW_LINE> <INDENT> return self.get_color(self.font.colour_index) | Get cell foreground-color as 3-tuple. | 625941be24f1403a92600a85 |
def get_user_name(): <NEW_LINE> <INDENT> return name | Returns current user name | 625941be57b8e32f524833b6 |
def getPlayListInfo(playListItem, myRow, playListType, level=None): <NEW_LINE> <INDENT> if not level: <NEW_LINE> <INDENT> level = Prefs['PlayList_Level'] <NEW_LINE> <DEDENT> if playListType == 'video': <NEW_LINE> <INDENT> myRow = getPlayListSimpleVideo(playListItem, myRow) <NEW_LINE> if level in [ 'Basic', "Extended", ... | This function will export and return the info for the Playlist | 625941be7c178a314d6ef378 |
def shift_vert(image): <NEW_LINE> <INDENT> i = numpy.roll(numpy.identity(len(image)), 100, axis=0) <NEW_LINE> shifted = numpy.dot(i, image) <NEW_LINE> return shifted | Shift an image horizontally
1) Create rolled identity matrix:
| 0 0 1 |
| 1 0 0 |
| 0 1 0 |
2) Dot with image | 625941be0fa83653e4656ed9 |
def get_cache(self, cache_type, cache_name): <NEW_LINE> <INDENT> return self.worker_store.cache_api.get_cache(cache_type, cache_name) | Returns a cache object of given type and name.
| 625941bee8904600ed9f1e46 |
def setupShipDesign(self, compDict, weapDict, name): <NEW_LINE> <INDENT> self.clearMyText() <NEW_LINE> self.componentdata = self.mode.game.componentdata <NEW_LINE> self.weapondata = self.mode.game.weapondata <NEW_LINE> self.myShipDesign = self.mode.game.getDroneDesign('1', self.id, compDict, weapDict, name) <NEW_LINE> ... | Setup the Ship design based on compDict and weapDict | 625941bebe7bc26dc91cd522 |
def make_auth_req(self, entity_id, nameid_format=None, relay_state="relay_state", request_binding=BINDING_HTTP_REDIRECT, response_binding=BINDING_HTTP_REDIRECT, subject=None): <NEW_LINE> <INDENT> _binding, destination = self.pick_binding( 'single_sign_on_service', [request_binding], 'idpsso', entity_id=entity_id) <NEW_... | :type entity_id: str
:rtype: str
:param entity_id: SAML entity id
:return: Authentication URL. | 625941befbf16365ca6f60db |
def reset_stats(self): <NEW_LINE> <INDENT> self.ships_left = self.settings.ship_limit <NEW_LINE> self.score = 0 <NEW_LINE> self.level = 1 | Initialize statistics that will change during the game | 625941be7d847024c06be1d6 |
def test_messages_invitation(self): <NEW_LINE> <INDENT> self.members_tab.log_in(self.team_owner.username, 'password') <NEW_LINE> self.messages_tab.open_messages_tab(self.team.slug) <NEW_LINE> self.members_tab.open_members_page(self.team.slug) <NEW_LINE> self.members_tab.invite_user_via_form( username = self.non_member.... | Invited user see the custom message. | 625941be67a9b606de4a7dd8 |
def cmpname(name1, name2): <NEW_LINE> <INDENT> if name1 is None and name2 is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if name1 is None: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> if name2 is None: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> lower_name1 = name1.lower() <NEW_LINE> lower_name2 = ... | Compare two CIM names. The comparison is done
case-insensitively, and one or both of the names may be `None`. | 625941be7cff6e4e811178a2 |
def __get_zs_integration_limits(zs): <NEW_LINE> <INDENT> ranges = [] <NEW_LINE> for zsi in zs: <NEW_LINE> <INDENT> pdftype = get_standard_soft_pdf_type(zsi[0]) <NEW_LINE> if pdftype in [1, 2]: <NEW_LINE> <INDENT> nl = zsi[1] <NEW_LINE> limi = zsi[2] <NEW_LINE> ranges.append((limi[0], limi[nl[0]-1])) <NEW_LINE> <DEDENT... | get soft data integration limit | 625941be23849d37ff7b2fad |
def predict(self, Xs : np.ndarray): <NEW_LINE> <INDENT> raise NotImplementedError | The predictive probabilities
:param Xs: numpy array, of shape N, Dx
:return: p, of shape (N, K) | 625941bed99f1b3c44c674b2 |
def record(self, identity, action, props=None): <NEW_LINE> <INDENT> props = props or {} <NEW_LINE> if isinstance(action, dict): <NEW_LINE> <INDENT> self.set(action) <NEW_LINE> <DEDENT> props.update({'_n': action}) <NEW_LINE> return self.request('e', props, identity=identity) | Record `action` with the KISSmetrics API.
:param str identity: User identity
:param str action: Action to record
:param dict props: Additional information to include | 625941becb5e8a47e48b79ca |
@login_required <NEW_LINE> def all_galleries(request, page): <NEW_LINE> <INDENT> user_galleries = {'queryset': Gallery.objects.filter(is_public=True, author=request.user), 'page': page, 'allow_empty': True, 'paginate_by': 2, 'extra_context':{'sample_size':SAMPLE_SIZE} } <NEW_LINE> return object_list(request, **user_... | Displays current user's galleries paginated.
Extended to support users. | 625941bee8904600ed9f1e47 |
def create_correspondence( self): <NEW_LINE> <INDENT> conll_words = [] <NEW_LINE> onto_words = [] <NEW_LINE> for bundle in self.conll_doc.bundles: <NEW_LINE> <INDENT> for root in bundle.trees: <NEW_LINE> <INDENT> sent_ID = root.sent_id <NEW_LINE> for node in root.descendants: <NEW_LINE> <INDENT> word_ID = node.ord <NEW... | main method, called from outside
it creates two lists of words (for conll file and for onf file) and then builds a bijection based on comparing of forms | 625941be67a9b606de4a7dd9 |
def mergeTwoLists(self, l1, l2): <NEW_LINE> <INDENT> temp_l1 = [] <NEW_LINE> while l1 != None: <NEW_LINE> <INDENT> temp_l1.append(l1.val) <NEW_LINE> l1 = l1.next <NEW_LINE> <DEDENT> temp_l2 = [] <NEW_LINE> while l2 != None: <NEW_LINE> <INDENT> temp_l2.append(l2.val) <NEW_LINE> l2 = l2.next <NEW_LINE> <DEDENT> result = ... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941be2eb69b55b151c7c9 |
def add(self, rule): <NEW_LINE> <INDENT> self._rules.append(rule) | Add a rule to the chain
Parameters:
rule (Rule): a rule to add to _rules | 625941beb545ff76a8913d33 |
def print_first_word(words): <NEW_LINE> <INDENT> word = words.pop(0) <NEW_LINE> print(word) | Prints the first word after popping off | 625941be5510c4643540f308 |
def read_seqs(filepath,randomize=False): <NEW_LINE> <INDENT> seqs = [] <NEW_LINE> with open(filepath,"r") as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> seqs.append(line.strip().upper()) <NEW_LINE> <DEDENT> <DEDENT> if randomize == True: <NEW_LINE> <INDENT> np.random.shuffle(seqs) <NEW_LINE> <DEDENT> retu... | Read in sequences from a text file of newline-delimited sequences
Input: file path as string
Output: 1D array of sequences as strings, all uppercase | 625941befff4ab517eb2f357 |
def _find_instance_or_cluster(cs, instance_or_cluster): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return _find_instance(cs, instance_or_cluster), 'instance' <NEW_LINE> <DEDENT> except exceptions.CommandError: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return _find_cluster(cs, instance_or_cluster), 'cluster' <NEW_L... | Returns an instance or cluster, found by id, along with the type of
resource, instance or cluster, that was found.
Raises CommandError if none is found. | 625941bed7e4931a7ee9de3a |
def get_normalized_entrys(self, curls): <NEW_LINE> <INDENT> result = set() <NEW_LINE> for url in set(curls): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result.add(self.get_normalized_entry(url)) <NEW_LINE> <DEDENT> except NoMatchAnalyzer as e: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> return result | Return all of the urls to a new url list.
This returned url list make sure the following things:
1. all urls are be normalized
2. no duplicated
3. all urls match at least one analyzers. | 625941beec188e330fd5a6c1 |
def initGui(self): <NEW_LINE> <INDENT> icon_path = ':/plugins/cartolinegen/icon.png' <NEW_LINE> self.add_action( icon_path, text=self.tr(u'Cartographic Line Generalization'), callback=self.run, parent=self.iface.mainWindow()) | Create the menu entries and toolbar icons inside the QGIS GUI. | 625941be29b78933be1e55ce |
def data(self, index, role = None): <NEW_LINE> <INDENT> return QVariant() | QVariant KDirModel.data(QModelIndex index, int role = Qt.DisplayRole) | 625941be236d856c2ad446f3 |
def __init__(self, query_id: int, cache_time: int, alert: Optional[bool]=None, message: Optional[str]=None, url: Optional[str]=None): <NEW_LINE> <INDENT> self.query_id = query_id <NEW_LINE> self.cache_time = cache_time <NEW_LINE> self.alert = alert <NEW_LINE> self.message = message <NEW_LINE> self.url = url | :returns Bool: This type has no constructors. | 625941be379a373c97cfaa61 |
def zip_with_m_(monad_t, zip_function, left, right): <NEW_LINE> <INDENT> return sequence_(monad_t, func.zip_with(zip_function, left, right)) | Same as zip_with_m, but ignores the result. | 625941be3eb6a72ae02ec3f3 |
def check_events(settings, screen, stats, play_button, sb, survivor, zombies, bullets): <NEW_LINE> <INDENT> for event in pygame.event.get(): <NEW_LINE> <INDENT> if event.type == pygame.QUIT: <NEW_LINE> <INDENT> sys.exit() <NEW_LINE> <DEDENT> elif event.type == pygame.KEYDOWN: <NEW_LINE> <INDENT> check_keydown_events(ev... | Respond to keypresses and mouse events. | 625941be32920d7e50b280eb |
def rand_port(): <NEW_LINE> <INDENT> return random.randint(10311, 12311) | Picks a random port number.
This is potentially unsafe, but shouldn't generally be a problem. | 625941be1d351010ab855a3a |
def is_valid(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.validate() <NEW_LINE> <DEDENT> except ValidationException: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Convenience wrapper for validate() to return True or False. | 625941be3539df3088e2e268 |
def list_supported_commands(self, data): <NEW_LINE> <INDENT> self.host.reply(self.PUBLIC_API_METHODS) | Get a list of all the commands this api supports
:param data: Message data {} (no data expected) | 625941be046cf37aa974cc67 |
def DeleteEdgeNodes(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DeleteEdgeNodes", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.DeleteEdgeNodesResponse() <NE... | 批量删除边缘节点
:param request: Request instance for DeleteEdgeNodes.
:type request: :class:`tencentcloud.iecp.v20210914.models.DeleteEdgeNodesRequest`
:rtype: :class:`tencentcloud.iecp.v20210914.models.DeleteEdgeNodesResponse` | 625941be009cb60464c632d1 |
def get_engine(self): <NEW_LINE> <INDENT> return self.engine | Get the database engine
| 625941be7d43ff24873a2bbb |
def ssh_check_mic(self, mic_token, session_id, username=None): <NEW_LINE> <INDENT> self._session_id = session_id <NEW_LINE> self._username = username <NEW_LINE> if username is not None: <NEW_LINE> <INDENT> mic_field = self._ssh_build_mic( self._session_id, self._username, self._service, self._auth_method, ) <NEW_LINE> ... | Verify the MIC token for a SSH2 message.
:param str mic_token: The MIC token received from the client
:param str session_id: The SSH session ID
:param str username: The name of the user who attempts to login
:return: None if the MIC check was successful
:raises: ``sspi.error`` -- if the MIC check failed | 625941be2ae34c7f2600d04f |
def save_as_mainfile(filepath: str = "", check_existing: bool = True, filter_blender: bool = True, filter_backup: bool = False, filter_image: bool = False, filter_movie: bool = False, filter_python: bool = False, filter_font: bool = False, filter_sound: bool = False, filter_text: bool = False, filter_btx: bool = False,... | Save the current file in the desired location
:param filepath: File Path, Path to file
:type filepath: str
:param check_existing: Check Existing, Check and warn on overwriting existing files
:type check_existing: bool
:param filter_blender: Filter .blend files
:type filter_blender: bool
:param filter_backup: Filte... | 625941be167d2b6e31218ab3 |
def inverable_unique_two_lists(item1_list, item2_list): <NEW_LINE> <INDENT> import utool as ut <NEW_LINE> unique_list1, inverse1 = np.unique(item1_list, return_inverse=True) <NEW_LINE> unique_list2, inverse2 = np.unique(item2_list, return_inverse=True) <NEW_LINE> flat_stacked, cumsum = ut.invertible_flatten2((unique_li... | item1_list = aid1_list
item2_list = aid2_list | 625941be5fcc89381b1e15da |
def write_config(): <NEW_LINE> <INDENT> global config <NEW_LINE> config = read_config() <NEW_LINE> print("GDrive_Sync") <NEW_LINE> print("\nPlease look below at the options which you wish to update: ") <NEW_LINE> print("(Enter the number followed by value, eg. \"1 input\")") <NEW_LINE> print("1. Add Upload Folder [full... | displays console for editing and manages input | 625941be97e22403b379ceb6 |
def parse_lattice_vectors(file_path): <NEW_LINE> <INDENT> file_name = 'input.xml' <NEW_LINE> treeinput = ET.parse(file_path) <NEW_LINE> if file_path.split('/')[-1] != file_name: <NEW_LINE> <INDENT> file_path = os.path.join(file_path, fileName) <NEW_LINE> <DEDENT> treeinput = ET.parse(file_path) <NEW_LINE> root_input = ... | Parse the lattice coordinate from the input.xml. Units are in bohr.
:param file_path: relative path to the input.xml
:return lattvec: matrix that holds the lattice vectors. | 625941be3346ee7daa2b2c87 |
def _on_connection_close(self, connection, reply_code, reply_text): <NEW_LINE> <INDENT> self._channel = None <NEW_LINE> if reply_code == 200: <NEW_LINE> <INDENT> _log.info('Server connection closed (%s), shutting down', reply_text) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> _log.warning('Connection to %s closed unex... | Callback invoked when a previously-opened connection is closed.
Args:
connection (pika.connection.SelectConnection): The connection that
was just closed.
reply_code (int): The AMQP code indicating why the connection was closed.
reply_text (str): The human-readable reason the connection was closed. | 625941be30dc7b7665901886 |
def test_node_printing(self): <NEW_LINE> <INDENT> tree = ParentedTree.fromstring("(S (n x) (N x))") <NEW_LINE> self.assertEqual( list(tgrep.tgrep_positions("N", [tree])), list(tgrep.tgrep_positions("'N", [tree])), ) <NEW_LINE> self.assertEqual( list(tgrep.tgrep_positions("/[Nn]/", [tree])), list(tgrep.tgrep_positions("... | Test that the tgrep print operator ' is properly ignored. | 625941beaad79263cf39095a |
def test_fetchSpecific(self): <NEW_LINE> <INDENT> d = self.client.fetchSpecific('7') <NEW_LINE> self.assertEqual( self.transport.value(), b'0001 FETCH 7 BODY[]\r\n') <NEW_LINE> self.client.lineReceived(b'* 7 FETCH (BODY[] "Some body")') <NEW_LINE> self.client.lineReceived(b'0001 OK FETCH completed') <NEW_LINE> self.ass... | L{IMAP4Client.fetchSpecific} sends the I{BODY[]} command if no
parameters beyond the message set to retrieve are given. It returns a
L{Deferred} which fires with a C{dict} mapping message sequence numbers
to C{list}s of corresponding message data given by the server's
response. | 625941be92d797404e3040a7 |
def __init__(self, filename): <NEW_LINE> <INDENT> self.filename = filename | Unlink all datasets associated with filename. | 625941bebaa26c4b54cb1040 |
def test_with_org_and_course_key(self): <NEW_LINE> <INDENT> self._enroll_users(self.course, self.users, 'audit') <NEW_LINE> CourseModeFactory(course_id=self.course.id, mode_slug='no-id-professional') <NEW_LINE> with self.assertRaises(CommandError): <NEW_LINE> <INDENT> call_command( 'bulk_change_enrollment', org=self.or... | Verify that command raises CommandError when `org` and `course_key` both are given. | 625941be9c8ee82313fbb692 |
def read_data(filename): <NEW_LINE> <INDENT> with open('tmp/text8') as f: <NEW_LINE> <INDENT> data = f.readlines() <NEW_LINE> data = data[0].split() <NEW_LINE> <DEDENT> return data | Extract the first file enclosed in a zip file as a list of words. | 625941bedd821e528d63b0c8 |
def get_changed_files(repo: Repo) -> List[str]: <NEW_LINE> <INDENT> untracked_files = repo.untracked_files <NEW_LINE> dirty_files = [item.a_path for item in repo.index.diff(None)] <NEW_LINE> return [*untracked_files, *dirty_files] | Get untracked / dirty files in the given git repo.
:param repo: Git repo to check.
:return: A list of filenames. | 625941be0fa83653e4656eda |
def create_universe(self, name, universe_id): <NEW_LINE> <INDENT> new_universe = { "name": name, "staff": {}, "committees": committee_list } <NEW_LINE> self.universes[universe_id] = new_universe | Ideally universe_id is the channel_id for the public main branch of the committee
and committee_list is the channel_id for the private channels of the branch | 625941beab23a570cc25009e |
def respondent_get(self, research_id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.respondent_get_with_http_info(research_id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.respondent_get_with_http_inf... | Find all Respondents of a Research
<p><strong>Permissions:</strong> ✓ Respondent ✗ Customer ✓ Manager</p>
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>... | 625941bed4950a0f3b08c26f |
def main(step=5, max_comparision=-1): <NEW_LINE> <INDENT> start_time = time.time() <NEW_LINE> data = [] <NEW_LINE> title = ('文件名', '协定名', '国家1', '国家2','签署时间','生效时间', '条款','条款数目') <NEW_LINE> data.append(title) <NEW_LINE> for filename in reader.read_path('E:/2018/2018-3-12-论文-BITs/B&R_Country_info/BITs_html', max_compari... | 使用jaccard算法,计算出xml文件夹下的文本之间的相似度。
:param step: 分词系数
:param max_comparision: 最大需要比较的文件数,默认是所有文件 | 625941be63f4b57ef000103d |
def most_recent(): <NEW_LINE> <INDENT> return VideoCollection.from_feed(yt_service.GetMostRecentVideoFeed()) | :rtype: VideoCollection | 625941bea05bb46b383ec742 |
def zapsat_statistiky(cursor): <NEW_LINE> <INDENT> cursor.execute("select cislo_smlouvy, down, up from elpr") <NEW_LINE> rows = cursor.fetchall() <NEW_LINE> for smlouva,down,up in rows: <NEW_LINE> <INDENT> print("DEBUG smlouva %d: d:%d u:%d" % (smlouva,down,up)) <NEW_LINE> if (not os.path.exists("/raid/elpr/rrd_real/id... | Zaznamenat statistiky do rrd.
@param cursor: databazovy kurzor | 625941be7d43ff24873a2bbc |
def load_expression_tree(self): <NEW_LINE> <INDENT> fp = filedialog.askopenfilename(initialdir = self.last_used_dir, initialfile = 'randomart1.json', defaultextension = 'json', title = "select file", filetypes = (("json","*.json"),("all files","*.*"))) <NEW_LINE> self.last_used_dir = os.path.dirname(fp) <NEW_LINE> try:... | loads the expressions that define a picture from file, and render corresponding picture
:return: | 625941be76e4537e8c35158e |
def delete(self, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> del self.replacement_map[key] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> self._write_replacement_map() <NEW_LINE> return True | remove item from dict | 625941bed6c5a10208143f66 |
def update(self): <NEW_LINE> <INDENT> direction_radians = math.radians(self.direction) <NEW_LINE> self.x += self.speed * math.sin(direction_radians) <NEW_LINE> self.y -= self.speed * math.cos(direction_radians) <NEW_LINE> self.image.pos = (self.x, self.y) <NEW_LINE> if self.y >= screen_size[1]/2.0: <NEW_LINE> <INDENT> ... | Update the position of the ball. | 625941bead47b63b2c509e9e |
def remove_unused_funcs(self): <NEW_LINE> <INDENT> ir = self.IR <NEW_LINE> inFunction = False <NEW_LINE> to_remove = [] <NEW_LINE> for idx, irLine in enumerate(ir): <NEW_LINE> <INDENT> ir_firstNode = irLine.treeList[0] <NEW_LINE> if inFunction == True: <NEW_LINE> <INDENT> if isinstance(ir_firstNode, irl.IRFunctionDecl)... | Removes function that are not reference in the symbol table. They can be removed if not used. | 625941be26238365f5f0ed89 |
def open(self): <NEW_LINE> <INDENT> file_name = os.path.join(self.current_dir, "out.txt") <NEW_LINE> with recipy.open('out.txt', 'w') as f: <NEW_LINE> <INDENT> f.write("This is a test") <NEW_LINE> <DEDENT> os.remove(file_name) | Use recipy.open to save a file out.txt. | 625941bea219f33f3462888b |
def MEDCouplingPointSet_Rotate3DAlg(*args): <NEW_LINE> <INDENT> return _MEDCoupling.MEDCouplingPointSet_Rotate3DAlg(*args) | Rotate3DAlg(PyObject center, PyObject vect, double angle, int nbNodes,
PyObject coords)
MEDCouplingPointSet_Rotate3DAlg(PyObject center, PyObject vect, double angle, PyObject coords)
1 | 625941bea8ecb033257d2fec |
def debounce(interval_s, keyed_by=None): <NEW_LINE> <INDENT> def wrapper(func): <NEW_LINE> <INDENT> timers = {} <NEW_LINE> lock = threading.Lock() <NEW_LINE> @functools.wraps(func) <NEW_LINE> def debounced(*args, **kwargs): <NEW_LINE> <INDENT> sig = inspect.signature(func) <NEW_LINE> call_args = sig.bind(*args, **kwarg... | Debounce calls to this function until interval_s seconds have passed. | 625941be6aa9bd52df036cc1 |
def coinChange(self, coins, amount): <NEW_LINE> <INDENT> dp=[0]+ [-1]* amount <NEW_LINE> for i in range(amount): <NEW_LINE> <INDENT> if dp[i]< 0: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> for c in coins: <NEW_LINE> <INDENT> if i+c > amount: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if dp[i+c]<0 or dp[i+c]... | :type coins: List[int]
:type amount: int
:rtype: int | 625941be4428ac0f6e5ba70f |
def testOBMolSeparatePreservesAromaticity(self): <NEW_LINE> <INDENT> smi = "C.c1ccccc1" <NEW_LINE> for N in range(2): <NEW_LINE> <INDENT> obmol = pybel.readstring("smi", smi).OBMol <NEW_LINE> if N == 0: <NEW_LINE> <INDENT> obmol.SetAromaticPerceived(False) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.assertTrue(o... | If the original molecule had aromaticity perceived,
then the fragments should also. | 625941be4527f215b584c378 |
def get_best(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return list(self.best_df["Name"])[0] <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> self.compare() <NEW_LINE> return list(self.best_df["Name"])[0] | Function that return the name of the best model.
Best here is define be the maximum value of the
feature "Score*Preci"
:rtype: str | 625941beac7a0e7691ed3ff3 |
def active(self, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if kwargs['user']: <NEW_LINE> <INDENT> user = kwargs['user'] <NEW_LINE> return super(ListManager, self).filter(archived=False, user=user) <NEW_LINE> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> return super(ListManager, self).filter(archived=Fals... | filter archived objs or archived and specific user Lists
:param args:
:param kwargs:
:return: Queryset of lists filtered by archived element or archived and user | 625941be3cc13d1c6d3c7299 |
def bwLim(self, tsampRate, strict = False, uniq = "abcd"): <NEW_LINE> <INDENT> if self.__sampRate < tsampRate: <NEW_LINE> <INDENT> raise ValueError("The target sampling rate must be less than current sampling rate") <NEW_LINE> <DEDENT> if strict: <NEW_LINE> <INDENT> self.__sig = signal.resample(self.signal, int(tsampRa... | Limit the bandwidth by downsampling
Args:
tsampRate (:obj:`int`): target sample rate
strict (:obj:`bool`, optional): if true, the target sample rate will be matched exactly
uniq (:obj:`str`, optional): in case chunked signal, uniq is to differentiate different bwLim funcs
Returns:
:obj:`commSignal`: U... | 625941be5fc7496912cc389c |
def restrict_by_tables(self, tables, fill=False): <NEW_LINE> <INDENT> nodes = [n for n in self.nodes() if self.node[n].get('label') in tables] <NEW_LINE> if fill: <NEW_LINE> <INDENT> nodes = self.fill_connection_nodes(nodes) <NEW_LINE> <DEDENT> return self.subgraph(nodes) | Creates a subgraph containing only specified tables.
:param tables: list of tables to keep in the subgraph
:param fill: set True to automatically include nodes connecting two nodes in the specified list
of tables
:return: a subgraph with specified nodes | 625941be66656f66f7cbc0c8 |
def versions(self): <NEW_LINE> <INDENT> out, err, status = self._run_prcs(["info", "-f", self._name]) <NEW_LINE> if status != 0: <NEW_LINE> <INDENT> raise PrcsCommandError(err.decode()) <NEW_LINE> <DEDENT> versions = {} <NEW_LINE> for line in out.splitlines(): <NEW_LINE> <INDENT> match = _INFO_RECORD_PATTERN.match(line... | Return a dictionary of the summary records for all the versions. | 625941be56ac1b37e62640f2 |
def boolean_graph(): <NEW_LINE> <INDENT> node1 = node(0,'',[],[1, 3]) <NEW_LINE> node2 = node(1,'&',[0,2],[]) <NEW_LINE> node3 = node(2,'',[],[1, 3]) <NEW_LINE> node4 = node(3,'|',[0,2],[4]) <NEW_LINE> node5 = node(4,'~',[3],[]) <NEW_LINE> nodelist = [node1,node2,node3,node4,node5] <NEW_LINE> g = open_digraph([0,2], [1... | create and return a logical well formed graph possibly boolean
with :
2 inputs
2 outputs
max_indegree = 2
max_outdegree = 2
min_indegree = 1
min_outdegree = 1 | 625941bea4f1c619b28aff5d |
def exec_(self): <NEW_LINE> <INDENT> return self._view.exec_() | Run the dialog.
| 625941be5e10d32532c5ee45 |
def fast_all_primes_less_than(n): <NEW_LINE> <INDENT> sieve = [True] * (n // 2) <NEW_LINE> for i in range(3, int(n ** 0.5) + 1, 2): <NEW_LINE> <INDENT> if sieve[i // 2]: <NEW_LINE> <INDENT> sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1) <NEW_LINE> <DEDENT> <DEDENT> return [2] + [2 * i + 1 for i in ra... | Returns a list of primes < num | 625941beb7558d58953c4e37 |
def forward(self, *args): <NEW_LINE> <INDENT> images, annotations, *_ = args <NEW_LINE> images, annotations = images.to(self.device), annotations.to(self.device) <NEW_LINE> anchors, regressions, classifications = self.model(images, annotations) <NEW_LINE> del images <NEW_LINE> classification_loss, regression_loss = sel... | Forward pass through the network and loss computation.
Returns:
torch.Tensor: The loss of the batch. | 625941be2c8b7c6e89b356e0 |
def get_visibility_techniques(filename): <NEW_LINE> <INDENT> groups_dict = {} <NEW_LINE> detection_techniques, name, platform = _load_detections(filename) <NEW_LINE> group_id = 'VISIBILITY' <NEW_LINE> groups_dict[group_id] = {} <NEW_LINE> groups_dict[group_id]['group_name'] = 'Visibility' <NEW_LINE> groups_dict[group_i... | Get all techniques (in a dict) from the detections administration
:param filename: path to the YAML technique administration file
:return: dictionary | 625941be73bcbd0ca4b2bf95 |
@user_logged_in.connect <NEW_LINE> def combine_cart(sender, user): <NEW_LINE> <INDENT> merge_carts(session_key_from=session.sid, user_id_to=str(user.id)) | 合并购物车
:param sender:
:param user:
:return: | 625941be3eb6a72ae02ec3f4 |
def add(self, command_id, func): <NEW_LINE> <INDENT> func.base = getattr(func, "base", func) <NEW_LINE> func.argspec = getattr(func, "argspec", inspect.getargspec(func)) <NEW_LINE> func.doc = getattr(func.base, "__doc__", "Call function %s with parameters %s" % (func.base.__name__, func.argspec.args)) <NEW_LINE> self.r... | 対象のコマンド名に対して対象の呼び出し可能オブジェクトを登録する
:param command_id: 対象のコマンド名
:param func: 呼び出し可能オブジェクト
:return: 呼び出し可能オブジェクト自体が返却される | 625941be76e4537e8c35158f |
def __init__(self, pid_or_name, debug=False, prefer_lock=False): <NEW_LINE> <INDENT> pid = None <NEW_LINE> name = None <NEW_LINE> if isinstance(pid_or_name, int): <NEW_LINE> <INDENT> pid = pid_or_name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pid = self.pid_from_name(pid_or_name) <NEW_LINE> name = pid_or_name <NEW_... | Create and Open a process object from its pid or from its name | 625941be8e71fb1e9831d6c9 |
def addxp(self, xp=[], verbose=False): <NEW_LINE> <INDENT> self.addshot(xp=xp, verbose=verbose) | Add all shots for one or more XPx
**Usage**
>>> nstx.addxp(1032)
>>> nstx.addxp(xp=1013)
>>> nstx.addxp([1042, 1016]) | 625941bed10714528d5ffbff |
def format(self, frame): <NEW_LINE> <INDENT> return str(frame) | Return the given frame in timecode format.
frame - Frame number, which can be negative. | 625941be5166f23b2e1a5077 |
def mylinearsvm(beta_init, theta_init, lambduh, eta_init, maxiter, x= x_train, y= y_train): <NEW_LINE> <INDENT> beta = beta_init <NEW_LINE> theta = theta_init <NEW_LINE> grad_theta = grad_obj(theta, lambduh, x=x, y=y) <NEW_LINE> beta_vals = beta <NEW_LINE> theta_vals = theta <NEW_LINE> iterate = 0 <NEW_LINE> while iter... | This function implements fast gradient algorithm with backtracking rule
to tune the step size.
It calls backtrack and gradient functions. | 625941beff9c53063f47c113 |
def randomize_molecule(molecule, manipulations, nonbond_thresholds, max_tries=1000): <NEW_LINE> <INDENT> for m in xrange(max_tries): <NEW_LINE> <INDENT> random_molecule = randomize_molecule_low(molecule, manipulations) <NEW_LINE> if check_nonbond(random_molecule, nonbond_thresholds): <NEW_LINE> <INDENT> return random_m... | Return a randomized copy of the molecule.
If no randomized molecule can be generated that survives the nonbond
check after max_tries repetitions, None is returned. In case of success,
the randomized molecule is returned. The original molecule is not
altered. | 625941bed99f1b3c44c674b3 |
def _inner_loop_update(self, loss, weights, use_second_order, current_update_step): <NEW_LINE> <INDENT> self.model.zero_grad(weights) <NEW_LINE> grads = torch.autograd.grad( loss, weights, create_graph=use_second_order, allow_unused=True) <NEW_LINE> updated_weights = list() <NEW_LINE> for idx, (weight, grad) in enumera... | Applies an inner loop update
Args:
loss: Loss on support set
weights: Network weights
use_second_order: If use second order
current_update_step
Returns:
updated network weights | 625941bede87d2750b85fcae |
def search_by_text(self, query_text: str, max_id: int = None) -> List[int]: <NEW_LINE> <INDENT> id_tweets = [] <NEW_LINE> text_list_include = FilterText.objects.filter(id_status=1).values_list('text') or [] <NEW_LINE> if not text_list_include: <NEW_LINE> <INDENT> logging.error("[e] reply_for_tweet_by_id - Please check ... | Search tweets by some text
:param query_text: str
Text for search in twitter
:param max_id: int
Max ID tweet for search new tweets
:return: list[dict]
Data for work | 625941bee64d504609d7475e |
def SetObjective(self, cost, ExtraArgs=None): <NEW_LINE> <INDENT> _cost,_raw,_args = self._cost <NEW_LINE> if (cost is None or cost is _raw or cost is _cost) and (ExtraArgs is None or ExtraArgs is _args): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if cost is None: cost = _raw <NEW_LINE> args = _args if Ex... | set the cost function for the optimization
input::
- cost is the objective function, of the form y = cost(x, *ExtraArgs),
where x is a candidate solution, and ExtraArgs is the tuple of positional
arguments required to evaluate the objective.
note::
this method decorates the objective with bounds, ... | 625941be9c8ee82313fbb693 |
def FileEntryExistsByPath(self, path): <NEW_LINE> <INDENT> if self._file_entries is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return path in self._file_entries | Determines if file entry for a specific path exists.
Returns:
bool: True if the file entry exists. | 625941bee76e3b2f99f3a72f |
def shEpoTrImg(dbe, ver, con, nStn, epo, iBat=1): <NEW_LINE> <INDENT> nm = '{}_{}_{}'.format(dbe, ver, con) <NEW_LINE> tmpFold = os.path.join(os.environ['HOME'], 'save/{}/torch/tmp/{}'.format(dbe, nm)) <NEW_LINE> outFold = os.path.join(os.environ['HOME'], 'save/{}/torch/deb_stn/{}'.format(dbe, nm)) <NEW_LINE> lib.mkDir... | Show the transformation of each epoch.
Input
dbe - database
ver - version
con - configuration
nStn - #stn
epo - epoch id
iBat - batch id | 625941be498bea3a759b99ce |
def test_set_circuit_not_missing(): <NEW_LINE> <INDENT> circuit_filename = os.path.join(SHEEP_HOME,"pysheep","pysheep","tests", "testfiles","simple_add.sheep") <NEW_LINE> r=sheep_client.set_circuit(circuit_filename) <NEW_LINE> check_404_response(r) | check the set_circuit function with a real filename
but no server
- should get status_code 404 | 625941be287bf620b61d3984 |
def list_jobs(self, project_id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> return self.list_jobs_with_http_info(project_id, **kwargs) | Returns a collection of Jobs # noqa: E501
Returns a collection of Jobs # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.list_jobs(project_id, async_req=True)
>>> result = thread.get()
:param async_req bool: execut... | 625941be29b78933be1e55cf |
def getMetaDataInfo(self): <NEW_LINE> <INDENT> return {'_id':self.channelNumber,'sensorName':self.sensorName, 'sensorReadingType':self.sensorReadingType, 'plotType':self.plotType,'lastSyncTime':time.time(),'signals':1} | Gets the meta data for the sensor
:return: meta data for the sensor
:rtype: dict | 625941be85dfad0860c3ad78 |
def unpackMail(mailString): <NEW_LINE> <INDENT> return unpackMultifile(multifile.MultiFile(StringIO.StringIO(mailString))) | returns body, content-type, html-body and attachments for mail-string.
| 625941becdde0d52a9e52f4f |
def open_file(r_file): <NEW_LINE> <INDENT> with open(r_file,'r') as f: <NEW_LINE> <INDENT> raw_data = f.read().splitlines() <NEW_LINE> <DEDENT> return raw_data | Open and read file into split lines and return
Input: text file (txt/sql)
Output: each line from input file returned | 625941bea934411ee37515b2 |
def conform_mlc_to_rectangle(beam, x, y, center): <NEW_LINE> <INDENT> xy = x,y <NEW_LINE> bld = getblds(beam.BeamLimitingDeviceSequence) <NEW_LINE> mlcdir, jawdir1, jawdir2 = get_mlc_and_jaw_directions(bld) <NEW_LINE> mlcidx = (0,1) if mlcdir == "MLCX" else (1,0) <NEW_LINE> nleaves = len(bld[mlcdir].LeafPositionBoundar... | Sets MLC to open at least x * y cm | 625941bef7d966606f6a9f20 |
def get_proper_type(typ: Optional[Type]) -> Optional[ProperType]: <NEW_LINE> <INDENT> if typ is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if isinstance(typ, TypeGuardedType): <NEW_LINE> <INDENT> typ = typ.type_guard <NEW_LINE> <DEDENT> while isinstance(typ, TypeAliasType): <NEW_LINE> <INDENT> typ = typ.... | Get the expansion of a type alias type.
If the type is already a proper type, this is a no-op. Use this function
wherever a decision is made on a call like e.g. 'if isinstance(typ, UnionType): ...',
because 'typ' in this case may be an alias to union. Note: if after making the decision
on the isinstance() call you pas... | 625941be60cbc95b062c6461 |
def extract_xray_structure(self, crystal_symmetry=None, min_distance_sym_equiv=None): <NEW_LINE> <INDENT> if min_distance_sym_equiv is not None: <NEW_LINE> <INDENT> return self.as_pdb_input(crystal_symmetry).xray_structure_simple( min_distance_sym_equiv=min_distance_sym_equiv) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDE... | Generate the equivalent cctbx.xray.structure object. If the crystal
symmetry is not provided, this will be placed in a P1 box. In practice it
is usually best to keep the original xray structure object around, but this
method is helpful in corner cases. | 625941be24f1403a92600a87 |
def quantize_cluster(C,data): <NEW_LINE> <INDENT> qC = [] <NEW_LINE> for i in C: <NEW_LINE> <INDENT> mC = np.mean(data[i,:],axis=0) <NEW_LINE> pos = find_nearest(mC,i,data) <NEW_LINE> qC.append(pos) <NEW_LINE> <DEDENT> return qC | Select Centroid of Each Cluster | 625941be6e29344779a62533 |
def _update_order(self, order_info): <NEW_LINE> <INDENT> if order_info["contract_type"] != self._contract_type or order_info["symbol"] != self._symbol: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> order_no = str(order_info["order_id"]) <NEW_LINE> status = order_info["status"] <NEW_LINE> order = self._orders.get(order... | Order update.
Args:
order_info: Order information. | 625941be1f037a2d8b94611d |
def twoSum(self, numbers, target): <NEW_LINE> <INDENT> i, j = 0, len(numbers) - 1 <NEW_LINE> s = numbers[i] + numbers[j] <NEW_LINE> while s != target: <NEW_LINE> <INDENT> if s < target: <NEW_LINE> <INDENT> i += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> j -= 1 <NEW_LINE> <DEDENT> s = numbers[i] + numbers[j] <NEW_L... | :type numbers: List[int]
:type target: int
:rtype: List[int] | 625941be498bea3a759b99cf |
def test_create_pool_with_all_params(self): <NEW_LINE> <INDENT> resource = 'pool' <NEW_LINE> cmd = pool.CreatePool(test_cli20.MyApp(sys.stdout), None) <NEW_LINE> name = 'my-name' <NEW_LINE> description = 'my-desc' <NEW_LINE> lb_method = 'round-robin' <NEW_LINE> protocol = 'http' <NEW_LINE> subnet_id = 'subnet-id' <NEW_... | lb-pool-create with all params set. | 625941be4f88993c3716bf89 |
def _convert(self, batch, output_format, output_batch, **kwargs): <NEW_LINE> <INDENT> if isinstance(output_format, DenseFormat): <NEW_LINE> <INDENT> return self._convert_to_DenseFormat(batch, output_format, output_batch, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise NotImplementedError("Conversion from ... | Converts a batch to another format.
Implemented by methods '_convert_to_XXX()' for target format XXX.
See those methods' documentation for details. | 625941be67a9b606de4a7dda |
def test_add_project_info_list(self): <NEW_LINE> <INDENT> self.assertRaises(TypeError, keenio.add_project_info_list) <NEW_LINE> self.assertRaises(TypeError, keenio.add_project_info_list, None) <NEW_LINE> self.assertRaises(TypeError, keenio.add_project_info_list, ["string"]) <NEW_LINE> self.assertListEqual([], keenio.ad... | Test keenio.add_project_info_list() | 625941be1d351010ab855a3b |
def stream_object_data(self, ref): <NEW_LINE> <INDENT> cmd = self._get_persistent_cmd("cat_file_all", "cat_file", batch=True) <NEW_LINE> hexsha, typename, size = self.__get_object_header(cmd, ref) <NEW_LINE> return (hexsha, typename, size, self.CatFileContentStream(size, cmd.stdout)) | As get_object_header, but returns the data as a stream
:return: (hexsha, type_string, size_as_int, stream)
:note: This method is not threadsafe, you need one independent Command instance
per thread to be safe ! | 625941be7b25080760e39379 |
def __init__(self, filename: str, events=None): <NEW_LINE> <INDENT> self.filename = os.path.abspath(filename) <NEW_LINE> self.stat = os.stat(self.filename) <NEW_LINE> self.start_datetime, self.end_datetime = None, None <NEW_LINE> self._events = [] <NEW_LINE> self._events_by_baseclass = collections.defaultdict(list) <NE... | List of ABINIT events.
Args:
filename: Name of the file
events: List of Event objects | 625941becb5e8a47e48b79cc |
def enqueue(self, value): <NEW_LINE> <INDENT> new_node = SimpleQueueNode(value, self._tail, None) <NEW_LINE> if self.is_empty(): <NEW_LINE> <INDENT> self._head = new_node <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._tail.next_node = new_node <NEW_LINE> <DEDENT> self._tail = new_node <NEW_LINE> self.size += 1 | Add an item to the end of the queue. Creates a new SimpleQueueNode
to accomplish this.
Arguments:
value - the value of the item to be added to the end of the queue. | 625941be67a9b606de4a7ddb |
def move_down(self): <NEW_LINE> <INDENT> if (self.y + 8) <= 700: <NEW_LINE> <INDENT> self.y += 8 | 飞机向下移 | 625941be3d592f4c4ed1cf94 |
def add_model(self, inputs): <NEW_LINE> <INDENT> with tf.variable_scope('InputDropout'): <NEW_LINE> <INDENT> inputs = [tf.nn.dropout(x, self.dropout_placeholder) for x in inputs] <NEW_LINE> <DEDENT> with tf.variable_scope('rnn') as scope: <NEW_LINE> <INDENT> self.initial_state = tf.zeros([self.config.batch_size, self.c... | Creates the RNN LM model.
In the space provided below, you need to implement the equations for the
RNN LM model. Note that you may NOT use built in rnn_cell functions from
tensorflow.
Hint: Use a zeros tensor of shape (batch_size, hidden_size) as
initial state for the RNN. Add this to self as instance variable
... | 625941be4d74a7450ccd40e2 |
def pathSum(self, root, sum): <NEW_LINE> <INDENT> self.result = [] <NEW_LINE> self.getpath(root, [], 0, sum) <NEW_LINE> return self.result | :type root: TreeNode
:type sum: int
:rtype: List[List[int]] | 625941be099cdd3c635f0b7b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.