code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def resnet101_rmac(out_dim=2048, dropout_p=None, weights=None, **kwargs): <NEW_LINE> <INDENT> model = ResNet_RMAC(Bottleneck, [3, 4, 23, 3], dropout_p=dropout_p, fc_out=out_dim, **kwargs) <NEW_LINE> if weights: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if torch.cuda.device_count()>0: <NEW_LINE> <INDENT> weight_dict ... | Constructs a ResNet-101 model.
| 625941d5379a373c97cfad5c |
def xdp(*args, **kwargs): <NEW_LINE> <INDENT> if d4.debug >= 2: <NEW_LINE> <INDENT> print("DEBUG: [DBG"+str(d4.debug)+"] ["+str(os.path.basename(__file__))+"] ["+str(inspect.currentframe().f_code.co_name)+"()]") <NEW_LINE> <DEDENT> return xdisplay(*args, **kwargs) | Alias for xdisplay()
| 625941d5a79ad161976cc35c |
def __zoomIn(self): <NEW_LINE> <INDENT> self.currentBrowser().zoomIn() <NEW_LINE> self.__zoomWidget.setValue(self.currentBrowser().zoomValue()) | Private slot called to handle the zoom in action. | 625941d5ad47b63b2c50a195 |
def build_network(self, hidden_config, n_outputs): <NEW_LINE> <INDENT> with self.init_scope(): <NEW_LINE> <INDENT> final_config = dict(hidden_config) <NEW_LINE> final_config.update( dict(layer_sizes=[n_outputs], activation="identity")) <NEW_LINE> blocks = [ DenseBlock(params=hidden_config), DenseBlock(params=final_conf... | Build a dense network according to the config. specified
| 625941d563d6d428bbe44705 |
def on_trial_end(self, trial): <NEW_LINE> <INDENT> if self.logger: <NEW_LINE> <INDENT> self.logger.report_trial_state(trial.trial_id, trial.get_state()) <NEW_LINE> <DEDENT> self.oracle.end_trial(trial.trial_id, trial_module.TrialStatus.COMPLETED) <NEW_LINE> self.oracle.update_space(trial.hyperparameters) <NEW_LINE> sel... | Called at the end of a trial.
Args:
trial: A `Trial` instance. | 625941d51f037a2d8b946413 |
def toolchain(self): <NEW_LINE> <INDENT> if 'tc_versop' in self: <NEW_LINE> <INDENT> return self['tc_versop'].as_dict() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Get toolchain spec for dependency (if any). | 625941d5d53ae8145f87a483 |
def Ortho(self): <NEW_LINE> <INDENT> (index, val) = self.LargestComponent() <NEW_LINE> index = index - 1 <NEW_LINE> if index < 0: <NEW_LINE> <INDENT> index = 2 <NEW_LINE> <DEDENT> temp = Point(0.012, 0.053, 0.00457) <NEW_LINE> if index == 0: <NEW_LINE> <INDENT> temp.x = 1 <NEW_LINE> <DEDENT> elif index == 1: <NEW_LINE>... | Returns a unit-length point orthogonal to this point | 625941d58c3a8732951585d1 |
def verify(self): <NEW_LINE> <INDENT> for i in range(len(self.tx_ins)): <NEW_LINE> <INDENT> if not self.verify_input(i): <NEW_LINE> <INDENT> LOGGER.info('failed at input {}'.format(i)) <NEW_LINE> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Verify every input of this transaction | 625941d56aa9bd52df036fba |
def get_full_save_path(self): <NEW_LINE> <INDENT> section = constants.PLAYER_GAME <NEW_LINE> game_name = self.get_config_value(section, "game_name", constants.STRING) <NEW_LINE> session_name = self.get_config_value(section, "session_name", constants.STRING) <NEW_LINE> save_folder = self.get_config_value(section, "save_... | Replaces all placeholders by real values and join all paths. | 625941d516aa5153ce36268d |
def extract_isnull_bytemap(array: Union[pa.ChunkedArray, pa.Array]) -> np.ndarray: <NEW_LINE> <INDENT> if array.null_count == len(array): <NEW_LINE> <INDENT> return np.ones(len(array), dtype=bool) <NEW_LINE> <DEDENT> if isinstance(array, pa.ChunkedArray): <NEW_LINE> <INDENT> result = np.zeros(len(array), dtype=bool) <N... | Extract the valid bitmaps of a (chunked) array into numpy isnull bytemaps.
Parameters
----------
array
Array from which we extract the validity bits as bytes
Returns
-------
valid_bytemap | 625941d51b99ca400220acc7 |
def get_file(self, name): <NEW_LINE> <INDENT> if name not in self._files: <NEW_LINE> <INDENT> self.get_files() <NEW_LINE> <DEDENT> data = self.session.get('files/' + self._files[name]['googleId']) <NEW_LINE> return dict(name=name, content=self.decrypt(data['content'])) | Get file by its name. | 625941d57d43ff24873a2eb6 |
def letter_score(position): <NEW_LINE> <INDENT> i, j = position <NEW_LINE> if BOARD[i][j] != ' ': <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> return LETTER_SCORE_MULTIPLIER.get(position, 1) | Double/Triple Letter Score multiplier. | 625941d594891a1f4081bcc0 |
def wine_deactivate(): <NEW_LINE> <INDENT> os.putenv('PATH', PATH) <NEW_LINE> print('deactivated. "which wine" output:') <NEW_LINE> test_call = 'which wine' <NEW_LINE> os.system(test_call) | remove WINE_BIN from PATH environment variable | 625941d597e22403b379d1b1 |
def rwh_primes1(n): <NEW_LINE> <INDENT> sieve = [True] * (n//2) <NEW_LINE> for i in _range(3,int(n**0.5)+1,2): <NEW_LINE> <INDENT> if sieve[i//2]: <NEW_LINE> <INDENT> sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1) <NEW_LINE> <DEDENT> <DEDENT> return [2] + [2*i+1 for i in _range(1,n//2) if sieve[i]] | Returns a list of primes < n | 625941d591f36d47f21ac70a |
def test_height_from_xml_correct(self): <NEW_LINE> <INDENT> assert_that(self.row.height, is_(equal_to(370840))) | _Row.height returns correct value from tr XML element | 625941d5e1aae11d1e749ecf |
def __init__(self, n, instance='key', m=None): <NEW_LINE> <INDENT> if n<89: <NEW_LINE> <INDENT> raise TypeError("Parameter too small") <NEW_LINE> <DEDENT> n2 = n <NEW_LINE> C = 4/sqrt(2*pi) <NEW_LINE> kk = floor((n2-2*log(n2, 2)**2)/5) <NEW_LINE> n1 = floor((3*n2-5*kk)/2) <NEW_LINE> ke = floor((n1-2*log(n1, 2)**2)/5) ... | Construct LWE instance parameterised by security parameter ``n`` where
all other parameters are chosen as in [CGW2013]_.
INPUT:
- ``n`` - security parameter (integer >= 89)
- ``instance`` - one of
- "key" - the LWE-instance that hides the secret key is generated
- "encrypt" - the LWE-instance that hides the mess... | 625941d5f9cc0f698b140810 |
def sim_filter(self, query, cutoff=0.75): <NEW_LINE> <INDENT> if len(self.fp_name) == 0 or self.fp_col not in self.data.columns: <NEW_LINE> <INDENT> raise KeyError( "No fingerprints found. Please generate them first with add_fp()." ) <NEW_LINE> <DEDENT> if len(self.data) > 5000: <NEW_LINE> <INDENT> show_prog = True <NE... | Similarity filter. Returns a new MolFrame instance.
Add a suitable fingerprint once with addf_fps(),
then give a reference molecule or a SMILES string as query. | 625941d563b5f9789fde72fb |
def Pickler(file, protocol=0): <NEW_LINE> <INDENT> return None | Pickler(file, protocol=0) -- Create a pickler.
This takes a file-like object for writing a pickle data stream.
The optional proto argument tells the pickler to use the given
protocol; supported protocols are 0, 1, 2. The default
protocol is 0, to be backwards compatible. (Protocol 0 is the
only protocol that can be ... | 625941d521a7993f00bc7f08 |
def setup_nginx_pod(self, name=None, namespace='default', metadata=None, container_port=80, labels=None, spec=None): <NEW_LINE> <INDENT> metadata = metadata or {} <NEW_LINE> spec = spec or {} <NEW_LINE> labels = labels or {} <NEW_LINE> name = name or get_random_name('nginx-pod') <NEW_LINE> if labels: <NEW_LINE> <INDENT... | Noticed that nginx continues to listen on port 80 even if target port
(container_port) is different | 625941d50383005118ecf7f8 |
def create_or_update( self, resource_group_name, namespace_name, event_hub_name, consumer_group_name, user_metadata=None, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> parameters = models.ConsumerGroup(user_metadata=user_metadata) <NEW_LINE> url = '/subscriptions/{subscriptionId}/resourceGrou... | Creates or updates an Event Hubs consumer group as a nested resource
within a Namespace.
:param resource_group_name: Name of the resource group within the
azure subscription.
:type resource_group_name: str
:param namespace_name: The Namespace name
:type namespace_name: str
:param event_hub_name: The Event Hub name
:t... | 625941d5eab8aa0e5d26dd6f |
def clean_fields(self, attrs, field_names): <NEW_LINE> <INDENT> for field in sorted(field_names): <NEW_LINE> <INDENT> name = ''.join((self.FIELD_CLEAN_PREFIX, field)) <NEW_LINE> if hasattr(self, name) and callable(getattr(self, name)) and field in attrs: <NEW_LINE> <INDENT> attrs[field] = getattr(self, name)(attrs[fiel... | If subclass defines functions named clean_<field_name>
where field_name corresponds to a field declared on the
serializer, executes such functions with the field's value
as the parameter and sets the return value on the attrs dict
:param attrs: dict to apply the cleaned values on
:param field_names: an iterable of fiel... | 625941d55e10d32532c5f13d |
def sample_minibatch(self, minibatch_size): <NEW_LINE> <INDENT> self.minibatch = np.random.choice( np.arange( self.N ), minibatch_size, replace = False ) | Sample the next minibatch | 625941d59f2886367277aaa3 |
def parse_message(server, signal_data): <NEW_LINE> <INDENT> details = {} <NEW_LINE> if int(version) >= 0x00030400: <NEW_LINE> <INDENT> details = weechat.info_get_hashtable("irc_message_parse", { "message": signal_data, "server": server }) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (source, command, channel, message)... | Parses an IRC PRIVMSG into a hash.
Provides support for WeeChat < 0.3.4
Returns: {
"arguments": arguments, (includes channel)
"channel": channel,
"command": command,
"host": host,
"text": text,
"nick": nick,
} | 625941d53c8af77a43ae39b7 |
def autontrast(src_path, dest_path, white_perc, black_perc): <NEW_LINE> <INDENT> img = cv2.imread(src_path) <NEW_LINE> img = np.sum(img, axis=2) / 3 <NEW_LINE> hist, _ = np.histogram(img, bins=256, range=(0, 256)) <NEW_LINE> cdf = np.cumsum(hist) <NEW_LINE> cdf_n = np.ma.masked_less_equal(cdf, cdf.max()*white_perc) <NE... | :param src_path: Source image path
:param dest_path: Destination image path
:param white_perc: Percentage of white pixels
:param black_perc: Percentage of black pixels | 625941d5d4950a0f3b08c564 |
def movie_review(name): <NEW_LINE> <INDENT> list_options = ["See it!", "A gem!", "Ideological claptrap!"] <NEW_LINE> return list_options[randint(0, 2)] | Input: the name of a movie
Output: a string (one of the review options), selected at random using randint | 625941d50c0af96317bb83ff |
def lerp(a, b, t): <NEW_LINE> <INDENT> assert 0.0 <= t <= 1.0 <NEW_LINE> value = (1 - t) * a + t * b <NEW_LINE> assert a <= value <= b, "Out of range" <NEW_LINE> return value | For interpolating between the range [a, b], according to the formula:
value = (1 - t) * a + t * b, for t in [0, 1] | 625941d524f1403a92600d7b |
def cmmi(self, dest): <NEW_LINE> <INDENT> options = self.configure_options <NEW_LINE> if options is None: <NEW_LINE> <INDENT> options = '--prefix="%s"' % dest <NEW_LINE> <DEDENT> if self.extra_options: <NEW_LINE> <INDENT> options += ' %s' % self.extra_options <NEW_LINE> <DEDENT> system("%s %s" % (self.configure_cmd, op... | Do the 'configure; make; make install' command sequence.
When this is called, the current working directory is the
source directory. The 'dest' parameter specifies the
installation prefix.
This can be overridden by subclasses to support packages whose
command sequence is different. | 625941d5a8ecb033257d32e3 |
def decimals(self, start: float = 0.0, end: float = 1000.0, n: int = 10) -> List[Decimal]: <NEW_LINE> <INDENT> return [self.decimal_number(start, end) for _ in range(n)] | Generate decimal number as Decimal objects.
:param start: Start range.
:param end: End range.
:param n: Length of the list.
:return: A list of random decimal numbers. | 625941d53617ad0b5ed6810d |
def build_albums(path, recursive=False): <NEW_LINE> <INDENT> def prep_album(files, path): <NEW_LINE> <INDENT> paths = [os.path.join(path, x) for x in files] <NEW_LINE> tracks = [Track(x) for x in paths if os.path.isfile(x) and File(x)] <NEW_LINE> if not tracks: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> album ... | Provides an iterable of Albums based on a path
build_albums provides an optional parameter: recursive.
If recursive is set to True, Albums will be created from
the given path, as well as any subdirectories. The
default is False, and so only one Album is created for
the iterable result. | 625941d582261d6c526ab6b8 |
def delete(self, notify=True): <NEW_LINE> <INDENT> shutil.rmtree(os.path.join(app.config['FLASKUP_UPLOAD_FOLDER'], self.path)) <NEW_LINE> if 'delete' in app.config['FLASKUP_NOTIFY'] and notify: <NEW_LINE> <INDENT> subject = render_template('emails/notify_delete_subject.txt', f=self) <NEW_LINE> body = render_template('e... | Remove the folder where the shared file is stored. | 625941d55fdd1c0f98dc044a |
def recursive2(game2: Any, t: list) -> int: <NEW_LINE> <INDENT> if game2.is_over(game2.current_state): <NEW_LINE> <INDENT> if game2.is_winner("p1"): <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> if game2.is_winner("p2"): <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> ... | A help function of recursive_minimax_strategy | 625941d52c8b7c6e89b359d7 |
def _stop(self): <NEW_LINE> <INDENT> self.__context.remove_service_listener(self) <NEW_LINE> try: <NEW_LINE> <INDENT> with use_ipopo(self.__context) as ipopo: <NEW_LINE> <INDENT> ipopo.remove_listener(self) <NEW_LINE> <DEDENT> <DEDENT> except BundleException: <NEW_LINE> <INDENT> pass | Stops the instantiation queue (called by its bundle activator) | 625941d5bd1bec0571d90846 |
def dropna(self, axis=0, inplace=False, how=None): <NEW_LINE> <INDENT> return super(Series, self).dropna(axis=axis, inplace=inplace) | Return a new Series with missing values removed. | 625941d5d58c6744b4257e75 |
def _get_vnf_mapping(self, context, vnf_mapping, vnf_members): <NEW_LINE> <INDENT> vnfm_plugin = manager.TackerManager.get_service_plugins()['VNFM'] <NEW_LINE> new_mapping = dict() <NEW_LINE> for vnfd in vnf_members: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> vnfd_id = vnfm_plugin.get_vnfds(context, {'name': [vnfd]},... | Creates/validates a mapping of VNFD names to VNF IDs for NFP.
:param context: SQL session context
:param vnf_mapping: dict of requested VNFD:VNF_ID mappings
:param vnf_members: list of constituent VNFs from a VNFFG
:return: dict of VNFD:VNF_ID mappings | 625941d5460517430c394398 |
def isOnWhichSymmetryLine(self): <NEW_LINE> <INDENT> grid = self.core.spatialGrid <NEW_LINE> return grid.overlapsWhichSymmetryLine(self.spatialLocator.getCompleteIndices()) | Block symmetry lines are determined by the reactor, not the parent. | 625941d563f4b57ef000132c |
def publish(self, repo_destdir): <NEW_LINE> <INDENT> for pkg in self.__bin_packages: <NEW_LINE> <INDENT> pkg.publish(self.__repository_path, repo_destdir) | Publish the rpm files from repository source | 625941d5d10714528d5ffefb |
def fetch_result(M, args): <NEW_LINE> <INDENT> M.select(args.folder, "true") <NEW_LINE> typ, data = M.search(None, args.message_since) <NEW_LINE> if args.list_folders: <NEW_LINE> <INDENT> folders = M.list() <NEW_LINE> if folders[0] == 'OK': <NEW_LINE> <INDENT> return [folder.decode() for folder in folders[1]] <NEW_LINE... | Fetch result as specified in args | 625941d599fddb7c1c9de5a7 |
def FCSoCursor(self): <NEW_LINE> <INDENT> import ctypes <NEW_LINE> so = ctypes.cdll.LoadLibrary(self.path) <NEW_LINE> return so | :return:
c = Cso(path)
print(c.FCSoCursor().get_board_count('void')) | 625941d576e4537e8c35188a |
def function_name(): <NEW_LINE> <INDENT> pass | Check if a is a factor of b | 625941d53346ee7daa2b2f83 |
def isHappy(self, n): <NEW_LINE> <INDENT> history = {} <NEW_LINE> while (n not in history): <NEW_LINE> <INDENT> history[n] = 1 <NEW_LINE> n = self.getDigitSum(n) <NEW_LINE> if (n == 1): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | :type n: int
:rtype: bool | 625941d5507cdc57c6306ef5 |
def get_results(): <NEW_LINE> <INDENT> res_list = [] <NEW_LINE> RESULTS_FOLDER = '../results-single-dataset/' <NEW_LINE> RESULTS_FOLDER_PLOTS = '../results-single-dataset/plots/' <NEW_LINE> for file_name in os.listdir(RESULTS_FOLDER): <NEW_LINE> <INDENT> if file_name.split('.')[-1] == 'mat': <NEW_LINE> <INDENT> res_lis... | Get results for all pairs of compared algorithms and save results
into ../results-single-datasets/ folder. The data is read from the .mat
files in ../results-single-dataset/ | 625941d58e71fb1e9831d9bf |
def get_number_rows(ia_settings, ship_height, alien_height): <NEW_LINE> <INDENT> avaliable_space_y = (ia_settings.screen_height - (3 * alien_height) - ship_height) <NEW_LINE> number_rows = int(avaliable_space_y / (2 * alien_height)) <NEW_LINE> return number_rows | Determina o número de linhas com alienígenas que cabem na tela | 625941d5046cf37aa974cf5d |
def test_config_not_ignored(): <NEW_LINE> <INDENT> assert "3 single benchmarks" in run_temci("short exec ls", settings={"run": {"runs": 3}}).out | Issue "Config now seems to be ignored completely after type checking #62" | 625941d59b70327d1c4e0fec |
def failure(self,reason,reason1): <NEW_LINE> <INDENT> print("Trace download failed", reason) | Handle file download failure. | 625941d5435de62698dfde64 |
def prepare_data(data, avg): <NEW_LINE> <INDENT> return data - avg | Подготавливает данные для кореляционного классификатора
:param data: np.array, данные (размер выборки, количество пикселей
:return: data: np.array, данные (размер выборки, количество пикселей | 625941d55fc7496912cc3b95 |
def get_trail_facts(module, client, name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> trail_resp = client.describe_trails(trailNameList=[name]) <NEW_LINE> <DEDENT> except (BotoCoreError, ClientError) as err: <NEW_LINE> <INDENT> module.fail_json_aws(err, msg="Failed to describe Trail") <NEW_LINE> <DEDENT> if len(trail... | Describes existing trail in an account
module : AnsibleAWSModule object
client : boto3 client connection object
name : Name of the trail | 625941d5ab23a570cc25039a |
def download_chunk(self, offset): <NEW_LINE> <INDENT> download_options = { 'format': 'json', 'limit': self._limit, 'offset': offset, 'platforms': self._platforms, 'api_key': self.api_key, 'field_list': ','.join(self.GAME_READ_FIELDS), } <NEW_LINE> response = requests.get(urljoin(self.API_BASE_URL, 'games/'), params=dow... | :param offset: int
:return: | 625941d5293b9510aa2c34ab |
def dragMoveEvent(self, QGraphicsSceneDragDropEvent): <NEW_LINE> <INDENT> pass | QGraphicsTextItem.dragMoveEvent(QGraphicsSceneDragDropEvent) | 625941d5aad79263cf390c5a |
def _get_connection_status(self, connection_id: str) -> ServiceResponse: <NEW_LINE> <INDENT> if connection_id in self._connections: <NEW_LINE> <INDENT> msg = messages.ConnectionStatus(connection_id, self._connections[connection_id].status) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = messages.IndyServiceFail("Un... | Return the status of a registered connection
Args:
connection_id: the unique identifier of the connection | 625941d57c178a314d6ef679 |
def trivial_eq(e): <NEW_LINE> <INDENT> return len(e.args) == 0 | Assumes e is a Sum.
Determine whether e == 0 is the trivial equality 0 == 0 | 625941d55fcc89381b1e18d8 |
def rent_control_check_post(self, body, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.rent_control_check_post_with_http_info(body, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.rent_control_check_post_... | Encadrement des loyers
Permet de controller vis-à-vis de la législation si un loyer est hors/dans l'encadrement des loyers.
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_funct... | 625941d5fff4ab517eb2f653 |
def make_counter(): <NEW_LINE> <INDENT> dic = {} <NEW_LINE> def counter(key,value): <NEW_LINE> <INDENT> if key in dic: <NEW_LINE> <INDENT> dic[key] += value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dic[key] = value <NEW_LINE> <DEDENT> return dic[key] <NEW_LINE> <DEDENT> return counter | Return a counter function.
>>> c = make_counter()
>>> c('a', 3)
3
>>> c('a', 5)
8
>>> c('b', 7)
7
>>> c('a', 9)
17
>>> c2 = make_counter()
>>> c2(1, 2)
2
>>> c2(3, 4)
4
>>> c2(3, c('b', 6))
17 | 625941d5462c4b4f79d1d8e7 |
def get_remote_timestamp(self, last_modified): <NEW_LINE> <INDENT> if self.debug: <NEW_LINE> <INDENT> print('[+] get_remote_timestamp called with: ' + last_modified) <NEW_LINE> <DEDENT> temp_time = time.strptime(last_modified, "%a, %d %b %Y %H:%M:%S %Z") <NEW_LINE> return round(time.mktime(temp_time)) | Convert the Last-Modified header time into epoch time
:param last_modified: Last-Modified header timestamp
:return: epoch time | 625941d5f9cc0f698b140811 |
def sample_batch(self, batch_size): <NEW_LINE> <INDENT> probs = self.probabilities.numpy() <NEW_LINE> indices = np.random.choice(len(self), batch_size, p=probs / np.sum(probs)) <NEW_LINE> return default_collate([self[i] for i in indices]) | Get a batch of data. | 625941d5d58c6744b4257e76 |
def __call__(self, data, variable): <NEW_LINE> <INDENT> raise NotImplementedError( "Subclasses of 'Discretization' need to implement " "the call operator") | Compute discretization of the given variable on the given data.
Return a new variable with the appropriate domain
(:obj:`Orange.data.DiscreteVariable.values`) and transformer
(:obj:`Orange.data.Variable.compute_value`). | 625941d530c21e258bdfa6b5 |
def addTwoNumbers(self, l1, l2): <NEW_LINE> <INDENT> l1nums = 0 <NEW_LINE> l1n =0 <NEW_LINE> while l1: <NEW_LINE> <INDENT> l1nums = l1nums + l1.val*(10**l1n) <NEW_LINE> l1= l1.next <NEW_LINE> l1n = l1n+1 <NEW_LINE> <DEDENT> l2nums = 0 <NEW_LINE> l2n =0 <NEW_LINE> while l2: <NEW_LINE> <INDENT> l2nums = l2nums + l2.val*(... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941d58da39b475bd6518c |
def importConfig(self, dObj): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if isinstance(dObj, dict): <NEW_LINE> <INDENT> self.__cD.update(dObj) <NEW_LINE> <DEDENT> elif isinstance(dObj, ruamel.yaml.comments.CommentedMap): <NEW_LINE> <INDENT> self.__cD = dObj <NEW_LINE> <DEDENT> elif isinstance(dObj, cp): <NEW_LINE> <I... | Import configuration options from the input dictionary-like object.
Args:
dObj (object): Dictionary-like configuration object
Returns:
bool: True for success or False otherwise | 625941d58a349b6b435e838b |
def rasters_to_array(self, maps): <NEW_LINE> <INDENT> rows = self.get_region_info()['cells'] <NEW_LINE> cols = len(maps) <NEW_LINE> rast = self.raster_to_array(maps[0]) <NEW_LINE> dtype = rast.dtype <NEW_LINE> arr = np.empty((rows, cols), dtype) <NEW_LINE> arr[:, 0] = rast <NEW_LINE> for i in range(1, cols): <NEW_LINE>... | Считывает список растров и возвращает их в виде двумерного numpy.array
(каждый растр в отдельном столбце) | 625941d5be8e80087fb20e58 |
def predict(self, X): <NEW_LINE> <INDENT> return self.clf.predict(self._get_features(X)) | Predict labels for estimators and values for regressors for all events in dataset.
:param X: pandas.DataFrame of shape [n_samples, n_features]
:rtype: numpy.array of shape [n_samples] with labels/values | 625941d5fbf16365ca6f63dd |
def test_video_instance(self): <NEW_LINE> <INDENT> video = VideoPlayer.objects.get(embed_link=EXAMPLE_VIDEO) <NEW_LINE> self.assertEqual(video.embed_link, EXAMPLE_VIDEO) | Video player instance has been created | 625941d5e64d504609d74a57 |
def test_create_object(self): <NEW_LINE> <INDENT> obj_perm = ObjectPermission( actions=['add'] ) <NEW_LINE> obj_perm.save() <NEW_LINE> obj_perm.users.add(self.user) <NEW_LINE> obj_perm.object_types.add(ContentType.objects.get_for_model(self.model)) <NEW_LINE> initial_count = self._get_queryset().count() <NEW_LINE> resp... | POST a single object with permission. | 625941d5a219f33f34628b7e |
def superEggDrop(K, N): <NEW_LINE> <INDENT> dp = [[0 for _ in range(N+1)] for _ in range(K+1)] <NEW_LINE> for i in range(N+1): <NEW_LINE> <INDENT> dp[1][i] = i <NEW_LINE> <DEDENT> for i in range(2, K+1): <NEW_LINE> <INDENT> for j in range(1, N+1): <NEW_LINE> <INDENT> minimum = float('inf') <NEW_LINE> for x in range(1, ... | :type K: int
:type N: int
:rtype: int | 625941d50a366e3fb873ea33 |
def read_routers(self, nslist): <NEW_LINE> <INDENT> bad_key = 0 <NEW_LINE> new = [] <NEW_LINE> for ns in nslist: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> r = self.get_router(ns) <NEW_LINE> if r: <NEW_LINE> <INDENT> new.append(r) <NEW_LINE> <DEDENT> <DEDENT> except ErrorReply: <NEW_LINE> <INDENT> bad_key += 1 <NEW_L... | Given a list a NetworkStatuses in 'nslist', this function will
return a list of new Router instances. | 625941d510dbd63aa1bd2dba |
def printList(self,list): <NEW_LINE> <INDENT> for x in list: <NEW_LINE> <INDENT> self.log(x) | 列表显示 | 625941d544b2445a339322ac |
def __init__(self,sensor_id): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.sensor_id = sensor_id <NEW_LINE> GPIO.setmode(GPIO.BOARD) <NEW_LINE> GPIO.setup(sensor_id,GPIO.IN) | sensor_id is port number
| 625941d515baa723493c418e |
def grid_check_352(CR_pos): <NEW_LINE> <INDENT> CR_x, CR_y = CR_pos <NEW_LINE> if CR_x < xg[0] and CR_y > yg[2]: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif CR_x > xg[0] and CR_x < xg[1] and CR_y > yg[2]: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif CR_x > xg[1] and CR_x < xg[2] and CR_y > yg[2]: <NE... | grid check for a 4-4-2 formation, returns an index from 0 to 9. | 625941d521bff66bcd684b69 |
def __init__(self, nav, waypoint=ll.LatLon(50.742810, 1.014469), target_radius=5, tack_voting_radius=15, waypoint_id=None, ): <NEW_LINE> <INDENT> self.nav = nav <NEW_LINE> self.waypoint = waypoint <NEW_LINE> x, y = self.nav.latlon_to_utm(waypoint.lat.decimal_degree, waypoint.lon.decimal_degree) <NEW_LINE> self.waypoint... | Sail towards a waypoint.
*nav* is a sailing_robot.navigation.Navigation instance.
*waypoint* is a LatLon object telling us where to go.
*target_radius* is how close we need to get to the waypoint, in metres.
*tack_voting_radius* is the distance within which we use tack voting, to
avoid too frequent tacks close to t... | 625941d54e696a04525c9663 |
def code_login(self, relative_x=140, relative_y=280): <NEW_LINE> <INDENT> self.handle_full_screen_shot(image_file_name='code_login.png') <NEW_LINE> self.show_screen_shot(key_function=self.check_login, key_params=(relative_x, relative_y)) | 二维码登陆 | 625941d5d486a94d0b98e35e |
def showWindow(self,index): <NEW_LINE> <INDENT> if self.showFPS: <NEW_LINE> <INDENT> time_start = time.time() <NEW_LINE> <DEDENT> if self.nowWindow != index: <NEW_LINE> <INDENT> if self.system: <NEW_LINE> <INDENT> os.system('clear') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> os.system('cls') <NEW_LINE> <DEDENT> <DED... | 调用窗口的显示方法来切换窗口 | 625941d5cdde0d52a9e5324c |
def _downsample(self, how, **kwargs): <NEW_LINE> <INDENT> self._set_binner() <NEW_LINE> how = self._get_cython_func(how) or how <NEW_LINE> ax = self.ax <NEW_LINE> obj = self._selected_obj <NEW_LINE> if not len(ax): <NEW_LINE> <INDENT> obj = obj.copy() <NEW_LINE> obj.index = obj.index._with_freq(self.freq) <NEW_LINE> as... | Downsample the cython defined function.
Parameters
----------
how : string / cython mapped function
**kwargs : kw args passed to how function | 625941d57b180e01f3dc4a12 |
def get_sendgrid(self): <NEW_LINE> <INDENT> user = self.getProperty("send_grid_user")["value"] <NEW_LINE> pwd = self.getProperty("send_grid_pwd")["value"] <NEW_LINE> logger.info("sendgrid={}/{}".format(user, pwd)) <NEW_LINE> sg = sendgrid.SendGridClient(user, pwd) <NEW_LINE> return sg | search in properties account to send email with sendgrid and return a sendclient
:return the sendGrid objet to send email | 625941d526238365f5f0f088 |
def end_bold(self): <NEW_LINE> <INDENT> self.emit('}') | End bold face | 625941d5287bf620b61d3c7a |
def __init__(self, msg=""): <NEW_LINE> <INDENT> self._msg = msg <NEW_LINE> super().__init__(self) | Default constructor | 625941d555399d3f055888cc |
def index_power(array, n): <NEW_LINE> <INDENT> if (len(array)<=n): <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> elif n == 0: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return array[n]**n <NEW_LINE> <DEDENT> return None | Find Nth power of the element with index N. | 625941d5a934411ee37518ab |
def to_night(timestamp=None): <NEW_LINE> <INDENT> if timestamp is None: <NEW_LINE> <INDENT> timestamp = datetime.utcnow() <NEW_LINE> <DEDENT> if timestamp.hour < 12: <NEW_LINE> <INDENT> timestamp = timestamp - timedelta(days=1) <NEW_LINE> <DEDENT> return timestamp | gives the date for a day change at noon instead of midnight | 625941d5cc0a2c11143dd0a8 |
def _get_api_definition_from_editor(self, editor): <NEW_LINE> <INDENT> raise NotImplementedError( "Method _setup_api_properties() must be implemented in a " "subclass of ImplicitApiPlugin" ) | Required function that returns the api body from the respective editor | 625941d5379a373c97cfad5d |
def track_characters(self, font, s): <NEW_LINE> <INDENT> realpath, stat_key = get_realpath_and_stat(font.fname) <NEW_LINE> used_characters = self.used_characters.setdefault( stat_key, (realpath, set())) <NEW_LINE> used_characters[1].update([ord(x) for x in s]) | Keeps track of which characters are required from
each font. | 625941d5379a373c97cfad5e |
def randval(self): <NEW_LINE> <INDENT> return volatile.RandLong() | :return: volatile.VolatileValue: a volatile value for this field "long"-compatible internal value. # noqa: E501 | 625941d567a9b606de4a80d0 |
def modbus_factory(url, port, use_rtu_framer = False): <NEW_LINE> <INDENT> if use_rtu_framer: <NEW_LINE> <INDENT> client = ModbusClient(url, port, ModbusRtuFramer) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> client = ModbusClient(url, port) <NEW_LINE> <DEDENT> return client | Builds the modbus client
WIP to add more types.
Arguments:
url {String} -- Address where the master is listening
port {String} -- Serial port string as it is used in pyserial | 625941d55e10d32532c5f13e |
def do_geturl(self, line): <NEW_LINE> <INDENT> if not line or len(line.split()) < 1: <NEW_LINE> <INDENT> print ("Wrong") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> auth = line.split()[0] <NEW_LINE> if auth != "hotp" and auth != "totp": <NEW_LINE> <INDENT> print("Wrong auth param") <NEW_LINE> <DEDENT> else: <NEW_LINE... | geturl authtype(hotp/totp) | 625941d5d4950a0f3b08c565 |
def rollN(nDice): <NEW_LINE> <INDENT> return result(summarize(roll(nDice))) | Combine roll, summarize, and result into one function. | 625941d573bcbd0ca4b2c28e |
def show_rule(name): <NEW_LINE> <INDENT> color = { 'bold': Style.BRIGHT, 'reset': Style.RESET_ALL, } <NEW_LINE> try: <NEW_LINE> <INDENT> meta = rule.Registry.get_meta(name) <NEW_LINE> <DEDENT> except squabble.UnknownRuleException: <NEW_LINE> <INDENT> sys.exit('{bold}Unknown rule:{reset} {name}'.format(**{ 'name': name,... | Print information about rule named ``name``. | 625941d58c3a8732951585d3 |
def _reset(self): <NEW_LINE> <INDENT> self.cache = SmtLibExecutionCache() <NEW_LINE> self.logic = None <NEW_LINE> self._current_env = self.pysmt_env <NEW_LINE> mgr = self.pysmt_env.formula_manager <NEW_LINE> self.cache.update({'+':mgr.Plus, '-':self._minus_or_uminus, '*':mgr.Times, '/':self._division, '>':mgr.GT, '<':m... | Resets the parser to the initial state | 625941d599cbb53fe6792dfe |
def p_overset(p): <NEW_LINE> <INDENT> p[3].above = p[2] <NEW_LINE> p[0] = [p[3]] | math_object : OVERSET argument argument | 625941d51f037a2d8b946416 |
def __init__(self, inputName) : <NEW_LINE> <INDENT> self.num += 1 <NEW_LINE> self.id = self.num <NEW_LINE> self._name = inputName | CONSTRUCTEUR de station
param inputName: nom de la station | 625941d51b99ca400220acca |
def t_vlanid_vlanrange_mtu(self, t): <NEW_LINE> <INDENT> t.value = (t.lexer.id, int(re.split('\s+',t.value)[1])) <NEW_LINE> return t | mtu\s+[0-9]+ | 625941d56aa9bd52df036fbc |
@photos_commands.cli.command('thumbnails') <NEW_LINE> def make_tumbnails(): <NEW_LINE> <INDENT> for p in Photo.query.all(): <NEW_LINE> <INDENT> utiles.StorageController.getInstance( ).generateThumbnail(p) | Make thumbnails for all photos | 625941d550812a4eaa59c538 |
@gin.configurable("dynamics", blacklist=["z", "ground_truth_data", "random_state", "return_index"]) <NEW_LINE> def simple_dynamics(z, ground_truth_data, random_state, return_index=False, k=gin.REQUIRED): <NEW_LINE> <INDENT> if k == -1: <NEW_LINE> <INDENT> k_observed = random_state.randint(1, ground_truth_data.num_facto... | Create the pairs. | 625941d5be8e80087fb20e59 |
def add_neighbor(self, neighbor=None, **kwargs): <NEW_LINE> <INDENT> if not neighbor: <NEW_LINE> <INDENT> conf = gobgp.PeerConf(**kwargs) <NEW_LINE> peer = gobgp.Peer(families=[65537]) <NEW_LINE> peer.conf.MergeFrom(conf) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> peer = neighbor.peer <NEW_LINE> <DEDENT> request = g... | Add a new BGP neighbor,
Two ways to add a neighbor.
- Either, define neighbor params as dict and pass as kwargs, or
- Use pygobgp.Neighbor class (preffered) to define Neighbor params.
If pygobgp.Neighbor class is used, kwargs won't be used.
kwargs must contain at least the following as an... | 625941d591f36d47f21ac70c |
def test_checkout_session(self): <NEW_LINE> <INDENT> with mock.patch("apps.stripe_checkout_subscription.views.stripe.checkout.Session.create") as gt: <NEW_LINE> <INDENT> gt.return_value = {'id': '998877'} <NEW_LINE> response = self.client.post('/stripe_sub_create_checkout_session/', data={'priceId': '101010'}, content_... | Checkout Session - check response from post | 625941d532920d7e50b283ea |
def _register_atomic_action(self, name): <NEW_LINE> <INDENT> self._atomic_actions[name] = None | Registers an atomic action by its name. | 625941d5e1aae11d1e749ed1 |
def many(self, inputimages, depth=-1, limit=25, clobber=True, single=True, **options): <NEW_LINE> <INDENT> images = np.array(inputimages) <NEW_LINE> if clobber: <NEW_LINE> <INDENT> self.clear() <NEW_LINE> <DEDENT> if single: <NEW_LINE> <INDENT> self.single() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.tile() <N... | display a bunch of images in ds9, each in its own frame.
inputimages = 3D cube of images to display
depth = the axis corresponding to independent images
limit = maximum number of images to display
clobber = should we erase what's in this display?
single = show "single" frame (False --> "tile")
**options = additional o... | 625941d516aa5153ce362690 |
def _create(self, **kwargs): <NEW_LINE> <INDENT> log_method_call(self, type=self.mountType, device=self.device, mountpoint=self.mountpoint) <NEW_LINE> if not self.formattable: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> argv = self._getFormatOptions(options=kwargs.get("options"), do_labeling=not self.relabels()) <NE... | Create the filesystem.
:param options: options to pass to mkfs
:type options: list of strings
:raises: FormatCreateError, FSError | 625941d5187af65679ca5337 |
def __init__(self, cache_location: str, cache_name: str): <NEW_LINE> <INDENT> self._cache_location = cache_location <NEW_LINE> self._cache_name = cache_name <NEW_LINE> self.loaded: bool = False <NEW_LINE> self.ids: Dict[int, dict] = dict() <NEW_LINE> self.names: Dict[str, int] = dict() | A cache to act as a lighter weight typeIDs.yaml from the Static Data Export.
:param cache_location: String path to the root folder to store the cache file inside.
:param cache_name: String name of the cache file, including file extension. | 625941d599cbb53fe6792dff |
def step(self, scores): <NEW_LINE> <INDENT> raise NotImplementedError | Updates current samples and images to increase expected future scores
:param scores: array of scalars corresponding to current images/samples | 625941d563b5f9789fde72fe |
def test_003(self): <NEW_LINE> <INDENT> self.models = {"top":self.RTL} <NEW_LINE> self.tb_config = {"simulation_time":"auto", "cosimulation":True, "trace":False, "fdump":False, "ipgi":0, "ipgo":0} <NEW_LINE> NUM_ADDR = 27 <NEW_LINE> ref = [] <NEW_LINE> for i in range(NUM_ADDR+1): <NEW_LINE> <INDENT> data = 10+i <NEW_LI... | >>>>>> TEST_003: All registers are accessible | 625941d54d74a7450ccd43db |
def _wait_hardware(self, value, timeout=None): <NEW_LINE> <INDENT> with Timeout(timeout, RuntimeError("Timeout waiting for hardware")): <NEW_LINE> <INDENT> while self.value_channel.get_value() != value: <NEW_LINE> <INDENT> sleep(0.5) | Wait timeout seconds till hardware in place.
Args:
value (str, int): value to be tested.
timeout(float): Timeout [s]. None means infinite timeout. | 625941d59f2886367277aaa5 |
def get_connection_rate(self): <NEW_LINE> <INDENT> content = urllib2.urlopen('http://localhost:7000/haproxy?stats;csv') <NEW_LINE> content = content.read() <NEW_LINE> fieldnames = content.split('\n')[0].split(',') <NEW_LINE> iocontent = StringIO(content) <NEW_LINE> reader = csv.DictReader(iocontent, fieldnames) <NEW_LI... | Returns req_rate from ha-proxy for the front-facing end.
See
https://cbonte.github.io/haproxy-dconv/1.6/management.html#9.1
for more information. | 625941d54d74a7450ccd43dc |
@nodeHandle <NEW_LINE> def NpcShopBuyItem_219(dynamicId,request_proto): <NEW_LINE> <INDENT> argument = NpcShopBuyItem_pb2.npcShopBuyItemRequest() <NEW_LINE> argument.ParseFromString(request_proto) <NEW_LINE> response = NpcShopBuyItem_pb2.npcShopBuyItemResponse() <NEW_LINE> characterId = argument.id <NEW_LINE> itemId = ... | 购买,回购商品 | 625941d54e696a04525c9664 |
def to_smiles(self, canonical=False, hydrogens=False): <NEW_LINE> <INDENT> logger.info("to_smiles") <NEW_LINE> obConversion = openbabel.OBConversion() <NEW_LINE> if canonical: <NEW_LINE> <INDENT> obConversion.SetOutFormat("can") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> obConversion.SetOutFormat("smi") <NEW_LINE> <... | Create the SMILES string from the system.
Parameters
----------
canonical : bool = False
Whether to create canonical SMILES
hydrogens : bool = False
Whether to keep H's in the SMILES string.
Returns
-------
str
The SMILES string, or (SMILES, name) if the rname is requested | 625941d544b2445a339322ad |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.