code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def facet_parameters(self): <NEW_LINE> <INDENT> facets, dependencies = facetParameters(self.context, self.request) <NEW_LINE> return urlencode({'facet': 'true', 'facet.field': facets, }, doseq=True) | Return the facet parameters to be queried for as an url-encoded
string. | 625941da4c3428357757c5ed |
def removeDuplicates(self, nums): <NEW_LINE> <INDENT> pointer = 0 <NEW_LINE> while pointer < len(nums): <NEW_LINE> <INDENT> while pointer + 1 < len(nums) and nums[pointer + 1] == nums[pointer]: <NEW_LINE> <INDENT> del nums[pointer] <NEW_LINE> <DEDENT> pointer += 1 <NEW_LINE> <DEDENT> return len(nums) | :type nums: List[int]
:rtype: int | 625941da287bf620b61d3d29 |
def print_board_titles(grid_size): <NEW_LINE> <INDENT> column_number = 0 <NEW_LINE> column_number_list = [' '] <NEW_LINE> for number in range(grid_size): <NEW_LINE> <INDENT> column_number_list.append(str(column_number)) <NEW_LINE> column_number_list.append(' ') <NEW_LINE> column_number += 1 <NEW_LINE> <DEDENT> st... | Creates column numbers for the game board | 625941dad10714528d5fffac |
def test_find_enrichment(run_all=False): <NEW_LINE> <INDENT> if run_all: <NEW_LINE> <INDENT> fin_obo = join(REPO, 'go-basic.obo') <NEW_LINE> get_godag(fin_obo, optional_attrs={'relationship'}, loading_bar=None) <NEW_LINE> fin_gaf = join(REPO, 'goa_human.gaf') <NEW_LINE> dnld_annotation(fin_gaf) <NEW_LINE> for idx, cmd ... | RUn an enrichments using all annotation file formats | 625941dadc8b845886cb57fd |
def build_filter(exclude): <NEW_LINE> <INDENT> return build_custom(exclude, FileFilter() & FnmatchFilter('*.py'), NotFilter) | Construct a filter from a comma-separated string of fnmatch patterns. | 625941da8a43f66fc4b54329 |
def friendly_channel_type(channel_type: str) -> str: <NEW_LINE> <INDENT> if channel_type == "controlled_load": <NEW_LINE> <INDENT> return "Controlled Load" <NEW_LINE> <DEDENT> if channel_type == "feed_in": <NEW_LINE> <INDENT> return "Feed In" <NEW_LINE> <DEDENT> return "General" | Return a human readable version of the channel type. | 625941da76d4e153a657edf9 |
def rescaled_ISI_autocorrelation(self): <NEW_LINE> <INDENT> u = self.uniform_rescaled_ISIs() <NEW_LINE> u[u == 0] = np.finfo(float).eps <NEW_LINE> u[u == 1] = 1 - np.finfo(float).eps <NEW_LINE> normal_rescaled_ISIs = norm.ppf(u) <NEW_LINE> c = correlate(normal_rescaled_ISIs, normal_rescaled_ISIs) <NEW_LINE> return c / ... | Examine rescaled ISI dependence.
Should be independent if the transformation to unit rate Poisson
process fits well. | 625941da7cff6e4e81117c4c |
def key(self, value): <NEW_LINE> <INDENT> return 'under construction' | return key from registry value and return | 625941da45492302aab5e58d |
def select_project(proj_selection_str): <NEW_LINE> <INDENT> if globs.selected_project is None and proj_selection_str is None: <NEW_LINE> <INDENT> raise TypeError("No selection provided") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if None not in (proj_selection_str, globs.selected_project) and globs.selected_project ... | Parse the string returned by the index page form. Three strings separated by a semicolon are expected by default.
If the last one (subproject in our use case) is missing, an empty list is appended to the returned list,
which is subsequently disregarded by looper.Project.__init__ and no subproject is activated
:param s... | 625941da004d5f362079a5f9 |
def upload_raster( self, name: str, mime: str, content: bytes, size: int, callback: Callable ) -> None: <NEW_LINE> <INDENT> data = json.dumps({"name": name}).encode('utf-8') <NEW_LINE> resp = self._http( method=HttpMethod.POST, endpoint='rasters/upload/file/', data=data, size=len(data), mime="application/json") <NEW_LI... | Upload and process an image from local
Given a raster file, launches an upload and starts a polling
in a thread for its completion
Args:
name: name for the raster
mime: MIME type for the raster (e.g. 'image/tiff')
content: byte content of the raster image
size: size in bytes of the image
callback:... | 625941da8c3a873295158684 |
def cli_command(command_key): <NEW_LINE> <INDENT> def _decorator(fn): <NEW_LINE> <INDENT> @functools.wraps(fn) <NEW_LINE> @events.subscriber(events.command_key(command_key), unique=True) <NEW_LINE> def wrapper(args): <NEW_LINE> <INDENT> log.logger.debug('Executing command "%s". Args: "%s"', command_key, args) <NEW_LINE... | Decorator for registering and logging CLI commands | 625941daa4f1c619b28b02fa |
def transformFromCRSToCRS(self, sourceCRS, destCRS): <NEW_LINE> <INDENT> if (sourceCRS is not None) and (destCRS is not None) and sourceCRS != destCRS: <NEW_LINE> <INDENT> coordTransform = QgsCoordinateTransform(sourceCRS, destCRS) <NEW_LINE> self.center = coordTransform.transform(self.center) | Transform this geometry as described by CRS. | 625941da57b8e32f52483763 |
def on_batch_end(self, batch, logs=None): <NEW_LINE> <INDENT> logs = logs or {} <NEW_LINE> if not hasattr(self, '_t_enter_batch'): <NEW_LINE> <INDENT> self._t_enter_batch = time.time() <NEW_LINE> <DEDENT> self._delta_t_batch = time.time() - self._t_enter_batch <NEW_LINE> t_before_callbacks = time.time() <NEW_LINE> for ... | Called at the end of a batch.
Arguments:
batch: integer, index of batch within the current epoch.
logs: dictionary of logs. | 625941da73bcbd0ca4b2c33d |
def split_protocol_banner(protocol_validity_json, raw_file_path, raw_file_name, result_path): <NEW_LINE> <INDENT> string_file_name = raw_file_name.split(".")[0] + "_stringok.txt" <NEW_LINE> ok_file_name = raw_file_name.split(".")[0] + "_ok.json" <NEW_LINE> error_file_name = raw_file_name.split(".")[0] + "_error.json" <... | 分割原始文件,将个协议标语文件按照ok和error进行分割
:param protocol_validity_json: 协议过滤json的方法
:param raw_file_path: 原始json文件所在路径
:param raw_file_name: 原始文件名称
:param result_path: 结果文件所在路径
:return: | 625941da07f4c71912b1174b |
def load_package_yaml(self, pkgname, parameters): <NEW_LINE> <INDENT> from .package import eval_condition <NEW_LINE> docs = self._yaml_cache.get(('package', pkgname), None) <NEW_LINE> if docs is None: <NEW_LINE> <INDENT> result = self.file_resolver.glob_files([pkgname + '.yaml', pjoin(pkgname, pkgname + '.yaml'), pjoin... | Loads mypkg.yaml from either $pkgs/mypkg.yaml or
$pkgs/mypkg/mypkg-*.yaml, and caches the result of loading all
of them. In case of many matches, any when'-clause is
evaluated on `parameters` and a single document should result,
otherwise an exception is raised. A document without a when-clause
is overridden by those w... | 625941daa4f1c619b28b02fb |
def findIntegers(self, num): <NEW_LINE> <INDENT> dp = [0]*(num+1) <NEW_LINE> dp[0] = 1 <NEW_LINE> def isConsecutive(n): <NEW_LINE> <INDENT> return (n & (n >> 1)) <NEW_LINE> <DEDENT> for i in range(1,num+1): <NEW_LINE> <INDENT> j = i-1 <NEW_LINE> while j >= 0 and isConsecutive(j): <NEW_LINE> <INDENT> j -= 1 <NEW_LINE> <... | :type num: int
:rtype: int | 625941da6aa9bd52df03706c |
def area(self) -> float: <NEW_LINE> <INDENT> return multiply_by_pi(calculate_square_of(self._radius())) | Method calculates the area for the given Circle instance | 625941da4f88993c3716c32c |
def get_screenshot_as_file(self, filename): <NEW_LINE> <INDENT> return self._selenium_web_driver().get_screenshot_as_file(filename) | Gets the screenshot of the current window. Returns False if there is
any IOError, else returns True. Use full paths in your filename.
:param filename: The full path you wish to save your screenshot to.
:Usage:
driver.get_screenshot_as_file('/Screenshots/foo.png') | 625941da3d592f4c4ed1d32f |
def get_dom_element_id(self): <NEW_LINE> <INDENT> return '%s%s' % (self.entry_type_id, self.review.pk) | Return the ID used for the DOM element for this entry.
Returns:
unicode:
The ID used for the element. | 625941da009cb60464c63677 |
def _post_process_successors(self, simrun, successors): <NEW_LINE> <INDENT> if isinstance(simrun, simuvex.SimIRSB) and simrun.initial_state.thumb: <NEW_LINE> <INDENT> successors = self._arm_thumb_filter_jump_successors(simrun.addr, successors, lambda state: state.scratch.ins_addr, lambda state: state.scratch.exit_stmt_... | Filter the list of successors
:param simuvex.SimIRSB simrun: The SimRun instance.
:param list successors: A list of successors generated by the simrun.
:return: A list of successors
:rtype: list | 625941da4c3428357757c5ee |
def _get_module_info(usage_key, rewrite_static_links=True): <NEW_LINE> <INDENT> store = get_modulestore(usage_key) <NEW_LINE> try: <NEW_LINE> <INDENT> module = store.get_item(usage_key) <NEW_LINE> <DEDENT> except ItemNotFoundError: <NEW_LINE> <INDENT> if usage_key.category in CREATE_IF_NOT_FOUND: <NEW_LINE> <INDENT> st... | metadata, data, id representation of a leaf module fetcher.
:param usage_key: A UsageKey | 625941da9f2886367277ab53 |
def action_pause_for_user(self, message, **kwargs): <NEW_LINE> <INDENT> userinput = 0 <NEW_LINE> while userinput != 'y': <NEW_LINE> <INDENT> userinput = str.lower(raw_input('{}\n(Type \'y\' to continue)\n'.format(message))) | print a message to the user and wait for a response. The content
of the user's reply will not be stored or used. This allows indefinate pauses
for user action. For example, changing the vertical position of the insert, which
has to be done manually. Any result of the user action which needs to be measured
should still ... | 625941da3346ee7daa2b3034 |
def list(self): <NEW_LINE> <INDENT> return [ self._scalar ] | Return the list of coefficient of this twisted derivation
on the canonical basis.
EXAMPLES::
sage: R.<x,y> = QQ[]
sage: K = R.fraction_field()
sage: theta = K.hom([y,x])
sage: M = K.derivation_module(twist=theta)
sage: M.basis()
Family (twisting_morphism - id,)
sage: f = (x+y) * M.gen()
... | 625941da091ae35668667221 |
def main(): <NEW_LINE> <INDENT> file_name = "listOfServices.csv" <NEW_LINE> service_list = read_csv_to_list(file_name) <NEW_LINE> sql_string = create_sql_string(service_list) <NEW_LINE> save_to_sql_file(sql_string, "output.sql") | Main function which results in writing SQL file | 625941daab23a570cc25044b |
def twoway_colors( n1: int, n2: int, hue_start: float = 0.2, hue_shift: float = 0., hues: Sequence[float] = None, lightness: Union[float, Sequence[float]] = None, ): <NEW_LINE> <INDENT> if hues is None: <NEW_LINE> <INDENT> hues = np.linspace(hue_start, hue_start + 1, n1, False) % 1. <NEW_LINE> <DEDENT> else: <NEW_LINE>... | Create colors for two-way interaction
Parameters
----------
n1
Number of levels on the first factor.
n2
Number of levels on the second factor.
hue_start : 0 <= scalar < 1
First hue value.
hue_shift : 0 <= scalar < 1
Use that part of the hue continuum between categories to shift hue
within categorie... | 625941da1b99ca400220ad79 |
def decomposition(self, *args, **kwargs): <NEW_LINE> <INDENT> pass | Returns the character decomposition mapping assigned to the character chr as string.
An empty string is returned in case no such mapping is defined. | 625941dac432627299f04f0f |
def _do(self): <NEW_LINE> <INDENT> pass | Called at the end of the ``do()`` method. | 625941dabf627c535bc13496 |
def setActionRole(self, role): <NEW_LINE> <INDENT> self.__menu.setActionRole(role) | Set the action role in model.
This is an item role in `model` that returns a QAction for the item.
Parameters
----------
role : Qt.ItemDataRole | 625941da44b2445a3393235c |
def addXref(self, fromva, tova, reftype, rflags=0): <NEW_LINE> <INDENT> ref = (fromva, tova, reftype, rflags) <NEW_LINE> if ref in self.getXrefsFrom(fromva): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._fireEvent(VWE_ADDXREF, (fromva, tova, reftype, rflags)) | Add an xref with the specified fromva, tova, and reftype
(see REF_ macros). This will *not* trigger any analysis.
Callers are expected to do their own xref analysis (ie, makeCode() etc) | 625941da8e71fb1e9831da70 |
def compute_parking_travel_time(self): <NEW_LINE> <INDENT> self._static_parking_travel_time = collections.defaultdict(list) <NEW_LINE> parkings = [] <NEW_LINE> for parking in self._parking_db.values(): <NEW_LINE> <INDENT> pid = parking['sumo']['id'] <NEW_LINE> edge = parking['sumo']['lane'].split('_')[0] <NEW_LINE> end... | For each parking, saves the parkings reachable by 'passenger' vClass where the weight
is the travel time at the current stage of the simulation.
Each call of the funcion destroy the previous state. | 625941da6fb2d068a760f368 |
def __init__(self, a): <NEW_LINE> <INDENT> pass | void QByteArray.__init__(QByteArray a) | 625941dae1aae11d1e749f81 |
def setup_i18n(self): <NEW_LINE> <INDENT> locale_name = self.locale <NEW_LINE> root = os.path.abspath( os.path.join( os.path.dirname(__file__), os.pardir)) <NEW_LINE> translation_path = os.path.join( root, 'i18n', 'inasafe_' + str(locale_name) + '.qm') <NEW_LINE> if os.path.exists(translation_path): <NEW_LINE> <INDENT>... | Setup internationalisation for the reports.
Args:
None
Returns:
None.
Raises:
TranslationLoadException | 625941dae76e3b2f99f3aacf |
def run(self) -> None: <NEW_LINE> <INDENT> if self.running or self.finished: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self.running = True <NEW_LINE> while True: <NEW_LINE> <INDENT> future = self.future <NEW_LINE> if future is None: <NEW_LINE> <INDENT> raise Exception("No pending future") ... | Starts or resumes the generator, running until it reaches a
yield point that is not ready. | 625941dabe7bc26dc91cd8c3 |
def test_getint_default(config): <NEW_LINE> <INDENT> assert config.getint('missing', default=1) == 1 | Tests :py:method:`Config.getint` bad path with default. | 625941da07d97122c4178b58 |
def _arith_op(self, s2, op): <NEW_LINE> <INDENT> if isinstance(s2, Spectrum): <NEW_LINE> <INDENT> return self._spec_arith_op(s2, op, inplace=False) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> newobj = copy.deepcopy(self) <NEW_LINE> newobj.core_y = op(newobj.core_y, s2) <NEW_LINE> if newobj.co... | Do the arithmetic operations
:param s2: an instance of Spectrum
:type s2: Spectrum,float
:param op: numpy ufunc, such as np.add, np.substract, np.multiply, np.divide
:return: the new Spectrum instance. | 625941daf8510a7c17cf99c5 |
def poisson_likelihood_full(image, prediction, spe_width, ped, width_fac=3, dtype=np.float32): <NEW_LINE> <INDENT> image = np.asarray(image, dtype=dtype) <NEW_LINE> prediction = np.asarray(prediction, dtype=dtype) <NEW_LINE> spe_width = np.asarray(spe_width, dtype=dtype) <NEW_LINE> ped = np.asarray(ped, dtype=dtype) <N... | Calculate likelihood of prediction given the measured signal,
full numerical integration from de Naurois et al 2009.
The width factor included here defines the range over
which photo electron contributions are summed, and is
defined as a multiple of the expected resolution of
the highest amplitude pixel. For most appl... | 625941dad164cc6175783016 |
def signal(self): <NEW_LINE> <INDENT> rnd_gen = RandomState(self.seed) <NEW_LINE> ma = self.handle_empty_coefficients(self.ma) <NEW_LINE> ar = self.handle_empty_coefficients(self.ar) <NEW_LINE> sos = tf2sos(ma, ar) <NEW_LINE> ntaps = ma.shape[0] <NEW_LINE> sdelay = round(0.5*(ntaps-1)) <NEW_LINE> wnoise = self.rms*rnd_... | Deliver the signal.
Returns
-------
Array of floats
The resulting signal as an array of length :attr:`~SignalGenerator.numsamples`. | 625941daec188e330fd5aa62 |
def download_pdb(self): <NEW_LINE> <INDENT> if (re.match(r"[1-9]\w\w\w", self.pdb_id) is None) or len(self.pdb_id) != 4: <NEW_LINE> <INDENT> raise ValueError('Input data does not conform to pdb standard') <NEW_LINE> <DEDENT> file_name = self.data_path + self.pdb_id + '.pdb' <NEW_LINE> if os.path.isfile(file_name) is Tr... | Downloads pdb file from rcsb.org.
For downloading uses the URL supplied by rcsb.org for uncompressed pdb files.
If given data path is not existing it is created. If the file already exists, download is not performed.
Raises:
ValueError: The supplied PDB-Id does not conform to the format standard. | 625941da1b99ca400220ad7a |
def load_sessions(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def wrapper(*args, **kwargs): <NEW_LINE> <INDENT> raw_sessions = get_raw_sessions(kwargs.pop('sessions_dir', None)) <NEW_LINE> sessions = parse_raw_sessions( raw_sessions, kwargs.pop('from_date', None), kwargs.pop('to_date', None) ) <NEW_LINE> return ... | Loads parsed sessions as a first argument of a function | 625941daa17c0f6771cbe317 |
def pv_wb_generator(batch_size = 64): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> xv = np.zeros((batch_size, 2)) <NEW_LINE> pvb = np.zeros((batch_size, 3)) <NEW_LINE> speeds = np.random.uniform(0,0.1,size=batch_size) <NEW_LINE> if np.random.rand() > 0.5: <NEW_LINE> <INDENT> x = 1-np.random.uniform(0, 2*speeds) ... | Generator for bounce. Border 0 or 1 is chosen randomly for the whole batch.
Yields: in coordinate and speed, output is time p (1 frame is 1) to bounce and new speed vp. | 625941da0a366e3fb873eae4 |
def ensemble_inference(model, x_in, n_ensemble, nclass): <NEW_LINE> <INDENT> batch = x_in.size(0) <NEW_LINE> prob = torch.zeros(batch, nclass).to(x_in) <NEW_LINE> softmax = nn.Softmax(dim=1) <NEW_LINE> with torch.no_grad(): <NEW_LINE> <INDENT> for _ in range(n_ensemble): <NEW_LINE> <INDENT> p = softmax(model(x_in)) <NE... | Get prediction nresult by averaging multiple forward | 625941da566aa707497f482d |
def local_position_callback(self): <NEW_LINE> <INDENT> if self.flight_state == States.TAKEOFF: <NEW_LINE> <INDENT> altitude = -1.0 * self.local_position[2] <NEW_LINE> if altitude > 0.95 * self.mission_altitude: <NEW_LINE> <INDENT> self.waypoint_transition() <NEW_LINE> <DEDENT> <DEDENT> elif self.flight_state == States.... | TODO: Implement this method
This triggers when `MsgID.LOCAL_POSITION` is received and self.local_position contains new data | 625941da3539df3088e2e612 |
def create_cloud_front_origin_access_identity(region=None, key=None, keyid=None, profile=None, **kwargs): <NEW_LINE> <INDENT> retries = 10 <NEW_LINE> sleep = 6 <NEW_LINE> kwargs = {k: v for k, v in kwargs.items() if not k.startswith('_')} <NEW_LINE> conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)... | Create a CloudFront origin access identity with the provided configuration details.
CloudFrontOriginAccessIdentityConfig
The origin access identity's configuration information.
region
Region to connect to.
key
Secret key to use.
keyid
Access key to use.
profile
Dict, or pillar key pointing to a... | 625941da7d847024c06be586 |
def test_numcharref_expansion_lxml(self): <NEW_LINE> <INDENT> rec = bibrecord.create_records(self.xml, verbose=1, correct=1, parser='lxml')[0][0] <NEW_LINE> self.assertEqual(rec, self.rec_expected) | bibrecord - numcharref expansion with lxml | 625941da9b70327d1c4e109d |
def is_widget_required_attribute(widget): <NEW_LINE> <INDENT> if not get_bootstrap_setting('set_required'): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if not widget.is_required: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if isinstance( widget, ( AdminFileWidget, HiddenInput, FileInput, CheckboxSelec... | Is this widget required? | 625941da3617ad0b5ed681be |
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <... | Returns the model properties as a dict | 625941da236d856c2ad44aa5 |
def post_buckets_id_labels_with_http_info(self, bucket_id, label_mapping, **kwargs): <NEW_LINE> <INDENT> local_var_params = locals() <NEW_LINE> all_params = ['bucket_id', 'label_mapping', 'zap_trace_span'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_pa... | Add a label to a bucket.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_buckets_id_labels_with_http_info(bucket_id, label_mapping, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str bucket_id: The ... | 625941da0c0af96317bb84b0 |
def h_levelsum(self) -> int: <NEW_LINE> <INDENT> level_sum = 0 <NEW_LINE> for goal in self.problem.goal: <NEW_LINE> <INDENT> found = False <NEW_LINE> for i, literals in enumerate(self.s_levels): <NEW_LINE> <INDENT> for literal in literals: <NEW_LINE> <INDENT> if literal.literal == goal: <NEW_LINE> <INDENT> level_sum +=... | The sum of the level costs of the individual goals (admissible if goals independent)
:return: int | 625941da29b78933be1e5970 |
def dispatch(self,obj,name): <NEW_LINE> <INDENT> if type(obj) is dict: <NEW_LINE> <INDENT> self.dict(obj,name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if self.typeok(obj,name): <NEW_LINE> <INDENT> self.storevalue(obj,name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> logging.warning('XTCAV Constants.py: variable... | either persist a supported object, or look into a dictionary
to see what objects need to be persisted | 625941da3cc13d1c6d3c7641 |
def math_question3(x, b): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return int(np.base_repr(x, base=b)) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return None | A function that takes two integers (x and b) as inputs and returns a string
that represents the number x in base b
Example 1: if x=5 and b=2 then the function will return "101"
Example 2: if x=5 and b=3 then the function will return "12"
:param int x: integer
:param int b: base
:return value of function, None if in... | 625941da96565a6dacc8f992 |
def write_salicus_flexus(i, j, k, last_glyph, lique=L_NOTHING): <NEW_LINE> <INDENT> new_glyph() <NEW_LINE> glyph_name = '%s%s%s%s%s' % (S_SALICUS_FLEXUS, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique) <NEW_LINE> if copy_existing_glyph(glyph_name): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> is_deminutus = last_glyph == ... | Writes the salicus glyphs. | 625941dacc0a2c11143dd159 |
def new_stream(self, conn, addr): <NEW_LINE> <INDENT> t = threading.Thread(target=self.handle_request, args=(conn, addr)) <NEW_LINE> t.start() <NEW_LINE> self.threads.append(t) | Make thread for each client | 625941da82261d6c526ab76b |
def tabulate_function(f, xvals, yvals=None, dtype=None, ufunc=0): <NEW_LINE> <INDENT> if yvals is None: <NEW_LINE> <INDENT> xvals = numpy.asarray(xvals, dtype) <NEW_LINE> if ufunc: <NEW_LINE> <INDENT> return f(xvals) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if dtype is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <IN... | Evaluate and tabulate a function on a 1- or 2-D grid of points.
f should be a function taking one or two floating-point
parameters.
If f takes one parameter, then xvals should be a 1-D array and
yvals should be None. The return value is a numpy array
'[f(x[0]), f(x[1]), ..., f(x[-1])]'.
If f takes two parameters, t... | 625941da73bcbd0ca4b2c33e |
def radiationExposure(start, stop, step): <NEW_LINE> <INDENT> pos = start <NEW_LINE> amount = 0 <NEW_LINE> while (pos < stop): <NEW_LINE> <INDENT> r = f(pos) <NEW_LINE> amount += (step*r) <NEW_LINE> pos += step <NEW_LINE> <DEDENT> return amount | Computes and returns the amount of radiation exposed
to between the start and stop times. Calls the
function f (defined for you in the grading script)
to obtain the value of the function at any point.
start: integer, the time at which exposure begins
stop: integer, the time at which exposure ends
step: float, the wid... | 625941da4d74a7450ccd448b |
def zscore(x): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> m = x.mean(axis=(_t_dim, _ev_dim), keepdims=True) <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> raise _chk_parameters(comp0=comp0) <NEW_LINE> <DEDENT> s = x.std(axis=(_t_dim, _ev_dim), keepdims=True) <NEW_LINE> masked_x = np.ma.array(x, mask=np.ab... | Computes (in place) a robust zscore of the data, using the trimmed
mean and std.
Parameters
----------
x : array
Data with shape equal to comp0.shape
Returns
-------
y : array
Normalized data, with shape equal to comp0.shape | 625941da45492302aab5e58e |
def is_not_authorized(item_id): <NEW_LINE> <INDENT> item = Item.query.get(int(item_id)) <NEW_LINE> return item.user.id != current_user.id | is_not_authorized checks if user is not authorized to access a page
This means he is not the one who created that item | 625941dabe8e80087fb20f07 |
def test_login_with_user(self): <NEW_LINE> <INDENT> request = self.factory.get('/accounts/login') <NEW_LINE> request.user = self.user <NEW_LINE> response = login(request) <NEW_LINE> self.assertEqual(response.status_code, 302) | Test logging in with a valid user. | 625941da3539df3088e2e613 |
def PermutationWithoutRepetition(n, r): <NEW_LINE> <INDENT> if type(n) != int or type(r) != int or (n <= 0) or not 0 < r <= n: <NEW_LINE> <INDENT> raise RuntimeError("Wrong arguments") <NEW_LINE> <DEDENT> return int(factorial(n)/factorial(n-r)) | Calculates amount of permutaions of r in n variables without repetition is possible
E.g n=4 (1,2,3,4), r=2, variants:
12
13
14
21
23
24
31
32
34
41
42
43
Order does matter!!! 21 != 12
Parameters
----------
n : int
Amount of different types. Positive integer.
r : int
Amount of selected types. Positive in... | 625941da97e22403b379d263 |
def run() -> None: <NEW_LINE> <INDENT> args = parse_args() <NEW_LINE> setup_logging(args) <NEW_LINE> config = read_config(args.config) <NEW_LINE> pushbroom(config, args.dry_run) | Main entry point | 625941dab5575c28eb68e2ca |
def _send(self, msg=None): <NEW_LINE> <INDENT> if msg is None: <NEW_LINE> <INDENT> addresses = self._mailAddress <NEW_LINE> if isinstance(self._mailAddress, six.string_types): <NEW_LINE> <INDENT> addresses = self._mailAddress.split(", ") <NEW_LINE> <DEDENT> result = self._create(addresses) <NEW_LINE> if not result["OK"... | send a single email message. If msg is in input, it is expected to be of email type, otherwise it will create it.
:param object msg: MIMEMultipart object
:return: S_OK()/S_ERROR() | 625941dacdde0d52a9e532fd |
def copy_blob(self, blob: Blob, to_bucket: Bucket): <NEW_LINE> <INDENT> assert isinstance(blob, GoogleCloudStorageBlob) <NEW_LINE> assert isinstance(to_bucket, GoogleCloudStorageBucket) <NEW_LINE> self._log.info('Copying %s to bucket %s', blob, to_bucket) <NEW_LINE> return self._gcs_bucket.copy_blob(blob.gblob, to_buck... | Copies the given blob from this bucket to the other bucket.
Returns the new blob. | 625941dabe383301e01b5749 |
def _validate_variations(self): <NEW_LINE> <INDENT> weights = [float(variation['weight']) for variation in self.variations] <NEW_LINE> if sum(weights) > 1.0: <NEW_LINE> <INDENT> raise ValueError('The sum of all your weights should not exceed 1.0') | Validate that all the weight for each variation is a valid float number and the sum of all weight is <= 1
:raises TypeError or ValueError: is the validation fails | 625941dabd1bec0571d908f7 |
def store_single_value(self, key: str, value: bytes, replace: bool = False) -> int: <NEW_LINE> <INDENT> file_index = self.read_file_index() <NEW_LINE> for file in file_index: <NEW_LINE> <INDENT> if file['path'] == key: <NEW_LINE> <INDENT> if replace: <NEW_LINE> <INDENT> self.drop_file(file['file_id']) <NEW_LINE> <DEDEN... | Store value as file with key as path.
Returns created Files.file_id. | 625941dafbf16365ca6f6490 |
def AppendSInt64(self, field_number, value): <NEW_LINE> <INDENT> self._AppendTag(field_number, wire_format.WIRETYPE_VARINT) <NEW_LINE> zigzag_value = wire_format.ZigZagEncode(value) <NEW_LINE> self._stream.AppendVarUInt64(zigzag_value) | Appends a 64-bit integer to our buffer, zigzag-encoded and then
varint-encoded. | 625941da76d4e153a657edfa |
def manual_import(self, **kwargs): <NEW_LINE> <INDENT> url_params = { 'folder': kwargs.get('folder', '/'), 'sort_by': kwargs.get('sort_by', 'qualityWeight'), 'order': kwargs.get('sort_by', 'desc'), 'apikey': self.api_key } <NEW_LINE> path = '/api/manualimport' <NEW_LINE> res = self.request_get(path, **url_params) <NEW_... | Manual import command
Kwargs:
folder (str): Folder to manually look at. Default is '/'.
sort_by (str): What field to sort by. Default is
'qualityWeight'.
order (str): desc or asc. Default is 'desc'
Returns:
requests.models.Response: Response object form requests. | 625941daf548e778e58cd847 |
def record_op_stat(self): <NEW_LINE> <INDENT> self.generate_attrs(self.policy, True) | Record Op Calling Statistics | 625941daf9cc0f698b1408c1 |
def get_chan_spec_exp(inpname,camera=None): <NEW_LINE> <INDENT> basename=os.path.basename(inpname) <NEW_LINE> if basename == "": <NEW_LINE> <INDENT> print("can't parse input file name") <NEW_LINE> sys.exit("can't parse input file name {}".format(inpname)) <NEW_LINE> <DEDENT> brk=string.split(inpname,'-') <NEW_LINE> if ... | Get channel, spectrograph and expid from the filename itself
Args:
inpname: can be raw or pix, or frame etc filename
camera: is required for raw case, eg, r0, b5, z8
irrelevant for others | 625941da94891a1f4081bd72 |
def test_to_nfa_alphabet_a_tt_and_tt_and_tt_and_ff(self): <NEW_LINE> <INDENT> tt = LogicalTrue() <NEW_LINE> ff = LogicalFalse() <NEW_LINE> tt_and_tt_and_tt_and_ff = And(tt, And(tt, And(tt, ff))) <NEW_LINE> a = self.a_sym <NEW_LINE> x = self.ldlf_a.to_nfa(tt_and_tt_and_tt_and_ff) <NEW_LINE> alphabet = {frozenset(), froz... | tt AND ff | 625941da796e427e537b0890 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, InlineResponse20042Questions): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941dadd821e528d63b470 |
def cookies(self, sysop = False): <NEW_LINE> <INDENT> self._loadCookies(sysop = sysop) <NEW_LINE> index = self._userIndex(sysop) <NEW_LINE> if self._cookies[index]: <NEW_LINE> <INDENT> outputDatas = "" <NEW_LINE> for k, v in self._cookies[index].iteritems(): <NEW_LINE> <INDENT> if v: <NEW_LINE> <INDENT> outputDatas += ... | Return a string containing the user's current cookies. | 625941da287bf620b61d3d2a |
def setDegree(self, grammaticalDegree): <NEW_LINE> <INDENT> self.grammaticalDegree = grammaticalDegree | Assign the given grammatical degree to this word form. | 625941da4527f215b584c71c |
def __init__(self, snmp_object): <NEW_LINE> <INDENT> self.snmp_object = snmp_object <NEW_LINE> super().__init__(snmp_object, '', tags=['layer3']) | Function for intializing the class.
Args:
snmp_object: SNMP Interact class object from snmp_manager.py
Returns:
None | 625941dac432627299f04f10 |
def get_user_handles(self): <NEW_LINE> <INDENT> return self.data.user_handle.unique() | Get all the unique user handles associated with this dataframe | 625941da31939e2706e4d12f |
def store_ticket(tkt, tkt_spool_dir): <NEW_LINE> <INDENT> _LOGGER.info('store ticket: %s', tkt.princ) <NEW_LINE> if not tkt.ticket: <NEW_LINE> <INDENT> _LOGGER.info('Ticket pending for %r', tkt.princ) <NEW_LINE> return False <NEW_LINE> <DEDENT> _LOGGER.info('Refreshing ticket for %r', tkt.princ) <NEW_LINE> tkt.write() ... | Store ticket received from ticket locker. | 625941da0a50d4780f66715d |
def test_setter_size_type(self): <NEW_LINE> <INDENT> Base._Base__nb_objects = 0 <NEW_LINE> self.assertRaises(TypeError, Square) <NEW_LINE> self.assertRaises(TypeError, Square, [1, 2]) <NEW_LINE> self.assertRaises(TypeError, Square, (1, 2)) <NEW_LINE> self.assertRaises(TypeError, Square, 12.5) <NEW_LINE> self.assertRais... | Test errors from setter | 625941da004d5f362079a5fa |
def validate_rows(board: list): <NEW_LINE> <INDENT> for row in board: <NEW_LINE> <INDENT> numbers = set() <NEW_LINE> for element in row: <NEW_LINE> <INDENT> if element not in('*', ' '): <NEW_LINE> <INDENT> if element in numbers: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> numbers.add(element) <NEW_LINE> <DEDEN... | Gets board configuration and returns True if all rows has not repeating
numbers
>>> validate_rows(["**** ****", "***1 ****", "** 3****", "* 4 1****", " 9 5 ", " 6 83 *", "3 1 **", " 8 2***", " 2 ****"])
True | 625941da15fb5d323cde0ddb |
def __init__(self, sess, input_height=108, input_width=108, crop=True, batch_size=64, sample_num = 64, output_height=64, output_width=64, y_dim=None, z_dim=100, gf_dim=64, df_dim=64, gfc_dim=1024, dfc_dim=1024, c_dim=3, dataset_name='default', input_fname_pattern='*.jpg', checkpoint_dir=None, sample_dir=None): <NEW_LIN... | Args:
sess: TensorFlow session
batch_size: The size of batch. Should be specified before training.
y_dim: (optional) Dimension of dim for y. [None]
z_dim: (optional) Dimension of dim for Z. [100]
gf_dim: (optional) Dimension of gen filters in first conv layer. [64]
df_dim: (optional) Dimension of discrim fi... | 625941da07d97122c4178b59 |
def __init__(self, **args): <NEW_LINE> <INDENT> self.type = CODE_CRS <NEW_LINE> self.k = 4 <NEW_LINE> self.m = 2 <NEW_LINE> self.w = 4 <NEW_LINE> self.packet_size = 512 <NEW_LINE> self.block_size = 1024 <NEW_LINE> try: <NEW_LINE> <INDENT> for (key, value) in args.items(): <NEW_LINE> <INDENT> if key == 'k': <NEW_LINE> <... | init the crs driver with args | 625941da15fb5d323cde0ddc |
def model(data, train=False): <NEW_LINE> <INDENT> conv = helpers.conv2d(data, name="conv1", kernel_width=5, num_filters=32, transfer=tf.nn.relu, decay_rate=DECAY_RATE) <NEW_LINE> print("After first conv: "+str(conv.get_shape())) <NEW_LINE> pool = helpers.pool(conv, name="pool1", kernel_width=2) <NEW_LINE> print("After ... | The Model definition. | 625941daff9c53063f47c4bb |
def build_nested_dict(entries): <NEW_LINE> <INDENT> result = {} <NEW_LINE> if not entries: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> for raw_path, value in entries.items(): <NEW_LINE> <INDENT> path = sanitize(raw_path) <NEW_LINE> basename = os.path.basename(path) <NEW_LINE> subpaths = path.split('/')[1:] <NEW_L... | Convert a flat dict of paths to a nested dict. | 625941da32920d7e50b2849b |
def comment_action_hook(sender, instance, created, **kwargs): <NEW_LINE> <INDENT> if not created: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> prof = UserProfile.objects.get(user=instance.user) <NEW_LINE> prof.rank_pts += 3 <NEW_LINE> prof.save() <NEW_LINE> action.send( instance.user, action_object = instance, t... | Action hook for comments - inform other people about the fact that
this comment was created and increase the amount of user points
accordingly. | 625941da046cf37aa974d00e |
def find_DCM_files_parallel(rootpath=None): <NEW_LINE> <INDENT> time_zero = time.time() <NEW_LINE> dcmFileList = [] <NEW_LINE> for root, dirs, files in os.walk(rootpath): <NEW_LINE> <INDENT> for file in files: <NEW_LINE> <INDENT> if file.endswith('.dcm'): <NEW_LINE> <INDENT> fullpath = os.path.join(root, file) <NEW_LIN... | Walk rootpath input directory, find all '*.dcm' files | 625941da7cff6e4e81117c4e |
def __init__(self, D, DT, M, C): <NEW_LINE> <INDENT> self.D = D <NEW_LINE> self.DT = DT <NEW_LINE> self.M = M <NEW_LINE> self.C = C <NEW_LINE> self.size = C.size <NEW_LINE> self.context = None <NEW_LINE> self.ksp = PETSc.KSP().create() <NEW_LINE> self.ksp.create(PETSc.COMM_WORLD) <NEW_LINE> self.ksp.setType("cg") <NEW_... | | M DT | |v| |f1|
| | | | = | |
| D C | |p| |f2| | 625941da2eb69b55b151cb7b |
def log_error( self, msg ): <NEW_LINE> <INDENT> self.logger.error( msg ) | Records record at error level | 625941dacad5886f8bd272a1 |
def db_for_read(self, model, **hints): <NEW_LINE> <INDENT> if model._meta.app_label == 'interpreter': <NEW_LINE> <INDENT> return 'interpreter_db' <NEW_LINE> <DEDENT> return None | Send all read operations on interpreter app models to `interpreter_db`. | 625941dacad5886f8bd272a2 |
def move(self, direction: str) -> int: <NEW_LINE> <INDENT> cur_pos = self.positions[-1] <NEW_LINE> move = self.moves[direction] <NEW_LINE> new_pos = cur_pos[0] + move[0], cur_pos[1] + move[1] <NEW_LINE> if new_pos[0] == self.height or new_pos[0] == -1 or new_pos[1] == self.width or new_pos[1] == -1 or (new_pos in self.... | Moves the snake.
@param direction - 'U' = Up, 'L' = Left, 'R' = Right, 'D' = Down
@return The game's score after the move. Return -1 if game over.
Game over when snake crosses the screen boundary or bites its body. | 625941da004d5f362079a5fb |
def firstBadVersion(self, n): <NEW_LINE> <INDENT> low = 0 <NEW_LINE> high = n-1 <NEW_LINE> while low <= high: <NEW_LINE> <INDENT> mid = (low + high) // 2 <NEW_LINE> if isBadVersion(mid)==True: <NEW_LINE> <INDENT> high = mid - 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> low = mid + 1 <NEW_LINE> <DEDENT> <DEDENT> ret... | :type n: int
:rtype: int | 625941da566aa707497f482e |
def _to_namelist_literals(self, name, values): <NEW_LINE> <INDENT> ( var_type, _, var_size, ) = self._definition.split_type_string(name) <NEW_LINE> if var_size == 1 and not isinstance(values, list): <NEW_LINE> <INDENT> values = [values] <NEW_LINE> <DEDENT> for i, scalar in enumerate(values): <NEW_LINE> <INDENT> if scal... | Transform a literal list as needed for `set_value`.
This is the inverse of `_to_python_value`, except that many of the
changes have potentially already been performed. | 625941dad53ae8145f87a534 |
def set_preset_mode(self, mode): <NEW_LINE> <INDENT> if mode == 'hold': <NEW_LINE> <INDENT> self._inf_device.set_hold(True) <NEW_LINE> <DEDENT> elif mode == 'home': <NEW_LINE> <INDENT> self._inf_device.set_hold(False) | Set new preset mode. | 625941da3eb6a72ae02ec7ac |
def delete_documents(self, docs): <NEW_LINE> <INDENT> result = [] <NEW_LINE> criteria = self.delete_criteria or {} <NEW_LINE> for doc in docs: <NEW_LINE> <INDENT> criteria.update({ '_id': doc.get('id'), }) <NEW_LINE> if not self.pre_delete_document(criteria): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> deleted_doc... | 批量删除资源
:param docs: | 625941da498bea3a759b9d77 |
def get_used_range( self, worksheet_id_or_name: str, item_id: str = None, item_path: str = None, values_only: bool = True, ) -> dict: <NEW_LINE> <INDENT> if values_only: <NEW_LINE> <INDENT> params = {"valuesOnly": values_only} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> params = None <NEW_LINE> <DEDENT> if item_id: <... | The used range is the smallest range that encompasses any cells
that have a value or formatting assigned to them. If the worksheet
is blank, this function will return the top left cell.
### Parameters
----
worksheet_id_or_name : str
The worksheet resource id or the worksheet name.
item_id : str (optional, Default... | 625941daeab8aa0e5d26de21 |
def stop(self): <NEW_LINE> <INDENT> self.stop_command() | Descript. : stops the motor immediately | 625941da3cc13d1c6d3c7642 |
def setPadding(self, padding): <NEW_LINE> <INDENT> self._pad = padding <NEW_LINE> self._zfill = sum([PAD_MAP[c] for c in self._pad]) | Set new padding characters for the sequence.
i.e. "#" or "@@@", or an empty string to disable range formatting.
:type padding: str
:rtype: None | 625941daa05bb46b383ecae9 |
def __init__(self, cities=None, zip_codes=None, departments=None): <NEW_LINE> <INDENT> self._cities = None <NEW_LINE> self._zip_codes = None <NEW_LINE> self._departments = None <NEW_LINE> if cities is not None: <NEW_LINE> <INDENT> self.cities = cities <NEW_LINE> <DEDENT> if zip_codes is not None: <NEW_LINE> <INDENT> se... | UserUserPreferenceCommercialZone - a model defined in Swagger | 625941daa4f1c619b28b02fc |
def pc_nproduced_avg(self): <NEW_LINE> <INDENT> return _blocks_swig3.multiply_const_vii_sptr_pc_nproduced_avg(self) | pc_nproduced_avg(multiply_const_vii_sptr self) -> float | 625941da55399d3f0558897e |
def run(self): <NEW_LINE> <INDENT> self._sender.start() <NEW_LINE> self._receiver.start() <NEW_LINE> while self._client_info.is_connected(): <NEW_LINE> <INDENT> msg_bytes = self._receiver.get_msg_from_queue() <NEW_LINE> if msg_bytes is not None: <NEW_LINE> <INDENT> self._handle_message(to_dict(msg_bytes)) <NEW_LINE> <D... | Runs ClientHandler thread.
@return: None. | 625941daec188e330fd5aa63 |
def rank_del(): <NEW_LINE> <INDENT> f = open('rank.txt','r') <NEW_LINE> user_lst = [line.strip() for line in f.readlines()] <NEW_LINE> f.close() <NEW_LINE> user_lst.sort(key = lambda x:int(x.split()[1]),reverse=True) <NEW_LINE> name_lst = [] <NEW_LINE> for item in user_lst: <NEW_LINE> <INDENT> name_lst.append(item.spli... | This function is to delete the user in the rank | 625941da442bda511e8be6de |
def p_having_condition_1(p): <NEW_LINE> <INDENT> p[0] = [p[1]] | having_condition : constraint | 625941dae8904600ed9f21f9 |
def set_turnover_adjust_total_value(self, turnover_adjust_total_value): <NEW_LINE> <INDENT> self.turnover_adjust_total_value = turnover_adjust_total_value | 在新的调仓日期调仓完毕后更新该调仓周期的调仓换手率之计算分子:每次调仓时卖出和调整过的股票市值 | 625941da6e29344779a628d9 |
@block <NEW_LINE> def lsu(r6_r7_data,ds1_data,mem_read,mem_write,mem_ok,lsu_out,addr,wdata,rdata,write,read,rdy): <NEW_LINE> <INDENT> @always_comb <NEW_LINE> def main_logic(): <NEW_LINE> <INDENT> write.next = mem_write <NEW_LINE> read.next = mem_read <NEW_LINE> mem_ok.next = rdy <NEW_LINE> lsu_out.next = rdata <NEW_LIN... | :param r6_r7_data: 16 in
:param ds1_data: 16 in
:param mem_read: 1 in
:param mem_write: 1 in
:param mem_ok: 1 out
:param lsu_out: 8 out
:param addr: 16 out
:param wdata: 8 in
:param rdata: 1 out
:param write: 1 out
:param read: 1 out
:param rdy: 1 in
:return: | 625941da2c8b7c6e89b35a88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.