code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def check_data(data): <NEW_LINE> <INDENT> if not isinstance(data, tuple): <NEW_LINE> <INDENT> data = (data,) <NEW_LINE> <DEDENT> return data | Check the *data* argument and make sure it's a tuple.
If the data is a single array, return it as a tuple with a single element.
This is the default format accepted and used by all gridders and processing
functions.
Examples
--------
>>> check_data([1, 2, 3])
([1, 2, 3],)
>>> check_data(([1, 2], [3, 4]))
([1, 2], [3... | 625941d156b00c62f0f147df |
def set_indesign_alerts_status(*, enabled: bool): <NEW_LINE> <INDENT> if enabled: <NEW_LINE> <INDENT> interaction_level = 'interact with all' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> interaction_level = 'never interact' <NEW_LINE> <DEDENT> run_applescript( 'tell application "Adobe InDesign CC 2019" to set user int... | Enable or disable InDesign alerts and dialogs
Modal dialogs (eg missing fonts, broken or modified links) can
prevent the execution of AppleScript and should be disabled
when running generation commands. | 625941d1aad79263cf390bc7 |
def list_nodes_select(): <NEW_LINE> <INDENT> ret = {} <NEW_LINE> nodes = list_nodes_full() <NEW_LINE> if 'error' in nodes: <NEW_LINE> <INDENT> raise SaltCloudSystemExit( 'An error occurred while listing nodes: {0}'.format( nodes['error']['Errors']['Error']['Message'] ) ) <NEW_LINE> <DEDENT> for node in nodes: <NEW_LINE... | Return a list of the VMs that are on the provider, with select fields | 625941d1d4950a0f3b08c4d4 |
def run(self): <NEW_LINE> <INDENT> if self.opts['gen_keys']: <NEW_LINE> <INDENT> salt.crypt.gen_keys( self.opts['gen_keys_dir'], self.opts['gen_keys'], self.opts['keysize']) <NEW_LINE> return <NEW_LINE> <DEDENT> if self.opts['list']: <NEW_LINE> <INDENT> self._list(self.opts['list']) <NEW_LINE> <DEDENT> elif self.opts['... | Run the logic for saltkey | 625941d1796e427e537b074c |
def move(key, snake): <NEW_LINE> <INDENT> return snake | Rating: ***
The snake will never catch anything to eat if it never moves. We know the player pressed
an arrow key but which one and what do we do about it?
HINT: The arrow keys are [curses.KEY_RIGHT, curses.KEY_UP, curses.KEY_LEFT, curses.KEY_DOWN]
:param key: The key that the player pressed
:param snake: A list of all... | 625941d1cad5886f8bd2715f |
def SetUpperThreshold(self, *args): <NEW_LINE> <INDENT> return _itkCannyEdgeDetectionImageFilterPython.itkCannyEdgeDetectionImageFilterIF3IF3_SetUpperThreshold(self, *args) | SetUpperThreshold(self, float _arg) | 625941d110dbd63aa1bd2d29 |
def testComposite12(self): <NEW_LINE> <INDENT> self.doTestCase("Composite12", "Composite12, Composite State entry-/exitPoint and completion event") | C Composite12, Composite State entry-/exitPoint and completion event | 625941d1091ae356686670e3 |
def add_queue(self, queue): <NEW_LINE> <INDENT> self.queues.append(queue) <NEW_LINE> self.queue_timestamp[queue] = very_old_timestamp <NEW_LINE> if self.dest_dir is not None: <NEW_LINE> <INDENT> queue.load_state(self.dest_dir) <NEW_LINE> <DEDENT> if queue.newest_seen_timestamp is not None: <NEW_LINE> <INDENT> self.queu... | Add an input queue. | 625941d1fbf16365ca6f634c |
def ovfcheck(r): <NEW_LINE> <INDENT> assert not isinstance(r, r_uint), "unexpected ovf check on unsigned" <NEW_LINE> assert not isinstance(r, r_longlong), "ovfcheck not supported on r_longlong" <NEW_LINE> assert not isinstance(r, r_ulonglong), "ovfcheck not supported on r_ulonglong" <NEW_LINE> if type(r) is long and no... | NOT_RPYTHON | 625941d145492302aab5e44a |
def delete(self, query): <NEW_LINE> <INDENT> return self.insert(query) | Call insert function as delete
:param query: database query
:return: insert function | 625941d14d74a7450ccd4349 |
def can_vote(self): <NEW_LINE> <INDENT> return self.is_published() and timezone.now() < self.end_date | Return True if the ending date of the question is after the publish date and current time. | 625941d194891a1f4081bc2f |
def visit(self, expr): <NEW_LINE> <INDENT> found = self.memo_map.get(expr) <NEW_LINE> if found: <NEW_LINE> <INDENT> return found <NEW_LINE> <DEDENT> if isinstance(expr, Function): <NEW_LINE> <INDENT> res = self.visit_function(expr) <NEW_LINE> <DEDENT> elif isinstance(expr, Call): <NEW_LINE> <INDENT> res = self.visit_ca... | Apply the visitor to an expression. | 625941d1507cdc57c6306e62 |
def print_model_summary(self): <NEW_LINE> <INDENT> all_attr = dir(self) <NEW_LINE> all_attr.sort() <NEW_LINE> past_models = [] <NEW_LINE> model_count = 0 <NEW_LINE> for attr in all_attr: <NEW_LINE> <INDENT> a_s = re.split("_", attr) <NEW_LINE> if len(a_s) == 2: <NEW_LINE> <INDENT> if (a_s[0] == "model") and (re.match("... | Prints all defined model names and their docstrings. | 625941d1c432627299f04dcc |
def slave_utilization(registry, xml_parent, data): <NEW_LINE> <INDENT> utilization = XML.SubElement( xml_parent, "com.suryagaddipati.jenkins.SlaveUtilizationProperty" ) <NEW_LINE> percent = int(data.get("slave-percentage", 0)) <NEW_LINE> exclusive_node_access = True if percent else False <NEW_LINE> mapping = [ ("", "ne... | yaml: slave-utilization
This plugin allows you to specify the percentage of a slave's capacity a
job wants to use.
Requires the Jenkins :jenkins-plugins:`Slave Utilization Plugin
<slave-utilization-plugin>`.
:arg int slave-percentage: Specify the percentage of a slave's execution
slots that this job should occupy... | 625941d17c178a314d6ef5e7 |
def runNodeosAndGetOutput(myNodeId, myTimeout=3): <NEW_LINE> <INDENT> Print("Launching nodeos process id: %d" % (myNodeId)) <NEW_LINE> cmd="programs/nodeos/nodeos --config-dir etc/eosio/node_bios --data-dir var/lib/node_bios --verbose-http-errors --http-validate-host=false" <NEW_LINE> Print("cmd: %s" % (cmd)) <NEW_LINE... | Startup nodeos, wait for timeout (before forced shutdown) and collect output. Stdout, stderr and return code are returned in a dictionary. | 625941d1baa26c4b54cb12a4 |
def _test(): <NEW_LINE> <INDENT> argc = len(sys.argv) <NEW_LINE> if argc != 2: <NEW_LINE> <INDENT> if argc == 1 and xdis.PYTHON3: <NEW_LINE> <INDENT> fn = __file__ <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sys.stderr.write("usage: %s [-|CPython compiled file]\n" % __file__) <NEW_LINE> sys.exit(2) <NEW_LINE> <DEDENT... | Simple test program to disassemble a file. | 625941d126238365f5f0eff5 |
def __init__(self, n_features, *args, **kwargs): <NEW_LINE> <INDENT> super(XGBFeatureSelection, self).__init__(*args, **kwargs) <NEW_LINE> self._n_features = n_features | Init method adding n_features. | 625941d10a366e3fb873e9a1 |
def d_c(self, parsedcmd): <NEW_LINE> <INDENT> addrs = parsedcmd.get('addresses') <NEW_LINE> if addrs[1] == "button": <NEW_LINE> <INDENT> self._update_from_button(parsedcmd, addrs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._update_from_move(parsedcmd) | desk to computer, switch by button or jog input | 625941d192d797404e304310 |
def compute_Von_Mises_or_Tresca(self, varname, lawname, dataname, mf_vm, version=None): <NEW_LINE> <INDENT> return self.get("compute_Von_Mises_or_Tresca", varname, lawname, dataname, mf_vm, version) | Compute on `mf_vm` the Von-Mises stress or the Tresca stress of a field
for nonlinear elasticity in 3D. `lawname` is the constitutive law which
could be 'SaintVenant Kirchhoff', 'Mooney Rivlin', 'neo Hookean' or
'Ciarlet Geymonat'.
`dataname` is a vector of parameters for the constitutive law. Its length
depends on the... | 625941d107f4c71912b11609 |
def __init__(self, data: List, error: Union[List, Real] = None, **kwargs): <NEW_LINE> <INDENT> if isinstance(error, ARRAY_TYPES) and len(error) != len(data): <NEW_LINE> <INDENT> raise ValueError("The lengths of uncertainties and data do not match") <NEW_LINE> <DEDENT> from .datasets import ExperimentalValueArray <NEW_L... | Constructor of a RepeatedlyMeasuredValue | 625941d176e4537e8c3517f9 |
def vanilla_inference(self, xin, S=1, smooth_eps=eps): <NEW_LINE> <INDENT> samples = [xin.expand(S, *(xin.size()))] <NEW_LINE> samplers = [None] <NEW_LINE> for l in range(self.L): <NEW_LINE> <INDENT> q = smooth_distribution( F.sigmoid(F.linear(samples[-1], self.W[l].t(), self.bq[l])), eps=smooth_eps ) <NEW_LINE> sample... | ARGS
----
xin: bs, nx sized FloatTensor
RETURNS
----
samples: FloatTensor list. Each element is S * bs * nzs[i]
length is self.L + 1 (+1 is for x)
samplers: Bernoulli list. Each element is S * bs * nzs[i]
length is self.L + 1 (+1 for x, but is None)
The order is x, z^0, z^1 ... z^{L-1} | 625941d1d6c5a102081441d2 |
@refDoc(__doi__, [24, 5]) <NEW_LINE> def MuG_StielThodos(T, Tc, Pc, M): <NEW_LINE> <INDENT> Pc_atm = Pc/101325 <NEW_LINE> Tr = T/Tc <NEW_LINE> T_R = unidades.K2R(T) <NEW_LINE> if M < 2: <NEW_LINE> <INDENT> if Tr <= 1.5: <NEW_LINE> <INDENT> mu = 3.7e-5*T_R**0.94 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> mu = 9.071e-... | Calculate the viscosity of a gas using the Stiel-Thodos correlation,
also referenced in API procedure 11B1.3, pag 1099
.. math::
\mu=N/\xi
.. math::
\xi=\frac{T_{c}^{1/6}}{M^{1/2}P_{c}^{2/3}}
.. math::
N=3.4e^{-4}T_{r}^{0.94} for Tr ≤ 1.5
.. math::
N=1.778e^{-4}\left(4.58T_{r}-1.67\right)^{0.625} ... | 625941d16e29344779a62797 |
def prep_data(array, input_seq_len, output_seq_len, output_seq_steps_ahead, expand_dim=True, expand_dim_axis=2): <NEW_LINE> <INDENT> data = data_split(data=array, input_seq_len=input_seq_len, output_seq_len=output_seq_len, output_seq_steps_ahead=output_seq_steps_ahead) <NEW_LINE> if expand_dim: <NEW_LINE> <INDENT> data... | Prepares data in accordance with supplied parameters by splitting and expanding datasets into third [:,:,1]
dimension. | 625941d16fb2d068a760f224 |
def __init__(self, data, event): <NEW_LINE> <INDENT> if not isinstance(data, dict): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> Field.__init__(self, data, event) <NEW_LINE> self.check_values() <NEW_LINE> self.create_label() <NEW_LINE> adjustment = Gtk.Adjustment(value=float(self.data["value"]), lower=int(self.data["... | This method is the constructor. | 625941d173bcbd0ca4b2c1fc |
def __init__(self, start, end, scene_object, animation=None): <NEW_LINE> <INDENT> self.start = start <NEW_LINE> self.end = end <NEW_LINE> self.scene_object = scene_object <NEW_LINE> self.animation = animation | Initializes an instance of :class:`TimelineItem`.
:param start:
The time, in seconds, when the object appears in the scene.
A value of ``None`` means that this item starts at the beginning of the timeline.
:param end:
The time, in seconds, when the object disappears from the scene.
A value of ``None`` ... | 625941d1a17c0f6771cbe1d6 |
def test_dav_header_carddav_disabled(self): <NEW_LINE> <INDENT> def do_test(response): <NEW_LINE> <INDENT> response = IResponse(response) <NEW_LINE> dav = response.headers.getHeader("dav") <NEW_LINE> if not dav: <NEW_LINE> <INDENT> self.fail("no DAV header: %s" % (response.headers,)) <NEW_LINE> <DEDENT> self.assertIn("... | DAV header does not advertise CardDAV | 625941d1d8ef3951e32436c3 |
def dis_someone(uid, sid): <NEW_LINE> <INDENT> Swiped.objects.update_or_create(uid=uid, sid=sid, stype='like') <NEW_LINE> if Swiped.objects.filter(uid=sid).filter(sid=uid).filter(stype__in=['dislike']): <NEW_LINE> <INDENT> Friend.make_friends(uid, sid) <NEW_LINE> return True <NEW_LINE> <DEDENT> return False | 喜欢(右划)某人 | 625941d1167d2b6e31218d1c |
def __init__(self, name="", compute_value=None): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> if compute_value is not None: <NEW_LINE> <INDENT> self.compute_value = compute_value <NEW_LINE> <DEDENT> self.unknown_str = set(Variable._DefaultUnknownStr) <NEW_LINE> self.source_variable = None <NEW_LINE> self.attributes ... | Construct a variable descriptor. | 625941d1ac7a0e7691ed4251 |
@asyncio.coroutine <NEW_LINE> def run_tk(root): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> root.update() <NEW_LINE> canvas.delete("all") <NEW_LINE> circle.render(canvas) <NEW_LINE> yield from asyncio.sleep(LOOP_DELAY) <NEW_LINE> <DEDENT> <DEDENT> except tk.TclError as e: <NEW_LINE> <IN... | Run a tkinter app in an asyncio event loop. | 625941d166673b3332b92217 |
def setSudokuFileName(self, fileName): <NEW_LINE> <INDENT> self._sudokuFileName = fileName | This method allows set a new value of the filename where will be
stored the sudoku game results/generation.
Keyword arguments:
fileName -- This is a String value for the new value of
self._sudokuFileName i.e."MyFile.txt" | 625941d13cc13d1c6d3c7500 |
def __abs__(self): <NEW_LINE> <INDENT> if self.is_signed: <NEW_LINE> <INDENT> v = self.signed() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> v = self.unsigned() <NEW_LINE> <DEDENT> return abs(v) | Absolute value of (signed) value. | 625941d11d351010ab855ca2 |
def generic_count(data_list, search_string): <NEW_LINE> <INDENT> counter = 0 <NEW_LINE> for data in data_list: <NEW_LINE> <INDENT> if data == search_string: <NEW_LINE> <INDENT> counter +=1 <NEW_LINE> <DEDENT> <DEDENT> return counter | Função de contagem genérica
Argumentos:
data_list: lista de dados.
search_string: string que será contada
Retorna:
o número de ocorrências de uma string na lista | 625941d11f5feb6acb0c4cd6 |
def read_and_distribute_data(self, mode, unscattered_data=None): <NEW_LINE> <INDENT> private_data = {} <NEW_LINE> for key in self._data_keys[mode]: <NEW_LINE> <INDENT> if key not in unscattered_data: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> sendbuff = None <NEW_LINE> if self._rank==self._root: <NEW_LINE> <INDEN... | Read the next batch of data from the interface (which, presumably, is
threaded so the data is ready to go when this is called) and distribute it
to the MPI Comm specified (Default = MPI.COMM_WORLD) | 625941d16e29344779a62798 |
def generate_database(self): <NEW_LINE> <INDENT> print('---------------------------------------------------------') <NEW_LINE> print("Generating database for pie") <NEW_LINE> cache_file = join(self.cache_path, 'pie_database.pkl') <NEW_LINE> if isfile(cache_file) and not self._regen_database: <NEW_LINE> <INDENT> with op... | Generates and saves a database of the pie dataset by integrating all annotations
Dictionary structure:
'set_id'(str): {
'vid_id'(str): {
'num_frames': int
'width': int
'height': int
'traffic_annotations'(str): {
'obj_id'(str): {
'frames': list(int)
... | 625941d191f36d47f21ac679 |
def __call__(self, coef): <NEW_LINE> <INDENT> return 0.5 * np.sum((self.y - self.x.dot(coef)) ** 2) / self.n | Mean squared error loss for the training data. | 625941d1dd821e528d63b32f |
def second_moments(self): <NEW_LINE> <INDENT> xc, yc = self.centroid.args <NEW_LINE> Ix, Iy, Ixy = 0, 0, 0 <NEW_LINE> args = self.args <NEW_LINE> for i in xrange(len(args)): <NEW_LINE> <INDENT> x1, y1 = args[i - 1].args <NEW_LINE> x2, y2 = args[i].args <NEW_LINE> x1 -= xc <NEW_LINE> x2 -= xc <NEW_LINE> y1 -= yc <NEW_LI... | The second moments of area of the polygon.
Returns
=======
Ix, Iy, Ixy : Second moments of area
Examples
========
>>> from sympy import Point, Polygon, S
>>> from numpy import arange
>>> p=[(cos(i),sin(i)) for i in arange(6)/S.One/3*pi]
>>> poly = Polygon(*p)
>>> second_moments(poly)
(5*sqrt(3)/16, 5*sqrt(3)/16... | 625941d163f4b57ef000129e |
def requestPixmap(self, id, qSize): <NEW_LINE> <INDENT> qimg, qSize = self.requestImage(id, qSize) <NEW_LINE> img = QPixmap.fromImage(qimg) <NEW_LINE> return img, qSize | Returns the next image formated as a pixmap for QT with the associated QSize object | 625941d1d164cc6175782ed4 |
@app.route('/', methods=["GET"]) <NEW_LINE> def index(): <NEW_LINE> <INDENT> return redirect(url_for("get_matches")) | default endpoint | 625941d1a05bb46b383ec9a7 |
def send_photo(chat_id, photo, caption=None, reply_to_message_id=None, reply_markup=None, disable_notification=False, **kwargs): <NEW_LINE> <INDENT> files = None <NEW_LINE> if isinstance(photo, InputFile): <NEW_LINE> <INDENT> files = [photo] <NEW_LINE> photo = None <NEW_LINE> <DEDENT> elif not isinstance(photo, str): <... | Use this method to send photos.
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
:param photo: Pass a file_id as String to send a photo that exists on the Telegram servers (recommended),
pass an HTTP URL as a String for Telegram to g... | 625941d121a7993f00bc7e77 |
def _get_conn(): <NEW_LINE> <INDENT> if 'config.option' in __salt__: <NEW_LINE> <INDENT> database = __salt__['config.option']('returner.sqlite3.database') <NEW_LINE> timeout = __salt__['config.option']('returner.sqlite3.timeout') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cfg = __opts__ <NEW_LINE> database = cfg.get... | Return a sqlite3 database connection | 625941d1ff9c53063f47c37a |
def candidate_pairs_iter(self): <NEW_LINE> <INDENT> T1_out = [node for node in self.G1 if (node in DiGMState.out_1) and (node not in DiGMState.core_1)] <NEW_LINE> T2_out = [node for node in self.G2 if (node in DiGMState.out_2) and (node not in DiGMState.core_2)] <NEW_LINE> if T1_out and T2_out: <NEW_LINE> <INDENT> node... | This function returns an iterator over pairs to be considered
for inclusion in the current partial isomorphism mapping. | 625941d1a05bb46b383ec9a8 |
def pytest_unconfigure(config): <NEW_LINE> <INDENT> bscr_writelog(config, "passed: %d; FAILED: %d" % (bscr_writelog._passcount, bscr_writelog._failcount)) | At the end of the run, log a summary | 625941d10a50d4780f667019 |
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(GetSearchPositionResponse, self).__init__(*args, **kwds) <NEW_LINE> if self.search_pose is None: <NEW_LINE> <INDENT> self.search_pose = geometry_msgs.msg.PoseStamped() <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT>... | Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
search_pose
:param args: complete... | 625941d191af0d3eaac9bba0 |
def slice(self, start_index: int, size: int) -> object: <NEW_LINE> <INDENT> if start_index < 0 or start_index > self.length() - 1: <NEW_LINE> <INDENT> raise SLLException <NEW_LINE> <DEDENT> elif start_index + size > self.length() or size < 0: <NEW_LINE> <INDENT> raise SLLException <NEW_LINE> <DEDENT> new_list = LinkedL... | Returns a new LinkedList containing nodes from the start index based on the length given | 625941d1851cf427c661a695 |
def match(self, string): <NEW_LINE> <INDENT> raise NotImplementedError() | Returns `None` or the position of the last matching character +1 so
that ``string[:i]`` is the matched string. | 625941d1ab23a570cc250309 |
def __init__(self, resul, mom_ref, ref, ref_name=''): <NEW_LINE> <INDENT> self.resul = resul <NEW_LINE> self.mom_ref = mom_ref <NEW_LINE> self.ref = ref <NEW_LINE> self.ref_name = ref_name <NEW_LINE> print('Création d\'un ', end='') <NEW_LINE> print(self) | torseur de résultant `resul` et de moment `mom_ref`
exprimé au point de coordonnées `ref`.
l'argument optionnel `ref_name` peut indiquer le nom du point `ref`. | 625941d1ab23a570cc25030a |
def save_to_db(self, overwrite=False): <NEW_LINE> <INDENT> logging.info("saving circus {}".format(self.name)) <NEW_LINE> if db.is_namespace_existing(namespace=self.name): <NEW_LINE> <INDENT> if overwrite: <NEW_LINE> <INDENT> logging.warning( "overwriting existing circus {}".format(self.name)) <NEW_LINE> db.remove_names... | Create a db namespace named after this circus and saves all the
populations there.
Only static data is saved, not the stories. | 625941d10a50d4780f66701a |
def _parse(self, r=None): <NEW_LINE> <INDENT> request = current.request if r is None else r <NEW_LINE> args = request.args <NEW_LINE> get_vars = request.get_vars <NEW_LINE> command = None <NEW_LINE> if len(args) > 0: <NEW_LINE> <INDENT> command = args[0] <NEW_LINE> if "." in command: <NEW_LINE> <INDENT> command = comma... | Parse the request info
@param r: the web2py Request, falls back to current.request | 625941d1d164cc6175782ed5 |
def _add_op_node(op, func, input_dict): <NEW_LINE> <INDENT> func.node_def.extend([_get_node_def(op)]) <NEW_LINE> node_def = func.node_def[-1] <NEW_LINE> for i in range(len(node_def.input)): <NEW_LINE> <INDENT> if not node_def.input[i].startswith("^"): <NEW_LINE> <INDENT> assert node_def.input[i] in input_dict, ( "%s mi... | Converts an op to a function def node and add it to `func`. | 625941d14e696a04525c95d2 |
def GetPlayer( self ): <NEW_LINE> <INDENT> return GEPlayer.CGEBotPlayer | If this NPC is a bot, it will be associated with a player
instance. This returns that player instance so that you can
check things like score, model, etc. | 625941d155399d3f0558883b |
def format_timestamp(stamp): <NEW_LINE> <INDENT> return None if stamp is None else int(stamp * 10e3) | Consistent way to format a floating point UNIX timestamp to a long ms resolution one
:param stamp: floating point unix timestamp
:return: Long, ms resolution timestamp | 625941d1ec188e330fd5a924 |
def load_demonstration(file_path: str) -> Tuple[BrainParameters, List[BrainInfo], int]: <NEW_LINE> <INDENT> INITIAL_POS = 33 <NEW_LINE> file_paths = [] <NEW_LINE> if os.path.isdir(file_path): <NEW_LINE> <INDENT> all_files = os.listdir(file_path) <NEW_LINE> for _file in all_files: <NEW_LINE> <INDENT> if _file.endswith("... | Loads and parses a demonstration file.
:param file_path: Location of demonstration file (.demo).
:return: BrainParameter and list of BrainInfos containing demonstration data. | 625941d1498bea3a759b9c35 |
def server_add(s_name, s_ip, s_state=None, **connection_args): <NEW_LINE> <INDENT> ret = True <NEW_LINE> if server_exists(s_name, **connection_args): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> nitro = _connect(**connection_args) <NEW_LINE> if nitro is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT>... | Add a server
Note: The default server state is ENABLED
CLI Example:
.. code-block:: bash
salt '*' netscaler.server_add 'serverName' 'serverIpAddress'
salt '*' netscaler.server_add 'serverName' 'serverIpAddress' 'serverState' | 625941d176e4537e8c3517fa |
def getCurrentTournamentId(): <NEW_LINE> <INDENT> with closing(connect()) as db: <NEW_LINE> <INDENT> cursor = db.cursor() <NEW_LINE> cursor.execute("SELECT max(id) FROM tournament_tracker;") <NEW_LINE> current_tourney = cursor.fetchone()[0] <NEW_LINE> <DEDENT> return current_tourney | Finds the current tournament
Returns:
The tournament id | 625941d17c178a314d6ef5e8 |
def __init__(self, imax3d, sig3d, qzx, qzy, **kwargs) : <NEW_LINE> <INDENT> imax3d = np.atleast_1d(np.ndarray(imax3d, dtype=np.float32)) <NEW_LINE> n_gaussians = size(imax3d) <NEW_LINE> sig3d = np.atleast_1d(np.ndarray(sig3d, dtype=np.float32)) <NEW_LINE> qzx = np.atleast_1d(np.ndarray(qzx, dtype=np.float32)) <NEW_LINE... | Initialise the set of 3D Gaussians
| 625941d13317a56b86939dde |
def sum_series(n, x = 0, y = 1): <NEW_LINE> <INDENT> if n<0: <NEW_LINE> <INDENT> print('NAHHHH') <NEW_LINE> <DEDENT> elif n == 0: <NEW_LINE> <INDENT> return 2 <NEW_LINE> <DEDENT> elif n == 1: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> elif n == 2: <NEW_LINE> <INDENT> return 3 <NEW_LINE> <DEDENT> elif n == 3: <NEW... | takes in one necessary parameter and two optional params | 625941d14428ac0f6e5ba97a |
def test_package_corrupt(): <NEW_LINE> <INDENT> tip = submain.test_inner_package <NEW_LINE> submain.test_inner_package = lambda x, y, z: "success" <NEW_LINE> name = "tests/resources/corrupt.xpi" <NEW_LINE> err = ErrorBundle(None, True) <NEW_LINE> result = submain.test_package(err, name, name) <NEW_LINE> submain.test_in... | Tests the test_package function fails with a corrupt file | 625941d16aa9bd52df036f2c |
def test_docutils_safe(self): <NEW_LINE> <INDENT> with captured_stderr() as self.docutils_stderr: <NEW_LINE> <INDENT> entry = Entry.objects.create( pub_date=self.now, is_active=True, headline='active', content_format='reST', body='.. raw:: html\n :file: somefile\n', slug='a', ) <NEW_LINE> <DEDENT> self.assertIn('<p>... | Make sure docutils' file inclusion directives are disabled by default. | 625941d121a7993f00bc7e78 |
def do_set_timeout(self, timeout): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._stc.set_timeout(float(timeout)) <NEW_LINE> print('timeout set to', timeout, 'seconds') <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e) | Set number of seconds to wait for response. | 625941d1bf627c535bc13356 |
def train(X,Y,model,epochs,logs=True): <NEW_LINE> <INDENT> training_loss = [] <NEW_LINE> classes = len(np.unique(Y)) <NEW_LINE> Y_OHT = one_hot(Y,classes) <NEW_LINE> for ix in range(epochs): <NEW_LINE> <INDENT> Y_ = model.forward(X) <NEW_LINE> l = loss(Y_OHT,Y_) <NEW_LINE> training_loss.append(l) <NEW_LINE> model.backw... | Creates and Model and Trains it! | 625941d150485f2cf553cf21 |
def main_zips(): <NEW_LINE> <INDENT> files = os.listdir('.') <NEW_LINE> zipfilenames = [] <NEW_LINE> dirnames = [] <NEW_LINE> for file in files: <NEW_LINE> <INDENT> if not os.path.isdir(file): <NEW_LINE> <INDENT> if zipfile.is_zipfile(file) and file.split('.')[1] == 'zip': <NEW_LINE> <INDENT> extract_zip(file) <NEW_LIN... | main program for zip files structure
:return: no return | 625941d1adb09d7d5db6c916 |
def __len__(self): <NEW_LINE> <INDENT> return len(self.items) | Return number of pairs in the stanza. | 625941d1d58c6744b4257de7 |
def fullname(self): <NEW_LINE> <INDENT> return '-'.join(['github', self._org]) | Return the prefix all of this org's imported groups will get in Trac. | 625941d123e79379d52ee6ea |
def _process_page(request, resource_id=None): <NEW_LINE> <INDENT> if 'text/html' not in http_accept(request): <NEW_LINE> <INDENT> return process_resource(request, resource_id) <NEW_LINE> <DEDENT> tmp_g = find_resource_by_id(resource_id, 1) <NEW_LINE> resource_uri = format_resource_uri_ref(resource_id) <NEW_LINE> triple... | Process the page dependent on the mime format. | 625941d132920d7e50b28358 |
@unthreadable <NEW_LINE> @audio_in <NEW_LINE> def main(ain, args, stdin=None, stdout=None, stderr=None, spec=None): <NEW_LINE> <INDENT> ns = PARSER.parse_args(args) <NEW_LINE> if ain is None and ns.infile is not None: <NEW_LINE> <INDENT> ain = Audio(ns.infile) <NEW_LINE> <DEDENT> if ns.dbfile is None: <NEW_LINE> <INDEN... | Labels audio | 625941d124f1403a92600cec |
def merge_config(overrides=None, defaults=None, jsonFileName=None, built_ins={}): <NEW_LINE> <INDENT> if defaults is None and jsonFileName is not None: <NEW_LINE> <INDENT> if jsonFileName[0:1] == '/': <NEW_LINE> <INDENT> fname = jsonFileName <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> homedir = os.environ.get('HOME',... | Construct web.storage config result from inputs.
The configuration parameters are obtained in descending order
of preference from these sources:
1. overrides[key] only if overrides != None
2. defaults[key] only if defaults != None
3. webauthn2_config.json[key] only if defaults == None a... | 625941d1d53ae8145f87a3f6 |
def extract_graph_edges_dict_from_IR(self, model, modelName="yolo2"): <NEW_LINE> <INDENT> saveName1 = 'onnx/{}_Node2nextEntity_dict.pkl'.format(modelName) <NEW_LINE> saveName2 = 'onnx/{}_Entity2nextNode_dict.pkl'.format(modelName) <NEW_LINE> if os.path.isfile(os.getcwd()+"/"+saveName1) and os.path.isfile(os.getcwd()+"/... | save out shape_dict from IR | 625941d1b545ff76a8913f9d |
def next_birthday(request, birthday): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> bday = datetime.strptime(birthday, '%Y-%m-%d') <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return HttpResponseBadRequest() <NEW_LINE> <DEDENT> now = datetime.now() <NEW_LINE> current_bday = bday.replace(year=now.year) <NEW... | Return a string with the format: 'Days until next birthday: XYZ'
based on a given string GET parameter that comes in the URL, with the
format 'YYYY-MM-DD' | 625941d1ad47b63b2c50a107 |
def evaluation(logits, labels, images, nlabels, loss_type): <NEW_LINE> <INDENT> mask = tf.arg_max(tf.nn.softmax(logits, dim=-1), dimension=-1) <NEW_LINE> mask_gt = labels <NEW_LINE> tf.summary.image('example_gt', prepare_tensor_for_summary(mask_gt, mode='mask', nlabels=nlabels)) <NEW_LINE> tf.summary.image('example_pre... | A function for evaluating the performance of the netwrok on a minibatch. This function returns the loss and the
current foreground Dice score, and also writes example segmentations and imges to to tensorboard.
:param logits: Output of network before softmax
:param labels: Ground-truth label mask
:param images: Input i... | 625941d17d43ff24873a2e28 |
def reImport(module): <NEW_LINE> <INDENT> import importlib <NEW_LINE> return importlib.reload(module) | imports and returns a {module} object. Automatically save itself in the global | 625941d115fb5d323cde0c98 |
def _split_remainder(self, seq): <NEW_LINE> <INDENT> last = None <NEW_LINE> a = [] <NEW_LINE> b = [] <NEW_LINE> for value in seq: <NEW_LINE> <INDENT> if last is None or value == last: <NEW_LINE> <INDENT> a.append(value) <NEW_LINE> last = value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> b.append(value) <NEW_LINE> <DE... | Assuming an input array of the form [a, a, a, a, b, b, b],
partitions the input into two halves and returns
([a, a, a, a], [b, b, b]) | 625941d1d4950a0f3b08c4d5 |
def encounter(self, word): <NEW_LINE> <INDENT> return word in self | A "report" that the give word was encountered.
The implementation changes the internal state of the object as
to "remember" this encounter.
:param word: The encountered word.
:return: True if the given word is contained in the dictionary,
False otherwise. | 625941d1097d151d1a222fe0 |
def shortest(self, word1, word2): <NEW_LINE> <INDENT> return min(abs(i - j) for i in self.word_dict[word1] for j in self.word_dict[word2]) | Adds a word into the data structure.
:type word1: str
:type word2: str
:rtype: int | 625941d13d592f4c4ed1d1f3 |
def simWalks(numSteps, numTrials, dClass): <NEW_LINE> <INDENT> Homer = dClass() <NEW_LINE> origin = Location(0, 0) <NEW_LINE> distances = [] <NEW_LINE> for t in range(numTrials): <NEW_LINE> <INDENT> f = Field() <NEW_LINE> f.addDrunk(Homer, origin) <NEW_LINE> distances.append(round(walk(f, Homer, numSteps), 1)) <NEW_LIN... | Assumes numSteps an int >= 0, numTrials an int > 0, dClass a subclass of Drunk
Simulates numTrials walks of numSteps steps each.
Returns a list of the final distances for each trial | 625941d13eb6a72ae02ec666 |
def _date_parse(self, date): <NEW_LINE> <INDENT> if type(date) is datetime.datetime: <NEW_LINE> <INDENT> return date <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return datetime.datetime(*date) | Allow dates to be entered as integer tuples (YYYY, MM, DD[, HH, MM]).
Removes the need to supply datetime objects, but still allows dates
to be entered as datetime.datetime objects. The Year, Month and
Day are compulsory, the Hours and Minutes optional. May cause exceptions
if poorly formatted tuples are used. | 625941d107f4c71912b1160a |
def default_console(self): <NEW_LINE> <INDENT> print(colorize("%BoldWhite", self.banner)) <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> exec(input("> ")) <NEW_LINE> <DEDENT> except EOFError: <NEW_LINE> <INDENT> print() <NEW_LINE> return 0 <NEW_LINE> <DEDENT> except SystemExit as e: <NEW_LINE> <IND... | Simple python console interpreter
Used as fallback when neither of other consoles are available
It basically consists in an exec(input("> ")) loop | 625941d167a9b606de4a8041 |
def get( self, resource_group_name, route_table_name, route_name, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = self.get.metadata['url'] <NEW_LINE> path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'routeTableName': se... | Gets the specified route from a route table.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param route_table_name: The name of the route table.
:type route_table_name: str
:param route_name: The name of the route.
:type route_name: str
:param dict custom_headers: headers t... | 625941d1507cdc57c6306e63 |
def get_test_service(context, **kw): <NEW_LINE> <INDENT> db_service = db_utils.get_test_service(**kw) <NEW_LINE> if 'id' not in kw: <NEW_LINE> <INDENT> del db_service['id'] <NEW_LINE> <DEDENT> service = objects.Service(context) <NEW_LINE> for key in db_service: <NEW_LINE> <INDENT> setattr(service, key, db_service[key])... | Return a Service object with appropriate attributes.
NOTE: The object leaves the attributes marked as changed, such
that a create() could be used to commit it to the DB. | 625941d1a219f33f34628af0 |
def __init__( self ): <NEW_LINE> <INDENT> ip = get_ipython() <NEW_LINE> root_path = ip.starting_dir.replace("\\", "/") <NEW_LINE> self.files_folder = root_path + "/" + ip.run_line_magic("config", "{0}.cache_folder_name".format(Constants.MAGIC_CLASS_NAME)) | File Client constructor.
Parameters
----------
cluster_folder : str
folder that contains all the databse_folders that contains the query result files | 625941d15fdd1c0f98dc03bb |
def _generate_time_steps(self, trajectory_list): <NEW_LINE> <INDENT> for time_step in gym_env_problem.GymEnvProblem._generate_time_steps( self, trajectory_list): <NEW_LINE> <INDENT> frame_np = np.array(time_step.pop(env_problem.OBSERVATION_FIELD)) <NEW_LINE> frame_np = frame_np.reshape( [self.frame_height, self.frame_w... | Transforms time step observations to frames of a video. | 625941d1e76e3b2f99f3a991 |
def is_error(self): <NEW_LINE> <INDENT> return self.code[0] in ('4', '5') | Checks if the SMTP reply indicates an error, which will be True if
the code begins with a ``4`` or ``5``.
:rtype: True or False | 625941d11f037a2d8b946385 |
def have_same_single_gene(mouse1, mouse2): <NEW_LINE> <INDENT> if mouse1.mousegene_set.count() != 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if mouse2.mousegene_set.count() != 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> mg1 = mouse1.mousegene_set.first() <NEW_LINE> mg2 = mouse2.mousegene_set.fi... | Returns True if mouse1 and mouse2 have the same single MouseGene
This is mainly useful for detecting homozygosing crosses | 625941d1cdde0d52a9e531bc |
def eval_call(self, operands, env): <NEW_LINE> <INDENT> args = operands.map(lambda function: scheme_eval(function, env)) <NEW_LINE> return scheme_apply(self,args,env) | Standard function-call evaluation on SELF with OPERANDS as the
unevaluated actual-parameter expressions and ENV as the environment
in which the operands are to be evaluated. | 625941d1a8370b7717052a26 |
def test_add_organization_course(self): <NEW_LINE> <INDENT> with self.assertNumQueries(2): <NEW_LINE> <INDENT> api.add_organization_course( self.test_organization, self.test_course_key ) | Unit Test: test_add_organization_course | 625941d14c3428357757c4af |
def cleanup(self): <NEW_LINE> <INDENT> used_waveforms = set() <NEW_LINE> if self._idle_waveform in self._waveforms.by_data: <NEW_LINE> <INDENT> used_waveforms.add(self._waveforms.by_data[self._idle_waveform].name) <NEW_LINE> <DEDENT> programs = self._programs.copy() <NEW_LINE> self._clear_sequence() <NEW_LINE> self.ini... | Delete all waveforms not used anymore and rewrite sequence entries if they are fragmented | 625941d191af0d3eaac9bba1 |
def user_get_api_counts(method): <NEW_LINE> <INDENT> @functools.wraps(method) <NEW_LINE> async def wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> method(self, *args, **kwargs) <NEW_LINE> await save_api_counts(self) <NEW_LINE> <DEDENT> return wrapper | 获取api调用的次数,用于做用户的行为统计分析,后面还有利用组织的分析的。但是这个可能需要storm做实时统计了。
:param method:
:return: | 625941d145492302aab5e44c |
def _set_weight(self, v, load=False): <NEW_LINE> <INDENT> if hasattr(v, "_utype"): <NEW_LINE> <INDENT> v = v._utype(v) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> t = YANGDynClass( v, base=RestrictedClassType( base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8 ), is_leaf=True, yang_name="weight", parent... | Setter method for weight, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/mt_isn/neighbors/neighbor/subTLVs/subTLVs/adjacency_sid/sid/state/weight (uint8)
If this variable is read-only (config: false) in the
source YANG file... | 625941d14e4d5625662d455e |
def test_pro_players_content(self): <NEW_LINE> <INDENT> account_id = 88470 <NEW_LINE> steam_id = '76561197960354198' <NEW_LINE> personaname = 'Magma.Tzy丶' <NEW_LINE> name = 'Tzy丶' <NEW_LINE> country_code = 'cn' <NEW_LINE> self.assertEqual(self.pro_players[0]['account_id'], account_id, 'account_id = {0} is {1}.'.format(... | Checks to make sure that the content being returned for pro players is as expected. | 625941d150812a4eaa59c4a8 |
def _prec_bounds(self, n, prec): <NEW_LINE> <INDENT> if self._p == 2: <NEW_LINE> <INDENT> e = self._e_bounds(n-2, prec) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> e = self._e_bounds(n-1, prec) <NEW_LINE> <DEDENT> c = self._c_bound() <NEW_LINE> return [e[j] - c for j in range(len(e))] | A helper function not designed for direct use.
It returns the `p`-adic precisions of the approximation
to the `p`-adic L-function.
EXAMPLES::
sage: E = EllipticCurve('11a1')
sage: Lp = E.padic_lseries(5)
sage: Lp._prec_bounds(3,10)
[+Infinity, 1, 1, 1, 1, 0, 0, 0, 0, 0]
sage: Lp._prec_bounds(3,12... | 625941d17d847024c06be444 |
def search(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | Missing associated documentation comment in .proto file. | 625941d1e1aae11d1e749e3f |
def get_arc(self, x_start: int, y: int, y_curve: int, x_end: int) -> str: <NEW_LINE> <INDENT> template = "M{x},{y} C{x},{c} {e},{c} {e},{y}" <NEW_LINE> if self.compact: <NEW_LINE> <INDENT> template = "M{x},{y} {x},{c} {e},{c} {e},{y}" <NEW_LINE> <DEDENT> return template.format(x=x_start, y=y, c=y_curve, e=x_end) | Render individual arc.
x_start (int): X-coordinate of arrow start point.
y (int): Y-coordinate of arrow start and end point.
y_curve (int): Y-corrdinate of Cubic Bézier y_curve point.
x_end (int): X-coordinate of arrow end point.
RETURNS (str): Definition of the arc path ('d' attribute). | 625941d123e79379d52ee6eb |
def _encode_params(**kw): <NEW_LINE> <INDENT> args = [] <NEW_LINE> for k, v in kw.iteritems(): <NEW_LINE> <INDENT> if k == 'redirect_uri' and v == ' ': <NEW_LINE> <INDENT> args.append('redirect=') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> qv = v.encode('utf-8') if isinstance(v, unicode) else str(v) <NEW_LINE> args.... | Encode parameters. | 625941d1adb09d7d5db6c917 |
def display_genre(self): <NEW_LINE> <INDENT> return ', '.join(genre.name for genre in self.genre.all()[:3]) | Create a string for the Genre. This is required to display genre in Admin. | 625941d194891a1f4081bc31 |
def plot_correlation(dataframe, number_of_columns=11): <NEW_LINE> <INDENT> corr = dataframe.corr() <NEW_LINE> fig, ax = plt.subplots(figsize=(number_of_columns, number_of_columns)) <NEW_LINE> ax.matshow(corr) <NEW_LINE> plt.xticks(range(len(corr.columns)), corr.columns) <NEW_LINE> plt.yticks(range(len(corr.columns)), c... | Function plots a graphical correlation matrix for each pair of columns in the dataframe.
Input:
df: pandas DataFrame
size: vertical and horizontal size of the plot
Displays:
matrix of correlation between columns. Blue-cyan-yellow-red-darkred => less to more correlated
... | 625941d1090684286d50ee6e |
def calcula_salario(self) -> float: <NEW_LINE> <INDENT> return self.salario_hora * self.consulta_carga_horaria() * 4.5 | Calcula o salário do mês para o funcionário | 625941d1d18da76e2353265f |
def deleteProposal(): <NEW_LINE> <INDENT> pass | Delete the proposal to merge. | 625941d130dc7b7665901aee |
def get_status(self, **kwargs): <NEW_LINE> <INDENT> if not check_unsafe(*self._UNSAFE, **kwargs): <NEW_LINE> <INDENT> _LOGGER.warning("%s: disabled, requires unsafe features '%s'", self.description, ','.join(self._UNSAFE)) <NEW_LINE> return [] <NEW_LINE> <DEDENT> treg = self._read_temperature_register() <NEW_LINE> treg... | Get a status report.
Returns a list of `(property, value, unit)` tuples. | 625941d1dd821e528d63b330 |
def min_distance_rectangle(self, other, p=2.): <NEW_LINE> <INDENT> return minkowski_distance(0, np.maximum(0,np.maximum(self.mins-other.maxes,other.mins-self.maxes)),p) | Compute the minimum distance between points in the two hyperrectangles. | 625941d1be8e80087fb20dc9 |
def allowed_file(filename): <NEW_LINE> <INDENT> if filename.count('.') != 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> suffix = filename.rsplit('.', 1)[-1] <NEW_LINE> if len(suffix) < 3: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return suffix[0] + suffix[1] + suffix[2] in ALLOWED_EXTENSIONS | Synopsis:
Checks if a given filename is allowed, i.e. contains exactly one '.' and ends on an allowed extension.
:param filename: filename to check
:returns allowed: boolean | 625941d14f88993c3716c1ee |
def __add__(self,other): <NEW_LINE> <INDENT> if isinstance(other, fuzzy_member): <NEW_LINE> <INDENT> return lambda : np.max([other._fire, self._fire]) <NEW_LINE> <DEDENT> elif callable(other): <NEW_LINE> <INDENT> return lambda : np.max([other(), self._fire]) | Aaddition is the rule OR funcion
let:
cold = fuzzy_member
cheap = fuzzy_member
then:
A rule named R1 can be defiined as:
R1 = cold + cheep
R1(x) => max(cold.fire(x),cheep.fire(x)) | 625941d1a4f1c619b28b01bf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.