code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def execute(self, namespace): <NEW_LINE> <INDENT> routes = sorted(self.server.dispatcher.routes.copy().values(), key=lambda route: (route.bundle_name, route.controller_name, route.action_name)) <NEW_LINE> table = Table("Pattern", "Bundle", "Controller", "Action", left_border=" ", right_border="") <NEW_LINE> if namespa... | Execute the command. | 625941e3b830903b967e9cec |
def __init__(self, id=None, name=None, slug=None, description=None, cluster_count=None): <NEW_LINE> <INDENT> self._id = None <NEW_LINE> self._name = None <NEW_LINE> self._slug = None <NEW_LINE> self._description = None <NEW_LINE> self._cluster_count = None <NEW_LINE> self.discriminator = None <NEW_LINE> if id is not No... | ClusterGroup - a model defined in Swagger | 625941e331939e2706e4d249 |
def check_input_folder(self): <NEW_LINE> <INDENT> if not os.path.exists(self.args.input_dir): <NEW_LINE> <INDENT> logger.error("Input location %s not found.", self.args.input_dir) <NEW_LINE> exit(1) <NEW_LINE> <DEDENT> if (os.path.isfile(self.args.input_dir) and os.path.splitext(self.args.input_dir)[1].lower() in _vide... | Check whether the input is a folder or video | 625941e30c0af96317bb85cd |
def hstack(tup): <NEW_LINE> <INDENT> arrs = [atleast_1d(_m) for _m in tup] <NEW_LINE> if arrs and arrs[0].ndim == 1: <NEW_LINE> <INDENT> return _nx.concatenate(arrs, 0) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _nx.concatenate(arrs, 1) | Stack arrays in sequence horizontally (column wise).
This is equivalent to concatenation along the second axis, except for 1-D
arrays where it concatenates along the first axis. Rebuilds arrays divided
by `hsplit`.
This function makes most sense for arrays with up to 3 dimensions. For
instance, for pixel-data with a ... | 625941e39f2886367277ac70 |
@run_priority(level='P0') <NEW_LINE> def test_get_world_size(): <NEW_LINE> <INDENT> assert dist.get_world_size() == 2 <NEW_LINE> print("{} ... ok".format(sys._getframe().f_code.co_name)) | get world size | 625941e38e71fb1e9831db8d |
def create_element(build_ele, doc): <NEW_LINE> <INDENT> del doc <NEW_LINE> common_props = AllplanBaseElements.CommonProperties() <NEW_LINE> common_props.GetGlobalProperties() <NEW_LINE> box = Box(build_ele.Length.value, build_ele.Width.value, build_ele.Height.value,) <NEW_LINE> if not box.is_valid(): <NEW_LINE> <INDENT... | Creation of element
Args:
build_ele: the building element.
doc: input document | 625941e3009cb60464c63794 |
def distribution_of_lifetimes(self, time_unit="D", node_level=False, community_level=False, nodes=[], communities=[], platform="all", action_types=[], date_range=[]): <NEW_LINE> <INDENT> data = self.preprocess(node_level, nodes, community_level, communities, platform, action_types, date_range) <NEW_LINE> speed_distribu... | Description: Calculate the distributions of the information lifetimes
Input:
time_unit: Granularity of time
node_level: If true, compute measurement for each node
community_level: If true, compute measurement for each community
nodes: List of specific nodes to calculate measurement, or keyword "all" to... | 625941e3ac7a0e7691ed44aa |
def update_table(self, model): <NEW_LINE> <INDENT> for field in model._meta.local_many_to_many: <NEW_LINE> <INDENT> if field.remote_field.through._meta.auto_created: <NEW_LINE> <INDENT> if not self.sql.table_exists(field.remote_field.through._meta.db_table): <NEW_LINE> <INDENT> self.create_table(field.remote_field.thro... | Update table properties and check M2M tables | 625941e323e79379d52ee944 |
def _extract_namespace_ast_node(self, desc): <NEW_LINE> <INDENT> if len(desc) == 0 or not isinstance(desc[0], AstNamespace): <NEW_LINE> <INDENT> if self._debug: <NEW_LINE> <INDENT> self._logger.info('Description: %r', desc) <NEW_LINE> <DEDENT> raise InvalidSpec('First declaration in a stone must be ' 'a namespace. Poss... | Checks that the namespace is declared first in the spec, and that only
one namespace is declared.
Args:
desc (List[stone.stone.parser.ASTNode]): All AST nodes in a spec
file in the order they were defined.
Return:
stone.frontend.ast.AstNamespace: The namespace AST node. | 625941e3a219f33f34628d49 |
def apply_mask(self, mask): <NEW_LINE> <INDENT> self.mask = mask | Apply mask to the property of SurfaceGeometry.
Mask will be reshaped to (n,).
This method has no return, it works when accessing the property.
If mask is not needed, set it to None. | 625941e38e05c05ec3eea75d |
def get_extra_files(): <NEW_LINE> <INDENT> FILES_TO_SKIP = ["src/gdbgui.js"] <NEW_LINE> THIS_DIR = os.path.dirname(os.path.abspath(__file__)) <NEW_LINE> extra_dirs = [THIS_DIR] <NEW_LINE> extra_files = [] <NEW_LINE> for extra_dir in extra_dirs: <NEW_LINE> <INDENT> for dirname, _, files in os.walk(extra_dir): <NEW_LINE>... | returns a list of files that should be watched by the Flask server
when in debug mode to trigger a reload of the server | 625941e34c3428357757c70b |
@register.inclusion_tag('calendarium/upcoming_events.html') <NEW_LINE> def render_upcoming_events(event_amount=5, category=None): <NEW_LINE> <INDENT> if not isinstance(category, EventCategory): <NEW_LINE> <INDENT> category = None <NEW_LINE> <DEDENT> return { 'occurrences': Event.objects.get_occurrences( now(), now() + ... | Template tag to render a list of upcoming events. | 625941e3379a373c97cfaf2c |
def main(): <NEW_LINE> <INDENT> module_four() | Test your module | 625941e3ff9c53063f47c5d7 |
def update(self, table, values, where_row=None): <NEW_LINE> <INDENT> stmt = f"UPDATE {table} SET " + ", ".join( f"{col}='{value!s}'" for col, value in values.items() ) <NEW_LINE> if where_row: <NEW_LINE> <INDENT> stmt += self.__handle_where(where_row) <NEW_LINE> <DEDENT> csr = self.cnx.cursor(dictionary=True) <NEW_LINE... | Executes an UPDATE statement against a table.
Arguments:
table -- name of the table to be updated
values -- dict of columns and values to update
where_row (optional) -- dict used to build WHERE clause
Returns: Number of rows updated. | 625941e3796e427e537b09ae |
def item_list(self, source): <NEW_LINE> <INDENT> return self._join_nest(source["content"][0], "\n", "") | Item list | 625941e3d53ae8145f87a64e |
@bp.route("/articles/<int:id>", methods = ["GET"]) <NEW_LINE> @token_auth.login_required <NEW_LINE> def get_articles(id): <NEW_LINE> <INDENT> if token_auth.current_user().id != id: <NEW_LINE> <INDENT> abort(403) <NEW_LINE> <DEDENT> user_articles = User.query.get_or_404(id).articles <NEW_LINE> data_articles = [ article.... | API that enables to get the articles list for a given user
(identified through its id)
:param id: the cuser identifier
:type id: int
:return: the Response object containing the data (in JSON format)
:rtype: flask.wrappers.Response | 625941e3cb5e8a47e48b7e8a |
def __call__(self, unitary, simplify=True, atol=DEFAULT_ATOL): <NEW_LINE> <INDENT> if hasattr(unitary, 'to_operator'): <NEW_LINE> <INDENT> unitary = unitary.to_operator().data <NEW_LINE> <DEDENT> elif hasattr(unitary, 'to_matrix'): <NEW_LINE> <INDENT> unitary = unitary.to_matrix() <NEW_LINE> <DEDENT> unitary = np.asarr... | Decompose single qubit gate into a circuit.
Args:
unitary (Operator or Gate or array): 1-qubit unitary matrix
simplify (bool): reduce gate count in decomposition [Default: True].
atol (bool): absolute tolerance for checking angles when simplifing
returnd circuit [Default: 1e-12].
Returns:... | 625941e3a8370b7717052c83 |
def get_md5(self): <NEW_LINE> <INDENT> hash_string = "".join([str(x) for x in self.__dict__.values()]) <NEW_LINE> hash_md5 = md5(hash_string.encode('utf-8')).hexdigest() <NEW_LINE> return hash_md5 | Concatenates all object properties as strings and hashes them using an MD5 checksum.
:return: MD5 checksum of all object properties. | 625941e3f548e778e58cd965 |
def recordLive(path: str) -> None: <NEW_LINE> <INDENT> global r <NEW_LINE> streamInfo = r.get_room_play_url() <NEW_LINE> url = streamInfo['durl'][0]['url'] <NEW_LINE> title = r.get_room_info()['room_info']['title'] <NEW_LINE> filename = '{}_{}'.format( title, datetime.datetime.now().strftime('%Y%m%d%H%M%S')) <NEW_LINE>... | Record live stream
Record bilibili live stream accroding to setted roomid.
Args:
room: live room's id
path: the path where save files | 625941e3442bda511e8be7f8 |
def onAdd(self): <NEW_LINE> <INDENT> personDict = self.getData() <NEW_LINE> data = ({"person":personDict}) <NEW_LINE> logic.addRecord(data) <NEW_LINE> commonDlgs.showMessageDlg("Contact Added", "Success!", wx.ICON_INFORMATION) <NEW_LINE> for child in self.GetChildren(): <NEW_LINE> <INDENT> if isinstance(child, wx.TextC... | Add the record to the database | 625941e3187af65679ca5506 |
def publishIntentTree(self, chatbots_folder, idChatBot=None): <NEW_LINE> <INDENT> intentTree_list = traductor_df(chatbots_folder, IntentTree) <NEW_LINE> pickle.dump(intentTree_list, open('Sessions/Conference.pck','wb')) <NEW_LINE> if idChatBot is None: <NEW_LINE> <INDENT> self.current_intentTree = intentTree_list[0].id... | Consult and publish the current IntentTree using the chatbots folder.
Here a project id is supplied to retrieve all intents from core
and build the IntentTree. At the end self.current_intentTree must
be updated and the tree saved it into session. | 625941e3097d151d1a22323d |
def remove(self, class_name, name): <NEW_LINE> <INDENT> if class_name not in self.components: <NEW_LINE> <INDENT> logger.error("Component class {} not found".format(class_name)) <NEW_LINE> return None <NEW_LINE> <DEDENT> cls_df = self.df(class_name) <NEW_LINE> cls_df.drop(name, inplace=True) <NEW_LINE> pnl = self.pnl(c... | Removes a single component from the network.
Removes it from component DataFrames.
Parameters
----------
class_name : string
Component class name
name : string
Component name
Examples
--------
>>> network.remove("Line","my_line 12345") | 625941e3656771135c3ebc59 |
def cart_modify(self, cart_id, hmac, item_ids, **params): <NEW_LINE> <INDENT> params.update({ 'CartId': cart_id, 'HMAC': hmac, }) <NEW_LINE> params.update(self._convert_cart_items(item_ids, key='CartItemId')) <NEW_LINE> return self.call(Operation='CartModify', **params) | The :meth:`cart_modify` operation enables you to change the quantity of
items that are already in a remote shopping cart and move items from
the active area of a cart to the ``SaveForLater`` area or the reverse.
To modify the number of items in a cart, you must specify the cart
using the ``CartId`` and HMAC values tha... | 625941e35fcc89381b1e1aa7 |
def name_validalidation(name, context): <NEW_LINE> <INDENT> if len(name.strip()) == 0 or not re.match("^[-a-zA-Z0-9_\\s]*$", name): <NEW_LINE> <INDENT> message = "Name shouldn't be empty. No special characters" <NEW_LINE> response = { "message": message + " for " + context + " names", context: "null" } <NEW_LINE> retur... | Function used to validate various names | 625941e3dd821e528d63b58b |
def setup_plugin_options(): <NEW_LINE> <INDENT> if args.twitch_cookie: <NEW_LINE> <INDENT> livestreamer.set_plugin_option("twitch", "cookie", args.twitch_cookie) <NEW_LINE> <DEDENT> if args.twitch_oauth_token: <NEW_LINE> <INDENT> livestreamer.set_plugin_option("twitch", "oauth_token", args.twitch_oauth_token) <NEW_LINE... | Sets Livestreamer plugin options. | 625941e34e696a04525c9833 |
@app.route("/healthz") <NEW_LINE> def healthz(): <NEW_LINE> <INDENT> return "OK", 200 | healthz for readyness checks | 625941e3711fe17d82542748 |
def setTopLeft(self, topLeft): <NEW_LINE> <INDENT> self._topLeft = topLeft | Sets the top left coordinate of this bounding box to topLeft.
@param topLeft: The topleft coord
@type topLeft: GeoCoordinate | 625941e3b545ff76a89141fb |
def wms_get_feature_info(request, wms_url, wms_params): <NEW_LINE> <INDENT> feature_info = urllib2.urlopen('http://'+wms_url, data=wms_params) <NEW_LINE> return HttpResponse(feature_info) | Request information from GeoServer via a WMS GetFeatureInfo call
| 625941e326068e7796caf0ca |
@request(url='/distribute/updateDistributorLevel',method='POST') <NEW_LINE> def distribute_updateDistributorLevel(self, orderAmount, levelRank, sysnumber, promotionAward, promotionAwardUnit, promotionNumber, activityNumber, levelName): <NEW_LINE> <INDENT> json = { "orderAmount": orderAmount, "levelRank": levelRank, "sy... | 编辑推客等级接口 | 625941e37d43ff24873a3089 |
def _service_contract_ios(self): <NEW_LINE> <INDENT> self.action.click(self.add_obligations_locator) <NEW_LINE> self.action.click(self.type_locator) <NEW_LINE> self.action.click(self.service_type_locator) <NEW_LINE> self.action.click(self.confirm_locator) <NEW_LINE> self.action.set_value(self.resource_discount_locator,... | ios:添加义务项(服务星级)
:return: | 625941e3236d856c2ad44bc5 |
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(UpdateControllerParametersRequest, self).__init__(*args, **kwds) <NEW_LINE> if self.params is None: <NEW_LINE> <INDENT> self.params = roboy_simulation_msgs.msg.ControllerParameters() <NEW_LINE> <DEDENT> <DEDENT> else: <NEW... | 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:
params
:param args: complete set ... | 625941e321a7993f00bc80dc |
def register(self): <NEW_LINE> <INDENT> if self.uuid is not None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> proxy = slave.Slave().getProxy() <NEW_LINE> try: <NEW_LINE> <INDENT> self.uuid = proxy.node.register(self.host_info) <NEW_LINE> Logger.log('Registered at master under uuid {0}' . format(self.uuid)) <NEW_LINE... | Register node at master | 625941e3851cf427c661a8f2 |
@jsonrpc_method() <NEW_LINE> def get_repo_groups(request, apiuser): <NEW_LINE> <INDENT> result = [] <NEW_LINE> _perms = ('group.read', 'group.write', 'group.admin',) <NEW_LINE> extras = {'user': apiuser} <NEW_LINE> for repo_group in RepoGroupList(RepoGroupModel().get_all(), perm_set=_perms, extra_kwargs=extras): <NEW_L... | Returns all repository groups.
:param apiuser: This is filled automatically from the |authtoken|.
:type apiuser: AuthUser | 625941e3e76e3b2f99f3abeb |
def find_place(self, board, ship_lenght): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> alingment = choice(['v', 'h']) <NEW_LINE> y = choice(range(len(board))) <NEW_LINE> x = choice(range(len(board[y]))) <NEW_LINE> taken = False <NEW_LINE> if not board[y][x] == 1: <NEW_LINE> <INDENT> if alingment == 'h': <NEW_LIN... | Find a place on a board for a ship with certain lenght and return cordinates | 625941e3627d3e7fe0d69237 |
def unpack_array (array, srcbpp = 4): <NEW_LINE> <INDENT> nparts = 8 // srcbpp <NEW_LINE> masks = [1 << srcbpp - 1] <NEW_LINE> shifts = [srcbpp * v for i in range (nparts)] <NEW_LINE> for i in range (1, nparts): <NEW_LINE> <INDENT> masks.append(masks[-1] << (srcbpp * i)) <NEW_LINE> <DEDENT> newshape = shape_bpp_adjust(... | unpack an array to 8bpp | 625941e3d58c6744b4258044 |
def testSizeOneAdd(self): <NEW_LINE> <INDENT> s = DrawSet() <NEW_LINE> s.add(1) <NEW_LINE> self.assertEqual(len(s), 1) | Test we get the size right after one addition. | 625941e34e4d5625662d47b8 |
def __init__(self, groupby, window=7, aggregation="max"): <NEW_LINE> <INDENT> self.groupby = groupby <NEW_LINE> self.window = window <NEW_LINE> self.aggregation = aggregation | Constructor. | 625941e366673b3332b92477 |
def test_criteria(self): <NEW_LINE> <INDENT> assert criteria("this should not pass") == 0 <NEW_LINE> assert criteria("Thu Sep 9 17:22:46 [rs_sync] replSet error RS102 too stale to catch up") == 1 <NEW_LINE> assert criteria("Thu Sep 9 17:24:46 [rs_sync] replSet error RS102 too stale to catch up, at least from primary: 1... | Test the criteria() method of stale_secondary.py | 625941e37c178a314d6ef84b |
def step(self): <NEW_LINE> <INDENT> ngrid = [["." for _ in row] for row in self.grid] <NEW_LINE> for y, row in enumerate(self.grid): <NEW_LINE> <INDENT> for x, _ in enumerate(row): <NEW_LINE> <INDENT> if (x, y) != self.mid_cell: <NEW_LINE> <INDENT> ngrid[y][x] = self.get_new_cell(x, y) <NEW_LINE> <DEDENT> else: <NEW_LI... | Compute the new cell values (as ngrid), then ensure all levels above and below
are computed, then set self.grid = ngrid. | 625941e3a934411ee3751a7a |
def GetPointer(self): <NEW_LINE> <INDENT> return _itkMaximumProjectionImageFilterPython.itkMaximumProjectionImageFilterIF3IF2_Superclass_GetPointer(self) | GetPointer(self) -> itkMaximumProjectionImageFilterIF3IF2_Superclass | 625941e373bcbd0ca4b2c45b |
def _match_major(self, version_condition: "VersionCondition") -> bool: <NEW_LINE> <INDENT> if self.operator != ConditionOperator.MAJOR: <NEW_LINE> <INDENT> raise ValueError( f"Condition {self!s} is not constrained by a major operator, " f"condition operator is {self.operator!r}" ) <NEW_LINE> <DEDENT> if version_conditi... | Match a given version condition against the major constrained version.
:param VersionCondition version_condition: The version condition to match
against the current major constrainted version
:raises ValueError: If the current condition's operator is not set to
:cvar:`~ConditionOperator.MAJOR`
:return: True if... | 625941e33317a56b8693a035 |
def pprint_debug(func: callable, tag: str = DEFAULT_TAG): <NEW_LINE> <INDENT> name = GetFunctionName(func) <NEW_LINE> @functools.wraps(func) <NEW_LINE> def wrapper_debug(*args, **kwargs): <NEW_LINE> <INDENT> Print(tag.format(name)) <NEW_LINE> signature = getPPrintStr({'kwargs': kwargs, 'args': args, }) <NEW_LINE> Print... | Print the function signature and return value
:param func: callable function to be debugged.
:param tag: a unique string to identify the output in the console window.
:return: | 625941e3293b9510aa2c3678 |
def maxArea(self, height): <NEW_LINE> <INDENT> res = 0 <NEW_LINE> l = 0 <NEW_LINE> r = len(height) - 1 <NEW_LINE> while(l < r): <NEW_LINE> <INDENT> res = max(res, min(height[l], height[r]) * (r - l)) <NEW_LINE> if height[l] < height[r]: <NEW_LINE> <INDENT> l = l + 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> r = r -... | :type height: List[int]
:rtype: int | 625941e326068e7796caf0cb |
def fillna(arg, fill_value): <NEW_LINE> <INDENT> return ops.IfNull(arg, fill_value).to_expr() | Replace any null values with the indicated fill value
Parameters
----------
fill_value : scalar / array value or expression
Examples
--------
>>> import ibis
>>> table = ibis.table([('col', 'int64'), ('other_col', 'int64')])
>>> result = table.col.fillna(5)
>>> result2 = table.col.fillna(table.other_col * 3)
Returns... | 625941e356ac1b37e62645af |
def remove_video_source(backend, args, opts): <NEW_LINE> <INDENT> source = {} <NEW_LINE> for source in get_sources(backend, args): <NEW_LINE> <INDENT> if source['Id'] == args['remove']: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> if not source: <NEW_LINE> <INDENT> print('Source Id {} not found'.format(args['... | See https://www.mythtv.org/wiki/Channel_Service#RemoveVideoSource | 625941e3c432627299f0502f |
def bitmask_octet(bit_count): <NEW_LINE> <INDENT> if bit_count <= 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if bit_count > 8: <NEW_LINE> <INDENT> bit_count = 8 <NEW_LINE> <DEDENT> return reduce( lambda x, y: x | y, [1 << (8 - bn) for bn in range(1, bit_count + 1)] ) | Return the numeric value (0-255) of a bitmask for k bits, 0 <= k <=8.
Arguments:
bit_count (int):
The number of high order bits to set to 1 in the bitmask.
Returns:
(int) The numeric value of the bitmask. If ``bit_count`` is
less than or equal to 0, the value 0 will be returned.
Otherwise, t... | 625941e310dbd63aa1bd2f88 |
def RemoveTemporaryGraphicsObjects(self,GraphicObjectIDs): <NEW_LINE> <INDENT> pass | RemoveTemporaryGraphicsObjects(self: GraphicsDrawer,GraphicObjectIDs: IEnumerable) | 625941e3a4f1c619b28b0416 |
def __init__(self, dbstate, uistate): <NEW_LINE> <INDENT> self.dbstate = dbstate <NEW_LINE> self.title = _("Import Family Tree") <NEW_LINE> ManagedWindow.__init__(self, uistate, [], self.__class__, modal=True) <NEW_LINE> pmgr = GuiPluginManager.get_instance() <NEW_LINE> import_dialog = Gtk.FileChooserDialog( title='', ... | A dialog to import a file into Gramps | 625941e3aad79263cf390e2d |
def get_from_config(dirct=DIRECTORY, conf_file=CONFIG_FILE): <NEW_LINE> <INDENT> path = os.path.join(dirct, conf_file) <NEW_LINE> if not os.path.exists(path): <NEW_LINE> <INDENT> print("Please, create config.ini with ini_maker.py in data!") <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> config = configparser.ConfigParser()... | Create, read, update, delete config | 625941e3b57a9660fec33c70 |
def _register_agent_service_fallback(self, failure, registration): <NEW_LINE> <INDENT> log.msg('Falling back for %s at %s.' % ( registration['Name'], self.endpoint)) <NEW_LINE> return self.request( 'PUT', '/v1/agent/service/register', json_data=registration, timeout=self.fallback_timeout) | Fallback to the default agent endpoint (`self.endpoint`) to register
a Consul service. | 625941e3b7558d58953c52f2 |
def play(moves, move_idx_from=0, number_of_moves=None): <NEW_LINE> <INDENT> if move_idx_from >= len(moves): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if number_of_moves is None: <NEW_LINE> <INDENT> number_of_moves = len(moves) - move_idx_from <NEW_LINE> <DEDENT> for index, m in enumerate(moves[move_idx_from :... | replay number of moves | 625941e3d486a94d0b98e52d |
def preForecast(self): <NEW_LINE> <INDENT> self.fuzzNumber = 0 <NEW_LINE> self.overflowNumber = 0 | Prepare the forecasts. | 625941e3be383301e01b5864 |
def get_rate_for_metric(self, metric): <NEW_LINE> <INDENT> return None | Override this method to report rate for metric | 625941e3c4546d3d9de72e1d |
def test_only_stopword_word_list(self): <NEW_LINE> <INDENT> self.assertEqual([], clean_word_list(LIST['STOP'])) | clean_word_list should return [] on stopword list. | 625941e38a349b6b435e8559 |
def computeRrup(self, lon, lat, depth): <NEW_LINE> <INDENT> mesh_dx = self._mesh_dx <NEW_LINE> oldshape = lon.shape <NEW_LINE> if len(oldshape) == 2: <NEW_LINE> <INDENT> newshape = (oldshape[0] * oldshape[1], 1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> newshape = (oldshape[0], 1) <NEW_LINE> <DEDENT> x, y, z = latl... | Method for computing rupture distance.
Args:
lon (array): Numpy array of longitudes.
lat (array): Numpy array of latitudes.
depth (array): Numpy array of depths (km; positive down).
Returns:
tuple: A tuple of an array of rupture distance (km), and None. | 625941e3b830903b967e9ced |
def runPruebas(): <NEW_LINE> <INDENT> step = 0 <NEW_LINE> traci.trafficlight.setPhase("0", 2) <NEW_LINE> while traci.simulation.getMinExpectedNumber() > 0: <NEW_LINE> <INDENT> traci.simulationStep() <NEW_LINE> if traci.trafficlight.getPhase("0") == 2: <NEW_LINE> <INDENT> if traci.inductionloop.getLastStepVehicleNumber(... | execute the TraCI control loop | 625941e3a05bb46b383ecc05 |
def loadObjects(): <NEW_LINE> <INDENT> cmudic = cmudict.dict() <NEW_LINE> pyphendic = pyphen.Pyphen(lang='en') <NEW_LINE> spaCyNLP = spacy.load('en_core_web_sm') <NEW_LINE> return {'cmudic':cmudic, 'pyphendic':pyphendic, 'spaCyNLP':spaCyNLP} | Requires: none
Effects: Returns a dictionary of complex objects from nltk, spacy, and
pyphen holding data that allows us to process data. | 625941e35f7d997b87174e81 |
def do_quit(self, line): <NEW_LINE> <INDENT> want_save = input("Do you wish to save new Employees to Database? Y/N") <NEW_LINE> while(want_save not in ["y", "Y", "n", "N"]): <NEW_LINE> <INDENT> want_save = input("Do you wish to save new Employees to Database? Y/N") <NEW_LINE> <DEDENT> if(want_save in ["y","Y"]): <NEW_L... | Quit from MyCMD
return: True | 625941e326238365f5f0f25a |
def emptyView(args, syn): <NEW_LINE> <INDENT> project_id = args.id <NEW_LINE> scopes = args.scopes <NEW_LINE> json_files = args.json <NEW_LINE> view_name = args.name <NEW_LINE> default_columns = args.add_default_columns <NEW_LINE> if args.viewType: <NEW_LINE> <INDENT> viewType = args.viewType <NEW_LINE> <DEDENT> else: ... | Given synapse scopes, creates an empty project/file view schema to be annotated.
:param args:
:param syn:
:return: | 625941e38da39b475bd6535f |
def test_weekly_release(self): <NEW_LINE> <INDENT> self.assertEqual(get_doc_version('0.3.2dev1'), '0.3.2dev1') | When the version is from a weekly release, the documentation version
is left unchanged. | 625941e3097d151d1a22323e |
def _move(self, event): <NEW_LINE> <INDENT> if self._current_tower.get_value() > self._coins: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> position = event.x, event.y <NEW_LINE> self._current_tower.position = position <NEW_LINE> legal, grid_path = self._game.attempt_placement(position) <NEW_LINE> path = [self._game.g... | Handles the mouse moving over the game view canvas
Parameter:
event (tk.Event): Tkinter mouse event | 625941e35166f23b2e1a553f |
def has_downloads(self): <NEW_LINE> <INDENT> return self._has_dl | Checks if this repository has downloads | 625941e33346ee7daa2b3155 |
def show(self, tic_tac_toe = None): <NEW_LINE> <INDENT> if tic_tac_toe: <NEW_LINE> <INDENT> self.__show_ttt(tic_tac_toe) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print(self.__display) | Show current game status.
:param tic_tac_toe: TicTacToe object to show or 0 for empty board
:type tic_tac_toe: TicTacToe or None | 625941e37b25080760e3983d |
def test_result(topN): <NEW_LINE> <INDENT> test = pd.read_csv(os.path.join(path, os.path.normpath('test/user_venues_test_' + city + '.csv')), sep = '|', names = ['user_id', 'venue_id'], dtype = str) <NEW_LINE> predict = pd.read_csv(os.path.join(path, os.path.normpath('test/part-r-00000')), sep = '|', header = None, dty... | topN: int | 625941e3d164cc6175783136 |
def calculate_ranges(page, items_per_page, total_items): <NEW_LINE> <INDENT> offset = min(page * items_per_page, total_items) <NEW_LINE> end = min(offset + items_per_page, total_items) <NEW_LINE> return offset, end | Return the offset and end indices for a slice. | 625941e3cdde0d52a9e5341c |
def extract_domain(host): <NEW_LINE> <INDENT> host = re.sub('https?://', '', host) <NEW_LINE> host = re.match('([^/]+)', host).groups()[0] <NEW_LINE> domain = '.'.join(host.split('.')[-2:]) <NEW_LINE> if domain in _domains: <NEW_LINE> <INDENT> domain = '.'.join(host.split('.')[-3:]) <NEW_LINE> <DEDENT> return domain | Domain name extractor. Turns host names into domain names, ported
from pwdhash javascript code | 625941e3ab23a570cc25056c |
def plot_etas_steadystate(fig, ew): <NEW_LINE> <INDENT> plt.figure(fig.number) <NEW_LINE> j__ = (ew.j*3)//4 <NEW_LINE> i_offset = ew.n_chi_domain//7 <NEW_LINE> phi__ = ew.phi_array[j__] <NEW_LINE> phi0__ = int(phi__/ew.Delta_chi)-i_offset <NEW_LINE> chi_s__= ew.chi_array[phi0__:]-ew.chi_array[phi0__+i_offset] <NEW_LIN... | Plot steady-state solution of weakness :math:`\eta_s`.
Graph the numerical solution
of the 1d weathering-mediated erosion model
for weakness :math:`\eta_s(\chi_i | W)`
as a function of depth from the rock surface :math:`\chi_i`
for a given value of the weathering number :math:`W`.
Args:
fig (:obj:`Matplotli... | 625941e3596a897236089ea2 |
@cli.command(short_help='upload a file to S3') <NEW_LINE> @click.option('--file', prompt='File path and name', default='./private_key.sec', type=click.Path(exists=True, readable=True, resolve_path=True), required=True, help='Path where the file is located which should be uploaded to S3.') <NEW_LINE> @click.option('--bu... | Simple file upload to a S3 bucket with server side AWS256 encryption enabled. | 625941e321bff66bcd684d35 |
def get_next(self): <NEW_LINE> <INDENT> self.current_month += 1 <NEW_LINE> if self.current_month > 12: <NEW_LINE> <INDENT> self.current_month = 1 <NEW_LINE> self.current_year += 1 <NEW_LINE> <DEDENT> return self.get_month(datetime(self.current_year, self.current_month, 1)) | Returns the next month's model. | 625941e371ff763f4b549a79 |
@activity <NEW_LINE> def lock_windows(): <NEW_LINE> <INDENT> only_supported_for("Windows") <NEW_LINE> import ctypes <NEW_LINE> ctypes.windll.user32.LockWorkStation() | Lock Windows
Locks Windows requiring login to continue.
:Example:
>>> lock_windows()
Keywords
windows, user, password, account, lock, freeze, hibernate, sleep, lockescreen
Icon
las la-user-lock | 625941e3046cf37aa974d12b |
def numberOfArithmeticSlices(self, A): <NEW_LINE> <INDENT> if len(A) < 3: <NEW_LINE> <INDENT> return 0; <NEW_LINE> <DEDENT> table = [0, 0, 0] <NEW_LINE> while len(table) <= len(A): <NEW_LINE> <INDENT> table.append(table[-1] + self.countslice(A[:len(table)])) <NEW_LINE> <DEDENT> return table[-1] | :type A: List[int]
:rtype: int | 625941e3091ae3566866733e |
def __str__(self): <NEW_LINE> <INDENT> struct_repr = ", ".join([ "covariance_matrix: " + str(self.covariance_matrix) ]) <NEW_LINE> return f"Covariance: [{struct_repr}]" | Covariance in string representation | 625941e3cc0a2c11143dd278 |
def send(self, message, use_transaction=True, callback=None, errback=None): <NEW_LINE> <INDENT> self._apply_extensions(message) <NEW_LINE> if not use_transaction: <NEW_LINE> <INDENT> return self._transport.send(message, callback, errback) <NEW_LINE> <DEDENT> return self._transaction_layer.send(message) | Apply extensions and send message to transaction layer. | 625941e34f6381625f114e22 |
def native(): <NEW_LINE> <INDENT> return _liboqs | Handle to native liboqs handler. | 625941e3287bf620b61d3e48 |
def _compute_position(self, component): <NEW_LINE> <INDENT> if self.layout_needed: <NEW_LINE> <INDENT> self.do_layout() <NEW_LINE> <DEDENT> valign, halign = self.align <NEW_LINE> if self.alternate_position: <NEW_LINE> <INDENT> x, y = self.alternate_position <NEW_LINE> if valign == "u": <NEW_LINE> <INDENT> self.outer_y ... | Given the alignment and size of the overlay, position it.
| 625941e3fb3f5b602dac3a7e |
def middle(_self=cmd): <NEW_LINE> <INDENT> r = DEFAULT_ERROR <NEW_LINE> try: <NEW_LINE> <INDENT> _self.lock(_self) <NEW_LINE> r = _cmd.set_frame(_self._COb,3,0) <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> _self.unlock(r,_self) <NEW_LINE> <DEDENT> if _self._raising(r,_self): raise pymol.CmdException <NEW_LINE> retu... | DESCRIPTION
"middle" goes to the middle of the movie.
USAGE
middle
PYMOL API
cmd.middle()
| 625941e3004d5f362079a718 |
def __len__(self): <NEW_LINE> <INDENT> if isinstance(self.ip4, IPSet): <NEW_LINE> <INDENT> return len(self.ip4.prefixes) + len(self.ip6.prefixes) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return len(self.ip4) + len(self.ip6) | IPy doesn't provide a len() for number of prefixes
but that's really what we're interested in here, so override
their semantics. | 625941e363f4b57ef00014f5 |
def set_background(self, *args): <NEW_LINE> <INDENT> self.canvas["bg"] = Color.to_hex(*args) | Sets the panel's background color to be the given color.
color -- the color to set, as a string such as "yellow" or "black"
@param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192) | 625941e33eb6a72ae02ec8ce |
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self <NEW_LINE> buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) <NEW_LINE> _x = self.header.frame_id <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <IND... | serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module | 625941e37cff6e4e81117d6c |
def replace(self, obj_id, data, verify=False): <NEW_LINE> <INDENT> assert data is None or isinstance(data, str) <NEW_LINE> self.__request("PUT", "/rest/objects/%s" % obj_id, body=data) <NEW_LINE> if verify: <NEW_LINE> <INDENT> obj = self.read(obj_id) <NEW_LINE> orig_checksum = sha1sum(data) <NEW_LINE> obj_checksum = sh... | Replace the content of the object.
:param obj_id: object ID
:param data: data to replace the object's current content with
:param verify: (optional) whether we should verify the content of the object created
:returns: the number of bytes written | 625941e3cc40096d61595d36 |
def time_to_string(self, cls, value): <NEW_LINE> <INDENT> return value.isoformat() | Returns ISO formatted dates. | 625941e3187af65679ca5507 |
def invertTree(self, root): <NEW_LINE> <INDENT> if not root: <NEW_LINE> <INDENT> return root <NEW_LINE> <DEDENT> stack = [root] <NEW_LINE> while stack: <NEW_LINE> <INDENT> node = stack.pop() <NEW_LINE> if node: <NEW_LINE> <INDENT> if node.left: <NEW_LINE> <INDENT> stack.append(node.left) <NEW_LINE> <DEDENT> if node.rig... | :type root: TreeNode
:rtype: TreeNode | 625941e360cbc95b062c692a |
def main(): <NEW_LINE> <INDENT> if len(sys.argv) < 2: <NEW_LINE> <INDENT> sys.exit('Usage: ' + sys.argv[0] + ' [Accounting files]') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> joblist = sys.argv[1:] <NEW_LINE> <DEDENT> corehours = np.zeros(1000) <NEW_LINE> jobs = jobstats.alljobs(joblist) <NEW_LINE> for job in jobs:... | Main routine: Print User stats | 625941e329b78933be1e5a8e |
def OnColumnReordered(self,*args): <NEW_LINE> <INDENT> pass | OnColumnReordered(self: DataGrid,e: DataGridColumnEventArgs)
Raises the System.Windows.Controls.DataGrid.ColumnReordered event.
e: The data for the event. | 625941e38e71fb1e9831db8f |
def get_token_for_org(org: str) -> Optional[str]: <NEW_LINE> <INDENT> creds = load_creds() <NEW_LINE> return creds.get(org) | Return the token for a given org. None if a token isn't found for that org | 625941e3377c676e9127258e |
def test_find_users_by_days_user_with_multiple_certs_1_lab(self): <NEW_LINE> <INDENT> db = CertTrackerDatabase(USER, PASSWORD, HOST, PORT, DATABASE) <NEW_LINE> users = db.get_users() <NEW_LINE> date = datetime(2019,6,3) <NEW_LINE> lab_users, pis = find_users_by_days(users,date.date()) <NEW_LINE> self.assertEqual(len(la... | Testing 1 user with 2 expired certifications in 1 lab | 625941e3a79ad161976cc52c |
def __scheduleNextJob(self): <NEW_LINE> <INDENT> msg = "Internal error" <NEW_LINE> assert len(self.__currAvailableGPUs) > 0, self.__logger.pCritial(msg) <NEW_LINE> gpu = self.__currAvailableGPUs.pop() <NEW_LINE> job = self.__toScheduleJobs.pop() <NEW_LINE> job.openFiles() <NEW_LINE> assert job.jobid is not None, 'No jo... | Moves a job from the __toScheduleJobs queue to the __runningJobs queue
after consuming one gpu device. | 625941e3adb09d7d5db6cb74 |
def _setUpProperties (self, params_dict): <NEW_LINE> <INDENT> self._sep = u'.' <NEW_LINE> for key, val in params_dict.iteritems(): <NEW_LINE> <INDENT> if key.endswith (self._sep): <NEW_LINE> <INDENT> key = key[:-1] <NEW_LINE> <DEDENT> self._setObjectProperties (self.graph, key, val) | Set-up properties of the inner objects | 625941e37d43ff24873a308a |
def format_month_day(time): <NEW_LINE> <INDENT> month = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ][time.month - 1] <NEW_LINE> day = str(time.day) <NEW_LINE> return month + " :n:" + day | Formats a date into a string representing the month and day of the date
that can be included in a sentence. For example,
time_format_month_day(datetime(month=3, day=14)) would
return "march :n:14". | 625941e3656771135c3ebc5a |
def test_forward_unique_with_counts(): <NEW_LINE> <INDENT> for dtype in ["int32", "int64"]: <NEW_LINE> <INDENT> for is_dyn in [False, True]: <NEW_LINE> <INDENT> _test_unique_with_counts(10, dtype, is_dyn) <NEW_LINE> _test_unique_with_counts(20, dtype, is_dyn) | test UniqueWithCounts | 625941e33317a56b8693a036 |
def __init__(self, api_key, response_format='json'): <NEW_LINE> <INDENT> if not api_key: <NEW_LINE> <INDENT> raise ValueError('API key must be specified.') <NEW_LINE> <DEDENT> if response_format.lower() not in self._SUPPORTED_FORMATS: <NEW_LINE> <INDENT> raise ValueError( 'Unknown response format: {}'.format(response_f... | :param api_key - The API key to identify ourselves
:param response_format - specify preferred format of the response,
default is 'json' | 625941e3099cdd3c635f1040 |
@httprettified <NEW_LINE> def test_httpretty_should_normalize_url_patching(): <NEW_LINE> <INDENT> HTTPretty.register_uri( HTTPretty.GET, "http://yipit.com/foo(bar)", body="Find the best daily deals") <NEW_LINE> response = requests.get('http://yipit.com/foo%28bar%29') <NEW_LINE> expect(response.text).to.equal('Find the ... | HTTPretty should normalize all url patching | 625941e37cff6e4e81117d6d |
def test_ColonyHW_Growth_Low(self): <NEW_LINE> <INDENT> planet = self.planetOne <NEW_LINE> colony = self.player.colonies[self.SO_ID] <NEW_LINE> assert_true(colony.population == self.population) <NEW_LINE> colony.populationGrowth() <NEW_LINE> assert_true(colony.population > self.population) <NEW_LINE> habVal = colony.pl... | _Low tests growth for a planet with pop below the 25'%' point
| 625941e33d592f4c4ed1d44a |
def delete_vault(vault_name): <NEW_LINE> <INDENT> glacier = boto3.client('glacier') <NEW_LINE> try: <NEW_LINE> <INDENT> response = glacier.delete_vault(vaultName=vault_name) <NEW_LINE> <DEDENT> except ClientError as e: <NEW_LINE> <INDENT> logging.error(e) <NEW_LINE> return False <NEW_LINE> <DEDENT> return True | Delete an Amazon S3Glacier vault
:param vault_name: string
:return: True if vault was deleted, otherwise False | 625941e326238365f5f0f25b |
def Is_Associate(x,y): <NEW_LINE> <INDENT> e=Gaussian_Integer(0,1) <NEW_LINE> a=(x==y) <NEW_LINE> b=(x==-y) <NEW_LINE> c=(x==y*e) <NEW_LINE> d=(x==y*(-e)) <NEW_LINE> return a|b|c|d | x,yは同伴?
x,y:Gauss整数 | 625941e32eb69b55b151cc9c |
def _get_templates(self): <NEW_LINE> <INDENT> template_path = os.path.join(BASE_DIR, self.paths['template']) <NEW_LINE> template_env = Environment(loader=FileSystemLoader(template_path)) <NEW_LINE> templates = {} <NEW_LINE> for k, v in settings['TEMPLATES'].items(): <NEW_LINE> <INDENT> templates[k] = template_env.get_t... | Get templates from template files. | 625941e37d847024c06be6a7 |
def __init__(self, partido, config={}): <NEW_LINE> <INDENT> self.config = default_settings.copy() <NEW_LINE> self.config.update(config) <NEW_LINE> self.partido = partido <NEW_LINE> try: <NEW_LINE> <INDENT> self.cargarCallejero() <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> raise e | Carga el callejero | 625941e3a17c0f6771cbe437 |
def load(self, obj_list): <NEW_LINE> <INDENT> self._nodes = obj_list | Populate this object using the supplied list of nodes | 625941e3442bda511e8be7fa |
def read(self, fields=None): <NEW_LINE> <INDENT> print(" - reading", self.fpath) <NEW_LINE> if fields is None: <NEW_LINE> <INDENT> fields = self.fields <NEW_LINE> positions = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> missing_fields = set(name for name, _ in fields) - set(self.fi... | imports one Xsv file with all columns
* columns can be in any order (they will be reordered if needed)
* row order is preserved | 625941e3462c4b4f79d1dab7 |
def p_import_list_1(self, t): <NEW_LINE> <INDENT> t[0] = [t[1]] | import_list : import_statement | 625941e34d74a7450ccd45ac |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.