code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def check_report(report_file, tests): <NEW_LINE> <INDENT> tree = ElementTree.parse(report_file) <NEW_LINE> root = tree.getroot() <NEW_LINE> report = {} <NEW_LINE> for test in root.iter("testcase"): <NEW_LINE> <INDENT> status = "passed" <NEW_LINE> if test.find("skipped") is not None: <NEW_LINE> <INDENT> status = "skippe... | Check an XML report_file for the exact occurrence of specific test results | 625941d83346ee7daa2b2fe8 |
def __init__(self, database): <NEW_LINE> <INDENT> self.database = database <NEW_LINE> self.recommended = defaultdict(list) <NEW_LINE> self.process() | Constructor
| 625941d8be7bc26dc91cd877 |
def insert_front(self, element): <NEW_LINE> <INDENT> if element == None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> new_node = self.Node(element) <NEW_LINE> if self.is_empty(): <NEW_LINE> <INDENT> self.head = new_node <NEW_LINE> self.tail = new_node <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.head.previous =... | Inserts the given element at the front of the list.
:param element: The element to be inserted. | 625941d823849d37ff7b3308 |
def moveZeroes(self, nums: List[int]) -> None: <NEW_LINE> <INDENT> cnt = nums.count(0) <NEW_LINE> for i in range(cnt): <NEW_LINE> <INDENT> nums.remove(0) <NEW_LINE> nums.append(0) | Do not return anything, modify nums in-place instead. | 625941d84c3428357757c5a2 |
def edus(self): <NEW_LINE> <INDENT> return frozenset(e for e in self.nodes() if self.is_edu(e)) | Set of nodes representing elementary discourse units | 625941d87cff6e4e81117c00 |
def __init__(self, name: str, parent: Optional[paths.DirPath] = None, backend: str = 'fs', path_type: str = 'pdf') -> None: <NEW_LINE> <INDENT> super().__init__(name=name, parent=parent, backend=backend, path_type=path_type) | Initializes a new GenericFile object.
:param name: inherited from paths.Path
:param parent: inherited from paths.Path
:param backend: inherited from paths.Path
:param path_type: inherited from paths.Path | 625941d8e76e3b2f99f3aa83 |
def common_assert_code(res, code): <NEW_LINE> <INDENT> assert res.status_code == code | 通用断言
:param res:
:param code:
:return: | 625941d8167d2b6e31218e10 |
def resetTermsChanged(self): <NEW_LINE> <INDENT> self.terms_changed = False | return true if terms have changed | 625941d8cb5e8a47e48b7d22 |
def recurPythTree(box, count): <NEW_LINE> <INDENT> if count>0: <NEW_LINE> <INDENT> v1 = box.left <NEW_LINE> v2 = box.right <NEW_LINE> v3 = box.right+R_matrix([[0],[box.length]],box.angle) <NEW_LINE> v4 = box.left+R_matrix([[0],[box.length]],box.angle) <NEW_LINE> coords = np.array([v1,v2,v3,v4,v1]) <NEW_LINE> Box.length... | Recursive function.
Calculate the four points of the current box, plot them, then create two new boxes on top of it with length 1/sqrt(2) and rotations pi/4 and 7pi/4.
Then apply it to those two boxes | 625941d84e696a04525c96c7 |
@Files.route("/<objectid:file_id>", methods=['GET']) <NEW_LINE> def process_request(file_id): <NEW_LINE> <INDENT> if has_permission(): <NEW_LINE> <INDENT> col = app.data.driver.db['files'] <NEW_LINE> file = col.find_one({'_id': ObjectId(file_id)}) <NEW_LINE> if not file: <NEW_LINE> <INDENT> return eve_abort(404, 'No fi... | This is the router actually for processing
| 625941d8b545ff76a8914090 |
def p_base_list_element0 (self, p): <NEW_LINE> <INDENT> self.currentClass.addBase(p[2]) | base_list_element : base_access_specifier qualified_id
| base_access_specifier template_type | 625941d8d164cc6175782fca |
def OnInit(self): <NEW_LINE> <INDENT> frame = MainFrame(None, 'Configuration') <NEW_LINE> self.SetTopWindow(frame) <NEW_LINE> frame.Show() <NEW_LINE> return True | This is called by the __init__ method of the
wx.App if I understood correctly, so this is to not
overwrite that method. | 625941d867a9b606de4a8133 |
def __init__(self): <NEW_LINE> <INDENT> self.ImsDetailSet = None <NEW_LINE> self.TotalCount = None <NEW_LINE> self.RequestId = None | :param ImsDetailSet: 返回列表数据----非必选,该参数暂未对外开放
注意:此字段可能返回 null,表示取不到有效值。
:type ImsDetailSet: list of ImsDetail
:param TotalCount: 总条数
:type TotalCount: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str
| 625941d8046cf37aa974cfc1 |
def consumeBodyIter(self): <NEW_LINE> <INDENT> return self._result | See IHTTPResponse | 625941d8fb3f5b602dac3911 |
def merge_snmp_target_host(self): <NEW_LINE> <INDENT> conf_str = CE_MERGE_SNMP_TARGET_HOST_HEADER % self.host_name <NEW_LINE> if self.domain: <NEW_LINE> <INDENT> conf_str += "<domain>%s</domain>" % self.domain <NEW_LINE> <DEDENT> if self.address: <NEW_LINE> <INDENT> conf_str += "<address>%s</address>" % self.address <N... | Merge snmp target host operation | 625941d8507cdc57c6306f5b |
@cache('step') <NEW_LINE> def ratio_banxinwpp_at_houchiweir(): <NEW_LINE> <INDENT> return allocation_banxin_wpp() / total_wpp_allocation_at_houchiweir() | Real Name: Ratio BanXinWPP At HouChiWeir
Original Eqn: Allocation BanXin WPP/Total WPP Allocation At HouChiWeir
Units: m3/m3
Limits: (None, None)
Type: component | 625941d8ab23a570cc2503ff |
def write_records(self, records_list: Iterable, paths_to_write: dict, base_schema_to_write: dict = None, nested_schemas_to_write: List[dict] = None, output_opts: dict = {}): <NEW_LINE> <INDENT> self.stats["write_count"] = {} <NEW_LINE> base_schema_to_write = self.original_base_schema if not base_schema_to_write ... | Write transformed records to one or several formats.
IMPORTANT NOTE:
The Record Mapper is able to write in both, csv and avro formats.
But it is always necessary writing an avro file at least.
:param records_list: An iterable of records.
:type records_list: Iterable
:param paths_to_write: A dict with the formats ... | 625941d845492302aab5e541 |
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(rendupdate, self).__init__(*args, **kwds) <NEW_LINE> if self.numOfUpdates is None: <NEW_LINE> <INDENT> self.numOfUpdates = 0 <NEW_LINE> <DEDENT> if self.data is None: <NEW_LINE> <INDENT> self.data = '' <NEW_LINE> <DEDENT> ... | Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
numOfUpdates,data
@param args: co... | 625941d8d99f1b3c44c67807 |
def youtube2aws(url): <NEW_LINE> <INDENT> yt = YouTube(url) <NEW_LINE> yt_title = yt.title.replace(' ', '_') <NEW_LINE> yt_title = unicodedata.normalize('NFKD', yt_title).encode('ASCII', 'ignore').decode('utf-8') <NEW_LINE> yt_title = re.sub('\+', '', yt_title) <NEW_LINE> file_name = yt.streams.first().download(output_... | Convert YouYubue videos to mp4, exctracts spanish translate if exists
:param url: Link to the video to uplaod
:return: Nothing | 625941d8d486a94d0b98e3c2 |
def _scal_elemwise_with_nfunc(nfunc, nin, nout): <NEW_LINE> <INDENT> def construct(symbol): <NEW_LINE> <INDENT> symbolname = symbol.__name__ <NEW_LINE> inplace = symbolname.endswith('_inplace') <NEW_LINE> if inplace: <NEW_LINE> <INDENT> msg = "inplace" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = "no_inplace" <N... | Replace a symbol definition with an elementwise version of the
corresponding scalar Op. If it is not None, the nfunc argument
should be a string such that getattr(numpy, nfunc) implements
a vectorized version of the elemwise operation. nin is the number
of inputs expected by that function, and nout is the number of
**... | 625941d85510c4643540f65b |
def proof_by_contradiction(proof, assumption, print_as_proof_forms=False): <NEW_LINE> <INDENT> assert type(proof) is Proof <NEW_LINE> assert proof.is_valid() <NEW_LINE> assert type(assumption) is Formula <NEW_LINE> assert Schema(assumption) in proof.assumptions <NEW_LINE> assert proof.assumptions.issuperset(Prover.AXIO... | Given a proof, whose assumptions/axioms include Prover.AXIOMS, of a
contradiction (a formula whose negation is a tautology) from a set of
assumptions/axioms that includes the given assumption as a simple
formula (i.e., without any templates), where no step of the proof is a
UG step over a variable that is free in the g... | 625941d897e22403b379d216 |
@app.route('/') <NEW_LINE> def show_form(): <NEW_LINE> <INDENT> return render_template('home.html', prompts = story.prompts, template = story.template ) | Shows the madlibs form | 625941d8851cf427c661a788 |
def __init__(self, dsize, fx=0, fy=0, interp=cv.INTER_LINEAR, buffer=False): <NEW_LINE> <INDENT> self.interp = thelper.utils.import_class(interp) if isinstance(interp, str) else interp <NEW_LINE> self.buffer = buffer <NEW_LINE> if isinstance(dsize, tuple): <NEW_LINE> <INDENT> self.dsize = dsize <NEW_LINE> <DEDENT> else... | Validates and initializes resize parameters.
Args:
dsize: size of the target image, forwarded to ``cv2.resize``.
fx: x-scaling factor, forwarded to ``cv2.resize``.
fy: y-scaling factor, forwarded to ``cv2.resize``.
interp: resize interpolation type, forwarded to ``cv2.resize``.
buffer: specifies wh... | 625941d8097d151d1a2230d3 |
def get_resources(self, published_only): <NEW_LINE> <INDENT> pass | Returns data about resource records from AS.
Args:
published_only (boolean): Fetch only published records from AS
Returns:
resources (list): Full JSON of AS resource records | 625941d810dbd63aa1bd2e1e |
def get_free_swap_memory() -> int: <NEW_LINE> <INDENT> return swap_memory().free | Get the free swap memory size in bytes. | 625941d873bcbd0ca4b2c2f2 |
def __init__(self): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.image_source = 0 <NEW_LINE> self.image_destination = 0 <NEW_LINE> self.image_entry = 0 <NEW_LINE> self.image_size = 0 <NEW_LINE> self.flags = 0 | Initialize IDS3b segment | 625941d850812a4eaa59c59b |
def read(data_reader_url, on_data_available_fnc): <NEW_LINE> <INDENT> read_or_take(data_reader_url, on_data_available_fnc, False) | Performns a read() operation on a DDS DataReader given its resource
URL. The operation performs a long-polling operation that calls the
given on_data_available_fnc whenever new samples become available.
As opposed to the take() operation, the read() operation does not remove
the samples it has read from the DataReaders... | 625941d8cc0a2c11143dd10c |
def __getstate__(self): <NEW_LINE> <INDENT> state = {'base' : ctools.csobservation.__getstate__(self), 'srcname' : self._srcname, 'tbins' : self._tbins, 'stacked' : self._stacked, 'onoff' : self._onoff, 'fits' : self._fits, 'nthreads' : self._nthreads, 'excl_reg_map' : self._... | Extend ctools.csobservation getstate method to include some members
Returns
-------
state : dict
Pickled instance | 625941d855399d3f05588930 |
def run(self): <NEW_LINE> <INDENT> if not self.session.can_do("SUMMARY MAILERS"): <NEW_LINE> <INDENT> self.bail("User not authorized to create Summary mailers") <NEW_LINE> <DEDENT> if self.request == self.SUBMENU: <NEW_LINE> <INDENT> return self.redirect("Mailers.py") <NEW_LINE> <DEDENT> elif self.request == self.SUBMI... | Override for custom routing. | 625941d8046cf37aa974cfc2 |
def construct(self): <NEW_LINE> <INDENT> EventSource.__init__(self, self._event_names) <NEW_LINE> self._device_manager = None <NEW_LINE> self._keyboard_slave_devices = None | Singleton constructor, runs only once. | 625941d8f9cc0f698b140875 |
def _prepare_http_request(request, raise_error=True, **kwargs): <NEW_LINE> <INDENT> if not isinstance(request, HTTPRequest): <NEW_LINE> <INDENT> request = HTTPRequest(request, **kwargs) <NEW_LINE> <DEDENT> return request, raise_error | Copying parameters from original `AsyncHTTPClient.fetch` function
:return: HTTPRequest, raise_error bool | 625941d85fcc89381b1e193d |
def GetXcodeArchsDefault(): <NEW_LINE> <INDENT> global XCODE_ARCHS_DEFAULT_CACHE <NEW_LINE> if XCODE_ARCHS_DEFAULT_CACHE: <NEW_LINE> <INDENT> return XCODE_ARCHS_DEFAULT_CACHE <NEW_LINE> <DEDENT> xcode_version, _ = XcodeVersion() <NEW_LINE> if xcode_version < '0500': <NEW_LINE> <INDENT> XCODE_ARCHS_DEFAULT_CACHE = Xcode... | Returns the |XcodeArchsDefault| object to use to expand ARCHS for the
installed version of Xcode. The default values used by Xcode for ARCHS
and the expansion of the variables depends on the version of Xcode used.
For all version anterior to Xcode 5.0 or posterior to Xcode 5.1 included
uses $(ARCHS_STANDARD) if ARCHS ... | 625941d82c8b7c6e89b35a3b |
@LocalContext <NEW_LINE> def run_assembly_exitcode(assembly): <NEW_LINE> <INDENT> p = run_assembly(assembly) <NEW_LINE> p.wait_for_close() <NEW_LINE> return p.poll() | Given an assembly listing, assemble and execute it, and wait for
the process to die.
Returns:
The exit code of the process.
Example:
>>> run_assembly_exitcode('mov ebx, 3; mov eax, SYS_exit; int 0x80;')
3 | 625941d87047854f462a1683 |
def __getshowsubsection(self, showname): <NEW_LINE> <INDENT> if showname in self.getshownames(): <NEW_LINE> <INDENT> return self.__config["Shows"][showname] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for show in self.getshownames(): <NEW_LINE> <INDENT> if showname in self.__config["Shows"][show]["alias"]: <NEW_LINE>... | Get the configuration options for the show, showname. | 625941d8711fe17d825425e2 |
def plot_area_source_polygons(model, bmap): <NEW_LINE> <INDENT> for key in sorted(model.sources): <NEW_LINE> <INDENT> src = model.sources[key] <NEW_LINE> if src.source_type == 'AreaSource': <NEW_LINE> <INDENT> x, y = bmap(src.polygon.lons, src.polygon.lats) <NEW_LINE> bmap.plot(x, y, '-b') | :parameter bmap:
A :class:Basemap instance | 625941d856ac1b37e6264448 |
@app.route('/gdisconnect') <NEW_LINE> def gdisconnect(): <NEW_LINE> <INDENT> access_token = login_session.get('access_token') <NEW_LINE> if access_token is None: <NEW_LINE> <INDENT> print('Access Token is None') <NEW_LINE> response = make_response( json.dumps('Current user not connected.'), 401 ) <NEW_LINE> response.he... | Processes a logout via Google | 625941d807f4c71912b11700 |
def dfs_lose(me): <NEW_LINE> <INDENT> if len(Tree[me].lose)==0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> global visited, g_win, g_lose <NEW_LINE> for there in Tree[me].lose: <NEW_LINE> <INDENT> if not there in visited: <NEW_LINE> <INDENT> g_lose += 1 <NEW_LINE> visited.add(there) <NEW_LINE> dfs_lose(there) <NEW_L... | 자신이 질 수 있는 사람만 카운팅 한다 | 625941d801c39578d7e750b8 |
def SetTransform(self, *args): <NEW_LINE> <INDENT> return _itkImageRegistrationMethodPython.itkImageRegistrationMethodIUC2IUC2_SetTransform(self, *args) | SetTransform(self, itkTransformD22 _arg) | 625941d8a8ecb033257d3348 |
def log_filter(record: Any) -> Any: <NEW_LINE> <INDENT> changed = False <NEW_LINE> res = [] <NEW_LINE> for arg in record.args: <NEW_LINE> <INDENT> sarg = str(arg) <NEW_LINE> if len(sarg) < 150: <NEW_LINE> <INDENT> res.append(arg) <NEW_LINE> continue <NEW_LINE> <DEDENT> res.append(f"{sarg[:130]}...{sarg[-20:]} len={len(... | Trim log messages.
https://relaxdiego.com/2014/07/logging-in-python.html | 625941d8c4546d3d9de72cb1 |
@click.command('user', cls=CommandWithOptionalPassword, short_help='Update user') <NEW_LINE> @click.option('--id', '-i', metavar='ID', help='User ID') <NEW_LINE> @click.option('--name', help='Name of user') <NEW_LINE> @click.option('--email', help='Email address (login username)') <NEW_LINE> @click.option('--password',... | Create user, show or update user details, including password reset, list user groups and delete user. | 625941d882261d6c526ab71e |
def get( self, resource_group_name, load_balancer_name, probe_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_versio... | Gets load balancer probe.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param load_balancer_name: The name of the load balancer.
:type load_balancer_name: str
:param probe_name: The name of the probe.
:type probe_name: str
:keyword callable cls: A custom type or function t... | 625941d8009cb60464c6362c |
def testUnboundVariableReused(self): <NEW_LINE> <INDENT> input_pt = self.Wrap(self.input) <NEW_LINE> unbound_var = prettytensor.UnboundVariable('width') <NEW_LINE> template = (input_pt.flatten().fully_connected(unbound_var) .fully_connected(unbound_var)) <NEW_LINE> out = self.RunTensor(template.construct(width=200)) <N... | The same unbound_var can be used multiple times in a graph. | 625941d84d74a7450ccd4440 |
def gxy(xp, yp, zp, spheres, dens=None): <NEW_LINE> <INDENT> if xp.shape != yp.shape != zp.shape: <NEW_LINE> <INDENT> raise ValueError("Input arrays xp, yp, and zp must have same shape!") <NEW_LINE> <DEDENT> res = numpy.zeros_like(xp) <NEW_LINE> for sphere in spheres: <NEW_LINE> <INDENT> if sphere is None or ('density'... | Calculates the :math:`g_xy` gravity gradient component.
.. note:: The coordinate system of the input parameters is to be
x -> North, y -> East and z -> Down.
.. note:: All input values in SI and output in Eotvos!
Parameters:
* xp, yp, zp : arrays
The x, y, and z coordinates where the field will be calculate... | 625941d876e4537e8c3518f0 |
def get_n_params(model: nn.Module): <NEW_LINE> <INDENT> return sum(p.numel() for p in model.parameters()) | get parameter size of trainable parameters in model
:param model: model
:return: int | 625941d85f7d997b87174d16 |
def write_bools_1_by_1_given_type(): <NEW_LINE> <INDENT> pass | >>> bools = 44100 * 2 * 8 * [True, False]
>>> stream = BitStream()
>>> for _bool in bools:
... stream.write(_bool, bool) | 625941d8cc0a2c11143dd10d |
def choices_validator(choices): <NEW_LINE> <INDENT> def validator(value): <NEW_LINE> <INDENT> if value not in choices: <NEW_LINE> <INDENT> raise ValidationError( "{} is not in {}".format(value, list(choices)) ) <NEW_LINE> <DEDENT> <DEDENT> return validator | Return validator function that will check if ``value in choices``.
Args:
max_value (list, set, tuple): allowed choices for new validator | 625941d84428ac0f6e5baa6f |
def parse_xml(self, filename): <NEW_LINE> <INDENT> tree = ElementTree.parse(filename) <NEW_LINE> root = tree.getroot() <NEW_LINE> self.walk_tree(root, 0) | Load and parse the XML filename | 625941d8566aa707497f47e2 |
def removeDuplicates(self, nums): <NEW_LINE> <INDENT> if len(nums) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> curr = nums[0] <NEW_LINE> i = 1 <NEW_LINE> while i < len(nums): <NEW_LINE> <INDENT> if curr == nums[i]: <NEW_LINE> <INDENT> del nums[i] <NEW_LINE> continue <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDE... | :type nums: List[int]
:rtype: int | 625941d876d4e153a657edae |
def test_business_can_be_edited(self): <NEW_LINE> <INDENT> self.business_data['name'] = 'iHub' <NEW_LINE> self.edit_business(code=200, msg='Business updated successfully') | Test edit an existing business works as expected | 625941d8e1aae11d1e749f35 |
def __iter__(self): <NEW_LINE> <INDENT> return iter(self._entries.values()) | Iterate over entries in the manifest. | 625941d80a366e3fb873ea98 |
def get_latest_trading_date(date): <NEW_LINE> <INDENT> trading_day = get_trading_days(start=date, end=date) <NEW_LINE> step = 0 if bool(trading_day) else 1 <NEW_LINE> return get_direct_trading_day(date, step=step, forward=False) | Get latest trading date | 625941d8be8e80087fb20ebc |
def __init__(self, width, height): <NEW_LINE> <INDENT> super().__init__(width, height) <NEW_LINE> self.ball = Ball() <NEW_LINE> self.paddle = Paddle() <NEW_LINE> self.score = 0 <NEW_LINE> self.filled1 = Filled() <NEW_LINE> self.filled2 = Filled() <NEW_LINE> self.filled3 = Filled() <NEW_LINE> self.filled4 = Filled() <NE... | Sets up the initial conditions of the game
:param width: Screen width
:param height: Screen height | 625941d8b57a9660fec33b03 |
def preDeploy(site): <NEW_LINE> <INDENT> pass | Called prior to deploying the site (built files)
A good time to configure custom headers
:param site: The site about to be deployed.
:returns: None | 625941d8091ae356686671d7 |
def _handle_error(self, response, message='Unexpected response from CAS server'): <NEW_LINE> <INDENT> raise CasHTTPError( code=response.status_code, message=message, headers=response.headers, content=response.content, ) | Handle an error response from CAS. | 625941d8ac7a0e7691ed4345 |
def parse1(self, response): <NEW_LINE> <INDENT> informationItems = response.meta["item"] <NEW_LINE> selector = Selector(response) <NEW_LINE> text1 = ";".join(selector.xpath('body/div[@class="c"]/text()').extract()) <NEW_LINE> nickname = re.findall(u'\u6635\u79f0[:|\uff1a](.*?);', text1) <NEW_LINE> gender = re.findall(u... | 抓取个人信息2 | 625941d8e64d504609d74abc |
def __init__(self, path: str) -> None: <NEW_LINE> <INDENT> self.database_path = path | Constructor.
:param path: Path to the inventory database. | 625941d80a50d4780f667110 |
def read_e2ds(rootname, night, instrument, header=False): <NEW_LINE> <INDENT> e2dsname = os.path.join(night, rootname+'_e2ds_A.fits') <NEW_LINE> try: <NEW_LINE> <INDENT> dd = datadir[instrument] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> print('Instrument not recognised.') <NEW_LINE> raise <NEW_LINE> <DED... | Read e2ds_A.fits file.
:param str rootname: name of file without e2ds termination.
:param str night: night of observation. Format YYYY-MM-DD
:param str instrument: instrument must exist in datadir dictionary.
:param bool header: determines if header instance is returned.
:return: e2ds data array (in e-), format (k x n... | 625941d8187af65679ca539b |
def updatepara_alien(self,ai_setting): <NEW_LINE> <INDENT> ai_setting.fleet_drop_speed = self.config['alien']['fleet_drop_speed'] <NEW_LINE> ai_setting.speedup_scale = self.config['alien']['speedup_scale'] <NEW_LINE> ai_setting.score_scale = self.config['alien']['score_scale'] <NEW_LINE> ai_setting.alien_points = self.... | 外星人字典 | 625941d89b70327d1c4e1052 |
def sliceit(iterable, lower=0, upper=None): <NEW_LINE> <INDENT> if upper is None: <NEW_LINE> <INDENT> upper = len(iterable) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> result = iterable[lower: upper] <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> result = [] <NEW_LINE> if lower < 0: <NEW_LINE> <INDENT> lowe... | Apply a slice on input iterable.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int lower: lower bound from where start to get items.
:param int upper: upper bound from where finish to get items.
:return: sliced object of the same type of iterable if not dict, or specific
object.... | 625941d8eab8aa0e5d26ddd5 |
def test_observed_property_variable_create(self): <NEW_LINE> <INDENT> assert self.observed_property_var.id == "FOO" <NEW_LINE> assert self.observed_property_var.full_name == "Groundwater Flux" <NEW_LINE> assert self.observed_property_var.categories == "Hydrology,Subsurface" | create the object and test attributes | 625941d83617ad0b5ed68173 |
def test_register_metadata_tool_duplicate_key(self): <NEW_LINE> <INDENT> app = Flask(__name__) <NEW_LINE> app.config['FOCA'] = Config( db=MongoConfig(**MONGO_CONFIG), endpoints=ENDPOINT_CONFIG, ) <NEW_LINE> mock_resp = MagicMock(side_effect=[DuplicateKeyError(''), None]) <NEW_LINE> app.config['FOCA'].db.dbs['trsStore']... | Test for creating a tool; duplicate key error occurs. | 625941d8d10714528d5fff62 |
def getSeqInfo(self, exportItems): <NEW_LINE> <INDENT> sequences = [] <NEW_LINE> if exportItems[0].trackItem(): <NEW_LINE> <INDENT> sequences.append(exportItems[0].trackItem().parent().parent()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sequences = [item.sequence() for item in exportItems if item.sequence() is not ... | This code is mainly from FnExternalRender | 625941d83d592f4c4ed1d2e6 |
def base58_check_encoding(payload, version=0): <NEW_LINE> <INDENT> assert isinstance(payload, bytes) <NEW_LINE> version_payload = bytes([version]) + payload <NEW_LINE> first_sha256 = hasher_sha256(version_payload) <NEW_LINE> second_sha256 = hasher_sha256(first_sha256) <NEW_LINE> checksum = second_sha256[:4] <NEW_LINE> ... | Base 58 binary-to-text encoding used for encoding Bitcoin addresses.
https://en.bitcoin.it/wiki/Base58Check_encoding
:param payload: Data to be converted.
:param version: One byte of version/application information.
BTC pubkey hash addresses use the version 0.
:return: A base58-encoded string. | 625941d8925a0f43d254a0f5 |
def save_action_results(self, s_hash, a_desc, sn_hash, reward_val): <NEW_LINE> <INDENT> self.add_action( s_hash, a_desc ) <NEW_LINE> self.define_statesD[ s_hash ].save_action_results( a_desc, sn_hash, reward_val ) | Add sn_hash to possible next states and add to its RunningAve | 625941d8e64d504609d74abd |
def sum_2(target, a_list): <NEW_LINE> <INDENT> nums_found = {} <NEW_LINE> for num in a_list: <NEW_LINE> <INDENT> if num not in nums_found: <NEW_LINE> <INDENT> nums_found[target - num] = num <NEW_LINE> continue <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> return None | Find the two numbers in a list that sum to a target number and return their product.
Return None if no two numbers sum to the target number. O(n) | 625941d8d268445f265b50eb |
def __init__(self, identifier=None, implementor=None): <NEW_LINE> <INDENT> super(RunExecution, self).__init__(identifier, implementor) <NEW_LINE> self.stage_of_execution = 0 <NEW_LINE> self.num_successful_embeddings = 0 <NEW_LINE> self.num_failed_embeddings = 0 <NEW_LINE> self.num_infeasible_embeddings = 0 <NEW_LINE> s... | Initializes object.
| 625941d830dc7b7665901be1 |
def persona_login(request): <NEW_LINE> <INDENT> user = authenticate(assertion=request.POST['assertion']) <NEW_LINE> if user: <NEW_LINE> <INDENT> login(request, user) <NEW_LINE> <DEDENT> return HttpResponse('OK') | 1: Instantiate authenticate with data from request as user
2: If authenticate created user, aka login worked, run login function for user | 625941d8cc40096d61595bcc |
def display_video_hooks(hook_args): <NEW_LINE> <INDENT> predictions = hook_args.predictions <NEW_LINE> max_outputs = hook_args.decode_hparams.max_display_outputs <NEW_LINE> with tf.Graph().as_default(): <NEW_LINE> <INDENT> _, best_decodes = video_metrics.compute_video_metrics_from_predictions( predictions) <NEW_LINE> <... | Hooks to display videos at decode time. | 625941d83346ee7daa2b2fea |
def validate(self, data): <NEW_LINE> <INDENT> if data.get('cost_center', False) is False and data.get('revenue_center', False) is False: <NEW_LINE> <INDENT> raise serializers.ValidationError( 'Ao menos uma das opções deve ser escolhida. "Centro de custo" ou "Centro de receita"' ) <NEW_LINE> <DEDENT> return data | Ao menos uma das opções deve ser escolhida! "centro de custo" ou "centro de receita". | 625941d830bbd722463cc045 |
def compute_bias(self, query_length, key_length): <NEW_LINE> <INDENT> context_position = tf.range(query_length)[:, None] <NEW_LINE> memory_position = tf.range(key_length)[None, :] <NEW_LINE> relative_position = memory_position - context_position <NEW_LINE> relative_position_bucket = self._relative_position_bucket( rela... | Compute binned relative position bias | 625941d84c3428357757c5a4 |
def test_item_was_updated(self): <NEW_LINE> <INDENT> self.assertEqual(TodoItem.objects.get().completed, self.NEW_COMPLETE) <NEW_LINE> self.assertEqual(TodoItem.objects.get().title, self.NEW_TITLE) | test item update fields | 625941d8f7d966606f6aa284 |
@api.api_method(http_method="POST", user_required=True, logger=log) <NEW_LINE> def create_volume(request): <NEW_LINE> <INDENT> req = utils.get_json_body(request) <NEW_LINE> log.debug("create_volume %s", req) <NEW_LINE> user_id = request.user_uniq <NEW_LINE> new_volume = req.get("volume") <NEW_LINE> if new_volume is Non... | Create a new Volume. | 625941d84e4d5625662d4652 |
def __call__(self, r, method=None, **attr): <NEW_LINE> <INDENT> self.request = r <NEW_LINE> manager = current.manager <NEW_LINE> self.permit = manager.permit <NEW_LINE> self.download_url = manager.s3.download_url <NEW_LINE> self.next = None <NEW_LINE> if method is not None: <NEW_LINE> <INDENT> self.method = method <NEW... | Entry point for the REST interface
@param r: the S3Request
@param method: the method established by the REST interface
@param attr: dict of parameters for the method handler
@returns: output object to send to the view | 625941d892d797404e304408 |
def find_digits(a,b,n): <NEW_LINE> <INDENT> res = [] <NEW_LINE> c = a//b <NEW_LINE> res.append(c) <NEW_LINE> i = 0 <NEW_LINE> while i < n: <NEW_LINE> <INDENT> a -= b*c <NEW_LINE> if a == 0: <NEW_LINE> <INDENT> return res <NEW_LINE> <DEDENT> if a < b: <NEW_LINE> <INDENT> a *= 10 <NEW_LINE> <DEDENT> c = a//b <NEW_LINE> r... | Simple division a/b to the nth-digit | 625941d85166f23b2e1a53d6 |
def remove_rc_jail_list(module): <NEW_LINE> <INDENT> jail_list = get_rc_jail_list(module) <NEW_LINE> try: <NEW_LINE> <INDENT> jail_list.remove(module.params['name']) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> msg = ("Unable to remove jail from jail_list in rc files becuase it's " "already absent. Is jai... | Remove jail name from jail_list rc variable
Args:
module (AnsibleModule):
Returns:
None | 625941d838b623060ff0b06a |
def predict(X_img_path,knn_clf=None,model_path=None,distance_threshold = 0.45): <NEW_LINE> <INDENT> if knn_clf is None and model_path is None: <NEW_LINE> <INDENT> raise Exception("请选择KNN分类器方式:knn_clf 或 model_path") <NEW_LINE> <DEDENT> if knn_clf is None: <NEW_LINE> <INDENT> with open(model_path,'rb') as f: <NEW_LINE> <... | 利用KNN分离器识别
:return :[人名,边界,...] | 625941d85fcc89381b1e193e |
def useQtAlt(): <NEW_LINE> <INDENT> import PyQt5.Qt as qt <NEW_LINE> qapp = qt.QApplication.instance() or qt.QApplication(sys.argv) <NEW_LINE> def qstep(): <NEW_LINE> <INDENT> qapp.processEvents() <NEW_LINE> qapp.sendPostedEvents() <NEW_LINE> loop = asyncio.get_event_loop() <NEW_LINE> loop.call_later(0.01, qstep) <NEW_... | Integrate asyncio and Qt loops:
Let the asyncio event loop spin the Qt event loop. | 625941d860cbc95b062c67c0 |
def compute_kkt_optimality(g, on_bound): <NEW_LINE> <INDENT> g_kkt = g * on_bound <NEW_LINE> free_set = on_bound == 0 <NEW_LINE> g_kkt[free_set] = np.abs(g[free_set]) <NEW_LINE> return np.max(g_kkt) | Compute the maximum violation of KKT conditions. | 625941d821bff66bcd684bce |
def getAverageQualScoreFromCode(team, year, code): <NEW_LINE> <INDENT> matches = query.getAllMatches(year,code) <NEW_LINE> teamkey = "frc"+str(team) <NEW_LINE> ans = 0 <NEW_LINE> count = 0 <NEW_LINE> for match in matches: <NEW_LINE> <INDENT> if match["comp_level"] == "qm" or match["comp_level"] == "ef": <NEW_LINE> <IN... | Calculates a team's qualification score at an event | 625941d8091ae356686671d8 |
def bohman(M, sym=True): <NEW_LINE> <INDENT> if M < 1: <NEW_LINE> <INDENT> return np.array([]) <NEW_LINE> <DEDENT> if M == 1: <NEW_LINE> <INDENT> return np.ones(1, 'd') <NEW_LINE> <DEDENT> odd = M % 2 <NEW_LINE> if not sym and not odd: <NEW_LINE> <INDENT> M = M + 1 <NEW_LINE> <DEDENT> fac = np.abs(np.linspace(-1, 1, M)... | Return a Bohman window.
Parameters
----------
M : int
Number of points in the output window. If zero or less, an empty
array is returned.
sym : bool, optional
When True, generates a symmetric window, for use in filter design.
When False, generates a periodic window, for use in spectral analysis.
Retur... | 625941d8cad5886f8bd27256 |
def get_all_keys(event, context): <NEW_LINE> <INDENT> db_response = get_table().scan() <NEW_LINE> items = db_response['Items'] <NEW_LINE> return form_http_response(200, items) | List all key/value pairs | 625941d856b00c62f0f148d8 |
def _fetch_latest_version(self, base_id): <NEW_LINE> <INDENT> cur = self.dbh.cursor() <NEW_LINE> cur.execute( "select VERSION from MATRIX where BASE_id = %s order by VERSION" " desc limit 1", (base_id,), ) <NEW_LINE> row = cur.fetchone() <NEW_LINE> latest = None <NEW_LINE> if row: <NEW_LINE> <INDENT> latest = row[0] <N... | Get the latest version number for the given base_id (PRIVATE). | 625941d8d53ae8145f87a4e9 |
def do_exit(self, arg): <NEW_LINE> <INDENT> print_yellow("\nNo data saved") <NEW_LINE> return True | Exit Program | 625941d8d164cc6175782fcc |
def solve(problem, unique=True): <NEW_LINE> <INDENT> first = None <NEW_LINE> for soln in all_solns(problem, 2): <NEW_LINE> <INDENT> if not unique: <NEW_LINE> <INDENT> return soln <NEW_LINE> <DEDENT> if first is not None: <NEW_LINE> <INDENT> raise MultipleSolutions([first, soln]) <NEW_LINE> <DEDENT> first = soln <NEW_LI... | Solve a problem.
If unique is set (the default), this will check for a second solution and
raise MultipleSolutions() if it finds one. | 625941d8f548e778e58cd7fc |
def wrap_ptr(*args): <NEW_LINE> <INDENT> return lambda original: common_loader(original, nullptr_check, c_void_p, *args) | Decorator that checks that returned pointer is not null | 625941d8b7558d58953c518e |
def to_frame(self, data, state): <NEW_LINE> <INDENT> length = state.length <NEW_LINE> if length is None: <NEW_LINE> <INDENT> length = self.decode_length(data, state) <NEW_LINE> <DEDENT> if len(data) < length: <NEW_LINE> <INDENT> state.length = length <NEW_LINE> raise exc.NoFrames() <NEW_LINE> <DEDENT> frame = six.binar... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instance of ``FramerState``. If the buffer
... | 625941d823e79379d52ee7df |
def get_training_outputs(self): <NEW_LINE> <INDENT> return [self.train_op, self.loss] | Return the training output tensors | 625941d8656771135c3ebaee |
def test_test_manifest_keys_extracted(self): <NEW_LINE> <INDENT> reader = self.reader('test-manifest-keys-extracted') <NEW_LINE> objs = [o for o in self.read_topsrcdir(reader) if isinstance(o, TestManifest)] <NEW_LINE> self.assertEqual(len(objs), 8) <NEW_LINE> metadata = { 'a11y.ini': { 'flavor': 'a11y', 'installs': { ... | Ensure all metadata from test manifests is extracted. | 625941d8ab23a570cc250401 |
def clip(boxes, image_size): <NEW_LINE> <INDENT> (h, w) = image_size <NEW_LINE> boxes[:, :1] = torch.clamp(boxes[:, :1], min=0, max=w) <NEW_LINE> boxes[:, 1:2] = torch.clamp(boxes[:, 1:2], min=0, max=h) <NEW_LINE> boxes[:, 2:3] = torch.clamp(boxes[:, 2:3], min=0, max=w) <NEW_LINE> boxes[:, 3:] = torch.clamp(boxes[:, 3:... | Args:
boxes (Tensor): shape in ((#boxes), 4)
image_size (tuple[int]): (H, W)
Return:
boxes (Tensor): in place transform, fit into image size. | 625941d8d486a94d0b98e3c4 |
def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.VirtualNetworkTapListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.upda... | Gets all the VirtualNetworkTaps in a subscription.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either VirtualNetworkTapListResult or the result o... | 625941d8d99f1b3c44c67809 |
def mput(self, data_set): <NEW_LINE> <INDENT> for i in data_set: <NEW_LINE> <INDENT> self.put(i) | 批量put | 625941d8ff9c53063f47c470 |
def generate(self, numRows): <NEW_LINE> <INDENT> if not numRows: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> ret = [] <NEW_LINE> row = [1] <NEW_LINE> ret.append(row) <NEW_LINE> for i in range(1, numRows): <NEW_LINE> <INDENT> cur = [1] <NEW_LINE> for r in range(len(row)): <NEW_LINE> <INDENT> if r > 0: <NEW_LINE> <... | :type numRows: int
:rtype: List[List[int]] | 625941d85510c4643540f65c |
@myapp.route('/api/v1/red_flags/<int:red_flag_id>', methods=['GET']) <NEW_LINE> @jwt_required <NEW_LINE> def get_specific_redflag(red_flag_id): <NEW_LINE> <INDENT> return Redflag().get_red_flag(red_flag_id) | Get a specific red-flag | 625941d8e8904600ed9f21ad |
def _TestSeekFileObject(self, file_object, base_offset=167): <NEW_LINE> <INDENT> file_object.seek(base_offset + 10) <NEW_LINE> self.assertEqual(file_object.read(5), b'53:01') <NEW_LINE> expected_offset = base_offset + 15 <NEW_LINE> self.assertEqual(file_object.get_offset(), expected_offset) <NEW_LINE> file_object.seek(... | Runs the seek tests on the file-like object.
Args:
file_object (file): file-like object with the test data.
base_offset (Optional[int]): base offset use in the tests. | 625941d88a43f66fc4b542e0 |
def get_vlanid_for_port_group(self, dvs_name, pg_name): <NEW_LINE> <INDENT> raise NotImplementedError() | Obtain VLAN id associated with a DVS portgroup. | 625941d8d53ae8145f87a4ea |
def flash_lights(al, current: tuple=()) -> None: <NEW_LINE> <INDENT> stop = al.coordinates <NEW_LINE> print(stop, current) <NEW_LINE> if within_range(stop, current): <NEW_LINE> <INDENT> al.activate() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('\nOut of range, cannot flash.\n') | Flash lights on AlertLight <al> if a passenger is within_range. | 625941d8a17c0f6771cbe2cd |
def makeLightCurves(self): <NEW_LINE> <INDENT> for targ,flist in self.objects.items(): <NEW_LINE> <INDENT> prefix = path.join(self.folder,'photometry',targ) <NEW_LINE> try: <NEW_LINE> <INDENT> makeLightCurves(map(self._getNstName,flist),prefix) <NEW_LINE> <DEDENT> except Exception as ex: <NEW_LINE> <INDENT> logger.warn... | create light curves from the output of the
photting process. | 625941d821a7993f00bc7f71 |
def run_cmake(self): <NEW_LINE> <INDENT> cmake_cmd = ['cmake', '-H..', '-Bbuild'] <NEW_LINE> cmake_cmd += ['-DPYTHON_EXECUTABLE=' + sys.executable] <NEW_LINE> rc = subprocess.call(cmake_cmd) <NEW_LINE> if rc != 0: <NEW_LINE> <INDENT> self.success = False <NEW_LINE> self.msg = 'Failed on cmake.' | Run CMake to create CTest script | 625941d830dc7b7665901be2 |
def solve(self): <NEW_LINE> <INDENT> while not self.state.done: <NEW_LINE> <INDENT> move = self.findnextmove() <NEW_LINE> if self.watch_type: <NEW_LINE> <INDENT> if isinstance(move, self.watch_type): <NEW_LINE> <INDENT> return move <NEW_LINE> <DEDENT> <DEDENT> self.apply(move) | Break out once we see a particular type of move. | 625941d873bcbd0ca4b2c2f4 |
def month_to_en(filter_time): <NEW_LINE> <INDENT> filter_time = str(filter_time) <NEW_LINE> filter_time = filter_time.split('-', -1) <NEW_LINE> year = filter_time[0] <NEW_LINE> month = int(filter_time[1]) <NEW_LINE> day = str(int(filter_time[2])) <NEW_LINE> en_month = change(month) <NEW_LINE> return en_month + " " + da... | 2018-03-05 11:37:07 to Mar 4 13:55:11 2018
:param filter_time:
:return: | 625941d855399d3f05588932 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.