code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def show_code(self, x, file=None): <NEW_LINE> <INDENT> return _show_code(x, self.opc.version_tuple, file, is_pypy=self.is_pypy)
Print details of methods, functions, or code to *file*. If *file* is not provided, the output is printed on stdout.
625941cccb5e8a47e48b7b89
def VirtualMachineDiskDeviceInfo(vim, *args, **kwargs): <NEW_LINE> <INDENT> obj = vim.client.factory.create('{urn:vim25}VirtualMachineDiskDeviceInfo') <NEW_LINE> if (len(args) + len(kwargs)) < 1: <NEW_LINE> <INDENT> raise IndexError('Expected at least 2 arguments got: %d' % len(args)) <NEW_LINE> <DEDENT> required = [ '...
The DiskDeviceInfo class contains basic information about a specific disk hardware device.
625941cc5f7d997b87174b76
def get_package_data(): <NEW_LINE> <INDENT> filenames = [] <NEW_LINE> root_dir = os.path.join(os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))), "isig") <NEW_LINE> folders = [os.path.join(root_dir, "tests", "data")] <NEW_LINE> for folder in folders: <NEW_LINE> <INDENT> for directory, _, files i...
Returns a list of all files needed for the installation relativ to the "isig" subfolder.
625941ccde87d2750b85fe71
def test_instrument_user_where(self): <NEW_LINE> <INDENT> self.base_where_clause(SAMPLE_INSTRUMENT_USER_HASH)
Test the hash portion using base object method.
625941ccff9c53063f47c2d2
def test_encoding_with_encoding_none(self): <NEW_LINE> <INDENT> out = MockPipedStdout() <NEW_LINE> uni_print(u'SomeChars\u2713\u2714OtherChars', out) <NEW_LINE> self.assertEqual(out.getvalue(), b'SomeChars??OtherChars')
When the output of the aws command is being piped, the `encoding` attribute of `sys.stdout` is `None`.
625941cc3eb6a72ae02ec5bb
def less(self): <NEW_LINE> <INDENT> import subprocess <NEW_LINE> command = ('npm', 'bin') <NEW_LINE> process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) <NEW_LINE> output = process.communicate() <NEW_LINE> directory = output[0].strip() <NEW_LINE> if not director...
Compile less files
625941cc10dbd63aa1bd2c82
def void(self) -> bool: <NEW_LINE> <INDENT> if not self.is_authorized(): <NEW_LINE> <INDENT> raise TransactionNotAuthorizedException('Cannot capture transaction, status is not authorized') <NEW_LINE> <DEDENT> from paynlsdk.api.transaction.voidauthorization import Request <NEW_LINE> from paynlsdk.api.client import APICl...
Void authorized transaction :return: Result of the void: True is successful :rtype: bool :raise: TransactionNotAuthorizedException if not yet authorized
625941cc7cff6e4e81117a64
def _sample_measured_states_once(self) -> int: <NEW_LINE> <INDENT> states = list(self._measured_states.keys()) <NEW_LINE> weights = list(self._measured_states.values()) <NEW_LINE> return random.choices(states, weights=weights)[0]
Obtain a random state from the :attr:`_measured_states`, taking into account the probability distribution.
625941cc6aa9bd52df036e82
def getUsers(fName): <NEW_LINE> <INDENT> if (isEmpty(fName)): <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> userDict = {} <NEW_LINE> f = open(fName, "r") <NEW_LINE> n = int(f.readline()) <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> pair = f.readline().strip("\n").split(",") <NEW_LINE> userDict[pair[0]] = pair[...
returns a dictionary of all users where key is the username
625941ccbd1bec0571d9070e
def dump(self, format='dot'): <NEW_LINE> <INDENT> if format == 'dot': <NEW_LINE> <INDENT> return self._to_dot() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> NotImplementedError('Currently, only dot format is supported.')
Dumps graph as a text. Args format(str): The graph language name of the output. Currently, it must be 'dot'. Returns str: The graph in specified format.
625941cc435de62698dfdd2b
def prompt_for_driver_settings(driver, config_dict): <NEW_LINE> <INDENT> settings = dict() <NEW_LINE> try: <NEW_LINE> <INDENT> __import__(driver) <NEW_LINE> driver_module = sys.modules[driver] <NEW_LINE> loader_function = getattr(driver_module, 'confeditor_loader') <NEW_LINE> editor = loader_function() <NEW_LINE> edito...
Let the driver prompt for any required settings. If the driver does not define a method for prompting, return an empty dictionary.
625941cc7047854f462a14e8
def evaluate_metadata_statement(metadata): <NEW_LINE> <INDENT> res = dict([(k, v) for k, v in metadata.items() if k not in IgnoreKeys]) <NEW_LINE> if 'metadata_statements' in metadata: <NEW_LINE> <INDENT> cres = {} <NEW_LINE> for ms in metadata['metadata_statements']: <NEW_LINE> <INDENT> _msd = evaluate_metadata_statem...
Computes the resulting metadata statement from a compounded metadata statement. If something goes wrong during the evaluation an exception is raised :param ms: The compounded metadata statement :return: The resulting metadata statement
625941cc5510c4643540f4c3
def setUp(self) -> None: <NEW_LINE> <INDENT> user = User.objects.create(username="nerd") <NEW_LINE> self.client = APIClient() <NEW_LINE> self.client.force_authenticate(user=user) <NEW_LINE> self.url = reverse('api-post-list')
Define the test client and other test variables.
625941cc0a50d4780f666f71
def number_entries_year(self): <NEW_LINE> <INDENT> return Entry.objects.filter( lang=self.language, date__year=self.year).count()
Return the total number of entries which belongs to this year.
625941cc67a9b606de4a7f98
def cancel_order(self,order_id): <NEW_LINE> <INDENT> return self._auth_request('POST', 'orders/{order_id}/submit-cancel'.format(order_id=order_id))
cancel specfic order
625941cc66673b3332b92170
@connection <NEW_LINE> def test_create_group(app): <NEW_LINE> <INDENT> app.group.create(Group(group_name='test', group_header='test', group_footer='test')) <NEW_LINE> app.group.click_group_page() <NEW_LINE> app.group.delete_first_group()
Validation of correct create test group (All field fill up)
625941cca8ecb033257d31ac
def get_instance(self): <NEW_LINE> <INDENT> return self._instance
Return the associated Instance.
625941cc046cf37aa974ce26
def longestValidParentheses(self, s): <NEW_LINE> <INDENT> stack = [-1] <NEW_LINE> l_max = 0 <NEW_LINE> for i in range(len(s)): <NEW_LINE> <INDENT> if s[i] == '(': <NEW_LINE> <INDENT> stack.append(i) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> stack.pop() <NEW_LINE> if len(stack) == 0: <NEW_LINE> <INDENT> stack.append...
:type s: str :rtype: int
625941cca05bb46b383ec900
def phi0(self): <NEW_LINE> <INDENT> b = self.parent().to_ambient_crystal()(self) <NEW_LINE> return b.phi(0) // 2
Calculate `\varphi_0` of ``self`` by mapping the element to the ambient crystal and calculating `\varphi_0` there. EXAMPLES:: sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1) sage: b = K.module_generators[0] sage: b.phi(0) # indirect doctest 0
625941cca79ad161976cc224
def char2int(char_in): <NEW_LINE> <INDENT> output = codec_s2i.get(char_in) <NEW_LINE> if output == None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return output
Codes a single character to an integer.
625941cc15fb5d323cde0bee
def read_categories(self): <NEW_LINE> <INDENT> categories = Utils.open_json_file(self.data_path, self.categories_dataset) <NEW_LINE> for cat in categories['categories']: <NEW_LINE> <INDENT> print(str(cat['id']) + ' --> ' + cat['name']) <NEW_LINE> for subcat in cat['subcategories']: <NEW_LINE> <INDENT> print('\t' + str(...
Just print the categories.
625941ccc4546d3d9de72b13
def Network_death(self, data): <NEW_LINE> <INDENT> name, = unpack_msg(data['msg'], SrvDeathMsg) <NEW_LINE> ev = NwRcvDeathEvt(name) <NEW_LINE> self._em.post(ev)
A charactor died.
625941cc236d856c2ad448b9
def suspend(self): <NEW_LINE> <INDENT> if self.is_running() and not self.is_suspended(): <NEW_LINE> <INDENT> from coco.core.signals.signals import container_suspended <NEW_LINE> container_suspended.send(sender=self, container=self)
Suspend the container.
625941cc97e22403b379d078
def get_selected_units(self): <NEW_LINE> <INDENT> selected_units = self.obs[-1].observation.feature_screen.selected <NEW_LINE> idx = np.where(selected_units == 1) <NEW_LINE> return np.transpose(idx)
returns the indices of the selected units
625941cc66656f66f7cbc289
def balance_data(data, category): <NEW_LINE> <INDENT> g = data.groupby(category) <NEW_LINE> return g.apply(lambda x: x.sample(g.size().min()).reset_index(drop=True))
Balance data based on a category/field :param pandas data: [description] :param string category: field to balance :return: data balanced
625941cca219f33f34628a49
def _validate(self): <NEW_LINE> <INDENT> if self._mass is None: <NEW_LINE> <INDENT> self.mass() <NEW_LINE> <DEDENT> if self._str is None: <NEW_LINE> <INDENT> self.serialize()
Populate the caching fields used for common behaviors, e.g. mass and string representation.
625941cc0c0af96317bb82c7
def load_image(file_name, is_color=False): <NEW_LINE> <INDENT> assert(os.path.isfile(file_name)) <NEW_LINE> image = Array() <NEW_LINE> safe_call(backend.get().af_load_image(c_pointer(image.arr), c_char_ptr_t(file_name.encode('ascii')), is_color)) <NEW_LINE> return image
Load an image on the disk as an array. Parameters ---------- file_name: str - Full path of the file name on disk. is_color : optional: bool. default: False. - Specifies if the image is loaded as 1 channel (if False) or 3 channel image (if True). Returns ------- image - af.Array A 2 dimensional (1...
625941cceab8aa0e5d26dc37
def test_unicode_dn_(self): <NEW_LINE> <INDENT> ou = Unit(LDAP_CONN) <NEW_LINE> ou.name = u'ąźćżłóśę' <NEW_LINE> ou.save() <NEW_LINE> self.assertEqual(ou.dn, u'ou=ąźćżłóśę,%s' % BASEDN) <NEW_LINE> ou.name = u'ŁĘĆŹ' <NEW_LINE> ou.save() <NEW_LINE> self.assertEqual(ou.dn, u'ou=ŁĘĆŹ,%s' % BASEDN) <NEW_LINE> ou.set_parent(...
Test handling objects with unicode characters in dn.
625941cc5166f23b2e1a5238
def to_stderr(self, message): <NEW_LINE> <INDENT> print(message.encode(preferredencoding()), file=sys.stderr)
Print message to stderr.
625941cc94891a1f4081bb88
def onUserimage(self, e): <NEW_LINE> <INDENT> global userimagename <NEW_LINE> sender = e.getSource() <NEW_LINE> config.userimage2 = True <NEW_LINE> userimagename = IJ.getImage() <NEW_LINE> if sender.isSelected() is True: <NEW_LINE> <INDENT> getimage() <NEW_LINE> green.show() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT...
Allow user to open an image and select as current image so that it can used to optimise analysis settings. This must be a .tif composite of myelin and neurites channels. The image will be split and only the myelin channel displayed.
625941ccbe8e80087fb20d22
def _handle_no_size(self): <NEW_LINE> <INDENT> super(BTRFSFactory, self)._handle_no_size() <NEW_LINE> if self.container and self.container.exists: <NEW_LINE> <INDENT> self.size = self.container.size
Set device size so that it grows to the largest size possible.
625941cc8c0ade5d55d3ea9a
def locate_and_move_data_between_dfs(df_to_move_from, rows, df_to_accept, col_to_erase=None): <NEW_LINE> <INDENT> df_to_move = df_to_move_from.loc[rows] <NEW_LINE> df_to_move_from.drop(rows, inplace=True) <NEW_LINE> if col_to_erase is not None: <NEW_LINE> <INDENT> df_to_move[col_to_erase] = "" <NEW_LINE> <DEDENT> print...
Select rows from df_to_move_from to df_to_accept
625941cc8e7ae83300e4b0ac
def get_pandas_df_from_table(database, session, tbl_name, qualifiers=False): <NEW_LINE> <INDENT> tbl = database.get_table_mappings(tbl_name) <NEW_LINE> query = session.query(tbl) <NEW_LINE> if qualifiers: <NEW_LINE> <INDENT> return pd.read_sql(query.statement, query.session.bind)[qualifiers] <NEW_LINE> <DEDENT> else: <...
Convert the specified table into a pandas dataframe, modify it according to qualifiers, and return the result Args: database: An instantiated DBInterface class from dbinterface.py session: SQLalchemy session object tbl_name: name of the desired table qualifiers: A list of columns or a function to filte...
625941cca4f1c619b28b0119
def IsSuperType(wsdl_types, sub_type, super_type): <NEW_LINE> <INDENT> if not wsdl_types or sub_type not in wsdl_types: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> while (sub_type != super_type and 'base_type' in wsdl_types[sub_type] and wsdl_types[sub_type]['base_type']): <NEW_LINE> <INDENT> sub_type = wsdl_t...
Checks to see if one type is a supertype of another type. Any case where the sub_type cannot be traced through to super_type is considered to be an invalid supertype. For example, if the WSDL definitions dictionary is empty or if one type's entry in the definitions does not include the required field (base_type), thes...
625941cc566aa707497f4648
def start(self): <NEW_LINE> <INDENT> t = threading.Thread(target=self.run, args=()) <NEW_LINE> t.setDaemon(True) <NEW_LINE> t.start()
Runs the run() loop in a separate thread
625941cc56ac1b37e62642af
def version( self, bundle: str = None, date: dt.datetime = None, version_id: int = None ) -> models.Version: <NEW_LINE> <INDENT> if version_id: <NEW_LINE> <INDENT> LOG.info("Fetching version with id: %s", version_id) <NEW_LINE> return self.Version.get(version_id) <NEW_LINE> <DEDENT> return ( self.Version.query.join(mod...
Fetch a version from the store.
625941cc293b9510aa2c3376
def test_start_service(self): <NEW_LINE> <INDENT> self._start_service() <NEW_LINE> self.kz_client.SetPartitioner.assert_called_once_with( self.zk_partition_path, set=set(self.buckets), time_boundary=self.time_boundary) <NEW_LINE> self.assertEqual( self.scheduler_service.kz_partition, self.kz_partition) <NEW_LINE> self....
startService() calls super's startService() and creates a SetPartitioner object.
625941cce1aae11d1e749d96
def pre_start_hook(self): <NEW_LINE> <INDENT> pass
Hook to provide the manager the ability to do additional start-up work before any RPC queues/consumers are created. This is called after other initialization has succeeded and a service record is created. Child classes should override this method.
625941cc4a966d76dd5510ee
def __setLayerDialog(self): <NEW_LINE> <INDENT> otherLayers = self.__lineVertices(True) <NEW_LINE> with_mnt = True <NEW_LINE> if self.ownSettings is None or self.ownSettings.mntUrl is None or self.ownSettings.mntUrl == "": <NEW_LINE> <INDENT> with_mnt = False <NEW_LINE> <DEDENT> if not with_mnt and len(o...
To create a Profile Layers Dialog
625941cc004d5f362079a412
def _asymmetric_round_price(self, price, prefer_round_down, tick_size=0.01, diff=0.95): <NEW_LINE> <INDENT> precision = self._number_of_decimal_places(tick_size) <NEW_LINE> multiplier = int(tick_size * (10 ** precision)) <NEW_LINE> diff -= 0.5 <NEW_LINE> diff *= (10 ** -precision) <NEW_LINE> diff *= multiplier <NEW_LIN...
Asymmetric rounding function for adjusting prices to the specified number of places in a way that "improves" the price. For limit prices, this means preferring to round down on buys and preferring to round up on sells. For stop prices, it means the reverse. If prefer_round_down == True: When .05 below to .95 above ...
625941cc8a349b6b435e8252
def __init__(self,n_dims,variance=1.,lengthscale=1.,active_dims=None,name=None): <NEW_LINE> <INDENT> super(Matern32, self).__init__( n_dims=n_dims, active_dims=active_dims, name=name) <NEW_LINE> logger.debug('Initializing %s kernel.' % self.name) <NEW_LINE> self.variance = np.float64(variance) <NEW_L...
squared exponential kernel Inputs: n_dims : number of dimensions variance : kernel variance lengthscale : kernel lengthscale active_dims : all dims active by default, subset can be specified
625941cc4e4d5625662d44b7
def onMoveTopTick(event): <NEW_LINE> <INDENT> if len(Page.phaseList) == 0: <NEW_LINE> <INDENT> print("there are tick marks (no phases)") <NEW_LINE> return <NEW_LINE> <DEDENT> G2frame.itemPicked = Page.tickDict[Page.phaseList[0]] <NEW_LINE> G2frame.G2plotNB.Parent.Raise() <NEW_LINE> OnPick(None)
Respond to a menu command to move the tick locations.
625941cca05bb46b383ec901
def remove_storage_files(): <NEW_LINE> <INDENT> shutil.rmtree(os.path.join( PROJECT_DIRECTORY, "internal/storage" ))
Removes files needed for storage
625941cc4f88993c3716c146
def GetPointer(self): <NEW_LINE> <INDENT> return _itkImageSourcePython.itkImageSourceIUL3_GetPointer(self)
GetPointer(self) -> itkImageSourceIUL3
625941cc4c3428357757c407
def OutNeighbours(graph): <NEW_LINE> <INDENT> string = '<< ' <NEW_LINE> for i in range(np.size(graph, 0)): <NEW_LINE> <INDENT> s = '{' <NEW_LINE> for j in range(np.size(graph, 1)): <NEW_LINE> <INDENT> if graph[i][j] == 1: <NEW_LINE> <INDENT> if s == '{': <NEW_LINE> <INDENT> s = s + str(j + 1) <NEW_LINE> <DEDENT> else: ...
serialize the graph as a string object and return the out neighbours for the graph :param graph: this is an array indicating the graph object :return: string representation for the graph
625941cc96565a6dacc8f7ab
def solution_data_analysis(lab): <NEW_LINE> <INDENT> lab1_sol = { '2a': { 'wrong_date': ( "The date is incorrect, check again", 2 ), 'wrong_blah': ( "The blah is wrong, maybe consider doing the assignment again" "blah blah blah lololz", 1 ), }, '3a': { } } <NEW_LINE> lab2_sol = { } <NEW_LINE> lab3_sol = { } <NEW_LINE> ...
solution bank for data analysis section for all 4 labs Many layers: 1) lab number (lab1_sol), 2) question_key (2a), 3) error_key (wrong_date), 4) actual content and points off in a tuple
625941cce76e3b2f99f3a8eb
def error(self, inputs:List[List[int]], actualoutputs:List[int]) -> float: <NEW_LINE> <INDENT> if not len(inputs) == len(actualoutputs): <NEW_LINE> <INDENT> raise Exception("Either not enough testinputs or true outputs. @ Perceptron {}".format(self.ID)) <NEW_LINE> <DEDENT> output = [] <NEW_LINE> for input in inputs: <N...
Calculates the MSE of this perceptron over a training set.
625941cce5267d203edcdd7d
def is_affix(s): <NEW_LINE> <INDENT> return s in affix_dict.values()
Returns true if the input string is found among the list of affixes.
625941cc1b99ca400220ab91
def EOriginUncertaintyDescriptionNames_name(i): <NEW_LINE> <INDENT> return _DataModel.EOriginUncertaintyDescriptionNames_name(i)
EOriginUncertaintyDescriptionNames_name(int i) -> char const *
625941cc63b5f9789fde71c5
def get_default_config(self): <NEW_LINE> <INDENT> config = super(PostgresqlCollector, self).get_default_config() <NEW_LINE> config.update({ 'path': 'postgres', 'host': 'localhost', 'dbname': 'postgres', 'user': 'postgres', 'password': 'postgres', 'port': 5432, 'sslmode': 'disable', 'underscore': False, 'extended': Fals...
Return default config.
625941ccd99f1b3c44c6766e
def get(self, key): <NEW_LINE> <INDENT> if self._root: <NEW_LINE> <INDENT> result = self._get(key, self._root) <NEW_LINE> if result: <NEW_LINE> <INDENT> return result.value <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None
Retrieve a value by the key
625941cc7d847024c06be39b
def __str__(self): <NEW_LINE> <INDENT> return str(self.as_list())
Return a string representation of this record.
625941cc460517430c394265
def load_test_cache(): <NEW_LINE> <INDENT> cache = YamlCache("test/data/cache.yml") <NEW_LINE> return cache.load_yaml()
Load cache with testing data.
625941cca8370b771705297f
def write(self, sep='\t'): <NEW_LINE> <INDENT> for game in self.game_data: <NEW_LINE> <INDENT> game.append('\n') <NEW_LINE> self.writer.write(sep.join(game).encode())
Write collected data to tab. Arguments: sep (str) -- separator used in data export. Returns: None
625941ccd53ae8145f87a350
def moveDown(path): <NEW_LINE> <INDENT> file = input(NAME) <NEW_LINE> if exists(path + '/' + file): <NEW_LINE> <INDENT> chdir(file) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print(NO_FILE, file)
Moving to the level down.
625941cce5267d203edcdd7e
def predict_proba(self, X): <NEW_LINE> <INDENT> return np.exp(self.predict_log_proba(X))
Return probability estimates for the test vector X. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Returns ------- C : array-like, shape = [n_samples, n_classes] Returns the probability of the sample for each class in the model, where classes are ordered by arithmetical...
625941cc1d351010ab855bfb
def is_duplicate(a, pa): <NEW_LINE> <INDENT> if pa and a.pos==pa.pos and a.flag==pa.flag and a.cigarstring==pa.cigarstring and a.isize==pa.isize and a.seq==pa.seq: <NEW_LINE> <INDENT> return True
Return True if read is duplicate
625941cc26238365f5f0ef4e
def update_structure(self, msg): <NEW_LINE> <INDENT> needs_update = False <NEW_LINE> if self._children != msg.children or self._internal_outcomes != msg.internal_outcomes or self._outcomes_from != msg.outcomes_from or self._outcomes_to != msg.outcomes_to or se...
Update the structure of this container from a given message. Return True if anything changes.
625941cc63f4b57ef00011fa
def get_element_by_attribure(attribute): <NEW_LINE> <INDENT> return driver.find_elements_by_xpath(XPATHS[attribute])
@Get page attribute- one of ['title', 'description', 'tags', 'time', 'language', 'rate'] @Return list of the attribute's data
625941cc099cdd3c635f0d3b
def testKernelShape(self): <NEW_LINE> <INDENT> snt.Conv3D(output_channels=10, kernel_shape=[3, 4, 5], name="conv1") <NEW_LINE> snt.Conv3D(output_channels=10, kernel_shape=3, name="conv1") <NEW_LINE> with self.assertRaisesRegexp(snt.Error, "Invalid kernel shape.*"): <NEW_LINE> <INDENT> snt.Conv3D(output_channels=10, ker...
Errors are thrown for invalid kernel shapes.
625941cc3d592f4c4ed1d14e
def _reroot_skeleton(treenode_id, project_id): <NEW_LINE> <INDENT> if treenode_id is None: <NEW_LINE> <INDENT> raise Exception('A treenode id has not been provided!') <NEW_LINE> <DEDENT> response_on_error = '' <NEW_LINE> try: <NEW_LINE> <INDENT> response_on_error = 'Failed to select treenode with id %s.' % treenode_id ...
Returns the treenode instance that is now root, or False if the treenode was root already.
625941cc091ae3566866703e
def get_switch(self, switch_name, include_locations=False): <NEW_LINE> <INDENT> raise NotImplementedError("get_switch must be implemented in " "subclass")
Get information for switch with name 'switch_name' The 'locations' field in the resulting SwitchInfo instance will be populated only if include_locations is True Returns deferred returning SwitchInfo instance or None if switch_name does not exist
625941cc45492302aab5e3a2
def ent_to_string(self): <NEW_LINE> <INDENT> self.ent_id2str = {} <NEW_LINE> for subj_id, ent_info in self.ents.items(): <NEW_LINE> <INDENT> ent_str = "" <NEW_LINE> place = ent_info["place"] <NEW_LINE> if not (place == "None" or place == "nan" or len(place) < 1): <NEW_LINE> <INDENT> ent_str += place <NEW_LINE> <DEDENT>...
实体信息变为字符串
625941ccf8510a7c17cf97dd
def remove_zero_variance_voxels(func_timeseries, mask): <NEW_LINE> <INDENT> for i in range(0, len(func_timeseries)): <NEW_LINE> <INDENT> for j in range(0, len(func_timeseries[0])): <NEW_LINE> <INDENT> for k in range(0, len(func_timeseries[0][0])): <NEW_LINE> <INDENT> var = func_timeseries[i][j][k].var() <NEW_LINE> if i...
Modify a head mask to exclude timeseries voxels which have zero variance. :type func_timeseries: Nibabel data :param func_timeseries: The 4D functional timeseries. :type mask: Nibabel data :param mask: The binary head mask. :rtype: Nibabel data :return: The binary head mask, but with voxels of zero variance excluded.
625941ccc432627299f04d26
def _xy_correct(self, correct_with=None, n_closest=21): <NEW_LINE> <INDENT> num_pts = len(self.use_flux) <NEW_LINE> logging.debug("Pixel position correction %d", num_pts) <NEW_LINE> if correct_with is None: <NEW_LINE> <INDENT> correct_with = self.use_flux <NEW_LINE> <DEDENT> self.corrected_flux = np.zeros(num_pts) <NEW...
Correct for positional variations in the lightcurve once selected.
625941cc30c21e258bdfa57d
def exception_logging_enabled(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ip = get_ipython() <NEW_LINE> <DEDENT> except NameError: <NEW_LINE> <INDENT> ip = None <NEW_LINE> <DEDENT> if ip is None: <NEW_LINE> <INDENT> return self._excepthook_orig is not None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _A...
Determine if the exception-logging mechanism is enabled. Returns ------- exclog : bool True if exception logging is on, False if not.
625941cc3317a56b86939d39
def test_types(self): <NEW_LINE> <INDENT> self.assertNotEqual(Artist("Name"), "Name")
Verify different types are not equal.
625941cc5fcc89381b1e179f
def parse(self): <NEW_LINE> <INDENT> node = self.program() <NEW_LINE> if self.current_token.type != EOF: <NEW_LINE> <INDENT> self.error() <NEW_LINE> <DEDENT> return node
program : compounds EOF compounds : compound | compounds compound : if_block | while_block | block if_block : IF( cond_block ) { compounds } | IF( cond_block ) { compounds } ELSE { compounds } while_block : WHILE( cond_block ) { compounds } cond_block : label condition block : label statem...
625941cca8370b7717052980
def convert_to_dictionary(self, item): <NEW_LINE> <INDENT> return dict(item)
Converts the given ``item`` to a Python ``dict`` type. Mainly useful for converting other mappings to normal dictionaries. This includes converting Robot Framework's own ``DotDict`` instances that it uses if variables are created using the ``&{var}`` syntax. Use `Create Dictionary` from the BuiltIn library for constr...
625941cc5f7d997b87174b78
def start( self, dirs, output_dir, analysis_start_date, analysis_end_date, analysis_timespan, cell_execution_timeout, make_configs, backend, ): <NEW_LINE> <INDENT> self.output_dir = output_dir <NEW_LINE> if self.output_dir is None: <NEW_LINE> <INDENT> self.output_dir = os.path.join('.', self.project_name) <NEW_LINE> <D...
Initiate new project. No files will be touched! Parameters ---------- dirs: list, optional List of sub-directory names that should be used in the project. By default all subdirectories defined in the contructor are taken into account.
625941cc60cbc95b062c6623
def SetAlpha(self, alpha): <NEW_LINE> <INDENT> self._AlphaChannel = alpha * 255 <NEW_LINE> if self._AlphaChannel is not None: <NEW_LINE> <INDENT> self.MasterFrame.SetTransparent(self._AlphaChannel)
Change the window's transparency :param alpha: From 0 to 1 with 0 being completely transparent :return:
625941cc91f36d47f21ac5d3
def to_binary(self): <NEW_LINE> <INDENT> c = containerize(exclude_fields(self)) <NEW_LINE> self.payload = MsgAcqResult._parser.build(c) <NEW_LINE> return self.pack()
Produce a framed/packed SBP message.
625941cc26068e7796caedbf
def test_program_page_faculty_subpage(): <NEW_LINE> <INDENT> program_page = ProgramPageFactory.create() <NEW_LINE> assert not program_page.faculty <NEW_LINE> FacultyMembersPageFactory.create( parent=program_page, members=json.dumps(_get_faculty_members()) ) <NEW_LINE> _assert_faculty_members(program_page)
FacultyMembersPage should return expected values if associated with ProgramPage
625941ccbe383301e01b5566
def fit(self, X, y, sample_weight=None, check_input=True, X_idx_sorted=None): <NEW_LINE> <INDENT> super().fit( X, y, sample_weight=sample_weight, check_input=check_input, X_idx_sorted=X_idx_sorted) <NEW_LINE> return self
Build a decision tree classifier from the training set (X, y). Parameters ---------- X : {array-like or sparse matrix} of shape (n_samples, n_features) The training input samples. Internally, it will be converted to ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csc_matrix``. y : ar...
625941cce64d504609d74920
def send_form_and_read(self, url, fields=(), files=(), headers=None, redir=True): <NEW_LINE> <INDENT> content_type, data = utils.encode_multipart_formdata(fields, files) <NEW_LINE> headers = dict(headers or ()) <NEW_LINE> headers['content-type'] = content_type <NEW_LINE> return self.urlread(url, data, headers, redir)
Аналогично :func:`~tabun_api.User.send_form`, но сразу возвращает тело ответа (bytes).
625941cc5fdd1c0f98dc0313
def build_png_image_boinc(): <NEW_LINE> <INDENT> ec2_helper = EC2Helper() <NEW_LINE> if ec2_helper.boinc_instance_running(BUILD_PNG_IMAGE): <NEW_LINE> <INDENT> LOG.info('A previous instance is still running') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> LOG.info('Starting up the instance') <NEW_LINE> instance_type = B...
We're running the process on the BOINC server. Check if an instance is still running, if not start it up. :return:
625941cc091ae3566866703f
def complete(self, container): <NEW_LINE> <INDENT> needle = container.autocomplete <NEW_LINE> usernames = self.factory.protocols.keys() <NEW_LINE> results = complete(needle, usernames) <NEW_LINE> self.write_packet("tab", autocomplete=results)
Attempt to tab-complete user names.
625941cc2c8b7c6e89b358a1
def testPatchContextManager(self): <NEW_LINE> <INDENT> with patchstdout() as m: <NEW_LINE> <INDENT> mocking.print_string('hi') <NEW_LINE> m.write.assert_called_once_with('hi\n')
Use mock.patch as a context manager on mocking.print_string.
625941cc6aa9bd52df036e85
def stopBatchDownload(self): <NEW_LINE> <INDENT> self.log.info("stopping batch tile download") <NEW_LINE> self._downloadPool.stop()
Stop threaded batch tile download
625941cc7b25080760e3953a
def _default_fork(self): <NEW_LINE> <INDENT> args, varargs, varkw, defaults = getargs(self.__init__)[:4] <NEW_LINE> args.remove("self") <NEW_LINE> if defaults: <NEW_LINE> <INDENT> non_default_keys = args[:-len(defaults)] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> non_default_keys = [] <NEW_LINE> <DEDENT> kwargs = di...
Default implementation of _fork. It uses introspection to determine the init kwargs and tries to fill them with attributes. These kwargs are then used to instanciate self.__class__ to create the fork instance. So you can use this method if all the required keys are also public attributes or have a single underscore i...
625941cc4d74a7450ccd42a4
def baidu(location, **kwargs): <NEW_LINE> <INDENT> return get(location, provider='baidu', **kwargs)
Baidu Provider :param location: Your search location you want geocoded. :param key: Baidu API key. :param referer: Baidu API referer website.
625941cc5e10d32532c5f007
def op_value_and_grad(f, *required_args): <NEW_LINE> <INDENT> gradient = op_grad(f, *required_args) <NEW_LINE> def v_and_g(*args, dout=1): <NEW_LINE> <INDENT> return f(*args), gradient(*args, dout=dout) <NEW_LINE> <DEDENT> return v_and_g
Implement operation value_and_grad.
625941cca219f33f34628a4a
def batch_product_3D(self,inp1,inp2): <NEW_LINE> <INDENT> def singel_instance(x): <NEW_LINE> <INDENT> w_qt = x[0] <NEW_LINE> qt = x[1] <NEW_LINE> weighted_qt= tf.matmul(w_qt,qt) <NEW_LINE> return weighted_qt <NEW_LINE> <DEDENT> elems = (inp1, inp2) <NEW_LINE> return tf.map_fn(singel_instance, elems, dtype=tf.float32)
function: compute 3D mtrix multiplication, (b,m,n)*(b,n,d)=>(b,m,d) inp1 act as the weight matrix of inp2 :param inp1: a 3D tensor of (b,x_len,y_len) :param inp2: a 3D tensor of (b,y_len,dim) :return: the weighted sum of inp1*inpu2, a 3D tensor with shape (b,x_len,dim)
625941cc2ae34c7f2600d212
def pc_work_time_var(self): <NEW_LINE> <INDENT> return _TestA_swig.cleanslate_sptr_pc_work_time_var(self)
pc_work_time_var(cleanslate_sptr self) -> float
625941cc4428ac0f6e5ba8d3
@never_cache <NEW_LINE> @csrf_exempt <NEW_LINE> @require_POST <NEW_LINE> def webhook(request): <NEW_LINE> <INDENT> webhook = Webhook.objects.create(body=request.body.decode('utf-8')) <NEW_LINE> process_webhook.delay(webhook.pk) <NEW_LINE> return HttpResponse('OK')
Receive webhook from easyDITA.
625941cceab8aa0e5d26dc38
@click.group() <NEW_LINE> @click.option( "--log-level", type=click.Choice(["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), default="INFO", ) <NEW_LINE> def cli(log_level: str): <NEW_LINE> <INDENT> logging.basicConfig(level=getattr(logging, log_level.upper()))
Base CLI command
625941cc66673b3332b92172
def verify(self, change): <NEW_LINE> <INDENT> tables = self.tables <NEW_LINE> action = change['change'] <NEW_LINE> schema = change['schema'] <NEW_LINE> table = schema['id'] <NEW_LINE> fields = schema['properties'] <NEW_LINE> if action == 'create': <NEW_LINE> <INDENT> return table not in tables <NEW_LINE> <DEDENT> if ac...
Verify change against the working schema
625941cc293b9510aa2c3377
def _templatize_metric_fn(self, metric_fn): <NEW_LINE> <INDENT> def _metric_fn(*args, **kwargs): <NEW_LINE> <INDENT> args = args if args else kwargs <NEW_LINE> metrics = _call_eval_metrics((metric_fn, args)) <NEW_LINE> if not self._use_tpu: <NEW_LINE> <INDENT> return metrics <NEW_LINE> <DEDENT> logging.log_first_n(logg...
Wraps the given metric_fn with a template so it's Variables are shared. Hooks on TPU cannot depend on any graph Tensors. Instead the eval metrics returned by metric_fn are stored in Variables. These variables are later read from the evaluation hooks which run on the host CPU. Args: metric_fn: The function to wrap w...
625941ccd6c5a1020814412b
def _exec_single_character_command(self): <NEW_LINE> <INDENT> method_name = self.control_characters[ord(self._buf)] <NEW_LINE> self._exec_method(method_name) <NEW_LINE> self._buf = ''
Executes control sequences like 10 (LF, line feed) or 13 (CR, carriage return).
625941cc55399d3f05588795
def send_data(self, data): <NEW_LINE> <INDENT> self.logger.debug("发送了一条消息") <NEW_LINE> return self.socket.send(data)
发送数据 :param data: bytes类型数据 :return: 返回已发送的大小
625941ccd10714528d5ffdc3
def run_test_problem1(): <NEW_LINE> <INDENT> print() <NEW_LINE> print('--------------------------------------------------') <NEW_LINE> print('Testing the problem1 function:') <NEW_LINE> print(' See the graphics windows that pop up.') <NEW_LINE> print('--------------------------------------------------') <NEW_LINE> t...
Tests the problem1 function.
625941ccf9cc0f698b1406dc
def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, MatchCriteria): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict()
Returns true if both objects are not equal
625941ccab23a570cc250263
def init(): <NEW_LINE> <INDENT> line1.set_data([], []) <NEW_LINE> line1_2.set_data([], []) <NEW_LINE> time_text.set_text('') <NEW_LINE> return line1, line1_2, time_text, velocity_text, position_text, height_text
initialize animation
625941cc63d6d428bbe445d0
def _insteon_hold_change(self, device, hold): <NEW_LINE> <INDENT> LOG.info("MQTT received hold change %s = %s", device.label, hold) <NEW_LINE> data = self.template_data() <NEW_LINE> data["hold_str"] = "temp" if hold else "off" <NEW_LINE> data["is_hold"] = 1 if hold else 0 <NEW_LINE> self.hold_state.publish(self.mqtt, d...
Posts to mqtt changes in the hold status This is triggered via signal when the hold status changes. Args: device (device.Thermostat): The Insteon device that changed. hold (bool): The hold Status
625941cc32920d7e50b282b0
def _init(): <NEW_LINE> <INDENT> return ctypes.cdll.LoadLibrary(r"magic")
Loads the shared library through ctypes and returns a library L{ctypes.CDLL} instance
625941ccfb3f5b602dac3773
@app.route('/logout') <NEW_LINE> def logout(): <NEW_LINE> <INDENT> session.pop('logged_in', None) <NEW_LINE> session.pop('u_id', None) <NEW_LINE> flash('You were logged out') <NEW_LINE> return redirect(url_for('index'))
Remove user session and logs a user out
625941cc97e22403b379d07a
def version(): <NEW_LINE> <INDENT> with io.open('pgmagick/_version.py') as input_file: <NEW_LINE> <INDENT> for line in input_file: <NEW_LINE> <INDENT> if line.startswith('__version__'): <NEW_LINE> <INDENT> return ast.parse(line).body[0].value.s
Return version string.
625941cc6fece00bbac2d81f
def _testMasterAttribute(self, attr, dependant_attr): <NEW_LINE> <INDENT> attr_value1 = "%s_value1" % attr <NEW_LINE> attr_value2 = "%s_value2" % attr <NEW_LINE> setattr(self.settings, attr, attr_value1) <NEW_LINE> setattr(self.settings, dependant_attr, {}) <NEW_LINE> getattr(self.settings, dependant_attr)["key1"] = "v...
Test changing the specified attr has effect on its dependant attr.
625941cc66656f66f7cbc28c
def complete(self): <NEW_LINE> <INDENT> return self.filter(status=JobRequest.STATUS_COMPLETE)
Filter by job requests that are complete.
625941cc57b8e32f5248357b
def path(self): <NEW_LINE> <INDENT> return QPainterPath(self.__path)
Return the items path.
625941cc76e4537e8c351753