code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def SiDinstall(app, config, area): <NEW_LINE> <INDENT> os.chdir(area) <NEW_LINE> appName = app[0] <NEW_LINE> appVersion = app[1] <NEW_LINE> appName = appName.lower() <NEW_LINE> app_tar = Operations().getValue('/AvailableTarBalls/%s/%s/%s' % (config, appName, appVersion), '') <NEW_LINE> if not app_tar: <NEW_LINE> <IN... | Install the Java soft, NOT USED
| 625941e776e4537e8c351aef |
def choose_action(self, q): <NEW_LINE> <INDENT> raise NotImplementedError("Please implement choose_action method") | This method of a policies_nn basically gets a Q function
and has to return the action to take now. Here you can
specify behaviour like taking the best action, or sometimes
different actions to them.
Args:
q: The q function to use for evaluating.
Returns: The index of the action that should be taken | 625941e70a50d4780f66730f |
def save(path): <NEW_LINE> <INDENT> utils.con_log("Saving New Map...") <NEW_LINE> os.makedirs(os.path.dirname(path), exist_ok=True) <NEW_LINE> with open(path, 'w') as f: <NEW_LINE> <INDENT> VMF.export(dest_file=f, inc_version=True) <NEW_LINE> <DEDENT> utils.con_log("Complete!") | Save the modified map back to the correct location.
| 625941e7c432627299f050c2 |
def count_sizes(self, u=0): <NEW_LINE> <INDENT> return self._count_sizes(self.root, u=u) | How deep are categories? | 625941e88c3a873295158839 |
def c_root_p(a, p): <NEW_LINE> <INDENT> if (a % p) == 0: <NEW_LINE> <INDENT> return [0] <NEW_LINE> <DEDENT> if p == 2 or p == 3 : <NEW_LINE> <INDENT> return [a % p] <NEW_LINE> <DEDENT> if (p % 3) == 2: <NEW_LINE> <INDENT> return [pow(a, (((2 * p) - 1) / 3), p)] <NEW_LINE> <DEDENT> p_div_3, p_mod_3 = divmod((p - 1), 3) ... | Return the cubic root modulo p.
(i.e. a^3 = x (mod p)) | 625941e7bde94217f3683265 |
def rotate(image_np, save_dir, input_filename,degree=[90,180,270]): <NEW_LINE> <INDENT> file_basename = os.path.basename(input_filename) <NEW_LINE> basename = os.path.splitext(file_basename)[0] <NEW_LINE> ext = os.path.splitext(file_basename)[1] <NEW_LINE> for angle in degree: <NEW_LINE> <INDENT> roate = iaa.Affine(rot... | roate image with 90, 180, 270 degree
Args:
image_np: image_np: 'images' should be either a 4D numpy array of shape (N, height, width, channels)
save_dir: the directory for saving images
input_filename: File base name (e.g basename.tif)
degree: the degree list for rotation
Returns: True if successful, ... | 625941e8d6c5a102081444c7 |
def _length_normalize(a_vec): <NEW_LINE> <INDENT> return vecnormalize(a_vec) | Length normalize vector
@param a_vec - vector to be normalized
@return normalized vector | 625941e88a43f66fc4b544d9 |
def read_roipac_rsc(fname, delimiter=' '): <NEW_LINE> <INDENT> with open(fname, 'r') as f: <NEW_LINE> <INDENT> lines = f.readlines() <NEW_LINE> <DEDENT> rscDict = {} <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> c = [i.strip() for i in line.strip().replace('\t',' ').split(delimiter, 1)] <NEW_LINE> key = c[0] <NEW_L... | Read ROI_PAC .rsc file into a python dict structure.
Parameters: fname : str.
File path of .rsc file.
Returns: rscDict : dict
Dictionary of keys and values in RSC file.
Examples:
from mintpy.utils import readfile
atr = readfile.read_roipac_rsc('filt_101120_110220_c10.unw.rsc') | 625941e86fb2d068a760f51d |
def _assign_pham_ids(phams, original_phams): <NEW_LINE> <INDENT> for key, value in phams.items(): <NEW_LINE> <INDENT> phams[key] = frozenset(value) <NEW_LINE> <DEDENT> for key, value in original_phams.items(): <NEW_LINE> <INDENT> original_phams[key] = frozenset(value) <NEW_LINE> <DEDENT> final_phams = {} <NEW_LINE> nex... | Re-assigns pham ids to match the original pham ids.
If a pham contains all new genes, use a new id.
If a pham was created by joining old phams, use a new id.
If a pham was created by splitting an old pham, use a new id.
Otherwise, use the old id of the original pham.
Returns a dictionary mapping pham_id to a frozense... | 625941e8adb09d7d5db6cc06 |
def _get_xy(self, xy: XY) -> DataSetXY: <NEW_LINE> <INDENT> return DataSetXY(self.name, self.split, self.phase, xy) | Gets an input x or an output y from this phase. | 625941e816aa5153ce3628f1 |
def F(x=None, z=None): <NEW_LINE> <INDENT> if x is None: <NEW_LINE> <INDENT> return rows, big_x <NEW_LINE> <DEDENT> big_f = cvxopt.matrix(0., (rows, 1)) <NEW_LINE> big_Df = cvxopt.spmatrix(0., [], [], size=(rows, cols)) <NEW_LINE> if z: <NEW_LINE> <INDENT> big_H = cvxopt.spmatrix(0., [], [], size=(cols, cols)) <NEW_LIN... | Oracle for function value, gradient, and Hessian.
| 625941e899fddb7c1c9de808 |
def fc_of_annotated_with(self, annotation, treatment, signs = False, category = None, std = 'none'): <NEW_LINE> <INDENT> if category is not None: <NEW_LINE> <INDENT> arr = self.aTidyFunc[np.where(self.aTidyFunc[:,2] == category)] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> arr = self.aTidyFunc <NEW_LINE> <DEDENT> set... | Returns the FC values of from phosphosites in one treatment annotated
with a certain functional annotation. | 625941e8a79ad161976cc5bf |
def maxlife_within_policy(input, maxlife, slush=3600): <NEW_LINE> <INDENT> data = input.split() <NEW_LINE> start = datetime.strptime(data[0] + ' ' + data[1], '%m/%d/%Y %H:%M:%S') <NEW_LINE> end = datetime.strptime(data[2] + ' ' + data[3], '%m/%d/%Y %H:%M:%S') <NEW_LINE> diff = int((end - start).total_seconds()) <NEW_LI... | Given klist output of the TGT verify that it is within policy
Ensure that the validity period is somewhere within the
absolute maxlife and a slush value, maxlife - slush.
Returns True if within policy.
Input should be a string like:
11/19/2019 16:37:40 11/20/2019 16:37:39 krbtgt/...
slush defaults to 1 * 60 * 60 ... | 625941e8a8370b7717052d16 |
def build_char_table(filename): <NEW_LINE> <INDENT> table={} <NEW_LINE> f=open(filename,'r') <NEW_LINE> fread=f.read() <NEW_LINE> for char in fread: <NEW_LINE> <INDENT> if(table.has_key(char)): <NEW_LINE> <INDENT> table[char]=table[char]+1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> table[char]=1 <NEW_LINE> <DEDENT> ... | Build and return a hash that maps every character in the file 'filename' to the
number of occurences of that char in the file | 625941e850812a4eaa59c796 |
def _parse_seat(self, seat): <NEW_LINE> <INDENT> rows, seat_letters = self._aircraft.seating_plan() <NEW_LINE> letter = seat[-1] <NEW_LINE> if letter not in seat_letters: <NEW_LINE> <INDENT> raise ValueError("Invalid seat row {}".format(letter)) <NEW_LINE> <DEDENT> row_text = seat[:-1] <NEW_LINE> try: <NEW_LINE> <INDEN... | Parse a seat designator into valid row and letter.
Args:
seat: A seat designator such as 12F
Returns:
A tuple containing an integer and a string for row and seat. | 625941e850485f2cf553d214 |
def ifft_pair(a, nfft=None, axis=-1, crop_fft=False): <NEW_LINE> <INDENT> shape, n, nfft, u, v = _ifft_preparations(a, nfft, axis) <NEW_LINE> planned_ifft = _ifft(n, nfft, u, v, shape, axis) <NEW_LINE> fft_obj = pyfftw.FFTW(u, v, direction='FFTW_FORWARD', axes=(axis,)) <NEW_LINE> if n > nfft: <NEW_LINE> <INDENT> raise ... | Returns a planned function that computes the 1-D inverse DFT of a
sequence or array.
Parameters
----------
a : number, shape or array-like
An input array, its shape or length.
nfft : Optional[int]
Number of FFT points. Default is input size along specified axis
axis : Optional[int]
Axis along which to perf... | 625941e850485f2cf553d215 |
def __init__ (self,importCommands,atAuto,language='unnamed',alternate_language=None): <NEW_LINE> <INDENT> ic = importCommands <NEW_LINE> self.atAuto = atAuto <NEW_LINE> self.c = c = ic.c <NEW_LINE> self.atAutoWarnsAboutLeadingWhitespace = c.config.getBool( 'at_auto_warns_about_leading_whitespace') <NEW_LINE> self.atAut... | ctor for BaseScanner. | 625941e8d486a94d0b98e5c0 |
def person_generator(n): <NEW_LINE> <INDENT> for i in xrange(n): <NEW_LINE> <INDENT> person_info = {'International_Terrorist_Watch_List': np.random.choice(a=[1,0], p=[0.03,0.97]), 'National_Terrorist_Watch_List': np.random.choice(a=[1,0], p=[0.05,0.95]), 'National_Law_Enforcement': np.random.choice... | n = how many person you want to generate | 625941e84c3428357757c79e |
def expand_vdup(vdup): <NEW_LINE> <INDENT> indices = [] <NEW_LINE> for i, count in enumerate(vdup): <NEW_LINE> <INDENT> indices.extend([i]*count) <NEW_LINE> <DEDENT> return indices | @param vdup: a vector of row duplication counts
@return: a vector of indices | 625941e85f7d997b87174f15 |
def record_pid(method): <NEW_LINE> <INDENT> @functools.wraps(method) <NEW_LINE> def wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> setattr(self, 'pid_in_%s' % method.__name__, os.getpid()) <NEW_LINE> return method(self, *args, **kwargs) <NEW_LINE> <DEDENT> return wrapper | Decorator that records the pid at method invocation.
Will probably only DTRT with class methods or bound instance
methods. | 625941e891af0d3eaac9be96 |
def _download(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> fh = io.FileIO(self.path, mode='w') <NEW_LINE> downloader = MediaIoBaseDownload(fh, request) <NEW_LINE> done = False <NEW_LINE> sys.stdout.write("\n") <NEW_LINE> sys.stdout.flush() <NEW_LINE> print("Downloading %s" % self) <NEW_LINE> while not d... | Downloads this file.
:param request: the API request that specifies the type of file to download | 625941e8656771135c3ebced |
def bossbar(self, source: StoreTarget) -> "Execute": <NEW_LINE> <INDENT> self._add_args("bossbar", source) <NEW_LINE> return self.parent | bossbar - Stores data in a bossbar
Args:
source (StoreTarget): The data location to store the data in
Returns:
Execute: The parent object | 625941e8b7558d58953c5384 |
def standind(line, cur_ind): <NEW_LINE> <INDENT> devfromstd = cur_ind % 4 <NEW_LINE> if not devfromstd == 0: <NEW_LINE> <INDENT> line = (devfromstd * '') + line <NEW_LINE> <DEDENT> return indentation(line), line | Standardizes indentation | 625941e856b00c62f0f14ad6 |
@click.option('-s', '--subsidies-json', help='JSON file containing the subsidies as returned from GET /subsidies') <NEW_LINE> @click.option('-t', '--transactions-json', help='JSON file containing the subsidies as returned from GET /master-accounts/{id}') <NEW_LINE> @click.option('-d', '--output-file', help='CSV output ... | Convert a JSON transactions response into CSV. This is what you get if you perform a GET /master-accounts/238h7c42c23f. | 625941e807f4c71912b118fe |
def __init__(self, aceList=None, xmlDoc=None): <NEW_LINE> <INDENT> if aceList: <NEW_LINE> <INDENT> self._entries = aceList <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._entries = None <NEW_LINE> <DEDENT> if xmlDoc: <NEW_LINE> <INDENT> self._xmlDoc = xmlDoc <NEW_LINE> self._entries = self._getEntriesFromXml() <NEW... | Constructor. Pass in either a dict of :class:`ACE` objects keyed to the
principalId or the XML representation of the ACL. | 625941e8796e427e537b0a43 |
def mutate(self, population, mutationRate, mutationRange): <NEW_LINE> <INDENT> newPopulation = np.apply_along_axis(self.mutateChromosome, axis=0, arr=np.mat(population), mutationRate=mutationRate, mutationRange=mutationRange) <NEW_LINE> return newPopulation[0] | mutates chromosomes | 625941e823849d37ff7b3505 |
def compute(self, node, input_val): <NEW_LINE> <INDENT> assert len(input_val) == 2 <NEW_LINE> return input_val[0] * input_val[1] | 节点和对应的输入节点的值, 只有数值节点, 没有操作节点, 操作都是在数值节点上的
:param node:
:param input_val:
:return: | 625941e863b5f9789fde755f |
def setX(self, n): <NEW_LINE> <INDENT> pass | self.setX(n) -> None
Set the left edge. The parameter n is an integer.
:param n: | 625941e88a43f66fc4b544da |
def get_sorted_pos_queryset(self, siblings, newobj): <NEW_LINE> <INDENT> fields, filters = [], [] <NEW_LINE> for field in self.node_order_by: <NEW_LINE> <INDENT> value = getattr(newobj, field) <NEW_LINE> filters.append( Q( *[Q(**{f: v}) for f, v in fields] + [Q(**{'%s__gt' % field: value})] ) ) <NEW_LINE> fields.append... | :returns:
A queryset of the nodes that must be moved to the right.
Called only for Node models with :attr:`node_order_by`
This function is based on _insertion_target_filters from django-mptt
(BSD licensed) by Jonathan Buchanan:
https://github.com/django-mptt/django-mptt/blob/0.3.0/mptt/signals.py | 625941e88da39b475bd653f3 |
def gentestcases(self): <NEW_LINE> <INDENT> linecount = 0 <NEW_LINE> lines = self.testfile.readlines() <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> if "#" in line or line == '\n': <NEW_LINE> <INDENT> linecount = linecount + 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> if "{" in line: <NEW_LINE> <INDENT> name = "" <NE... | Gets all the test cases from the test file specified | 625941e8baa26c4b54cb1595 |
def img_croproias(img, roi, d = None, val = 0): <NEW_LINE> <INDENT> output = img_crop(img, roi) <NEW_LINE> if d is not None: <NEW_LINE> <INDENT> output = img_shapeas(output, d, val = val, mode = 'scale') <NEW_LINE> <DEDENT> return output | Crop the roi from img and scale to the desired shape d, blank area will
be padded with value val
Args
-------
img
The input image
roi
The region of interest as (x0, y0, x1, y1)
d
The desired output size as (h, w)
val
The padding value | 625941e823e79379d52ee9d8 |
def __init__(self, url, **kwargs): <NEW_LINE> <INDENT> self.kwargs = kwargs <NEW_LINE> self.kafka_cluster = kwargs.pop("kafka_cluster", config.KAFKA_CLUSTER) <NEW_LINE> self.burrow_client = burrow.BurrowApi(url) | url: burrow api addr
kwargs: pair of topic and consumer group | 625941e894891a1f4081bf25 |
def get_negative_ten_billion( self, long_query=-10000000000, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = '/queries/long/-10000000000' <NEW_LINE> query_parameters = {} <NEW_LINE> query_parameters['longQuery'] = self._serialize.query("long_query", long_query, 'long') <NEW_LINE> header_p... | Get '-10000000000' 64 bit integer value
:param long_query: '-10000000000' 64 bit integer value
:type long_query: long
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configur... | 625941e8dd821e528d63b61f |
def rmse(y, y_pred): <NEW_LINE> <INDENT> return np.sqrt(mean_squared_error(y[np.where(y>0)], y_pred[np.where(y>0)])) | Root Mean Squared Error Calculation | 625941e8aad79263cf390ec1 |
def iterate_files_upload(request): <NEW_LINE> <INDENT> files = FileMetaData.objects.all() <NEW_LINE> for file in files: <NEW_LINE> <INDENT> taxonomy = request.POST.get('taxonomy_{}'.format(file.id)) <NEW_LINE> user_notes = request.POST.get('file_desc_{}'.format(file.id)) <NEW_LINE> uploaded_file = request.FILES.get('fi... | iterate over all files to upload them to OH. | 625941e8442bda511e8be88b |
def figure(*args, **kwargs): <NEW_LINE> <INDENT> intercept(False) <NEW_LINE> mpltr, mplfigure = MPLTracker.init_object(plt.figure, *args, **kwargs) <NEW_LINE> intercept(True) <NEW_LINE> return mplfigure | create a new mpl figure and track only that object (and its children) | 625941e826238365f5f0f2ee |
def test_cant_create_pairing_same_mentor_mentee(self): <NEW_LINE> <INDENT> user = UserFactory.create() <NEW_LINE> mentor = self.create_mentor(user) <NEW_LINE> mentee = self.create_mentee(user) <NEW_LINE> new_pairing = Pairing() <NEW_LINE> new_pairing.mentor = mentor <NEW_LINE> new_pairing.mentee = mentee <NEW_LINE> wit... | Test that we can't pair a user with themself. | 625941e8566aa707497f49dc |
def parse_xml_node(self, node): <NEW_LINE> <INDENT> super(Preceding, self).parse_xml_node(node) <NEW_LINE> p_nodes = node.getElementsByTagNameNS(RTS_NS, 'Preceding') <NEW_LINE> if p_nodes.length != 1: <NEW_LINE> <INDENT> raise InvalidParticipantNodeError <NEW_LINE> <DEDENT> p_node = p_nodes[0] <NEW_LINE> if p_node.hasA... | Parse an xml.dom Node object representing a preceding condition into
this object. | 625941e821a7993f00bc8171 |
def get_vertex_seq_id(G, original_id): <NEW_LINE> <INDENT> return G.vs.find(id=str(original_id)).index | gets the igraph vertex sequence id for a given node id | 625941e810dbd63aa1bd301c |
def findTilt(self, root): <NEW_LINE> <INDENT> self.res = 0 <NEW_LINE> self.subsum(root) <NEW_LINE> return self.res | :type root: TreeNode
:rtype: int | 625941e83c8af77a43ae3c1f |
@_wrap('a') <NEW_LINE> def iqr(a, axis=None): <NEW_LINE> <INDENT> if axis is None: <NEW_LINE> <INDENT> return _stats.iqr(a) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _stats.iqr(a, axis) | Interquartile range of input | 625941e8a05bb46b383ecc97 |
def test_image_access(): <NEW_LINE> <INDENT> print('Testing image get/setPixel methods') <NEW_LINE> p = [(255,0,0),(0,255,0),(0,0,255),(0,255,255),(255,0,255),(255,255,0)] <NEW_LINE> rgb1 = (255,255,255) <NEW_LINE> rgb2 = (64,128,192) <NEW_LINE> image = a6image.Image(p,2) <NEW_LINE> for n in range(6): <NEW_LINE> <INDEN... | Tests the methods the two-dimensional get/setPixel methods in class Image | 625941e8009cb60464c63828 |
def loadDataSet(filename): <NEW_LINE> <INDENT> numFeat = len(open(filename).readline().split(','))-1 <NEW_LINE> x = [] <NEW_LINE> y = [] <NEW_LINE> file = open(filename) <NEW_LINE> for line in file.readlines(): <NEW_LINE> <INDENT> lineArr = [] <NEW_LINE> curLine = line.strip().split(',') <NEW_LINE> for i in range(numFe... | read data from file | 625941e857b8e32f52483918 |
def get_preprocessing(preprocessing_fn): <NEW_LINE> <INDENT> _transform = [ albu.Lambda(image=preprocessing_fn), albu.Lambda(image=to_tensor, mask=to_tensor), ] <NEW_LINE> return albu.Compose(_transform) | get_preprocessing Preprocessing transformations.
@param preprocessing_fn Transformations depending on the model. | 625941e83346ee7daa2b31e9 |
def setup_bot(skip_reboot): <NEW_LINE> <INDENT> if os.environ.get('SWARMING_EXTERNAL_BOT_SETUP') == '1': <NEW_LINE> <INDENT> logging.info('Skipping setup_bot, SWARMING_EXTERNAL_BOT_SETUP is set') <NEW_LINE> return <NEW_LINE> <DEDENT> botobj = get_bot(get_config()) <NEW_LINE> try: <NEW_LINE> <INDENT> from config import ... | Calls bot_config.setup_bot() to have the bot self-configure itself.
Reboots the host if bot_config.setup_bot() returns False, unless skip_reboot
is also true.
Does nothing if SWARMING_EXTERNAL_BOT_SETUP env var is set to 1. It is set in
case bot's autostart configuration is managed elsewhere, and we don't want
the bo... | 625941e821bff66bcd684dc8 |
def customize(self, args): <NEW_LINE> <INDENT> if args: <NEW_LINE> <INDENT> self.args = args <NEW_LINE> <DEDENT> if self.args and getattr(self.args, 'allow_stdout', None): <NEW_LINE> <INDENT> self.allow_stdout = self.args.allow_stdout <NEW_LINE> <DEDENT> if self.args and getattr(self.args, 'test_pattern', None): <NEW_L... | Green-specific behavior customization via an args dictionary from
the green.config module. If you don't pass in an args dictionary,
then this class acts like TestSuite from Python 3.4. | 625941e8fb3f5b602dac3b12 |
def exec_module(self, **kwargs): <NEW_LINE> <INDENT> for key in list(self.module_arg_spec.keys()): <NEW_LINE> <INDENT> if hasattr(self, key): <NEW_LINE> <INDENT> setattr(self, key, kwargs[key]) <NEW_LINE> <DEDENT> <DEDENT> old_response = None <NEW_LINE> response = None <NEW_LINE> self._client = self.get_mgmt_svc_client... | Main module execution method | 625941e863f4b57ef0001586 |
def release(self, buttons): <NEW_LINE> <INDENT> self.report[0] &= ~buttons <NEW_LINE> self._send_no_move() | Release the given mouse buttons.
:param buttons: a bitwise-or'd combination of ``LEFT_BUTTON``,
``MIDDLE_BUTTON``, and ``RIGHT_BUTTON``. | 625941e8d4950a0f3b08c7c3 |
def test_bad_repr(): <NEW_LINE> <INDENT> with pytest.raises(ZeroDivisionError): <NEW_LINE> <INDENT> pretty.pretty(BadRepr()) | Don't catch bad repr errors. | 625941e8aad79263cf390ec2 |
def parse_games(*games): <NEW_LINE> <INDENT> holder = [] <NEW_LINE> for g in games: <NEW_LINE> <INDENT> holder.append([g[0], int(g[1])-int(g[3]), g[2]]+g[4:]) <NEW_LINE> holder.append([g[2], int(g[3])-int(g[1]), g[0]]+g[4:]) <NEW_LINE> <DEDENT> return holder | convert games to long form outcomes | 625941e83c8af77a43ae3c20 |
def zone_update(self, ctrl: pizone.Controller, zone: pizone.Zone) -> None: <NEW_LINE> <INDENT> async_dispatcher_send(self.hass, DISPATCH_ZONE_UPDATE, ctrl, zone) | Zone update message is received from the controller. | 625941e8d18da76e23532956 |
def _wait_for_cleanups(self): <NEW_LINE> <INDENT> for wait in self.cleanup_waits: <NEW_LINE> <INDENT> self.delete_timeout(**wait) | To handle async delete actions, a list of waits is added
which will be iterated over as the last step of clearing the
cleanup queue. That way all the delete calls are made up front
and the tests won't succeed unless the deletes are eventually
successful. This is the same basic approach used in the api tests to
limit cl... | 625941e8f8510a7c17cf9b79 |
def SetMinimumIndex(self, *args): <NEW_LINE> <INDENT> return _itkStatisticsLabelObjectPython.itkStatisticsLabelObjectUL3_SetMinimumIndex(self, *args) | SetMinimumIndex(self, itkIndex3 v) | 625941e88a349b6b435e85ed |
def recommend(self): <NEW_LINE> <INDENT> artists = self.db.table('artists') <NEW_LINE> albums = self.db.table('albums') <NEW_LINE> tracks = self.db.table('tracks') <NEW_LINE> Q = Query() <NEW_LINE> genre_seeds = self.sp.recommendation_genre_seeds().get('genres', []) <NEW_LINE> seed_genres = [] <NEW_LINE> max_candidates... | recommendations(
seed_artists=None,
seed_genres=None,
seed_tracks=None,
limit=20,
country=None,
**kwargs
) | 625941e83617ad0b5ed68371 |
def datetime_of_index(start_datetime, index, frequency=1): <NEW_LINE> <INDENT> index_in_seconds = index / frequency <NEW_LINE> offset = timedelta(seconds=index_in_seconds) <NEW_LINE> return (start_datetime or 0) + offset | Returns the datetime of an index within the flight at a particular
frequency.
:param start_datetime: Start datetime of the flight available as the 'Start Datetime' attribute.
:type start_datetime: datetime
:param index: Index within the flight.
:type index: int
:param frequency: Frequency of the index.
:type frequency... | 625941e8d7e4931a7ee9e399 |
def get_float(self): <NEW_LINE> <INDENT> return float32(pn_data_get_float(self._data)) | Get the current node value as a :class:`float32`.
:return: If the current node is a float, its value, 0 otherwise.
:rtype: :class:`float32` | 625941e8ab23a570cc250600 |
def full_copy(tablename, src_curs, dst_curs, column_list = [], condition = None): <NEW_LINE> <INDENT> qtable = quote_fqident(tablename) <NEW_LINE> if column_list: <NEW_LINE> <INDENT> qfields = ",".join([quote_ident(f) for f in column_list]) <NEW_LINE> src = dst = "%s (%s)" % (qtable, qfields) <NEW_LINE> <DEDENT> else: ... | COPY table from one db to another. | 625941e89b70327d1c4e1251 |
def __init__(self, amount=None, faction_id=None): <NEW_LINE> <INDENT> self.swagger_types = { 'amount': 'int', 'faction_id': 'int' } <NEW_LINE> self.attribute_map = { 'amount': 'amount', 'faction_id': 'faction_id' } <NEW_LINE> self._amount = amount <NEW_LINE> self._faction_id = faction_id | GetFwLeaderboardsYesterday - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition. | 625941e8097d151d1a2232d1 |
def __init__(self, size=0): <NEW_LINE> <INDENT> self.table = [None for index in range(0, size)] <NEW_LINE> self.size = size | 构造函数,初始化 hash table 以及表的大小
:param size: hash table 的大小 | 625941e81f5feb6acb0c4fc4 |
def __deserialize(self, data, klass): <NEW_LINE> <INDENT> if data is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if type(klass) == str: <NEW_LINE> <INDENT> if klass.startswith('list['): <NEW_LINE> <INDENT> sub_kls = re.match('list\[(.*)\]', klass).group(1) <NEW_LINE> return [self.__deserialize(sub_data, s... | Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object. | 625941e8090684286d50f166 |
def findImmediate(self, range_start, range_end, value): <NEW_LINE> <INDENT> raise NotImplementedError("Subclasses should implement this!") | Return all of the places (in the range) in which the immediate value was found.
Args:
range_start (int): ea of the range's start
range_end (int): ea of the range's end
value (int): value of the searched immediate
Return Value:
collection of ea's in which the value was found | 625941e81d351010ab855f95 |
def __call__(self, action, uids): <NEW_LINE> <INDENT> objs = map(api.get_object, uids) <NEW_LINE> containers = filter( lambda o: IStorageLayoutContainer.providedBy(o), objs) <NEW_LINE> container_uids = map(api.get_uid, containers) <NEW_LINE> url = "{}/storage_move_container?uids={}".format( self.back_url, ",".join(cont... | Redirects the user to the Samples selector view
| 625941e8a934411ee3751b0f |
def remove_colorbar(self): <NEW_LINE> <INDENT> self._fig.delaxes(self._fig.axes[1]) | Remove the colorbar from the plot. | 625941e8507cdc57c6307160 |
def song_features(songs, session): <NEW_LINE> <INDENT> chunks = chop(10, songs) <NEW_LINE> features = [] <NEW_LINE> for c in chunks: <NEW_LINE> <INDENT> r = session.audio_features(c) <NEW_LINE> features.append(r) <NEW_LINE> <DEDENT> features = [y for x in features for y in x] <NEW_LINE> df = pd.DataFrame.from_records(... | Pass list of song ids
spotipy sessionobject
returns DataFrame | 625941e856ac1b37e6264641 |
def test_box_hocr_serialization(self): <NEW_LINE> <INDENT> fp = StringIO() <NEW_LINE> fp.write(serialization.serialize(self.box_records, image_name='foo.png', template='hocr')) <NEW_LINE> validate_hocr(self, fp) | Test hOCR serialization | 625941e87d43ff24873a311e |
def _periodic_resync_helper(self): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> eventlet.sleep(self.conf.resync_interval) <NEW_LINE> if self.needs_resync: <NEW_LINE> <INDENT> self.needs_resync = False <NEW_LINE> self.sync_state() | Resync the dhcp state at the configured interval. | 625941e89f2886367277ad04 |
def _assert_tier_unchanged(self) -> None: <NEW_LINE> <INDENT> subscription = self.user.alumni.subscription <NEW_LINE> self._assert_subscription_equal( subscription, subscription=self.start_subscription, tier=self.start_tier, start=self.start_time, end=self.end_time) <NEW_LINE> self.assertEqual(self.user.alumni.membersh... | Asserts that the tier is still the original tier and has not changed | 625941e8f8510a7c17cf9b7a |
def kmeans(X, num_clusters): <NEW_LINE> <INDENT> kmeans = KMeans(num_clusters) <NEW_LINE> kmeans.fit(X) <NEW_LINE> return kmeans.cluster_centers_, kmeans.labels_ | Performs K-Means clustering on the data X
Args:
X: (n, k) dimensional numpy array representing n data points
and k features
num_clusters: number of clusters to form | 625941e87b25080760e398d1 |
def test_edit_packet_no_packet(self, app, db): <NEW_LINE> <INDENT> with app.test_client() as tc: <NEW_LINE> <INDENT> rv = tc.get(url_for('seeds.edit_packet', pkt_id=42)) <NEW_LINE> <DEDENT> assert rv.location == url_for('seeds.select_packet', dest='seeds.edit_packet', _external=True) | Redirect to select if no packet exists with pkt_id. | 625941e8cc40096d61595dc9 |
def _write(self, chunk): <NEW_LINE> <INDENT> chunk_size = self._count_samples(chunk) <NEW_LINE> if 0 == chunk_size: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if 0 == self._written_items_count: <NEW_LINE> <INDENT> with h5py.File(self._output_filename, "w") as f: <NEW_LINE> <INDENT> for key, data_buffer in chunk.ite... | :param chunk: data already concatenated and ready to be written
:return: | 625941e8097d151d1a2232d2 |
@app.route('/') <NEW_LINE> def home(): <NEW_LINE> <INDENT> return render_template('home.html', site_menu=dbase.get_menu(), articles=dbase.get_all_articles()) | Defines Home Page Functionality | 625941e8c4546d3d9de72eb2 |
def testChangeFilter(self): <NEW_LINE> <INDENT> insts = self.model.objects.filter(ccy = 'EUR') <NEW_LINE> N = insts.count() <NEW_LINE> for inst in insts: <NEW_LINE> <INDENT> self.assertEqual(inst.ccy, 'EUR') <NEW_LINE> inst.ccy = 'USD' <NEW_LINE> inst.save() <NEW_LINE> <DEDENT> insts = self.model.objects.filter(ccy = '... | Change the value of a filter field and perform filtering to
check for zero values | 625941e88c0ade5d55d3ee39 |
def make_workspace(self, image, mask=None, labels=None, binary_image=None): <NEW_LINE> <INDENT> module = YS.IdentifyYeastCells() <NEW_LINE> module.module_num = 1 <NEW_LINE> module.input_image_name.value = IMAGE_NAME <NEW_LINE> module.object_name.value = OBJECTS_NAME <NEW_LINE> module.binary_image.value = BINARY_IMAGE_N... | Make a workspace and IdentifyPrimaryObjects module
image - the intensity image for thresholding
mask - if present, the "don't analyze" mask of the intensity image
labels - if thresholding per-object, the labels matrix needed
binary_image - if thresholding using a binary image, the image | 625941e844b2445a3393250d |
def player_guess(self): <NEW_LINE> <INDENT> guess = self.human.ask('What letter do you guess? ') <NEW_LINE> if len(guess) != 1 or guess.lower() not in 'abcdefghijklmnopqrstuvwxyz': <NEW_LINE> <INDENT> return self.handle_cmd(guess) <NEW_LINE> <DEDENT> if guess in self.guessed_letters: <NEW_LINE> <INDENT> self.human.tell... | Handle the player guessing if letters are correct. (bool) | 625941e81f037a2d8b946677 |
def readouterr(self): <NEW_LINE> <INDENT> out = self._readsnapshot('out') <NEW_LINE> err = self._readsnapshot('err') <NEW_LINE> return out, err | return snapshot value of stdout/stderr capturings. | 625941e8eab8aa0e5d26dfd4 |
def test_macros(self): <NEW_LINE> <INDENT> self.expected_history = [ TestCommit(), TestCommit(), TestCommit(), TestCommit( TestFile("macros.c", confident=TestAsserts( added={"(X)==1", "(fun(_a)->field&SOME_mask)==SOME_shadow||(fun(_b)->field&ANOTHER_mask)==ANOTHER_shadow", "*argv"}), problematic=TestAsserts( added={"pr... | Assertions within macros and including pre-processor directives | 625941e8d58c6744b42580d9 |
def get_urls(league='c', year=2017): <NEW_LINE> <INDENT> df_player_url = pd.DataFrame() <NEW_LINE> parser = lxml.html.HTMLParser(encoding='utf8') <NEW_LINE> base = get_base_url(year) <NEW_LINE> url = '{base}/{league}top.html'.format(**locals()) <NEW_LINE> tree = lxml.html.parse(url, parser) <NEW_LINE> for tr_item in tq... | 規定打数に届いた選手を取得し, 打撃結果の json への url を含む DataFrame を作成する
:param str league: `"c"` or `"p"` (central or pacific)
:param int year: | 625941e876e4537e8c351af0 |
def refresh_if(self, p4, create_if_missing=False): <NEW_LINE> <INDENT> if self._needs_refresh(p4): <NEW_LINE> <INDENT> self._from_depot_file(self.repo_name, p4, create_if_missing) | If the Perforce copy of our config file has changed since the
last time we ran from_depot_file(), run it again. | 625941e826068e7796caf161 |
def semieixos(self): <NEW_LINE> <INDENT> a = self.matriu[0,0] <NEW_LINE> b = - self.matriu[1,1] <NEW_LINE> t = - 2 * self.matriu[2,3] <NEW_LINE> return (sqrt(t,a),sqrt(t,b)) | Retorna els semieixos del paraboloide hiperbòlic | 625941e8b5575c28eb68e47f |
def get_value_from_string(text): <NEW_LINE> <INDENT> if len(text.strip()) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> if '-' in text or '+' in text: <NEW_LINE> <INDENT> tl = [ti for ti in text.split('-')] <NEW_LINE> for i in range(1, len(tl)): <NEW_LINE> <INDENT> tl[i] = '-' + tl[... | Get float value from string expression. | 625941e8cc0a2c11143dd30d |
def get_descendants(self): <NEW_LINE> <INDENT> data = set() <NEW_LINE> def descendants(comment): <NEW_LINE> <INDENT> if comment.children: <NEW_LINE> <INDENT> data.update(comment.children) <NEW_LINE> for child in comment.children: <NEW_LINE> <INDENT> descendants(child) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> descendants(s... | 获取一级评论的所有子孙 | 625941e899fddb7c1c9de809 |
def contracted_nodes(G, u, v, self_loops=True): <NEW_LINE> <INDENT> H = G.copy() <NEW_LINE> if H.is_directed(): <NEW_LINE> <INDENT> in_edges = ((w, u, d) for w, x, d in G.in_edges(v, data=True) if self_loops or w != u) <NEW_LINE> out_edges = ((u, w, d) for x, w, d in G.out_edges(v, data=True) if self_loops or w != u) <... | Returns the graph that results from contracting ``u`` and ``v``.
Node contraction identifies the two nodes as a single node incident to any
edge that was incident to the original two nodes.
Parameters
----------
G : NetworkX graph
The graph whose nodes will be contracted.
u, v : nodes
Must be nodes in ``G``.
... | 625941e8dc8b845886cb59b1 |
def get_style(self, node): <NEW_LINE> <INDENT> if node.attrib.has_key("style"): <NEW_LINE> <INDENT> style = node.attrib.get('style') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> style = "" <NEW_LINE> <DEDENT> return style | Get the style attribute of the node if it exists. | 625941e823849d37ff7b3506 |
def getCount(data): <NEW_LINE> <INDENT> lines = len(data.split("\n")) <NEW_LINE> words = len(data.split()) <NEW_LINE> chars = len(data)-lines+1 <NEW_LINE> blanks = data.count(" ") <NEW_LINE> return lines, words, chars, blanks | Counts lines, words, chars in data | 625941e8a219f33f34628dde |
def cal_taxes(my_income, my_expenses): <NEW_LINE> <INDENT> keep_for_taxes = 0.0 <NEW_LINE> tax_rate = 0.30 <NEW_LINE> get_diff_taxRate = input("Is your tax rate 30% enter y/n: ") <NEW_LINE> if get_diff_taxRate == 'n': <NEW_LINE> <INDENT> tax_rate = input("Enter tax rate like so (0.25): ") <NEW_LINE> tax_rate = float(ta... | tax rate can be changed to what ever the user needs | 625941e816aa5153ce3628f3 |
def _Emit(self, template_source, parameters): <NEW_LINE> <INDENT> template = self._ParseTemplate(template_source) <NEW_LINE> parameter_bindings = self._bindings.Extend(parameters) <NEW_LINE> hole_names = template._holes <NEW_LINE> if hole_names: <NEW_LINE> <INDENT> hole_map = {} <NEW_LINE> replacements = {} <NEW_LINE> ... | Implementation of Emit, with map in place of named parameters. | 625941e873bcbd0ca4b2c4f0 |
def plotpoint(self): <NEW_LINE> <INDENT> location = self.__GeocodeCoor() <NEW_LINE> gmap = gmplot.GoogleMapPlotter(location.latitude, location.longitude, 20) <NEW_LINE> gmap.marker(location.latitude,location.longitude) | Returns a google map with the specified location from street and town. | 625941e84e4d5625662d484c |
def test_coupon_payment_serializer(): <NEW_LINE> <INDENT> payment = CouponPaymentFactory.build() <NEW_LINE> assert str(payment) == "CouponPayment {}".format(payment.name) <NEW_LINE> serialized = CouponPaymentSerializer(payment).data <NEW_LINE> assert serialized == { "name": payment.name, "created_on": None, "updated_on... | Test that the CouponPaymentSerializer has correct data | 625941e8a79ad161976cc5c1 |
def __init__(self, question): <NEW_LINE> <INDENT> self.question = question <NEW_LINE> self.responses = [] | 存储一个问题,并为存储答案做准备 | 625941e855399d3f05588b32 |
def PushApp(self, context, params): <NEW_LINE> <INDENT> return Xinge3Helper.PushApp(self.appId, self.secretKey, context, params) | TODO | 625941e8a8370b7717052d18 |
def get(self, request, pk, format=None): <NEW_LINE> <INDENT> queryset1 = Product.objects.values('name').filter( id__in=EnvironmentProductsList.objects.values('products').filter(org_id=pk)).distinct() <NEW_LINE> queryset2 = EnvironmentInstanceProduct.objects.values('name').filter( instance_id__in=EnvironmentInstance.obj... | The default get method, i.e on page load | 625941e899fddb7c1c9de80a |
def calculate_importance_sampling_weights(self, experiences): <NEW_LINE> <INDENT> td_errors = [experience.key for experience in experiences] <NEW_LINE> importance_sampling_weights = [ ( (1.0 / self.number_experiences_in_deque) * (self.give_adapted_sum_of_td_errors() / td_error) ) ** self.beta for td_error in td_errors ... | Calculates the importance sampling weight of each observation in the sample. The weight is proportional to the td_error of the observation,
see the paper here for more details: https://arxiv.org/pdf/1511.05952.pdf | 625941e850812a4eaa59c798 |
def testVariables(self): <NEW_LINE> <INDENT> data = mooseutils.PostprocessorReader(self._filename) <NEW_LINE> self.assertTrue(data) <NEW_LINE> self.assertIn('time', data.variables()) <NEW_LINE> for k in self._keys: <NEW_LINE> <INDENT> self.assertIn(k, data.variables()) | Test the the variables names are being read. | 625941e8d7e4931a7ee9e39a |
def reject(self, req, allowed_methods, *args, **kwargs): <NEW_LINE> <INDENT> raise webob.exc.HTTPMethodNotAllowed( headers=[('Allow', allowed_methods)]) | Return a 405 method not allowed error. As a convenience, the 'Allow'
header with the list of implemented methods is included in the
response as well. | 625941e8627d3e7fe0d692cd |
def var_count(self, kind): <NEW_LINE> <INDENT> return self.kind_indexes[kind] | Returns the number of variables of the given kind already defined in the current
scope.
:param kind: The name of the kind
:return: the counter for this kind according to kind_indexes dictionary | 625941e8eab8aa0e5d26dfd5 |
def setup(hass, config): <NEW_LINE> <INDENT> conf = config[DOMAIN] <NEW_LINE> username = conf.get(CONF_USERNAME) <NEW_LINE> password = conf.get(CONF_PASSWORD) <NEW_LINE> name = conf.get(CONF_NAME) <NEW_LINE> driver = conf.get(CONF_DRIVER) <NEW_LINE> import myusps <NEW_LINE> try: <NEW_LINE> <INDENT> cookie = hass.config... | Use config values to set up a function enabling status retrieval. | 625941e83cc13d1c6d3c77f3 |
def findSubstring(self, s, words): <NEW_LINE> <INDENT> if not words or not words[0]: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> m, n = len(words), len(words[0]) <NEW_LINE> res = [] <NEW_LINE> cur = 0 <NEW_LINE> while cur + m * n <= len(s): <NEW_LINE> <INDENT> tmp = words.copy() <NEW_LINE> for i in range(0, m): <... | 暴力解法 与 28. 实现strStr 类似
复制一个words列表到tmp,使用cur指针遍历s
切出和列表里的字符长度相等的字符判断是否存在于tmp列表里面,存在的话就在列表里面删除这个字符串,开始下一轮比较
如果tmp列表被删光了,说明words中的字符串能组成子串,res列表中添加cur
:type s: str
:type words: List[str]
:rtype: List[int] | 625941e8d164cc61757831cb |
def count_passwords(check_function: Callable, input_data: list) -> int: <NEW_LINE> <INDENT> return sum(check_function(line) for line in input_data) | Count correct passwords for specific password check function. | 625941e85fcc89381b1e1b3d |
def softLightBlendMode(self, backgroundImage=None): <NEW_LINE> <INDENT> attr = dict() <NEW_LINE> if backgroundImage: <NEW_LINE> <INDENT> attr["inputBackgroundImage"] = backgroundImage._ciImage() <NEW_LINE> <DEDENT> filterDict = dict(name="CISoftLightBlendMode", attributes=attr) <NEW_LINE> self._addFilter(filterDict) | Either darkens or lightens colors, depending on the input image sample color.
Attributes: `backgroundImage` an Image object. | 625941e8baa26c4b54cb1596 |
def test_get_query(client): <NEW_LINE> <INDENT> new_query = Query({"mynewquery": time.time()}) <NEW_LINE> new_query.save() <NEW_LINE> res = client.get("/query/%s" % new_query.id) <NEW_LINE> assert res.status_code == 200 <NEW_LINE> assert new_query.id == res.json["id"] <NEW_LINE> assert new_query.description == res.json... | Get an ID and a description
| 625941e8956e5f7376d712e7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.