code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def obfn_gvar(self): <NEW_LINE> <INDENT> return self.Y if self.opt['gEvalY'] else np.mean(self.X, axis=-1) | Variable to be evaluated in computing :math:`g(\cdot)`,
depending on the ``gEvalY`` option value. | 625941b97b180e01f3dc4676 |
def custom_score_2(game, player): <NEW_LINE> <INDENT> opponent_player = game.get_opponent(player) <NEW_LINE> if game.is_winner(player): <NEW_LINE> <INDENT> return float("inf") <NEW_LINE> <DEDENT> if game.is_winner(opponent_player): <NEW_LINE> <INDENT> return float("-inf") <NEW_LINE> <DEDENT> score = .0 <NEW_LINE> total... | Calculate the heuristic value of a game state from the point of view
of the given player.
Note: this function should be called from within a Player instance as
`self.score()` -- you should not need to call this function directly.
Parameters
----------
game : `isolation.Board`
An instance of `isolation.Board` enco... | 625941b944b2445a33931f10 |
def __init__(self, temboo_session): <NEW_LINE> <INDENT> super(ListIndustryCodes, self).__init__(temboo_session, '/Library/CorpWatch/Lists/ListIndustryCodes') | Create a new instance of the ListIndustryCodes Choreo. A TembooSession object, containing a valid
set of Temboo credentials, must be supplied. | 625941b992d797404e303ffa |
def getclaims(self): <NEW_LINE> <INDENT> raise NotImplementedError("%s needs to implement .getclaims() -> []" % self.__class__.__name__) | Returns a list of arbitrary strings describing things claimed by this
helper. | 625941b923849d37ff7b2f02 |
def __init__(self, oElement, Checksum=None): <NEW_LINE> <INDENT> if not ElementTree.iselement(oElement): <NEW_LINE> <INDENT> raise TypeError("Invalid type '%s' passed to constructor." % type(XML)) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self.ROOT = self.MakeNode(oElement) <NEW_LINE> <DEDENT> except _SpecError as e... | Either pass a valid xml.etree.ElementTree.Element that represents the <Node> tag, or a
string containing valid <Node> xml (none other). | 625941b9377c676e9127201b |
def word_split(text): <NEW_LINE> <INDENT> word_list = [] <NEW_LINE> stop_p = p + "~·!@#¥%……&*()——=+-{}【】:;“”‘’《》,。?、|、" <NEW_LINE> seg_list = [i for i in jieba.cut(text, cut_all=False) if (i != ' ' and i not in stop_p)] <NEW_LINE> table = {} <NEW_LINE> for i, c in enumerate(seg_list): <NEW_LINE> <INDENT> if c in table:... | Find the word position in a document.
:param text: a document
:return: [(position, word) ...] | 625941b930bbd722463cbc33 |
def _parse_parameters(val_type, val): <NEW_LINE> <INDENT> if val_type == "logical": <NEW_LINE> <INDENT> return val == "T" <NEW_LINE> <DEDENT> if val_type == "int": <NEW_LINE> <INDENT> return int(val) <NEW_LINE> <DEDENT> if val_type == "string": <NEW_LINE> <INDENT> return val.strip() <NEW_LINE> <DEDENT> return float(val... | Helper function to convert a Vasprun parameter into the proper type.
Boolean, int and float types are converted.
Args:
val_type: Value type parsed from vasprun.xml.
val: Actual string value parsed for vasprun.xml. | 625941b9f8510a7c17cf9575 |
def create_compact_constraint(self): <NEW_LINE> <INDENT> self.delete([self.bg_label]) <NEW_LINE> if self.is_run_clicked: <NEW_LINE> <INDENT> self.insert_constraint(self.last_viewed_schedule) | Creates a more compact graphical schedule
respresentation of the valid schedules | 625941b9f9cc0f698b140476 |
def testLbPersistenceCookieTime(self): <NEW_LINE> <INDENT> pass | Test LbPersistenceCookieTime | 625941b945492302aab5e131 |
def addTwoNumbers(self, l1, l2): <NEW_LINE> <INDENT> c = 0 <NEW_LINE> dummyHead = ListNode(0) <NEW_LINE> curr = dummyHead <NEW_LINE> while l1 != None or l2 != None: <NEW_LINE> <INDENT> x = l1.val if l1 != None else 0 <NEW_LINE> y = l2.val if l2 != None else 0 <NEW_LINE> sum = x + y + c <NEW_LINE> curr.next = ListNode(s... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941b9d7e4931a7ee9dd8c |
def spheroidalCF2(r, psize, axrat): <NEW_LINE> <INDENT> pelpt = 1.0 * axrat <NEW_LINE> if psize <= 0 or pelpt <= 0: <NEW_LINE> <INDENT> return numpy.zeros_like(r) <NEW_LINE> <DEDENT> v = pelpt <NEW_LINE> d = 1.0 * psize <NEW_LINE> d2 = d*d <NEW_LINE> v2 = v*v <NEW_LINE> if v == 1: <NEW_LINE> <INDENT> return sphericalCF... | Spheroidal nanoparticle characteristic function.
Form factor for ellipsoid with radii (psize/2, psize/2, axrat*psize/2)
r -- distance of interaction
psize -- The equatorial diameter
axrat -- The ratio of axis lengths
From Lei et al., Phys. Rev. B, 80, 024118 (2009) | 625941b926068e7796caeb49 |
def __str__(self): <NEW_LINE> <INDENT> if isinstance(self._symbol, str): <NEW_LINE> <INDENT> return "%s" % self._symbol <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return "%s" % repr(self._symbol) | Return a string representation for this ``Nonterminal``.
:rtype: str | 625941b9cdde0d52a9e52ea0 |
def _get_assistants_snippets(path, name): <NEW_LINE> <INDENT> result = [] <NEW_LINE> subdirs = {'assistants': 2, 'snippets': 1} <NEW_LINE> for loc in subdirs: <NEW_LINE> <INDENT> for root, dirs, files in os.walk(os.path.join(path, loc)): <NEW_LINE> <INDENT> for filename in [utils.strip_prefix(os.path.join(root, f), pat... | Get Assistants and Snippets for a given DAP name on a given path | 625941b98c3a87329515822f |
def verify_mapping(self, key, object): <NEW_LINE> <INDENT> assert self.verify_key(key), "precondition: key must be well-formed." + " -- " + "key: %s" % hr(key) <NEW_LINE> raise NotImplementedError <NEW_LINE> pass | @returns true if and only if `object' is a valid result for `key'
@precondition key must be well-formed.: self.verify_key(key): "key: %s" % hr(key)
@noblock This method may not block, either by waiting for network traffic, by waiting for a lock, or by sleeping. | 625941b9460517430c393fff |
def player(board): <NEW_LINE> <INDENT> xcount = 0 <NEW_LINE> ocount = 0 <NEW_LINE> for i in range (3): <NEW_LINE> <INDENT> for j in range (3): <NEW_LINE> <INDENT> if board[i][j] == "X": <NEW_LINE> <INDENT> xcount += 1 <NEW_LINE> <DEDENT> if board[i][j] == "O": <NEW_LINE> <INDENT> ocount += 1 <NEW_LINE> <DEDENT> <DEDENT... | Returns player who has the next turn on a board. | 625941b90a366e3fb873e688 |
def buscaCadenaTuplas(cadena,listaTuplas): <NEW_LINE> <INDENT> busqueda=[] <NEW_LINE> for n in range(len(listaTuplas)): <NEW_LINE> <INDENT> if cadena in listaTuplas[n][0]: <NEW_LINE> <INDENT> busqueda.append(listaTuplas[n]) <NEW_LINE> <DEDENT> <DEDENT> print(busqueda) <NEW_LINE> return busqueda | Escribir una función que reciba una cadena a buscar y una lista de tuplas
(nombre_completo, telefono), y busque dentro de la lista, todas las entradas que
contengan en el nombre completo la cadena recibida (puede ser el nombre, el apellido
o sólo una parte de cualquiera de ellos). Debe devolver una lista con todas l... | 625941b916aa5153ce3622e9 |
def load_shapes(self): <NEW_LINE> <INDENT> zones_shape = self['zones_shape'] <NEW_LINE> layers_group = self.get_layers_group() <NEW_LINE> for layer in layers_group.findLayers(): <NEW_LINE> <INDENT> if layer.layer().source() == zones_shape: <NEW_LINE> <INDENT> self['zones_shape_id'] = layer.layer().id() | @summary: Loads zone shape | 625941b98da39b475bd64de8 |
def save(self): <NEW_LINE> <INDENT> self.client.save_app_data(self.get('uuid'), self.get('app_data')) | Persists the user's app data to the `unicore.hub` server. | 625941b930c21e258bdfa30e |
def auth(func): <NEW_LINE> <INDENT> def inner(*args,**kwargs): <NEW_LINE> <INDENT> login_count = 0 <NEW_LINE> while login_count < 3: <NEW_LINE> <INDENT> username = input('username:') <NEW_LINE> password = input('password:') <NEW_LINE> if username in d_user: <NEW_LINE> <INDENT> if md5sum(password) == d_user[username][1]... | 用户认证函数
演示密码都是123 | 625941b9d99f1b3c44c67408 |
def GetReferenceImage(self): <NEW_LINE> <INDENT> return _itkChangeInformationImageFilterPython.itkChangeInformationImageFilterIF2_GetReferenceImage(self) | GetReferenceImage(self) -> itkImageF2 | 625941b9e8904600ed9f1d9a |
def test_create_token_no_user(self): <NEW_LINE> <INDENT> payload = { 'email': '[email protected]', 'password': 'testpass' } <NEW_LINE> res = self.client.post(TOKEN_URL, payload) <NEW_LINE> self.assertNotIn('token', res.data) <NEW_LINE> self.assertTrue(res.status_code, status.HTTP_400_BAD_REQUEST) | Test that token is not created if user doesn't exist | 625941b9925a0f43d2549ce5 |
def _write_json_file(self, filename, state): <NEW_LINE> <INDENT> json_file = os.path.join(self._options.config_path, filename) <NEW_LINE> if not os.path.exists(json_file): <NEW_LINE> <INDENT> common.file_util.mkdir_p(self._options.config_path) <NEW_LINE> <DEDENT> with atomic_write_file(json_file) as outfile: <NEW_LINE>... | Write a json file given a filename under the default config path.
Creates the file and directory if required. | 625941b9baa26c4b54cb0f94 |
def test_metallicity_outside_range_nomoto(yields_nomoto): <NEW_LINE> <INDENT> yields_nomoto.set_metallicity(0.99) <NEW_LINE> assert yields_nomoto.H_1 == 2.45E-2 <NEW_LINE> assert yields_nomoto.H_2 == 5.34E-16 <NEW_LINE> assert yields_nomoto.O_16 == 6.14E-3 <NEW_LINE> assert yields_nomoto.Al_27 == 6.53E-5 <NEW_LINE> ass... | Tests what happens when the metallicity is outside the range the
models span. I will assert that it should be the same as the yields of the
model that is at the extreme. | 625941b9167d2b6e31218a0e |
def select(self, *fields): <NEW_LINE> <INDENT> stmt = SelectStatement(self, *fields) <NEW_LINE> stmt.stmt_id = self._connection.get_next_statement_id() <NEW_LINE> return stmt | Creates a new :class:`mysqlx.SelectStatement` object.
Args:
*fields: The fields to be retrieved.
Returns:
mysqlx.SelectStatement: SelectStatement object | 625941b90c0af96317bb805b |
def show_progress(last_time, nrec=None): <NEW_LINE> <INDENT> if nrec: <NEW_LINE> <INDENT> msg = "Records processed: %d; time: %s\r" % (nrec, timestamp_to_string(last_time)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = "Processed through: %s\r" % timestamp_to_string(last_time) <NEW_LINE> <DEDENT> pri... | Utility function to show our progress | 625941b9d486a94d0b98dfbe |
def build_bq_schema(input_convention): <NEW_LINE> <INDENT> with open(input_convention) as tsvfile: <NEW_LINE> <INDENT> reader = csv.DictReader(tsvfile, dialect='excel-tab') <NEW_LINE> schema = [] <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> entry = {} <NEW_LINE> entry['name'] = row['attribute'] <NEW_LINE> entry['t... | Build schema as a Python dictionary | 625941b931939e2706e4cce1 |
def producto_cartesiano(self, lista1, lista2): <NEW_LINE> <INDENT> if not lista1: <NEW_LINE> <INDENT> return lista2 <NEW_LINE> <DEDENT> elif not lista2: <NEW_LINE> <INDENT> return lista1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> lista = list() <NEW_LINE> for flags1, flags2 in itertools.product(lista1, lista2): <NEW... | Realiza el producto cartesiano entre dos listas de diccionarios. | 625941b9b57a9660fec336f2 |
def to_indented_string(self, obj): <NEW_LINE> <INDENT> if obj: <NEW_LINE> <INDENT> return str(obj).replace("\n", "\n ") <NEW_LINE> <DEDENT> return "" | Convert the given object to string with each line indented by 4
spaces (except the first line).
:param obj:
:return: | 625941b985dfad0860c3acca |
def __init__(self): <NEW_LINE> <INDENT> self.Filters = None <NEW_LINE> self.Limit = None <NEW_LINE> self.Offset = None <NEW_LINE> self.OrderBy = None <NEW_LINE> self.OrderByType = None | :param Filters: Filter condition. Valid values: db-instance-id, db-instance-name, db-project-id, db-pay-mode, db-tag-key.
:type Filters: list of Filter
:param Limit: Number of entries returned per page. Default value: 10.
:type Limit: int
:param Offset: Page number, starting from 0.
:type Offset: int
:param OrderBy: So... | 625941b924f1403a926009db |
def extract_mags(number_of_quakes, dictionary_obj): <NEW_LINE> <INDENT> magnitude_per_code_dictionary = {} <NEW_LINE> for i in range(number_of_quakes): <NEW_LINE> <INDENT> k = dictionary_obj['features'][i]['id'] <NEW_LINE> v = dictionary_obj['features'][i]['properties']['mag'] <NEW_LINE> magnitude_per_code_dictionary[s... | Loops over the report to extract the magnitude per quake for each record and stores all key/value pairs in a dictionary | 625941b9507cdc57c6306b45 |
def error(description, code=500, **keywords): <NEW_LINE> <INDENT> resp = dict(problem=description, **keywords) <NEW_LINE> return Response(dumps(resp), status=code, content_type='application/json') | Produce a response:
Args:
code (int): HTTP response code
description (str): problem description text
other arguments are added to the JSON response dictionary.
Returns:
Response: a Flask Response instance | 625941b963b5f9789fde6f57 |
def set_attribute(self, attr: str, val: str) -> None: <NEW_LINE> <INDENT> self.__attrs[attr] = val | Set an attribute to a particular string value on this node.
Parameters:
attr - A string attribute to set on the node.
val - The string value to set the attribute value to. | 625941b9a8ecb033257d2f48 |
def _recursive_copy_to_device(value: Any, non_blocking: bool, device: torch.device) -> Any: <NEW_LINE> <INDENT> if isinstance(value, torch.Tensor): <NEW_LINE> <INDENT> return value.to(device, non_blocking=non_blocking) <NEW_LINE> <DEDENT> if isinstance(value, (list, tuple)): <NEW_LINE> <INDENT> values = [_recursive_cop... | Recursively searches lists, tuples, dicts and copies tensors to device if
possible. Non-tensor values are passed as-is in the result.
.. note: These are all copies, so if there are two objects that reference
the same object, then after this call, there will be two different objects
referenced on the device. | 625941b976d4e153a657e9a2 |
def updateDownloadingStatus(self, pkgName, progress, feedback): <NEW_LINE> <INDENT> if self.itemDict.has_key(pkgName): <NEW_LINE> <INDENT> appItem = self.itemDict[pkgName] <NEW_LINE> appItem.updateDownloadingStatus(progress, feedback) | Update downloading status. | 625941b9293b9510aa2c310a |
def input_type_number(): <NEW_LINE> <INDENT> pass | <div class="row">
<div class="form-group ma mb-2">
<label class="sr-only" for="age">Campo para escrever idade</label>
<input type="number" class="form-control" id="age" name="age" min="1" max="120" placeholder="sua idade" size="20" required>
</div>
</div> | 625941b90383005118ecf456 |
def _read_line(original_text=None, terminating_characters=None): <NEW_LINE> <INDENT> if original_text == None: <NEW_LINE> <INDENT> original_text = "" <NEW_LINE> <DEDENT> if not terminating_characters: <NEW_LINE> <INDENT> terminating_characters = "\r" <NEW_LINE> <DEDENT> assert isinstance(original_text, str) <NEW_LINE> ... | Reads a line of input with the given unicode string of original
text, which is editable, and the given unicode string of terminating
characters (used to terminate text input). By default,
terminating_characters is a string containing the carriage return
character ('
'). | 625941b90a50d4780f666d01 |
def enumerate_algo_examples(): <NEW_LINE> <INDENT> exclude = NON_ALGO_EXAMPLES + LONG_RUNNING_EXAMPLES <NEW_LINE> all_examples = EXAMPLES_ROOT_DIR.glob('**/*.py') <NEW_LINE> return [str(e) for e in all_examples if e not in exclude] | Return a list of paths for all algo examples
Returns:
List[str]: list of path strings | 625941b95166f23b2e1a4fcb |
def _load_multiple_files(fn, subdirs): <NEW_LINE> <INDENT> return [np.load(str(subdir / fn)).squeeze() for subdir in subdirs] | Load the same filename in the different subdirectories. | 625941b9097d151d1a222cce |
def pth_nms(dets, thresh): <NEW_LINE> <INDENT> if not dets.is_cuda: <NEW_LINE> <INDENT> x1 = dets[:, 0] <NEW_LINE> y1 = dets[:, 1] <NEW_LINE> x2 = dets[:, 2] <NEW_LINE> y2 = dets[:, 3] <NEW_LINE> scores = dets[:, 4] <NEW_LINE> areas = (x2 - x1) * (y2 - y1) <NEW_LINE> order = scores.sort(0, descending=True)[1] <NEW_LINE... | dets has to be a tensor | 625941b9a219f33f346287e6 |
def testRepresentativeStory(self): <NEW_LINE> <INDENT> inst_req_only = self.make_instance(include_optional=False) <NEW_LINE> inst_req_and_optional = self.make_instance(include_optional=True) | Test RepresentativeStory | 625941b9cc0a2c11143dcd0a |
def create_channel(device_id, channel): <NEW_LINE> <INDENT> global _LOGGER <NEW_LINE> global DATABASE <NEW_LINE> _LOGGER.info("Device : " + str(device_id) + ", channel: " + str(channel) + ", does not exists") <NEW_LINE> sql = "INSERT INTO channel (device_id, channel) VALUES (%s, %s)" <NEW_LINE> _LOGGER.... | Creates new channel record | 625941b991af0d3eaac9b886 |
def call_later(self, seconds, target, *args, **kwargs): <NEW_LINE> <INDENT> if '_errback' not in kwargs and hasattr(self, 'handle_error'): <NEW_LINE> <INDENT> kwargs['_errback'] = self.handle_error <NEW_LINE> <DEDENT> callback = self.ioloop.call_later(seconds, target, *args, **kwargs) <NEW_LINE> self._tasks.append(call... | Same as self.ioloop.call_later but also cancel()s the
scheduled function on close(). | 625941b9711fe17d825421e4 |
def run(self): <NEW_LINE> <INDENT> super(SIPpTestCase, self).run() <NEW_LINE> self.create_ami_factory() <NEW_LINE> self.ast[0].cli_exec('sip set debug on') <NEW_LINE> self.ast[0].cli_exec('pjsip set logger on') | Override of the run method.
Create an AMI factory in case anyone wants it | 625941b9090684286d50eb52 |
def plotMatch(self, **kwargs): <NEW_LINE> <INDENT> kwargs.setdefault('keypoints_color', 'k') <NEW_LINE> kwargs.setdefault('matches_color', 'g') <NEW_LINE> kwargs.setdefault('only_matches', False) <NEW_LINE> fig, ax = plt.subplots(1, 1, figsize=(12, 6)) <NEW_LINE> plot_matches(ax, fun.bgr2rgb(self.pattern), fun.bgr2rgb(... | Plot matches between pattern image and scene image | 625941b997e22403b379ce0a |
@charity_signup.route('/authorize') <NEW_LINE> def authorize(): <NEW_LINE> <INDENT> site = 'https://connect.stripe.com' + '/oauth/authorize' <NEW_LINE> params = {'response_type': 'code', 'scope': 'read_write', 'client_id': app.config.get('CLIENT_ID') } <NEW_LINE> url = site + '?' + urllib.parse.urlencode(params) <NEW_L... | Rediects user to stripe signup website, which will return a stripe
key for charging users on their behalf | 625941b94d74a7450ccd4034 |
def build_graph_from_queries(query_sampler_variable_graph_tuples, grakn_transaction, concept_dict_converter=concept_dict_to_graph, infer=True): <NEW_LINE> <INDENT> query_concept_graphs = [] <NEW_LINE> for query, sampler, variable_graph in query_sampler_variable_graph_tuples: <NEW_LINE> <INDENT> concept_maps = sampler(g... | Builds a graph of Things, interconnected by roles (and *has*), from a set of queries and graphs representing those
queries (variable graphs)of those queries, over a Grakn transaction
Args:
infer: whether to use Grakn's inference engine
query_sampler_variable_graph_tuples: A list of tuples, each tuple containin... | 625941b93539df3088e2e1bd |
def cutadapt_worker(fname, regions, primers): <NEW_LINE> <INDENT> sample = basename(fname).split('_R1.fastq')[0] <NEW_LINE> for region, seq in primers.items(): <NEW_LINE> <INDENT> fwd, rev = seq.split('-') <NEW_LINE> if exists('{}_unknown_R1.fastq'.format(sample)): <NEW_LINE> <INDENT> fname = '{}_unknown_R1.fastq'.form... | Split fastq files into regions by matching 5 prime ends with conserved region primer sequences.
This function requires cutadapt installed (tested with cutadapt 2.8) | 625941b997e22403b379ce0b |
@_print_function_call <NEW_LINE> def unhook(handler): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _hook_handlers.remove(handler) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> _unload_hook_handlers.remove(handler) | Unhooks any hook registered with the hook functions above.
:param handler: Handler returned from :func:`hook_print`, :func:`hook_command`, :func:`hook_server` or :func:`hook_timer`
As of version 1.0 of the plugin hooks from :func:`hook_print` and :func:`hook_command` can be unhooked by their names. | 625941b9a8370b7717052713 |
def test_create_model_with_log( mocked_vgg_extract_mapping, mocked_filesystem_create_log_path, mocked_filesystem_fetch_images, mocked_core_extract_style_from_path, mocked_core_optimize_model ): <NEW_LINE> <INDENT> mocked_filesystem_fetch_images.return_value = [ "/path/to/image1", "/path/to/image2", "/path/to/image3" ] ... | Train a style generator model with specific log path. | 625941b950812a4eaa59c197 |
def __init__(self, id=None, name=None, description=None): <NEW_LINE> <INDENT> self._id = None <NEW_LINE> self._name = None <NEW_LINE> self._description = None <NEW_LINE> self.discriminator = None <NEW_LINE> if id is not None: <NEW_LINE> <INDENT> self.id = id <NEW_LINE> <DEDENT> self.name = name <NEW_LINE> if descriptio... | JsonAddStatusRequest - a model defined in Swagger | 625941b9236d856c2ad44650 |
def reduce(self, show_noisy=False): <NEW_LINE> <INDENT> if not show_noisy: <NEW_LINE> <INDENT> for log in self.quiet_logs: <NEW_LINE> <INDENT> yield log['raw'].strip() <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> for log in self.noisy_logs: <NEW_LINE> <INDENT> yield log['raw'].strip() | Yield the reduced log lines
:param show_noisy: If this is true, shows the reduced log file. If this is false, it shows the logs that
were deleted. | 625941b994891a1f4081b91a |
def load_module(self,fullname): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return sys.modules[fullname] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> info = self._get_module_info(fullname) <NEW_LINE> code = self.get_code(fullname,info) <NEW_LINE> if code is None: <NEW_LINE> <INDENT... | Load the specified module.
This method locates the file for the specified module, loads and
executes it and returns the created module object. | 625941b9a79ad161976cbfb7 |
def testJsonDateAttributeImpl(self): <NEW_LINE> <INDENT> pass | Test JsonDateAttributeImpl | 625941b96fece00bbac2d5ad |
def get_compete_user_obj(self,compete_dict): <NEW_LINE> <INDENT> from apps.models.virtual.monster import Monster <NEW_LINE> obj = Monster.get_compete(compete_dict) <NEW_LINE> return obj | 获取竞技对手的对象
| 625941b97047854f462a127f |
def package_command(self, command, args=None, pkgs=None): <NEW_LINE> <INDENT> if pkgs is None: <NEW_LINE> <INDENT> pkgs = [] <NEW_LINE> <DEDENT> e = os.environ.copy() <NEW_LINE> e["DEBIAN_FRONTEND"] = "noninteractive" <NEW_LINE> wcfg = self.get_option("apt_get_wrapper", APT_GET_WRAPPER) <NEW_LINE> cmd = _get_wrapper_pr... | Run the given package command.
On Debian, this will run apt-get (unless APT_GET_COMMAND is set).
command: The command to run, like "upgrade" or "install"
args: Arguments passed to apt itself in addition to
any specified in APT_GET_COMMAND
pkgs: Apt packages that the command will apply to | 625941b91b99ca400220a923 |
def setSecurityLevel(self, level): <NEW_LINE> <INDENT> if level == SecurityLevel.RDP_LEVEL_RDP: <NEW_LINE> <INDENT> self._x224Layer._requestedProtocol = x224.Protocols.PROTOCOL_RDP <NEW_LINE> <DEDENT> elif level == SecurityLevel.RDP_LEVEL_SSL: <NEW_LINE> <INDENT> self._x224Layer._requestedProtocol = x224.Protocols.PROT... | @summary: Request basic security
@param level: {SecurityLevel} | 625941b98a43f66fc4b53edb |
def uint2int64(value): <NEW_LINE> <INDENT> if value & 0x8000000000000000: <NEW_LINE> <INDENT> return value - 0x10000000000000000 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return value | Convert an unsigned 64 bits integer into a signed 64 bits integer. | 625941b9b7558d58953c4d8d |
def get_vspring(self): <NEW_LINE> <INDENT> if self.nbeads == 1: <NEW_LINE> <INDENT> return 0.0 <NEW_LINE> <DEDENT> if len(self.bosons) == 0: <NEW_LINE> <INDENT> sqnm = dstrip(self.qnm) * dstrip(self.beads.sm3) <NEW_LINE> q2 = (sqnm ** 2).sum(axis=1) <NEW_LINE> vspring = (self.omegak2 * q2).sum() <NEW_LINE> for j in sel... | Returns the spring energy calculated in NM representation for distinguishable particles.
For bosons, get the first element of vspring_and_fspring_B[0]
For a mixture of both, calculate separately and combine. | 625941b930dc7b76659017dc |
@tf_export("summary.record_summaries", v1=[]) <NEW_LINE> @tf_contextlib.contextmanager <NEW_LINE> def record_summaries(boolean=True): <NEW_LINE> <INDENT> global _SHOULD_RECORD_SUMMARIES <NEW_LINE> key = ops.get_default_graph()._graph_key <NEW_LINE> old = _SHOULD_RECORD_SUMMARIES.setdefault(key, False) <NEW_LINE> try: <... | Sets summary recording on or off per the provided boolean value.
The provided value can be a python boolean, a scalar boolean Tensor, or
or a callable providing such a value; if a callable is passed it will be
invoked each time should_record_summaries() is called to determine whether
summary writing should be enabled.... | 625941b9293b9510aa2c310b |
def successful_signing_test(self): <NEW_LINE> <INDENT> privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N', 'cVKpPfVKSJxKqVpE9awvXNWuLHCa5j5tiE7K6zbUSptFpTEtiFrA'] <NEW_LINE> inputs = [ {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0, 'scriptPubKey': '76a91460baa0f4... | Creates and signs a valid raw transaction with one input.
Expected results:
1) The transaction has a complete set of signatures
2) No script verification error occurred | 625941b985dfad0860c3accb |
def genere_balise_fin_image(): <NEW_LINE> <INDENT> return "</svg>" | Retourne la chaine de caractères correspondant à la balise svg fermante.
Cette balise doit être placée après tous les éléments de description de
l’image, juste avant la fin du fichier. | 625941b9283ffb24f3c5577e |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> loop = kwargs.pop('loop', None) <NEW_LINE> self.loop = loop or asyncio.get_event_loop() <NEW_LINE> protocol.WebSocketServerFactory.__init__(self, *args, **kwargs) | .. note::
In addition to all arguments to the constructor of
:meth:`autobahn.websocket.interfaces.IWebSocketServerChannelFactory`,
you can supply a ``loop`` keyword argument to specify the
asyncio event loop to be used. | 625941b94e696a04525c92c6 |
def test_write_id_index_overflow(self): <NEW_LINE> <INDENT> res = 0 <NEW_LINE> time_sample = 0 <NEW_LINE> morton = 11 <NEW_LINE> id = 4 <NEW_LINE> version = 0 <NEW_LINE> last_partition_key = 2 <NEW_LINE> rev_id = 224 <NEW_LINE> no_rev_id = None <NEW_LINE> max_capacity = 100 <NEW_LINE> obj_key = AWSObjectStore.generate_... | Case where a new Dynamo key needs to be created because the
current key is full. The LAST_PARTITION_KEY should be updated. | 625941b907f4c71912b112f9 |
def calculate_alignments(self, words, features): <NEW_LINE> <INDENT> for feature in features: <NEW_LINE> <INDENT> denom = 0.0 <NEW_LINE> for word in words: <NEW_LINE> <INDENT> denom += self._learned_lexicon.prob(word, feature, self._decay, self._time) <NEW_LINE> <DEDENT> denom += self._beta * self._alpha <NEW_LINE> for... | Update the alignments between words and features.
Update the alignments for each combination of word-feature pairs from
the list words and the set features:
alignment: P(a|u,f) = p(f|w) / sum(w' in words) p(f|w') | 625941b9be383301e01b52ff |
def test_tag_str(self): <NEW_LINE> <INDENT> tag = models.Tag.objects.create( user=sample_user(), name='Home roasting' ) <NEW_LINE> self.assertEqual(str(tag), tag.name) | Test the tag string representation | 625941b9851cf427c661a387 |
def add_dictval_to_list(adict, key, alist): <NEW_LINE> <INDENT> if key in adict: <NEW_LINE> <INDENT> if isinstance(adict[key], six.string_types): <NEW_LINE> <INDENT> alist.append(adict[key]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> alist.extend(adict[key]) | add a value from a dictionary to a list
:param adict: dictionary
:param key: key of value
:param list: list where value should be added | 625941b9b5575c28eb68de70 |
def load_embed_txt(embed_file): <NEW_LINE> <INDENT> emb_dict = dict() <NEW_LINE> emb_size = None <NEW_LINE> with codecs.getreader("utf-8")(tf.gfile.GFile(embed_file, 'rb')) as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> tokens = line.strip().split(" ") <NEW_LINE> word = tokens[0] <NEW_LINE> vec = list(map... | Load embed_file into a python dictionary.
Note: the embed_file should be a Glove formated txt file. Assuming
embed_size=5, for example:
the -0.071549 0.093459 0.023738 -0.090339 0.056123
to 0.57346 0.5417 -0.23477 -0.3624 0.4037
and 0.20327 0.47348 0.050877 0.002103 0.060547
Args:
embed_file: file path to the embe... | 625941b98e71fb1e9831d61f |
def contains( self, sphere): <NEW_LINE> <INDENT> for item in self.container: <NEW_LINE> <INDENT> if item == sphere: <NEW_LINE> <INDENT> return True; <NEW_LINE> <DEDENT> if item.center == sphere.center and item.radius == sphere.radius: <NEW_LINE> <INDENT> return True; <NEW_LINE> <DEDENT> <DEDENT> return False; | True if the grid contains the sphere | 625941b92ae34c7f2600cfa4 |
def set_key(self, keygrip): <NEW_LINE> <INDENT> self.keygrip = keygrip | Set hexadecimal keygrip for next operation. | 625941b9711fe17d825421e5 |
def read_har_file(filename): <NEW_LINE> <INDENT> fhandle = open(filename) <NEW_LINE> try: <NEW_LINE> <INDENT> har = json.loads(fhandle.read(), object_hook=encode_strings) <NEW_LINE> <DEDENT> except Exception as oops: <NEW_LINE> <INDENT> sys.stderr.write("Unable to parse %s\n\n" % filename) <NEW_LINE> sys.stderr.write(o... | Read filename and return the header dictionaries for it. | 625941b96e29344779a62487 |
def is_ip(addr): <NEW_LINE> <INDENT> if '.' not in addr: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> parts = addr.split('.') <NEW_LINE> for part in parts: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> int(part) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> ... | Determine if a string is really an ip, or a hostname instead.
Args:
addr (str): The ip address string to check
Returns:
bool: Whether or not `addr` is a valid ip. | 625941b9cc40096d615957c6 |
def __init__( self, more_items_remaining=None, total_item_count=None, continuation_token=None, items=None, ): <NEW_LINE> <INDENT> if more_items_remaining is not None: <NEW_LINE> <INDENT> self.more_items_remaining = more_items_remaining <NEW_LINE> <DEDENT> if total_item_count is not None: <NEW_LINE> <INDENT> self.total_... | Keyword args:
more_items_remaining (bool): Returns a value of `true` if subsequent items can be retrieved.
total_item_count (int): The total number of records after applying all filter query parameters. The `total_item_count` will be calculated if and only if the corresponding query parameter `total_item_count`... | 625941b957b8e32f52483313 |
def __init__(self, executable_path, port=0): <NEW_LINE> <INDENT> self.port = port <NEW_LINE> self.path = executable_path <NEW_LINE> if self.port == 0: <NEW_LINE> <INDENT> self.port = utils.free_port() | Creates a new instance of the Service
:Args:
- executable_path : Path to the OperaDriver
- port : Port the service is running on | 625941b9ec188e330fd5a618 |
def has_perm(self, user): <NEW_LINE> <INDENT> for dashboard in self.registry: <NEW_LINE> <INDENT> if dashboard.has_perm(user): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | True if there is at least one avaialble dashboard. | 625941b98e71fb1e9831d620 |
def _create_attachment(self, cr, uid, data, context=None): <NEW_LINE> <INDENT> attachment_obj = self.pool.get('ir.attachment') <NEW_LINE> vals = { 'name': 'pain001_%s' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), 'datas': data['base64_data'], 'datas_fname': 'pain001_%s.xml' % time.strftime( "%Y-%m-%d_%H:%M:%S",... | Create an attachment using data provided
data needed are :
- model : type of object to attach to
- id : id of object model
- base64_data | 625941b992d797404e303ffc |
def find_centroid(cluster): <NEW_LINE> <INDENT> location_list=[restaurant_location(i) for i in cluster] <NEW_LINE> latitude=mean([i[0] for i in location_list]) <NEW_LINE> longitude=mean([i[1] for i in location_list]) <NEW_LINE> return [latitude,longitude] | Return the centroid of the locations of the restaurants in cluster. | 625941b932920d7e50b2803f |
def command(cmd, **kwargs): <NEW_LINE> <INDENT> message = create(protobuf.SEND_COMMAND_MESSAGE) <NEW_LINE> send_command = message.inner() <NEW_LINE> send_command.command = cmd <NEW_LINE> for key, value in kwargs.items(): <NEW_LINE> <INDENT> setattr(send_command.options, key, value) <NEW_LINE> <DEDENT> return message | Playback command request. | 625941b97d847024c06be133 |
def add(self, key): <NEW_LINE> <INDENT> if key in self._data: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._data[key] = 1 | :type key: int
:rtype: None | 625941b9377c676e9127201d |
def execution_time_and_output(function, n_times=1, *args, **kwargs): <NEW_LINE> <INDENT> start = time.time() <NEW_LINE> retval = function(*args, **kwargs) <NEW_LINE> elapsed = time.time() - start <NEW_LINE> return round(elapsed, 3), retval | Return the execution time of a function in seconds together with
its output. | 625941b93c8af77a43ae3610 |
def to_dict(self, target_dict=None): <NEW_LINE> <INDENT> if target_dict is None: <NEW_LINE> <INDENT> target_dict = self.storage <NEW_LINE> <DEDENT> result_dict = dict() <NEW_LINE> def to_inner_dict(actual_value): <NEW_LINE> <INDENT> if hasattr(actual_value, 'to_dict'): <NEW_LINE> <INDENT> return actual_value.to_dict() ... | Recursive serialization to dict
:param target_dict:
:return: | 625941b96fece00bbac2d5ae |
def BeginInvoke(self, sender, e, callback, object): <NEW_LINE> <INDENT> pass | BeginInvoke(self: PagesChangedEventHandler, sender: object, e: PagesChangedEventArgs, callback: AsyncCallback, object: object) -> IAsyncResult | 625941b9796e427e537b0435 |
def rename_files(path: str): <NEW_LINE> <INDENT> old_content = os.listdir(path) <NEW_LINE> new_content = [re.sub(r".*[sS](\d\d)[eE](\d\d).*\.(.+)$", r"S\1E\2.\3", f) for f in old_content] <NEW_LINE> print("Here is the changment that will be applied : ") <NEW_LINE> for (old, new) in zip(old_content, new_content): <NEW_L... | Rename the files in the path from the long format to the short format (see the description of the program up there). | 625941b91f037a2d8b946072 |
def mount_procfs(newroot, target='/proc'): <NEW_LINE> <INDENT> while target.startswith('/'): <NEW_LINE> <INDENT> target = target[1:] <NEW_LINE> <DEDENT> mnt_flags = [ mount.MS_NODEV, mount.MS_NOEXEC, mount.MS_NOSUID, mount.MS_RELATIME, ] <NEW_LINE> return mount.mount( source='proc', target=os.path.join(newroot, target)... | Mounts procfs on directory.
| 625941b93d592f4c4ed1cef2 |
def createPodActions(self, statements): <NEW_LINE> <INDENT> r = -1 <NEW_LINE> try: <NEW_LINE> <INDENT> if not statements: raise ParsingError(EMPTY_NOTE) <NEW_LINE> main = statements[0] <NEW_LINE> aRes = self.Rex.action.match(main) <NEW_LINE> if not aRes: <NEW_LINE> <INDENT> raise ParsingError(BAD_STATEMENT % main) <NEW... | Tries to create action(s) based on p_statements. If the statement is
not correct, r_ is -1. Else, r_ is the index of the element within
the buffer that is the object of the action(s). | 625941b90a366e3fb873e68a |
def _make_texts_(self, tick_list, text_list, f, g, dx_units, dy_units, angles, text_distance, text_size, manual_texts=[]): <NEW_LINE> <INDENT> for idx, u in enumerate(tick_list): <NEW_LINE> <INDENT> if dy_units[idx] < 0: <NEW_LINE> <INDENT> text_attr = [pyx.text.valign.middle, pyx.text.halign.right, text_size, pyx.traf... | makes list of text definitions | 625941b994891a1f4081b91b |
def declareAdapterForProtocol ( protocol, adapter, proto, depth = 1 ): <NEW_LINE> <INDENT> adapt( protocol, IOpenProtocol ) <NEW_LINE> adapt( proto, IOpenProtocol ).addImpliedProtocol( protocol, bindAdapter( adapter, protocol ), depth ) | Declare that 'adapter' adapts 'proto' to 'protocol' | 625941b915baa723493c3de5 |
@manager.command <NEW_LINE> def adduser(username, password): <NEW_LINE> <INDENT> _adduser(username, password) | Add a user | 625941b930dc7b76659017dd |
def import_data(self, input, password): <NEW_LINE> <INDENT> entrystore = data.EntryStore() <NEW_LINE> folders = {} <NEW_LINE> for line in input.splitlines()[1:]: <NEW_LINE> <INDENT> f_csv = csv.reader([line.decode()]) <NEW_LINE> for row in f_csv: <NEW_LINE> <INDENT> if len(row) != 6 and len(row) != 10: <NEW_LINE> <INDE... | Import data from a file into the entry store | 625941b94428ac0f6e5ba665 |
def convert_prefixed_properties(self, doc, filename): <NEW_LINE> <INDENT> converted_properties = [] <NEW_LINE> inline_styles = doc.findAll(style=re.compile('.*')) <NEW_LINE> style_tags = doc.findAll('style') <NEW_LINE> all_styles = inline_styles + style_tags <NEW_LINE> for tag in all_styles: <NEW_LINE> <INDENT> style_t... | Searches a BeautifulSoup |doc| for any CSS properties requiring the -webkit- prefix and converts them.
Returns the list of converted properties and the modified document as a string | 625941b95510c4643540f26a |
def update_grid(self, *args): <NEW_LINE> <INDENT> grid = self.panel.gridExp <NEW_LINE> num_rows = len(model.instrument.inst.positions) <NEW_LINE> if grid.GetNumberRows() > num_rows: <NEW_LINE> <INDENT> grid.DeleteRows(0, grid.GetNumberRows()-num_rows) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> old_num_rows = grid.Ge... | Fill the grid rows with data, and set the right editors. | 625941b9627d3e7fe0d68cc2 |
def get_licenses_as_dict(self): <NEW_LINE> <INDENT> return json.load(self.data_source) | Get licenses as python dict from stdin or from file
:return: licenses dict
Called by: get_email_and_company() | 625941b9e8904600ed9f1d9c |
def getAvailableSubtitleStreams(self): <NEW_LINE> <INDENT> return list() | Get Subtitle stream names
:returns: List of subtitle streams as name.
:rtype: list | 625941b9b57a9660fec336f3 |
def test_switch_class_value_off(): <NEW_LINE> <INDENT> test_name = "light" <NEW_LINE> test_value = "test" <NEW_LINE> switch = Switch(test_name, off=test_value) <NEW_LINE> assert len(switch.options) == 2 <NEW_LINE> assert switch.options[0] == test_value <NEW_LINE> assert switch.options[1] == "" <NEW_LINE> assert switch.... | check that the Switch class returns the specified value for "off",
defaults to the required value for "on" and stores the correct
value for name | 625941b921bff66bcd6847c8 |
def vs(youngs=None, vp=None, rho=None, mu=None, lam=None, bulk=None, pr=None, pmod=None): <NEW_LINE> <INDENT> if (mu is not None) and (rho is not None): <NEW_LINE> <INDENT> return np.sqrt(mu / rho) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Computes Vs given bulk density and shear modulus. SI units only.
Args:
Mu
Rho
Returns:
Vs in m/s | 625941b950485f2cf553cc0c |
def get_args(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser(description='Run CNN training on prostate segmentation.') <NEW_LINE> parser.add_argument('--run_id', type=int, help='Training sessions ID') <NEW_LINE> parser.add_argument('--dir_in', type=str, help='Path to input file') <NEW_LINE> parser.add_argument(... | get commandline parameters | 625941b9d486a94d0b98dfc0 |
def test_all_example_files_against_strict_schema(self): <NEW_LINE> <INDENT> self.folder_should_pass( schema=self.sportsjs_strict_schema, folder_name=EXAMPLE_FILES_FOLDER ) | Run all files in EXAMPLE_FILES_FOLDER/should_pass against the schema.
They should all pass (ie they are all valid against the schema).
We use "subTest" so we can see which file failed in test output. | 625941b923e79379d52ee3db |
def keys(self): <NEW_LINE> <INDENT> return self.redis.hkeys('adhoc') | Return a list of session ID values. | 625941b967a9b606de4a7d30 |
def dns_hostname(uid): <NEW_LINE> <INDENT> return common.format_hostname('dns', uid) | Formats hostname for a docker hosting DNS.
NOTE: Hostnames are also used as docker names! | 625941b9fbf16365ca6f6030 |
def detect_language(text, languages): <NEW_LINE> <INDENT> text = text.split() <NEW_LINE> lang_count = {} <NEW_LINE> for lang in languages: <NEW_LINE> <INDENT> counter = 0 <NEW_LINE> for word in text: <NEW_LINE> <INDENT> if word in lang['common_words']: <NEW_LINE> <INDENT> counter += 1 <NEW_LINE> <DEDENT> <DEDENT> lang_... | Returns the detected language of given text. | 625941b9d18da76e23532345 |
def end(self): <NEW_LINE> <INDENT> if not self.playing or self.ended: <NEW_LINE> <INDENT> log.warn('[%s] Invalid Track.end() call (playing: %s, ended: %s)', self.uri, self.playing, self.ended) <NEW_LINE> return <NEW_LINE> <DEDENT> log.debug('[%s] Sending "track_end" event (position: %s)', self.uri, self.position) <NEW_... | Send track end/completion events | 625941b971ff763f4b549502 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.