code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_cascade(self): <NEW_LINE> <INDENT> profile = self.F.ProfileFactory.create() <NEW_LINE> profile.environments.add( *self.F.EnvironmentFactory.create_full_set({"OS": ["Windows"]})) <NEW_LINE> cv = self.F.CaseVersionFactory.create( productversion=self.pv, case__product=self.pv.product) <NEW_LINE> form = self.Popul... | Populated envs cascade to cases. | 625941d7be383301e01b56d2 |
def test_deployment_serialization(self): <NEW_LINE> <INDENT> deployment_model_json = {} <NEW_LINE> deployment_model_json['id'] = 'testString' <NEW_LINE> deployment_model_json['label'] = 'testString' <NEW_LINE> deployment_model_json['name'] = 'testString' <NEW_LINE> deployment_model_json['short_description'] = 'testStri... | Test serialization/deserialization for Deployment | 625941d78da39b475bd651c4 |
def _parser(self, content=None): <NEW_LINE> <INDENT> rc, out = super(ShowCommand, self)._parser(content) <NEW_LINE> if rc != 0: <NEW_LINE> <INDENT> return rc, out <NEW_LINE> <DEDENT> if len(out) < 6: <NEW_LINE> <INDENT> return rc, [] <NEW_LINE> <DEDENT> detect_type = self.detect_type() <NEW_LINE> if detect_type == "lis... | Parse Table or Detail format into dict.
# Table format
ID Name LD-amount
----------------------
123 LV-1 1
# Result
{
'ID': '123',
'Name': 'LV-1',
'LD-amount': '1'
}
# Detail format
ID: 5DE94FF775D81C30
Name: LV-1
LD-amount: 1
# Result
{
'ID': '123',
'Name': 'LV-1',
'LD-amount'... | 625941d7a219f33f34628bb6 |
def still(self): <NEW_LINE> <INDENT> return self._random_image_gen(resolution=self.resolution) | Captures a still from the camera and returns it as 3-dimensional RGB array representing the image.
:return: multidimensional list of row, column, RGB values between 0-255. | 625941d7d164cc6175782f9d |
def aggregate_channels(recording_list, renamed_channel_ids=None): <NEW_LINE> <INDENT> return ChannelsAggregationRecording(recording_list, renamed_channel_ids) | Aggregates channels of multiple recording into a single recording object
Parameters
----------
recording_list: list
List of BaseRecording objects to aggregate
renamed_channel_ids: array-like
If given, channel ids are renamed as provided. If None, unit ids are sequential integers.
Returns
-------
aggregate_rec... | 625941d74a966d76dd551260 |
def __len__(self): <NEW_LINE> <INDENT> return len(self._environ) | Get length. | 625941d79b70327d1c4e1024 |
def get(self,user_id,questionario_id): <NEW_LINE> <INDENT> quiz = Questionario.query.get(questionario_id) <NEW_LINE> if not quiz: <NEW_LINE> <INDENT> return 'Quiz Not Found', 404 <NEW_LINE> <DEDENT> if quiz.user_id != user_id: <NEW_LINE> <INDENT> return 'This quiz is not by this user', 400 <NEW_LINE> <DEDENT> response ... | get a quiz from a user | 625941d7d486a94d0b98e395 |
def validate_email(self, email): <NEW_LINE> <INDENT> if email.data != current_user.email: <NEW_LINE> <INDENT> user = User.query.filter_by(email=email.data.upper()).first() <NEW_LINE> if user: <NEW_LINE> <INDENT> raise ValidationError('That email is taken. Please choose a different one.') | Check if Email Already Exists in Database | 625941d7d18da76e23532727 |
def store_hash_of_key(self, key: bytes) -> None: <NEW_LINE> <INDENT> self.key_hashes_lock.acquire() <NEW_LINE> hash_of_key = self.hash_key(key) <NEW_LINE> with open(globals.KEY_HASHES, 'a') as file: <NEW_LINE> <INDENT> file.write(hash_of_key.hex() + "\n") <NEW_LINE> <DEDENT> self.key_hashes_lock.release() | Store hash to later compare with another key's hash.
Args:
key: the key to hash and store | 625941d74527f215b584c6a4 |
def test_get_kubernetes_version_details_unpopulated() -> None: <NEW_LINE> <INDENT> assert ViyaDeploymentReport().get_kubernetes_version_details() is None | This test verifies that a None value is returned for the kubernetes version information when the report is
unpopulated. | 625941d7b830903b967e9b58 |
def get_stack_info(name): <NEW_LINE> <INDENT> client = boto3.client('cloudformation') <NEW_LINE> stackinfo = client.describe_stacks(StackName=name).get('Stacks') <NEW_LINE> if stackinfo is not None: <NEW_LINE> <INDENT> return stackinfo[0] <NEW_LINE> <DEDENT> return {} | Get a dictonary object with detailed info for stack with name | 625941d7711fe17d825425b7 |
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues): <NEW_LINE> <INDENT> if normalize: <NEW_LINE> <INDENT> cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] <NEW_LINE> print("Normalized confusion matrix") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('Confusi... | This function prints and plots the confusion matrix.
Normalization can be applied by setting `normalize=True`. | 625941d7d58c6744b4257eae |
def ansi_code(*digits): <NEW_LINE> <INDENT> return "\x1b[%sm" % ';'.join(map(str, digits)) | 0 20 reset
1 21 bright on/off
2 22 faint
3 23 italic
4 24 underlin
5 25
6 26
7 27 image negative
8 28 conceal
9 29 crossed-out
3* foreground
4* background
0
1 red
2 green
3 yellow
4 blue
5 purple
6 mint
7 gray / white
8 faint | 625941d7009cb60464c635ff |
def sumEvenAfterQueries(self, A, queries): <NEW_LINE> <INDENT> even_sum = 0 <NEW_LINE> for v in A: <NEW_LINE> <INDENT> if v % 2 == 0: <NEW_LINE> <INDENT> v += v <NEW_LINE> <DEDENT> <DEDENT> ret = [] <NEW_LINE> for query in queries: <NEW_LINE> <INDENT> if A[query[1]] % 2 == 0: <NEW_LINE> <INDENT> even_sum -= A[query[1]]... | :type A: List[int]
:type queries: List[List[int]]
:rtype: List[int] | 625941d750812a4eaa59c56f |
def _TotalSeconds(delta): <NEW_LINE> <INDENT> return delta.days * 24 * 60 * 60 + delta.seconds | Re-implementation of datetime.timedelta.total_seconds() for Python 2.6. | 625941d7091ae356686671aa |
def projects_project_id_deployments_post_with_http_info(self, project_id, **kwargs): <NEW_LINE> <INDENT> all_params = ['project_id'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_tim... | This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.projects_project_id_deployments_post_with_http_info(project_id,... | 625941d723849d37ff7b32dd |
def getHilbertSpace(self): <NEW_LINE> <INDENT> return self.createHilbertSpace() | Cached getter mehtod that calls createHilbertSpace() if necessary.
| 625941d710dbd63aa1bd2df2 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.unpack(str[start:end]) <NEW_LINE> start = end <NEW_LINE> end += length <NEW_LINE> if python3: <NEW_LINE> <INDENT> self.path = str[start:end].decode('utf-8') <NEW_L... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941d70fa83653e4657209 |
def ConvertJsonToDict(content): <NEW_LINE> <INDENT> data = [] <NEW_LINE> if isinstance(content, basestring): <NEW_LINE> <INDENT> content = json.loads(content) <NEW_LINE> <DEDENT> content = content['entities'] if 'entities' in content else [content] <NEW_LINE> for obj in content: <NEW_LINE> <INDENT> item = {} <NEW_LINE>... | Convert qc json format to regular dict format for usability
:param content: json content received from HTTP request
:type content: dict or str
:return: usable dict
:rtype: dict | 625941d721bff66bcd684ba0 |
def find_similar_boxids(boxidlist: list) -> tuple: <NEW_LINE> <INDENT> similarboxids_scores={} <NEW_LINE> similarboxids_chars={} <NEW_LINE> for boxid1 in boxidlist: <NEW_LINE> <INDENT> for boxid2 in boxidlist: <NEW_LINE> <INDENT> if boxid1 == boxid2 : <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if (boxid1, boxid2) in... | Given a list of str, find the two that are the most similar.
Similar is equal letters in equal spaces. | 625941d744b2445a339322e4 |
def select(arr, begin, end, index): <NEW_LINE> <INDENT> if begin == end: <NEW_LINE> <INDENT> return arr[begin] <NEW_LINE> <DEDENT> pivot = getMedianOfMedians(arr, begin, end) <NEW_LINE> L, R = partition(arr, begin, end, pivot) <NEW_LINE> if index >= L and index <= R: <NEW_LINE> <INDENT> return pivot <NEW_LINE> <DEDENT>... | "BFPRT主程序
| 625941d7566aa707497f47b5 |
def createGradientModel2D(data, mesh, VTop, VBot): <NEW_LINE> <INDENT> p = np.polyfit(pg.x(data.sensorPositions()), pg.y(data.sensorPositions()), deg=1) <NEW_LINE> n = np.asarray([-p[0], 1.0]) <NEW_LINE> nLen = np.sqrt(np.dot(n, n)) <NEW_LINE> x = pg.x(mesh.cellCenters()) <NEW_LINE> z = pg.y(mesh.cellCenters()) <NEW_LI... | Creates a smooth, linear, starting model that takes the slope
of the topography into account. This is done by fitting a straight line
and using the distance to that as the depth value.
Known as "The Marcus method"
Parameters
----------
data : pygimli DataContainer
The topography list is in here.
mesh : pygimli.Me... | 625941d7d268445f265b50be |
def __init__(self, iterable=None): <NEW_LINE> <INDENT> self.head = None <NEW_LINE> self._size = 0 <NEW_LINE> if iterable: <NEW_LINE> <INDENT> if hasattr(iterable, "__iter__"): <NEW_LINE> <INDENT> for value in iterable: <NEW_LINE> <INDENT> self.push(value) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> raise Typ... | Construct the linked list object. | 625941d76fece00bbac2d990 |
def testAdditionalAttributes(self): <NEW_LINE> <INDENT> for attr in ['sharing_user_id', 'foo']: <NEW_LINE> <INDENT> self.assertRaisesHttpError(400, self._tester.UpdateViewpoint, self._cookie, self._new_vp_id, attr=attr) | Try to update attributes which not available for update. | 625941d7507cdc57c6306f2e |
def str(self, val): <NEW_LINE> <INDENT> return self.format("%.12g", val) | Convert float to integer, taking the locale into account. | 625941d7a8370b7717052aee |
def protocolNamed(name): <NEW_LINE> <INDENT> name = unicode(name) <NEW_LINE> try: <NEW_LINE> <INDENT> return PROTOCOL_CACHE[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> for p in _objc.protocolsForProcess(): <NEW_LINE> <INDENT> pname = p.__name__ <NEW_LINE> PROTOCOL_CACHE.setde... | Returns a Protocol object for the named protocol. This is the
equivalent of @protocol(name) in Objective-C.
Raises objc.ProtocolError when the protocol does not exist. | 625941d75fc7496912cc3bcd |
def __init__(self,pars,N,resolution=1.,unit='pixel'): <NEW_LINE> <INDENT> ShapeObj.__init__(self,self.mkradialwedges,pars,N,resolution=resolution,unit=unit) | The initialization function for the object. | 625941d75e10d32532c5f176 |
def sign_transaction(self, tx_data): <NEW_LINE> <INDENT> data = json.loads(tx_data) <NEW_LINE> unspents = [Unspent.from_dict(unspent) for unspent in data['unspents']] <NEW_LINE> outputs = data['outputs'] <NEW_LINE> return create_p2pkh_transaction(self, unspents, outputs) | Creates a signed P2PKH transaction using previously prepared
transaction data.
:param tx_data: Output of :func:`~bit.PrivateKey.prepare_transaction`.
:type tx_data: ``str``
:returns: The signed transaction as hex.
:rtype: ``str`` | 625941d7d164cc6175782f9e |
def evalf(self, prec=None, **options): <NEW_LINE> <INDENT> if prec is None: <NEW_LINE> <INDENT> coords = [x.evalf(**options) for x in self.args] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> coords = [x.evalf(prec, **options) for x in self.args] <NEW_LINE> <DEDENT> return Point(*coords, **dict(evaluate=False)) | Evaluate the coordinates of the point.
This method will, where possible, create and return a new Point
where the coordinates are evaluated as floating point numbers to
the precision indicated (default=15).
Returns
=======
point : Point
Examples
========
>>> from sympy import Point, Rational
>>> p1 = Point(Rational... | 625941d7be7bc26dc91cd84c |
def url(*args, **kwargs): <NEW_LINE> <INDENT> arg = args and args[0] or '' <NEW_LINE> if arg and not arg.startswith('/') and not arg.startswith('http://'): <NEW_LINE> <INDENT> args = list(args) <NEW_LINE> if kwargs.get('prefix'): <NEW_LINE> <INDENT> args.insert(0, kwargs['prefix']) <NEW_LINE> <DEDENT> else: <NEW_LINE> ... | return a path to script. you can change the root_url. default to `/jquery`:
.. sourcecode:: python
>>> url.root_url = '/path_to_static'
>>> print url('/absolute.js')
/absolute.js
>>> print url('relative', 'plugin.js')
/path_to_static/relative/plugin.js
>>> print url('..', 'plugin.js')
/pat... | 625941d7851cf427c661a75d |
def plot_all_vis2_fits(results, tgt_info): <NEW_LINE> <INDENT> plt.close("all") <NEW_LINE> with PdfPages("plots/bootstrapped_fits.pdf") as pdf: <NEW_LINE> <INDENT> for star_i in np.arange(0, len(results)): <NEW_LINE> <INDENT> sci = results.iloc[star_i]["STAR"] <NEW_LINE> pid = tgt_info[tgt_info["Primary"]==sci].index.v... | Plot a single multi-page pdf of all fits using plot_vis2_fit
| 625941d7cc0a2c11143dd0e0 |
def priority(self, pubkey:str, request_type:bittensor.proto.RequestType, inputs_x: torch.FloatTensor) -> float: <NEW_LINE> <INDENT> priority = self.metagraph.S[ self.metagraph.hotkeys.index(pubkey) ] / sys.getsizeof(inputs_x) <NEW_LINE> return priority | Return the request priority based on stake and size of input.
Used by the Axon to order requests.
Args:
pubkey ( str, `required`):
The public ss58 address of the caller.
inputs_x ( :obj:`torch.Tensor`, `required`):
torch inputs to be forward processed.
request_type ( bittensor.proto.Request... | 625941d75fdd1c0f98dc0483 |
def get_extra_notification_kwargs(self): <NEW_LINE> <INDENT> return None | Return a dict of extra keywords arguments for the ``notify_of_new_report`` method, or None. | 625941d767a9b606de4a8108 |
def test_get_annual_mode_count(self): <NEW_LINE> <INDENT> count = self.summary.get_annual_mode_count(2017) <NEW_LINE> assert(count["CW"] == 1) <NEW_LINE> assert(count["FM"] == 2) <NEW_LINE> assert(count["SSB"] == 1) | Check that, in the year 2017, there was 1 QSO made using CW, 2 QSOs made using FM, and 1 QSO made using SSB. | 625941d7379a373c97cfad95 |
def initialize(self, values: 'Module.ValuesType') -> None: <NEW_LINE> <INDENT> if values: <NEW_LINE> <INDENT> tools.checkValidBasename(self.baseName.value, self.lenName.num()) <NEW_LINE> if int(self.memory.value) < 256 or int(self.memoryGuaranteed.value) < 256: <NEW_LINE> <INDENT> raise Service.ValidationException( _('... | We check here form values to see if they are valid.
Note that we check them throught FROM variables, that already has been
initialized by __init__ method of base class, before invoking this. | 625941d732920d7e50b28422 |
def delete(self, id): <NEW_LINE> <INDENT> cursor = self._connection.cursor() <NEW_LINE> command = "DELETE FROM semester WHERE id={}".format(id) <NEW_LINE> cursor.execute(command) <NEW_LINE> self._connection.commit() <NEW_LINE> cursor.close() | Löschen der Daten eines Semester-Objekts aus der Datenbank
:param id | 625941d716aa5153ce3626c7 |
def bcolz_candidates(self): <NEW_LINE> <INDENT> variant_ids = set() <NEW_LINE> try: <NEW_LINE> <INDENT> for i, family_id in enumerate(self.family_ids): <NEW_LINE> <INDENT> gt_filter = self.family_masks[i] <NEW_LINE> if isinstance(gt_filter, dict): <NEW_LINE> <INDENT> for k, flt in gt_filter.items(): <NEW_LINE> <INDENT>... | Get all the variant ids that meet the genotype filter for any fam. | 625941d7379a373c97cfad96 |
def test_validate_postcode3(self): <NEW_LINE> <INDENT> postcode_inst = PostCodes(10) <NEW_LINE> num = postcode_inst.validate_postcode('A9X 0AX') <NEW_LINE> assert num == False <NEW_LINE> print('Test8: Successful') | Unit test for validating of the Postcode
Negative case | 625941d71f037a2d8b94644d |
def mlbteamsalary(self, irc, msg, args, optteam): <NEW_LINE> <INDENT> optteam = optteam.upper().strip() <NEW_LINE> if optteam not in self._validteams(): <NEW_LINE> <INDENT> irc.reply("Team not found. Must be one of: %s" % self._validteams()) <NEW_LINE> return <NEW_LINE> <DEDENT> lookupteam = self._translateTeam('short'... | [team]
Display top 5 salaries for teams. Ex: Yankees | 625941d7462c4b4f79d1d920 |
def evaluate_locally(self, environment={}): <NEW_LINE> <INDENT> evaluated = [] <NEW_LINE> for (parameter, _) in self.fields: <NEW_LINE> <INDENT> argument = getattr(self, parameter) <NEW_LINE> if isinstance(argument, Expression): <NEW_LINE> <INDENT> evaluated.append(argument.evaluate_locally(environment)) <NEW_LINE> <DE... | Evaluate the QIR expression directly in Python.
The default behavior is to recursively evaluate all the arguments of
the expression from first to last, and then return a new instance of
the expression where the arguments are replaced with their evaluated
counterparts. | 625941d71b99ca400220ad01 |
def adjust_bag(request, item_id): <NEW_LINE> <INDENT> product = get_object_or_404(Product, pk=item_id) <NEW_LINE> quantity = int(request.POST.get('quantity')) <NEW_LINE> size = None <NEW_LINE> if 'product_size' in request.POST: <NEW_LINE> <INDENT> size = request.POST['product_size'] <NEW_LINE> <DEDENT> bag = request.se... | Add a qty of the specified product to the shopping bag | 625941d701c39578d7e7508b |
def istype(filetype): <NEW_LINE> <INDENT> filetype=filetype.lower() <NEW_LINE> if filetype==".xls": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif filetype==".xlsx": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif filetype==".csv": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> ... | 判断是否为Excel或者CSV文件
:param filetype: 文件扩展名
:return: 是,返回True,不是,返回False | 625941d7167d2b6e31218de5 |
def EmitDataChanged(model, topLeft, bottomRight): <NEW_LINE> <INDENT> if QtCore.qVersion().startswith('4.'): <NEW_LINE> <INDENT> model.dataChanged.emit(topLeft, bottomRight) <NEW_LINE> <DEDENT> elif QtCore.qVersion().startswith('5.'): <NEW_LINE> <INDENT> model.dataChanged.emit(topLeft, bottomRight, []) | The data changed API has changed between Qt4 and Qt5 | 625941d745492302aab5e516 |
def package_export(package_id, file_format='', extension='xml'): <NEW_LINE> <INDENT> converted_package = None <NEW_LINE> context = { 'model': model, 'session': model.Session, 'user': toolkit.g.user } <NEW_LINE> content_type = 'text / plain' <NEW_LINE> if extension == 'xml': <NEW_LINE> <INDENT> content_type = 'applicati... | Return the given dataset as a converted file.
| 625941d755399d3f05588905 |
def _backward_linalg_potri(name=None, attr=None, out=None, **kwargs): <NEW_LINE> <INDENT> return (0,) | Parameters
----------
name : string, optional.
Name of the resulting symbol.
Returns
-------
Symbol
The result symbol. | 625941d7507cdc57c6306f2f |
def test_maxgap_default(self): <NEW_LINE> <INDENT> self.assertAlmostEqual(self.args.maxgap,1500.0) | Check the default value of --maxgap | 625941d73617ad0b5ed68146 |
def to_bool(string): <NEW_LINE> <INDENT> true_values = ["True", True, 1] <NEW_LINE> false_values = ["False", False, 0] <NEW_LINE> if string in true_values: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif string in false_values: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rais... | Converting various values to True or False. | 625941d701c39578d7e7508c |
def on_left_pressed(self, event): <NEW_LINE> <INDENT> self.game_of_life.undo() <NEW_LINE> self.draw() | LEFT: UNDO | 625941d7de87d2750b85ffe4 |
def __getitem__(self, key): <NEW_LINE> <INDENT> if 0 <= key < self.pixel_count: <NEW_LINE> <INDENT> pixel_start = key * COLORS_PER_PIXEL <NEW_LINE> return ( self._get_channel_16bit_value(pixel_start + 0), self._get_channel_16bit_value(pixel_start + 1), self._get_channel_16bit_value(pixel_start + 2), ) <NEW_LINE> <DEDEN... | Retrieve the R, G, B values for the provided channel as a 3-tuple.
Each value is a 16-bit number from 0-65535. | 625941d76aa9bd52df036ff4 |
def RequireInternalRequest(methods=ALL_METHODS): <NEW_LINE> <INDENT> def _decorate(f, *a, **kw): <NEW_LINE> <INDENT> check_csrf(methods) <NEW_LINE> return f(*a, **kw) <NEW_LINE> <DEDENT> return decorator(_decorate) | CSRF Spoof Filter
TODO: There is still a scenario in which an attacker opens an adhocracy
page in an iframe, extracts a valid modtoken via javascript and uses this
token to execute the request. | 625941d74428ac0f6e5baa43 |
def handle_kill(self, source, command, args): <NEW_LINE> <INDENT> killed = args[0] <NEW_LINE> data = self.irc.users.get(killed) <NEW_LINE> if data: <NEW_LINE> <INDENT> self.removeClient(killed) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> killer = self.irc.getFriendlyName(source) <NEW_LINE> <DEDENT> except KeyError: <N... | Handles incoming KILLs. | 625941d72eb69b55b151cb01 |
def extractClusters(polyData, clusterInXY=False, **kwargs): <NEW_LINE> <INDENT> if not polyData.GetNumberOfPoints(): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> if (clusterInXY == True): <NEW_LINE> <INDENT> polyDataXY = vtk.vtkPolyData() <NEW_LINE> polyDataXY.DeepCopy(polyData) <NEW_LINE> points=vtkNumpy.getNumpy... | Segment a single point cloud into smaller clusters
using Euclidean Clustering | 625941d7287bf620b61d3cb3 |
def reload(self, client=None): <NEW_LINE> <INDENT> client = self._require_client(client) <NEW_LINE> query_params = self._query_params <NEW_LINE> query_params["projection"] = "noAcl" <NEW_LINE> api_response = client._connection.api_request( method="GET", path=self.path, query_params=query_params, headers=self._encryptio... | Reload properties from Cloud Storage.
If :attr:`user_project` is set, bills the API request to that project.
:type client: :class:`~google.cloud.storage.client.Client` or
``NoneType``
:param client: the client to use. If not passed, falls back to the
``client`` stored on the current obje... | 625941d7cad5886f8bd27229 |
def forward(self, x: np.array)->np.array: <NEW_LINE> <INDENT> y = self._w * x + self._b <NEW_LINE> out = LR.__sigmod_fuc(y) <NEW_LINE> return out | :param x:
:return: y为1的概率 | 625941d73317a56b86939ea4 |
def normal(self, num: int = 18): <NEW_LINE> <INDENT> return self.generate_password(self.alphabet, num) | Generates a normal alphabetic password with lowercase and uppercase letters | 625941d763f4b57ef0001364 |
def create_payment_order(self, product_quantity, price, create_url, description, merchant_id): <NEW_LINE> <INDENT> order_data = self.get_base_payment_data(product_quantity, price, description) <NEW_LINE> if merchant_id: <NEW_LINE> <INDENT> json_params = json.dumps({"merch_code": merchant_id}) <NEW_LINE> order_data['jso... | create new order
:param product_quantity: number of units
:param price: product price for unit
:param create_url: one or two stage create order url
:param description: short order description
:param merchant_id: seller id in bank system
:return: | 625941d77b25080760e396a9 |
def __init__(self, interface=None, use_thread=True, sleep_dt=1./10, verbose=False): <NEW_LINE> <INDENT> if interface is None: <NEW_LINE> <INDENT> interface = webcam.WebcamInterface(use_thread=use_thread, sleep_dt=sleep_dt, verbose=verbose) <NEW_LINE> <DEDENT> if not isinstance(interface, webcam.WebcamInterface): <NEW_L... | Initialize the webcam (input) interface state.
Args:
interface (WebcamInterface, None): webcam input interface. If None, it will initialize the interface.
use_thread (bool): If True, it will run the interface in a thread. Otherwise, it will run the interface
everytime it is called.
sleep_dt (float)... | 625941d7956e5f7376d710bc |
def parse(self, stream, media_type=None, parser_context=None): <NEW_LINE> <INDENT> parser_context = parser_context or {} <NEW_LINE> request = parser_context['request'] <NEW_LINE> encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET) <NEW_LINE> meta = request.META <NEW_LINE> upload_handlers = request.uploa... | Treats the incoming bytestream as a raw file upload and returns
a `DateAndFiles` object.
`.data` will be None (we expect request body to be a file content).
`.files` will be a `QueryDict` containing one 'file' element. | 625941d730bbd722463cc018 |
def __init__(self, snowflake): <NEW_LINE> <INDENT> self.id = int(snowflake) <NEW_LINE> self.name = '' <NEW_LINE> self.created_at = datetime.datetime.utcnow() | Init. Method. | 625941d75fdd1c0f98dc0484 |
def add_access_attempt(self, source, port, when): <NEW_LINE> <INDENT> if port in self.__included_ports: <NEW_LINE> <INDENT> address = Address.for_source(source) <NEW_LINE> if not self.__countries.has_key(address.country.name): <NEW_LINE> <INDENT> self.__countries[address.country.name] = address.country <NEW_LINE> <DEDE... | Tracks a new attempt at accessing the network. | 625941d7627d3e7fe0d690a1 |
def retrieveVals(self): <NEW_LINE> <INDENT> self._genStats = None <NEW_LINE> if self.hasGraph('mysql_connections'): <NEW_LINE> <INDENT> if self._genStats is None: <NEW_LINE> <INDENT> self._genStats = self._dbconn.getStats() <NEW_LINE> <DEDENT> self.setGraphVal('mysql_connections', 'conn', self._genStats.get('Connection... | Retrieve values for graphs. | 625941d74527f215b584c6a5 |
def __init__(self, X, W, Y, H, R, sample_weight=None, n_threads=1, approx_type="quadratic"): <NEW_LINE> <INDENT> super(QAObjectiveLogLoss, self).__init__( X, W, Y, H, R, sample_weight=sample_weight, n_threads=n_threads, approx_type=approx_type) | Build the Quadratic approximation. | 625941d7bf627c535bc1341f |
def setUp(self): <NEW_LINE> <INDENT> self.youtube_uploader = { 'scope': "https://www.googleapis.com/auth/youtube.upload", 'auth_host_name': 'localhost', 'auth_host_port': [8080, 8000], 'client_info': { "client_id": "109430273076-t3e30ie5aseb3laj2da0gkpikir6b0e9.apps.googleusercontent.com", "client_secret": "o3U69gnO4FR... | Set up tests. | 625941d7a219f33f34628bb7 |
def on_moved(self, event): <NEW_LINE> <INDENT> if event.src_path in self.watches: <NEW_LINE> <INDENT> self.watches.remove(event.src_path) <NEW_LINE> self.handler(event.dest_path, self.experiment, self.verbose) | Handle when a file has been modified | 625941d7442bda511e8be666 |
def test_instantiate(self): <NEW_LINE> <INDENT> obj = ChartView3d() | Autogenerated. | 625941d799cbb53fe6792e37 |
def Reposition(self, toButton): <NEW_LINE> <INDENT> nLeft = toButton._left <NEW_LINE> nRight = toButton._left + toButton._width + 1 <NEW_LINE> nButton = self._buttons.index(toButton) <NEW_LINE> for n in range(nButton + 1, len(self._buttons)): <NEW_LINE> <INDENT> oButton = self._buttons[n] <NEW_LINE> oButton._left = nRi... | Repositions all the buttons inside the :class:`ZoomBar`.
:param `toButton`: the button currently hovered by the mouse (and hence zoomed). | 625941d7187af65679ca536f |
def __init__(self, iterable, start=0): <NEW_LINE> <INDENT> pass | Create an enumerate object.
:type iterable: collections.Iterable[T]
:type start: numbers.Integral
:rtype: enumerate[T] | 625941d78e71fb1e9831d9f9 |
def check_cities_available_to_flight(city_from, city_to): <NEW_LINE> <INDENT> flag_from = False <NEW_LINE> flag_to = False <NEW_LINE> available_cities_from = get_lists_of_available_cities('from') <NEW_LINE> available_cities_to = get_lists_of_available_cities('to') <NEW_LINE> for city in available_cities_from: <NEW_LINE... | Check if the cities are available for flight | 625941d71f5feb6acb0c4d9e |
def test_move_sync_root_child_to_user_workspace(self): <NEW_LINE> <INDENT> admin_remote_client = self.root_remote_client <NEW_LINE> user1_workspace_uid = None <NEW_LINE> try: <NEW_LINE> <INDENT> remote_user1 = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.passw... | See https://jira.nuxeo.com/browse/NXP-14870 | 625941d73eb6a72ae02ec732 |
def get_req(url): <NEW_LINE> <INDENT> request = urllib.request.Request(url) <NEW_LINE> request.add_header('Authorization', 'token %s' % API_TOKEN) <NEW_LINE> try: <NEW_LINE> <INDENT> response = urllib.request.urlopen(request).read().decode('utf-8') <NEW_LINE> return response <NEW_LINE> <DEDENT> except urllib.error.HTTP... | simple get request | 625941d7cc40096d61595ba1 |
def ExportSelectFittingOrCutPlane(self, pFittingOrCutPlane): <NEW_LINE> <INDENT> pass | ExportSelectFittingOrCutPlane(self: CDelegateWrapper, pFittingOrCutPlane: dotFittingOrCutPlane_t) -> (int, dotFittingOrCutPlane_t) | 625941d76fece00bbac2d991 |
def bail(message: str) -> None: <NEW_LINE> <INDENT> print(message, file=sys.stderr) <NEW_LINE> raise SystemExit(1) | Write a message to stderr and exit unsuccesfully. | 625941d75e10d32532c5f177 |
def __init__(self, account=None, payment_method=None, hosted_payment_page_fields=None, payment_method_plugin_properties=None, audit_logs=None): <NEW_LINE> <INDENT> self._account = None <NEW_LINE> self._payment_method = None <NEW_LINE> self._hosted_payment_page_fields = None <NEW_LINE> self._payment_method_plugin_proper... | ComboHostedPaymentPage - a model defined in Swagger | 625941d78c0ade5d55d3ec0d |
def get_schemacomponents(self): <NEW_LINE> <INDENT> node1 = etree.Element( util.nspath_eval('csw:SchemaComponent', self.context.namespaces), schemaLanguage='XMLSCHEMA', targetNamespace=self.namespace, parentSchema='gmd.xsd') <NEW_LINE> schema = etree.parse(os.path.join(self.context.pycsw_home, 'plugins', 'profiles', 'a... | Return schema components as lxml.etree.Element list | 625941d744b2445a339322e5 |
def is_latin(uchr): <NEW_LINE> <INDENT> latin_letters = {} <NEW_LINE> try: <NEW_LINE> <INDENT> return latin_letters[uchr] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return latin_letters.setdefault(uchr, 'LATIN' in unic.name(uchr)) | Return True if "uchr" is a latin letter. | 625941d7b7558d58953c5162 |
def checkXY(): <NEW_LINE> <INDENT> if os.path.exists("x:/") and os.path.exists("y:/"): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> print("Please check x: and y:") <NEW_LINE> return False | Check x and y whether creat or connect
True have condition both of xy
:return: | 625941d7e76e3b2f99f3aa59 |
def corr_write_files(cfg, docDict): <NEW_LINE> <INDENT> CORR_FILE_PATH = "/tmp/corr_%d_%%d.json" % os.getpid() <NEW_LINE> halfBin = int( cfg['period'] / 2 ) <NEW_LINE> if ( not cfg['by_tbin'] ): <NEW_LINE> <INDENT> filename = CORR_FILE_PATH % 0 <NEW_LINE> cfg['files'].append(filename) <NEW_LINE> myFile = open(filename,... | function to write MonIT documents to file for editing/correction | 625941d792d797404e3043db |
def _update_offset(self, last_message, response): <NEW_LINE> <INDENT> self.request.offset_id = last_message.id <NEW_LINE> if self.reverse: <NEW_LINE> <INDENT> self.request.offset_id += 1 <NEW_LINE> <DEDENT> if isinstance(self.request, functions.messages.SearchRequest): <NEW_LINE> <INDENT> self.request.max_date = None <... | After making the request, update its offset with the last message. | 625941d73317a56b86939ea5 |
def write(self, value): <NEW_LINE> <INDENT> if isinstance(value, list) and isinstance(self.variable_designator.resolve_type, list): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> self.variable_designator._set_current_protected(value) <NEW_LINE> <DEDENT> elif isinstance(value[0], self.variable_designator.resolve_... | Write a value to the designator this writer is associated with.
:param value: the value to be written
:return: None
Value can be either a singular object or a list, which may be empty or not.
The singular object's type has to fit the resolve_type.
If the value is a list, then resolve_type must also be a list,
whi... | 625941d723e79379d52ee7b2 |
def mem_mode_to_string(mem_mode: MemMode) -> str: <NEW_LINE> <INDENT> if mem_mode == MemMode.TIMING: <NEW_LINE> <INDENT> return "timing" <NEW_LINE> <DEDENT> elif mem_mode == MemMode.ATOMIC: <NEW_LINE> <INDENT> return "atomic" <NEW_LINE> <DEDENT> elif mem_mode == MemMode.ATOMIC_NONCACHING: <NEW_LINE> <INDENT> return "at... | Returns the string form of the mem_mode, compatible with the gem5
simulator.
:returns: The string form of the mem_mode | 625941d756b00c62f0f148ab |
def SwitchModels(self,switchpatterns=None,unregister=None,switchtofat=None,clearpatterns=None,clearmodels=None,update=None): <NEW_LINE> <INDENT> cmd = 'switchmodels ' <NEW_LINE> if switchpatterns is not None: <NEW_LINE> <INDENT> for pattern,filename in switchpatterns: <NEW_LINE> <INDENT> cmd += 'register %s %s '%(patte... | See :ref:`module-taskmanipulation-switchmodels`
| 625941d715baa723493c41c8 |
def sieve_of_eratosthenes(limit): <NEW_LINE> <INDENT> if limit <= 1: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> nrs = list(range(limit + 1)) <NEW_LINE> i = 2 <NEW_LINE> while i*i <= limit: <NEW_LINE> <INDENT> if nrs[i] == 0: <NEW_LINE> <INDENT> i += 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> elim = i*i <NEW_LINE>... | Find all primes up to a certain limit.
This function makes use of the `Sieve of Eratosthenes <http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>`_
to find all prime numbers up to a certain limit.
:param int limit: upper limit of the algorithm
:return: list of prime numbers up to the given limit
:rtype: list
Example... | 625941d730c21e258bdfa6ef |
def RPL_TRACELINK(sender, receipient, message): <NEW_LINE> <INDENT> return "<" + sender + ">: " + message | Reply Code 200 | 625941d7b57a9660fec33ad8 |
def is_alphanumeric_string(self, string): <NEW_LINE> <INDENT> return bool(re.compile("^[a-zA-Z0-9]+$").match(string)) | Check whether a string is alphanumeric. | 625941d73346ee7daa2b2fbe |
def _compute_hecke_matrix_prime_power(self, p, r): <NEW_LINE> <INDENT> if self.level() == 1: <NEW_LINE> <INDENT> return self._compute_hecke_matrix(p**r) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return space.ModularFormsSpace._compute_hecke_matrix_prime_power(self, p, r) | Compute the Hecke matrix `T_{p^r}`, where `p` is prime and `r \ge 2`.
This is an internal method. End users are encouraged to use the
method hecke_matrix() instead.
TESTS:
sage: M = ModularForms(1, 12)
sage: M._compute_hecke_matrix_prime_power(5, 3)
[ 116415324211120654296876 11038396588040733750558720... | 625941d7d58c6744b4257eaf |
def write16bit(self, register, value): <NEW_LINE> <INDENT> if value > ((2 ** 16) - 1) or value < 0: <NEW_LINE> <INDENT> raise ValueError <NEW_LINE> <DEDENT> valuearray = struct.pack('!H', value) <NEW_LINE> self.device.writeregistermulti(register, valuearray) | Write 16-bit integer into register. | 625941d75fcc89381b1e1912 |
def blocks(self, ignore_blank_lines=True): <NEW_LINE> <INDENT> start, end = self.get_range(ignore_blank_lines=ignore_blank_lines) <NEW_LINE> block = self._trigger.next() <NEW_LINE> ref_lvl = self.scope_level <NEW_LINE> while block.blockNumber() <= end and block.isValid(): <NEW_LINE> <INDENT> lvl = TextBlockHelper.get_f... | This generator generates the list of blocks directly under the fold
region. This list does not contain blocks from child regions.
:param ignore_blank_lines: True to ignore last blank lines. | 625941d7cb5e8a47e48b7cf8 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> super(ZoneManager, self).__init__(**kwargs) <NEW_LINE> self.configuration = config.Configuration(zone_manager_opts, 'fc-zone-manager') <NEW_LINE> self._build_driver() | Load the driver from the one specified in args, or from flags. | 625941d776d4e153a657ed83 |
def __len__(self): <NEW_LINE> <INDENT> if self.ndim == 1: <NEW_LINE> <INDENT> return 1; <NEW_LINE> <DEDENT> return super().__len__() | Number of positions in Array | 625941d74a966d76dd551262 |
@api.route('/exif/<filename:path>') <NEW_LINE> def json_exif_information(filename): <NEW_LINE> <INDENT> filename = clean_url_path(filename) <NEW_LINE> if not filename in all_images(): <NEW_LINE> <INDENT> abort(404, "image not found") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> exif = structure_exif_data( clean_exif_da... | Return EXIF information in JSON format.
A dictionary is being returned containing the EXIF key numbers as keys and
an dictionary containing the name and value of the respective EXIF tag. | 625941d7d99f1b3c44c677dd |
def collapse_includes_found(classes): <NEW_LINE> <INDENT> base_class_map = get_base_class_map() <NEW_LINE> collapsed_includes_found = {} <NEW_LINE> for source in includes_found: <NEW_LINE> <INDENT> source_base = get_base_class(source, base_class_map, classes) <NEW_LINE> for target in includes_found[source]: <NEW_LINE> ... | Convert "includes_found" dict to a new dict which replaces each class
by the base class (as determined through merges). This done to determine
which classes depend on other classes, which is needed to figure out
the order in which the classes should be displayed.
classes is the list of classes to which all entries in ... | 625941d7009cb60464c63601 |
def getUsers(self): <NEW_LINE> <INDENT> import re <NEW_LINE> files = os.listdir('.') <NEW_LINE> l = [] <NEW_LINE> p = re.compile('^(.+)_Bioscope.cfg$') <NEW_LINE> def func(fileName): <NEW_LINE> <INDENT> r = p.match(fileName) <NEW_LINE> if r is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> l.append(r.groups()[0])... | Return a list of users | 625941d7711fe17d825425b9 |
def _new_conn(self): <NEW_LINE> <INDENT> self.num_connections += 1 <NEW_LINE> log.info("Starting new HTTPS connection (%d): %s" % (self.num_connections, self.host)) <NEW_LINE> if not self.ConnectionCls or self.ConnectionCls is DummyConnection: <NEW_LINE> <INDENT> raise SSLError("Can't connect to HTTPS URL because the S... | Return a fresh :class:`httplib.HTTPSConnection`. | 625941d7090684286d50ef38 |
def _dK_computations(self, dL_dK): <NEW_LINE> <INDENT> self._dL_dl = (dL_dK*self.variance*self._K_dvar*(self.input_dim/2.*(self._lengthscales_two.T**4 - self._lengthscales**4) + 2*self._lengthscales2*self._K_dist2)/(self._w2*self._w2*self._lengthscales)).sum(1) <NEW_LINE> if self._lengthscales_two is self._lengthscales... | Pre-computations for the gradients of the covaraince function. Here the gradient of the covariance with respect to all the individual lengthscales is computed.
:param dL_dK: the gradient of the objective with respect to the covariance function.
:type dL_dK: ndarray | 625941d7d58c6744b4257eb0 |
def cached_property(func): <NEW_LINE> <INDENT> name = func.__name__ <NEW_LINE> doc = func.__doc__ <NEW_LINE> def getter(self, name=name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.__dict__[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> self.__dict__[name] = value = func(self) <NEW_LINE> r... | Special property decorator that caches the computed
property value in the object's instance dict the first
time it is accessed. | 625941d7091ae356686671ac |
def match_by_envelope(full_sound, pattern, window_size=500, corr_thresh=0.85, rms_threshold=None, window_step=1, rolling_method='pandas'): <NEW_LINE> <INDENT> logger.info('Matching envelope across sound with {0} samples'.format(full_sound.n_samples)) <NEW_LINE> logger.info('Pattern has {} samples'.format(pattern.sample... | :param full_sound: Sound with the full sound
:param pattern: Chunk with the pattern to find
:param window_size: size of window for the envelope
:param corr_thresh: threshold for peaks of correlation
:param rms_threshold: threshold for rms (in standard deviations)
:param window_step: sub_sampling rate for the rolling wi... | 625941d710dbd63aa1bd2df4 |
def __len__(self): <NEW_LINE> <INDENT> return len(self._scopes) | Number of scopes in this profile
:return: Number of scopes
:rtype: Int | 625941d721bff66bcd684ba2 |
def vocabulary(definition): <NEW_LINE> <INDENT> if callable(definition): <NEW_LINE> <INDENT> definition = definition() <NEW_LINE> <DEDENT> if isinstance(definition, STR_TYPE): <NEW_LINE> <INDENT> return [(definition, definition), ] <NEW_LINE> <DEDENT> if hasattr(definition, '__getitem__') and hasattr(definition, 'keys'... | Convert different kinds of input into a list of bi-tuples, both strings.
| 625941d77b180e01f3dc4a4b |
def image_viewer(self, idx, base_idx=None, viewer=None): <NEW_LINE> <INDENT> if notebook_env: <NEW_LINE> <INDENT> if base_idx: <NEW_LINE> <INDENT> display(gui.image_viewer(self, self.steps[idx], self.steps[base_idx], viewer=viewer)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> display(gui.image_viewer(self, self.steps... | Launch image viewer
:param idx:
:param base_idx:
:return: | 625941d74e696a04525c969d |
def compare_ps(compareParameter='mag', groupParameter='all'): <NEW_LINE> <INDENT> dat = Table.read('lists/gaia_coord/gaia_lris_targsNGC2506.fits') <NEW_LINE> closePt = group_sources(dat,groupParameter=groupParameter) <NEW_LINE> color = dat['G_PS'] - dat['R_PS'] <NEW_LINE> deltaMag = dat['G_PS'] - dat['Gmag'] <NEW_LINE>... | Compare Gaia DR2 and PS
Parameters
----------
compareParameter: str
If 'mag', show the g - G magnitude difference
If 'dist', show the offsets in coordinates between Pan-Starrs
and Gaia DR2
If 'pm', show the proper motions
groupParameter: str
If 'dist', group the sources by Gaia-PS distance
If '... | 625941d7ff9c53063f47c444 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.