code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def selector(self): <NEW_LINE> <INDENT> print("1. login ","2. new user\n") <NEW_LINE> selector_call = str(input()) <NEW_LINE> if selector_call == "new user": <NEW_LINE> <INDENT> userdata.create_user() <NEW_LINE> <DEDENT> elif selector_call == "login": <NEW_LINE> <INDENT> controllers.login() <NEW_LINE> <DEDENT> else: <N... | function that controls the flow of the application | 625941c821bff66bcd6849cb |
def mostLikes(name,prefs, udict): <NEW_LINE> <INDENT> most = 0 <NEW_LINE> mname = '' <NEW_LINE> for user in udict: <NEW_LINE> <INDENT> if str(user)[-1] != '?': <NEW_LINE> <INDENT> if len(udict[user]) > most: <NEW_LINE> <INDENT> most = len(udict[user]) <NEW_LINE> mname = str(user) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> i... | prints out the user name with the most likes (artists) | 625941c891af0d3eaac9ba8f |
def wlstsq(X,y,w): <NEW_LINE> <INDENT> assert np.ndim(X) == 2 and np.ndim(w) == 1 <NEW_LINE> assert len(X) == len(y) and len(X) == len(w) <NEW_LINE> X = X * np.reshape(w, (-1,1)) <NEW_LINE> if np.ndim(y) == 1: y = y * w <NEW_LINE> else: y = y * np.reshape(w, (-1,1)) <NEW_LINE> fit,resid = la.lstsq(X,y)[:2... | weighted least squares regression | 625941c8009cb60464c63429 |
@APP.route('/sentinel/processing/<scene>/<int:z>/<int:x>/<int:y>.<ext>', methods=['GET'], cors=True) <NEW_LINE> def ratio(scene, tile_z, tile_x, tile_y, tileformat): <NEW_LINE> <INDENT> if tileformat == 'jpg': <NEW_LINE> <INDENT> tileformat = 'jpeg' <NEW_LINE> <DEDENT> query_args = APP.current_request.query_params <NEW... | Handle processing requests
| 625941c85fcc89381b1e1735 |
@subcommand("devpi.list_remove:main_list", "list") <NEW_LINE> def list_(parser): <NEW_LINE> <INDENT> parser.add_argument("-f", "--failures", action="store_true", dest="failures", help="show test setup/failure logs (implies -t)") <NEW_LINE> parser.add_argument("--all", action="store_true", help="show all versions instea... | list project versions and files for the current index.
Without a spec argument this command will show the names
of all projects which have releases on the current index.
You can use a pip/setuptools style spec argument to show files
for particular versions of a project.
RED files come from an an inherited version whic... | 625941c8bd1bec0571d906a6 |
def Run(self): <NEW_LINE> <INDENT> _res = self.ShowModal() <NEW_LINE> if _res == wx.ID_OK: <NEW_LINE> <INDENT> self.secondButtonFun() <NEW_LINE> <DEDENT> elif _res == wx.ID_CANCEL: <NEW_LINE> <INDENT> self.firstButtonFun() | 显示 | 625941c897e22403b379d010 |
def add_fc(net, bottom, name, param_name, nout, lr_factor=1, std=0.01): <NEW_LINE> <INDENT> param = [{'name': param_name['weights'], 'lr_mult': lr_factor, 'decay_mult': 1}, {'name': param_name['bias'], 'lr_mult': 2*lr_factor, 'decay_mult': 0}] <NEW_LINE> weight_filler, bias_filler = get_init_params(std) <NEW_LINE> net[... | Add a fully-connected layer | 625941c8796e427e537b063c |
def close_to_init_no_debug(rwdobj: DetailsForReward): <NEW_LINE> <INDENT> ir = angular_similarity(rwdobj.current_joint_position, rwdobj.init_joint_pos) <NEW_LINE> grip_strength = np.round(np.sum(np.abs(rwdobj.tactile_state[-1])), 2) <NEW_LINE> obj_fell = (grip_strength < (0.004 * rwdobj.action_space)) <NEW_LINE> if obj... | stay close to current joint position, policy may cheats, because the object fell definition only relies on tactile information. | 625941c8d164cc6175782dc4 |
def dictOrListToCSV(filename, data, delimiter=';', quotechar='"', quoting=csv.QUOTE_NONNUMERIC, folder="./output/"): <NEW_LINE> <INDENT> folder = enhanceDir(folder) <NEW_LINE> if not isinstance(data, list): <NEW_LINE> <INDENT> data = dictOfListToListOfDict(data) <NEW_LINE> <DEDENT> with open(folder + filename + '.csv',... | With these default params, all texts will be quoted. The delimiter is a ';'.
If there are delimiters in a text, it will be escaped by using 2 double-quotes ('""').
For example in calc, just set ';' as the column delimiter and '"' as the text delimiter. | 625941c8462c4b4f79d1d748 |
def bubble_sort(alist): <NEW_LINE> <INDENT> n = len(alist) <NEW_LINE> for j in range(n-1): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> for i in range(0, n-1-j): <NEW_LINE> <INDENT> if alist[i] > alist[i+1]: <NEW_LINE> <INDENT> alist[i],alist[i+1] = alist[i+1], alist[i] <NEW_LINE> count += 1 <NEW_LINE> <DEDENT> <DEDENT> if... | 冒泡排序 | 625941c8627d3e7fe0d68ec6 |
def message_subscribers(self, *args, **kwargs): <NEW_LINE> <INDENT> return _blocks_swig2.bin_statistics_f_sptr_message_subscribers(self, *args, **kwargs) | message_subscribers(bin_statistics_f_sptr self, swig_int_ptr which_port) -> swig_int_ptr | 625941c899cbb53fe6792c5e |
def test_parse_G_all_with_whitespace(self): <NEW_LINE> <INDENT> self._test_parse_line( source=" N1 G28 X YZ *123 ; Comment \n", leadingWhitespace=" ", text="N1 G28 X YZ ", trailingWhitespace=" ", lineNumber=1, type="G", code=28, parameters="X YZ", parameterDict=OrderedDict([ ("X", None), ("Y", None), ("Z",... | Test parsing a Gcode general command with all components. | 625941c8c432627299f04cbc |
def sort(self, inplace=True, ascending=True, na_position='last'): <NEW_LINE> <INDENT> warn("sort is deprecated, use sort_values(...)", FutureWarning, stacklevel=2) <NEW_LINE> return self.sort_values(inplace=inplace, ascending=ascending, na_position=na_position) | DEPRECATED: use :meth:`Categorical.sort_values`. That function
is just like this one, except that a new Categorical is returned
by default, so make sure to pass in 'inplace=True' to get
inplace sorting.
See Also
--------
Categorical.sort_values | 625941c810dbd63aa1bd2c1b |
def taglist_to_dict(tags, fields, strip_lf=True): <NEW_LINE> <INDENT> has_text = TEXT_FIELD in fields <NEW_LINE> has_tag = TAG_FIELD in fields <NEW_LINE> finfields = fields.copy() <NEW_LINE> data = [] <NEW_LINE> if has_text: finfields.remove(TEXT_FIELD) <NEW_LINE> if has_tag: finfields.remove(TAG_FIELD) <NEW_LINE> for ... | Converts list of tags into dict | 625941c8dc8b845886cb55ac |
def insert_df2mysql(df,table=''): <NEW_LINE> <INDENT> conn = pymysql.connect(host=host,port=port,user=user,passwd=passwd,db=db) <NEW_LINE> cursor = conn.cursor() <NEW_LINE> col_name = list(df.columns) <NEW_LINE> col_name.extend(['create_date']) <NEW_LINE> date = time.strftime('%Y-%m-%d') <NEW_LINE> keys = str(tuple(col... | :param df:DataFrame with columns'name
:param table: str,table_name of your databases(default:'stock_market')
This will be collected into a class (mysql_insert) in the future | 625941c8f8510a7c17cf9773 |
def duck_TriggerType(uco_document, is_enabled=Missing(), trigger_begin_time=Missing(), trigger_delay=Missing(), trigger_end_time=Missing(), trigger_max_run_time=Missing(), trigger_session_change_type=Missing(), **kwargs): <NEW_LINE> <INDENT> if not isinstance(is_enabled, Missing): <NEW_LINE> <INDENT> assert isinstance(... | :param IsEnabled: At most one value of type Bool.
:param TriggerBeginTime: At most one value of type Datetime.
:param TriggerDelay: At most one value of type String.
:param TriggerEndTime: At most one value of type Datetime.
:param TriggerMaxRunTime: At most one value of type String.
:param TriggerSessionChangeType: At... | 625941c8d486a94d0b98e1bd |
def show_dialog(self): <NEW_LINE> <INDENT> self._log_location() <NEW_LINE> self.interface_action_base_plugin.do_user_config() | Show the configuration dialog | 625941c8091ae35668666fd7 |
def wrapped(function, *args, **kwargs): <NEW_LINE> <INDENT> supplied_args = _get_supplied_args(signature_params, args, kwargs) <NEW_LINE> clashes = [ argument for argument in supplied_args if argument in exclusive_params ] <NEW_LINE> if len(clashes) > 1: <NEW_LINE> <INDENT> raise InvalidParameterError( 'These parameter... | The wrapped function (whose docstring will get replaced). | 625941c88e05c05ec3eea3eb |
def list_by_resource_group( self, resource_group_name: str, **kwargs ) -> AsyncIterable["_models.ManagedClusterListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwarg... | Gets the list of Service Fabric cluster resources created in the specified resource group.
Gets all Service Fabric cluster resources created or in the process of being created in the
resource group.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A cus... | 625941c885dfad0860c3aed2 |
def calculate_T1map_pyrd(ir_img, inversiontime): <NEW_LINE> <INDENT> if inversiontime[-1] == 0: <NEW_LINE> <INDENT> inversiontime = inversiontime[0:-1] <NEW_LINE> <DEDENT> if ir_img.shape[2] > inversiontime.shape[0]: <NEW_LINE> <INDENT> ir_img = ir_img[:,:,0:ir_img.shape[2]-1] <NEW_LINE> <DEDENT> extra = {} <NEW_LINE> ... | implementation of Barral's method | 625941c8eab8aa0e5d26dbcf |
def reload_messages(self): <NEW_LINE> <INDENT> def do_reload(messages): <NEW_LINE> <INDENT> step = 1 <NEW_LINE> count = len(messages) <NEW_LINE> for msgid, translation, source in messages: <NEW_LINE> <INDENT> if self.loading_cancel: <NEW_LINE> <INDENT> yield False <NEW_LINE> <DEDENT> message = MessageInfo(msgid.replace... | Load messages from the database memory | 625941c8c432627299f04cbd |
def getmtime(filename): <NEW_LINE> <INDENT> return os.stat(filename)[ST_MTIME] | Return the last modification time of a file, reported by os.stat(). | 625941c8099cdd3c635f0cd3 |
def parse_url(url): <NEW_LINE> <INDENT> if url: <NEW_LINE> <INDENT> url = url.split("://", 1)[-1] <NEW_LINE> provider, rest = url.split("/", 1) <NEW_LINE> if provider == "sourceforge.net": <NEW_LINE> <INDENT> return provider, rest.rsplit("/", 1)[-1] <NEW_LINE> <DEDENT> return provider, rest <NEW_LINE> <DEDENT> return N... | Return provider and project id
>>> parse_url("github.com/user/repo")
('github.com', 'user/repo')
>>> parse_url("bitbucket.org/user/repo")
('bitbucket.org', 'user/repo')
>>> parse_url("gitlab.com/user/repo")
('gitlab.com', 'user/repo')
>>> parse_url("A quick brown fox jumps over the lazy dog")
(None, None)
>>> parse_url... | 625941c832920d7e50b28247 |
def load_sequencing_run(seq_run): <NEW_LINE> <INDENT> seq_runs = load_sequencing_runs() <NEW_LINE> seq_run_obj = SequencingRun(seq_runs.loc[seq_run]) <NEW_LINE> return seq_run_obj | Load a single sequencing run (with extended attributes) | 625941c83d592f4c4ed1d0e7 |
def make_remaining_time(self): <NEW_LINE> <INDENT> time_sg = 30 <NEW_LINE> mas10min = self.dateTimeReserved + timedelta(seconds=time_sg) <NEW_LINE> return mas10min | Metodo que permite crear el tiempo limite para start moto desde la reserva | 625941c8796e427e537b063d |
def make_search_query(help): <NEW_LINE> <INDENT> def query_decorator(query_func): <NEW_LINE> <INDENT> def query_wrap(corpus, dict, categories): <NEW_LINE> <INDENT> def query(*args, **kwargs): <NEW_LINE> <INDENT> return query_func(corpus, dict, categories, *args, **kwargs) <NEW_LINE> <DEDENT> return query <NEW_LINE> <DE... | Given a function query_func: (corpus, dict, args...) -> (content) -> value,
wraps it so it can be used in a query string. | 625941c863b5f9789fde715d |
def normal_sell(sell,symbol_code,volum_filter,soll_count,preis_differenz,durchschnit_preis,risikoClasse,order_art): <NEW_LINE> <INDENT> if sell=="1": <NEW_LINE> <INDENT> soll_count2 = soll_count*-1 <NEW_LINE> mein_order_preis = client.get_orderbook_best_preis(symbol_code,"ask",volum_filter,preis_differenz) <NEW_LINE> i... | verkaufsignal 00stk 2% ist null | 625941c83c8af77a43ae3817 |
def filter_dictionary(dictionary, field_list): <NEW_LINE> <INDENT> return_dictionary = {} <NEW_LINE> for item in dictionary: <NEW_LINE> <INDENT> if item in field_list: <NEW_LINE> <INDENT> return_dictionary[item] = dictionary[item] <NEW_LINE> <DEDENT> <DEDENT> return return_dictionary | Takes dictionary and list of elements and returns dictionary with just
elements specified. Also decodes the items to unicode
:param dictionary: the dictionary to filter
:param field_list: list containing keys to keep
:return: dictionary with just keys from list. All values decoded | 625941c8377c676e91272221 |
def test_createmd(self): <NEW_LINE> <INDENT> mock_cmd = MagicMock(return_value=True) <NEW_LINE> with patch.dict(drbd.__salt__, {'cmd.retcode': mock_cmd}): <NEW_LINE> <INDENT> assert drbd.createmd() <NEW_LINE> mock_cmd.assert_called_once_with('drbdadm create-md all --force') | Test if createmd function work well | 625941c8f7d966606f6aa07b |
def run(self): <NEW_LINE> <INDENT> logging.warning("%s[%s] start...", self.__class__.__name__, self.getName()) <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not self.working(): <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> except queue.Empty: <NEW_LINE> <INDENT> if self._pool.is_all_ta... | rewrite run function, auto running and must call self.work() | 625941c84428ac0f6e5ba86a |
def testJIDFullNoUserNoResource(self): <NEW_LINE> <INDENT> j = JID('user@domain/resource') <NEW_LINE> j.full = 'otherdomain' <NEW_LINE> self.check_jid(j, '', 'otherdomain', '', 'otherdomain', 'otherdomain', 'otherdomain') | Test setting the full JID without a user
portion and without a resource. | 625941c85510c4643540f45e |
def is_price_reached(share, price): <NEW_LINE> <INDENT> max = share.High.max() <NEW_LINE> if price <= max: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Checks if a specific share reached the priced | 625941c838b623060ff0ae65 |
def area(self): <NEW_LINE> <INDENT> return self.__size ** 2 | Returns the current square area of the instance
Returns:
int: Value of 'size' | 625941c891f36d47f21ac56a |
def get(self, request, pk): <NEW_LINE> <INDENT> job = self.get_queryset() <NEW_LINE> serializer = JobSerializer(job, many=True) <NEW_LINE> return Response(serializer.data) | Return list of Job objects for given table. | 625941c829b78933be1e5725 |
def fc_infer(self, fact, rule, kb): <NEW_LINE> <INDENT> bindings = match(fact.statement,rule.lhs[0]) <NEW_LINE> if bindings: <NEW_LINE> <INDENT> if len(rule.lhs)>1: <NEW_LINE> <INDENT> new_rule_lhs = [instantiate(remaining_facts,bindings) for remaining_facts in rule.lhs[1:]] <NEW_LINE> new_rule_rhs = instantiate(rule.r... | Forward-chaining to infer new facts and rules
Args:
fact (Fact) - A fact from the KnowledgeBase
rule (Rule) - A rule from the KnowledgeBase
kb (KnowledgeBase) - A KnowledgeBase
Returns:
Nothing | 625941c81b99ca400220ab29 |
def registerObject(self, name, object): <NEW_LINE> <INDENT> if name in self.__objectRegistry: <NEW_LINE> <INDENT> raise KeyError('Object "{0}" already registered.'.format(name)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.__objectRegistry[name] = object | Public method to register an object in the object registry.
@param name name of the object (string)
@param object reference to the object
@exception KeyError raised when the given name is already in use | 625941c81f037a2d8b946276 |
def perform_create(self, serializer): <NEW_LINE> <INDENT> serializer.save(user_profile = self.request.user) | Sets the user profile to the user logged in user | 625941c83d592f4c4ed1d0e8 |
def sign_figs(x, n=0): <NEW_LINE> <INDENT> if _USE_SIGN_FIGS: <NEW_LINE> <INDENT> if type(x) == float or type(x) == int: <NEW_LINE> <INDENT> if x == 0.: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> exponent = np.ceil(np.log10(x)) <NEW_LINE> return 10**exponent * my_round(x / 10**exponent, ... | Round x to n significant figures (not decimal points).
This function is needed because the rounding specified in the CIE
recommendation is different from the standard rounding scheme in python
(which is following the IEEE recommendation). Uses my_round (above).
Args:
:x:
| int, float or ndarray
| N... | 625941c80fa83653e4657034 |
@users_blueprint.route('/api/v0/authenticate', methods=['POST']) <NEW_LINE> def authenticate_user(): <NEW_LINE> <INDENT> if request.headers['content-type'] == 'application/json': <NEW_LINE> <INDENT> print(request) <NEW_LINE> data = request.get_json() <NEW_LINE> if data: <NEW_LINE> <INDENT> username = data['username'] <... | API endpoint for authenticating a new user
:return: status code 400 BAD REQUEST - missing application/json header
:return: status code 400 BAD REQUEST - missing username or password
:return: status code 403 FORBIDDEN - user not authenticated
:return: status code 201 CREATED - successful submission | 625941c84a966d76dd551087 |
def clean_variable_name(name): <NEW_LINE> <INDENT> return re.sub(r'\W|^(?=\d)', '_', name) | Converts a string into a valid Python variable name | 625941c8d10714528d5ffd5a |
def CommonValidateOptions(self, opt, args): <NEW_LINE> <INDENT> opt.quiet = opt.output_mode is False <NEW_LINE> opt.verbose = opt.output_mode is True | Validate common options. | 625941c810dbd63aa1bd2c1c |
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None): <NEW_LINE> <INDENT> if extra_args is None: extra_args = [ None for _ in range(num_nodes) ] <NEW_LINE> if binary is None: binary = [ None for _ in range(num_nodes) ] <NEW_LINE> rpcs = [] <NEW_LINE> try: <NEW_LINE> <INDENT> fo... | Start multiple vpubds, return RPC connections to them | 625941c8adb09d7d5db6c808 |
def getLabel(self): <NEW_LINE> <INDENT> return self._labelTexture.text | The label displayed in the label field. | 625941c83c8af77a43ae3818 |
def __init__(self,ni,nh,no): <NEW_LINE> <INDENT> self.ni=ni+1 <NEW_LINE> self.nh=nh <NEW_LINE> self.no=no <NEW_LINE> '''activate all points (vector)''' <NEW_LINE> self.ai=[1.0]*self.ni <NEW_LINE> self.ah=[1.0]*self.nh <NEW_LINE> self.ao=[1.0]*self.no <NEW_LINE> self.wi=makeMatrix(self.ni,self.nh) <NEW_LINE> self.wo=mak... | ni represents points of input level | 625941c8aad79263cf390ab8 |
def markByData(self, colName, itemData): <NEW_LINE> <INDENT> col = self._getColPos(colName) <NEW_LINE> if col is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for row in range(self.rowCount()): <NEW_LINE> <INDENT> if self[row, col] == itemData: <NEW_LINE> <INDENT> item = self.item(row, col) <NEW_LINE> self._mark... | @colName: 指定item所在的列名
@itemData: item的数据 | 625941c896565a6dacc8f744 |
def __array_finalize__(self, obj): <NEW_LINE> <INDENT> super(SpikeTrain, self).__array_finalize__(obj) <NEW_LINE> if obj is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.t_start = getattr(obj, 't_start', None) <NEW_LINE> self.t_stop = getattr(obj, 't_stop', None) <NEW_LINE> self.waveforms = getattr(obj, 'wa... | This is called every time a new :class:`SpikeTrain` is created.
It is the appropriate place to set default values for attributes
for :class:`SpikeTrain` constructed by slicing or viewing.
User-specified values are only relevant for construction from
constructor, and these are set in __new__. Then they are just
copied... | 625941c816aa5153ce3624f1 |
def log(space, w_x, w_base=None): <NEW_LINE> <INDENT> if w_base is None: <NEW_LINE> <INDENT> base = 0.0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> base = _get_double(space, w_base) <NEW_LINE> if base <= 0.0: <NEW_LINE> <INDENT> return math1(space, math.log, w_base) <NEW_LINE> <DEDENT> <DEDENT> return _log_any(space,... | log(x[, base]) -> the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x. | 625941c855399d3f0558872c |
def get_revision_weights(self, service_name): <NEW_LINE> <INDENT> service = self.get_service(service_name) <NEW_LINE> if not service: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> return {k: int(v) for k, v in service.items() if len(k) == REV_LENGTH and v >= 0} | Load revision weights for a particular service.
:param service_name Service name. | 625941c83539df3088e2e3c3 |
def display_table(results: Dict) -> None: <NEW_LINE> <INDENT> for title, sect in results["sections"].items(): <NEW_LINE> <INDENT> fields = sect["fields"] <NEW_LINE> t = PrettyTable(fields) <NEW_LINE> t.title = title <NEW_LINE> for row in sect["rows"]: <NEW_LINE> <INDENT> r = [row[field]["text"] for field in sect["field... | Display results in nice neat tables
:param results: Results from extraction
:return: None | 625941c8fb3f5b602dac370b |
def play_round(self, current_game_time): <NEW_LINE> <INDENT> for i, bot in enumerate(self.universe.bots): <NEW_LINE> <INDENT> player_team = self.player_teams[bot.team_index] <NEW_LINE> try: <NEW_LINE> <INDENT> universe_copy = self.universe.copy() <NEW_LINE> if self.noiser: <NEW_LINE> <INDENT> universe_copy = self.noise... | Play only a single round.
A single round is defined as all bots moving once.
Parameters
----------
current_game_time : int
the number of this round | 625941c83317a56b86939cd3 |
def test_tasks_treeView_tasks_are_sorted(self): <NEW_LINE> <INDENT> item_model = self.dialog.tasks_treeView.model() <NEW_LINE> selection_model = self.dialog.tasks_treeView.selectionModel() <NEW_LINE> index = item_model.index(0, 0) <NEW_LINE> project1_item = item_model.itemFromIndex(index) <NEW_LINE> self.dialog.tasks_t... | testing if tasks in tasks_treeView are sorted according to their
names | 625941c8d268445f265b4ee6 |
def create(self, src, dst, offsets, pdd): <NEW_LINE> <INDENT> if src and dst: <NEW_LINE> <INDENT> sdt = offsets[0] <NEW_LINE> itd_cst = offsets[1] <NEW_LINE> if not self.solve(src, dst, sdt, pdd, itd_cst=itd_cst): <NEW_LINE> <INDENT> self.solve(src, dst, sdt, pdd, mode=1, itd_cst=itd_cst) | Create (sub)graph. RCSP attempted with fallback to STSP | 625941c87cff6e4e811179fe |
def reset_materials(self): <NEW_LINE> <INDENT> self.materials.reset() | Clear material data so that next materials.time_update() is
performed even for stationary materials. | 625941c8925a0f43d2549eef |
def query_dev_id_path_by_sdx_path(self, sdx_path): <NEW_LINE> <INDENT> for disk_by_id in os.listdir(CommonVariables.disk_by_id_root): <NEW_LINE> <INDENT> disk_by_id_path = os.path.join(CommonVariables.disk_by_id_root, disk_by_id) <NEW_LINE> if os.path.realpath(disk_by_id_path) == sdx_path: <NEW_LINE> <INDENT> return di... | return /dev/disk/by-id that maps to the sdx_path, otherwise return the original path | 625941c8a17c0f6771cbe0ca |
def __init__(self, firstName, lastName, user_password ) : <NEW_LINE> <INDENT> self.firstName = firstName <NEW_LINE> self.lastName = lastName <NEW_LINE> self.user_password = user_password | __init__ method that help us create properties of the object
Args :
firstName :new user firstName .
lastName : new user lastName .
user_password : new user_password . | 625941c9442bda511e8be492 |
def check_rows_on_node(self, node_to_check, rows, found=None, missings=None, restart=True): <NEW_LINE> <INDENT> if found is None: <NEW_LINE> <INDENT> found = [] <NEW_LINE> <DEDENT> if missings is None: <NEW_LINE> <INDENT> missings = [] <NEW_LINE> <DEDENT> stopped_nodes = [] <NEW_LINE> for node in self.cluster.nodes.val... | Function to verify the rows on a given node, without interference
from the other nodes in the cluster
@param node_to_check The given node to check. Should be the node, not the index
@param rows The number of rows we expect
@param found A list of partition keys that we expect to be on the node
@param missings A list of ... | 625941c8bde94217f3682e6a |
def delete(self, timestamp): <NEW_LINE> <INDENT> fp, md = self._filesystem.get_object(self._name) <NEW_LINE> if md['X-Timestamp'] < Timestamp(timestamp): <NEW_LINE> <INDENT> self._filesystem.del_object(self._name) | Perform a delete for the given object in the given container under the
given account.
This creates a tombstone file with the given timestamp, and removes
any older versions of the object file. Any file that has an older
timestamp than timestamp will be deleted.
:param timestamp: timestamp to compare with each file | 625941c815fb5d323cde0b87 |
def get_ds_config_for_storage(self, params=None): <NEW_LINE> <INDENT> ds_config = { CONFIG_FIELDS.COUNT: params.get(CONFIG_FIELDS.COUNT), CONFIG_FIELDS.SEARCH: params.get(CONFIG_FIELDS.SEARCH) } <NEW_LINE> return ds_config | :param params: dict, required to generate ds_config dict object for storage
:return: newly created ds_config. The value obtained in params is
a dictionary that should contain following keys: | 625941c857b8e32f52483513 |
def test_callback(msg): <NEW_LINE> <INDENT> self.assertEqual(msg.__class__.__name__, 'N_SET_RQ') | Callback | 625941c9f7d966606f6aa07c |
def __str__(self): <NEW_LINE> <INDENT> return json.dumps(self._to_dict(), indent=2) | Return a `str` version of this MessageContextSkills object. | 625941c9d10714528d5ffd5b |
def __init__(self, parser): <NEW_LINE> <INDENT> self.parser = parser <NEW_LINE> log.info(self.__class__.__name__ + " initialized") <NEW_LINE> try: <NEW_LINE> <INDENT> st = parser.options.string <NEW_LINE> now = datetime.datetime.now() <NEW_LINE> then = now + datetime.timedelta(2, 60) <NEW_LINE> difference = calc_workin... | Constructor | 625941c9b545ff76a8913e8f |
def insert_user(self, account: str, password: str, name: str) -> bool: <NEW_LINE> <INDENT> if self.find_user(account) is not None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> self.user_table.insert_one({ 'account': account, 'password': password, 'name': name }) <NEW_LINE> return True | 向user表插入一个用户数据
:return 成功返回True,失败返回False | 625941c97d43ff24873a2d19 |
def instance_type_extra_specs_get_item(context, flavor_id, key): <NEW_LINE> <INDENT> return IMPL.instance_type_extra_specs_get_item(context, flavor_id, key) | Get extra specs by key and flavor_id. | 625941c9b7558d58953c4f8e |
def check_pigs_bottom(ai_settings, stats, screen, sb, bird, pigs, bullets, super_bullets): <NEW_LINE> <INDENT> screen_rect = screen.get_rect() <NEW_LINE> for pig in pigs.sprites(): <NEW_LINE> <INDENT> if pig.rect.left <= screen_rect.left: <NEW_LINE> <INDENT> bird_hit(ai_settings, stats, screen, sb, bird, pigs, bullets,... | 检查是否有猪到达屏幕底端
:param ai_settings: 游戏设置
:param stats: 游戏统计信息对象
:param screen: 屏幕对象
:param sb: 记分牌对象
:param bird: 小鸟对象
:param pigs: 猪编组
:param bullets: 子弹编组
:param super_bullets: 导弹编组 | 625941c950812a4eaa59c39b |
def sigleton(func): <NEW_LINE> <INDENT> _instance={} <NEW_LINE> def wrapper(*args,**kwargs): <NEW_LINE> <INDENT> if func not in _instance: <NEW_LINE> <INDENT> _instance[func] = func(*args,**kwargs) <NEW_LINE> <DEDENT> <DEDENT> return wrapper | 单例模式 | 625941c907f4c71912b114fa |
def get_viewer(self): <NEW_LINE> <INDENT> return self._viewer | Retruns the Viewer object. | 625941c99c8ee82313fbb7ed |
def genKeySalt(): <NEW_LINE> <INDENT> return genSalt(SALT_KEY_LEN) | Generates secret key salt, implements genSalt(SALT_KEY_LEN). | 625941c95166f23b2e1a51d2 |
def TMO_Instance_Urgency_01(self): <NEW_LINE> <INDENT> return QUrl() | static QUrl Nepomuk.Vocabulary.TMO.TMO_Instance_Urgency_01() | 625941c9cc0a2c11143dcf09 |
def get_authority(self): <NEW_LINE> <INDENT> return | Gets the authority of this ``Id``.
The authority is a string used to ensure the uniqueness of this
``Id`` when using a non- federated identifier space. Generally,
it is a service name identifying the provider of this ``Id``.
This method is used to compare one ``Id`` to another.
:return: the authority of this ``Id``
:... | 625941c9004d5f362079a3ac |
def get_word_signature(str): <NEW_LINE> <INDENT> return ''.join(sorted(str)) | Calculate signature of annagram as sorted string
:param str: str - source str
:return: str signature of string | 625941c926068e7796caed56 |
@stac_bp.route('/list') <NEW_LINE> def render_list(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> api_key = flask.request.args.get('api_key', None) <NEW_LINE> return flask.render_template('list.html', **{ 'search_url': flask.url_for( 'stac.search', api_key=api_key, _external=True), 'fetch_url': flask.url_for( 'stac.fe... | Render a listing webpage. | 625941c97047854f462a1484 |
def __init__(self, ext="ALL"): <NEW_LINE> <INDENT> if ext !="ALL": <NEW_LINE> <INDENT> self.target_ext = [ ext ] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.target_ext = [".csv",".tsv",".xls",".xlsx",".json"] <NEW_LINE> <DEDENT> return | コンストラクタ
(読み込み対象とする拡張子を引数extで指定可能) | 625941c9bf627c535bc13247 |
def bytes2size(b, how): <NEW_LINE> <INDENT> pr = 4 <NEW_LINE> if how == 'kibi': <NEW_LINE> <INDENT> if b < 2**10: <NEW_LINE> <INDENT> return '%d bytes' % (b) <NEW_LINE> <DEDENT> elif b < 2**20: <NEW_LINE> <INDENT> if not b % 2**10: pr = 0 <NEW_LINE> return '%.*f K' % (pr, b / 2**10) <NEW_LINE> <DEDENT> elif b < 2**30: ... | Convert size in bytes to human-readable format.
Show 4 decimal points unless it's exact multiple. | 625941c976d4e153a657eba9 |
@pkg.log.test() <NEW_LINE> def test_validation(init_validation_test): <NEW_LINE> <INDENT> reference = init_validation_test[0] <NEW_LINE> validated_class = type(reference) <NEW_LINE> pkg.log.open("Testing fixture {class=%s}..." % (validated_class.__name__)) <NEW_LINE> pkg.log.comment(reference) <NEW_LINE> test = validat... | Construct a class instance and perform comparison to its validation
reference.
:param init_validation_test: reference returned by init_validation_test()
:return: None | 625941c9379a373c97cfabbd |
def run(self, edit): <NEW_LINE> <INDENT> regions = self.view.get_regions(SEL_REGION) + self.view.get_regions(OUT_REGION) <NEW_LINE> if len(regions): <NEW_LINE> <INDENT> self.view.sel().clear() <NEW_LINE> map(lambda x: self.view.sel().add(x), regions) <NEW_LINE> <DEDENT> self.view.erase_regions(SEL_REGION) <NEW_LINE> se... | Look for the next wrapping tab stop region | 625941c945492302aab5e33b |
def insertColumn(self, column, parent = QModelIndex()): <NEW_LINE> <INDENT> return bool() | bool QAbstractItemModel.insertColumn(int column, QModelIndex parent = QModelIndex()) | 625941c9283ffb24f3c5597b |
def get_instance_type_name(glance_connection: GlanceConnection, instance_name: str): <NEW_LINE> <INDENT> instance_name_list = [] <NEW_LINE> for image in glance_connection.connection.images.list(): <NEW_LINE> <INDENT> image_info = dict(image) <NEW_LINE> if 'instance_type_name' in image_info and 'name' in image_info and ... | Get all the instance type name with instance_name instance name from glance_connection region
:param glance_connection: GlanceConnection
:param instance_name: str content the name of the instance
:return: list of the instance_type_name | 625941c9bf627c535bc13248 |
def check_single_notebook(notebook_filename, timeout=500): <NEW_LINE> <INDENT> with open(notebook_filename) as notebook_file: <NEW_LINE> <INDENT> notebook_content = nbformat.reads(notebook_file.read(), as_version=nbformat.current_nbformat) <NEW_LINE> os.chdir(os.path.dirname(notebook_filename)) <NEW_LINE> _, client = m... | Checks single notebook being given its full name
(executes cells one-by-one checking there are no exceptions, nothing more is guaranteed) | 625941c96fb2d068a760f115 |
def count(inp): <NEW_LINE> <INDENT> def getyear(row): <NEW_LINE> <INDENT> if len(row) == 116: <NEW_LINE> <INDENT> return row[11:15] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return row[12:16] <NEW_LINE> <DEDENT> <DEDENT> res = dict((int(year),len(list(rows))) for year,rows in itertools.groupby(sorted(inp, key=getye... | *inp* is a file in GHCN-M format (either v2 or v3).
Counts the number of rows in each year.
The result is a dict that maps from year (a number) to
count (also a number). | 625941c999cbb53fe6792c5f |
def calc_bit_error_rate(b1, b2): <NEW_LINE> <INDENT> if len(b1) != len(b2): <NEW_LINE> <INDENT> raise ValueError('List of bits differ in length') <NEW_LINE> <DEDENT> diff = np.array(b1) - np.array(b2) <NEW_LINE> if diff.ndim == 1: <NEW_LINE> <INDENT> result = np.sum(np.absolute(diff)) <NEW_LINE> return result / len(dif... | Calculates the bit error rate for two binary lists.
:param b1: a list of bits
:param b2: another list of bits
:return: the resulting bit error rate | 625941c9dc8b845886cb55ad |
def creerFormulaire(self): <NEW_LINE> <INDENT> formulaire = QtGui.QFormLayout() <NEW_LINE> depart = QtGui.QLineEdit() <NEW_LINE> destination = QtGui.QLineEdit() <NEW_LINE> date = QtGui.QCalendarWidget() <NEW_LINE> ranges = QtGui.QComboBox(self) <NEW_LINE> for i in range(10, 31): <NEW_LINE> <INDENT> ranges.addItem(str(i... | On créer les éléments du formulaire | 625941c915baa723493c3fee |
def _get_cache(): <NEW_LINE> <INDENT> global _cache <NEW_LINE> if _cache is not None: <NEW_LINE> <INDENT> return _cache <NEW_LINE> <DEDENT> if isfile(config.cache_file): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(config.cache_file, 'rb') as f: <NEW_LINE> <INDENT> _cache = pickle.load(f) <NEW_LINE> <DEDENT> ... | Lazy load cache file into variable `_cache`
Returns `_cache` if already loaded | 625941c9ac7a0e7691ed4147 |
def findDiagonalOrder(self, nums): <NEW_LINE> <INDENT> res = [] <NEW_LINE> for r, row in enumerate(nums): <NEW_LINE> <INDENT> for c, col in enumerate(row): <NEW_LINE> <INDENT> if len(res)<= r+c: <NEW_LINE> <INDENT> res.append([]) <NEW_LINE> <DEDENT> res[r+c].append(col) <NEW_LINE> <DEDENT> <DEDENT> return [num for row ... | :type nums: List[List[int]]
:rtype: List[int] | 625941c9e5267d203edcdd17 |
def _parse_cod_segment(self, fptr): <NEW_LINE> <INDENT> offset = fptr.tell() - 2 <NEW_LINE> read_buffer = fptr.read(2) <NEW_LINE> length, = struct.unpack('>H', read_buffer) <NEW_LINE> read_buffer = fptr.read(length - 2) <NEW_LINE> scod, = struct.unpack_from('>B', read_buffer, offset=0) <NEW_LINE> spcod = read_buffer[1:... | Parse the COD segment.
Parameters
----------
fptr : file
Open file object.
Returns
-------
COD segment instance. | 625941c921a7993f00bc7d67 |
def localize_triples(triples: List[Dict[str, str]], graphs: List[str]) -> Iterable[Dict[str, str]]: <NEW_LINE> <INDENT> for (s, p, o) in triples: <NEW_LINE> <INDENT> for graph in graphs: <NEW_LINE> <INDENT> yield { 'subject': format_term(s), 'predicate': format_term(p), 'object': format_term(o), 'graph': graph } | Performs data localization of a set of triple patterns.
Args:
* triples: Triple patterns to localize.
* graphs: List of RDF graphs URIs used for data localization.
Yields:
The localized triple patterns. | 625941c97b25080760e394d3 |
def computeGroundingScore(question, sceneGraph, attentionMap): <NEW_LINE> <INDENT> regions = [] <NEW_LINE> regions += [ getRegion(sceneGraph, pointer) for pointer in question["annotations"]["question"].values() ] <NEW_LINE> regions += [ getRegion(sceneGraph, pointer) for pointer in question["annotations"]["fullAnswer"]... | Compute grounding score.
Compute amount of attention (probability) given to each of the regions the
question and answers refer to. | 625941c932920d7e50b28248 |
def read(self, force=False, **kwargs): <NEW_LINE> <INDENT> if self.__have_read and not force: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> iterator = self.fd.__iter__() <NEW_LINE> iter_ctr = 0 <NEW_LINE> if 'headers' in kwargs: <NEW_LINE> <INDENT> self.dictkeys = kwargs['headers'] <NEW_LINE> iter_ctr += 1 <NEW_LINE> ... | Read the file associated with this instance and load the data
into a usable representation. All lines beginning with '#' are
ignored.
@param force: Read even if have already read.
@type force: C{bool}
@keyword headers: A list of headers names to use. Must match the number
of columns
@keyword skiplines: Skip this many ... | 625941c96fece00bbac2d7b6 |
def test_service_area_multiple(self, db_session, create_test_library, create_test_place): <NEW_LINE> <INDENT> (place_alpha, place_bravo) = [create_test_place(db_session) for _ in range(2)] <NEW_LINE> library = create_test_library(db_session, eligibility_areas=[place_alpha, place_bravo]) <NEW_LINE> assert library.servic... | GIVEN: A Library with multiple service areas
WHEN: That Library instance's .service_area property is accessed
THEN: None should be returned | 625941c926068e7796caed57 |
def empty(self): <NEW_LINE> <INDENT> return len(self.temp)==0 | Returns whether the queue is empty.
:rtype: bool | 625941c976d4e153a657ebaa |
def test_get_image_details_of_rejected_image(self): <NEW_LINE> <INDENT> resp = self.images.client.get_image_details( self.rejected_image.id_) <NEW_LINE> self.assertEqual( resp.status_code, 200, Messages.STATUS_CODE_MSG.format(200, resp.status_code)) <NEW_LINE> get_image = resp.entity <NEW_LINE> errors = self.images.beh... | @summary: Get image details of a rejected image
1) Get image details of a rejected image
2) Verify that the response code is 200
3) Verify that the returned image's properties are as expected
generically | 625941c94527f215b584c4d1 |
def find_in_list(alist, prop, value): <NEW_LINE> <INDENT> n = -1 <NEW_LINE> for i in range(len(alist)): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if alist[i][prop] == value: <NEW_LINE> <INDENT> n = i <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> except KeyError: <NEW_LINE> <INDENT> log("The object at index " + str(i... | Returns the index of the first object in a list which has a field
named *prop* with value *value*. If no such object is found, returns -1. | 625941c94f88993c3716c0e1 |
def run_container(name, image, command=None, environment=None, ro=None, rw=None, links=None, detach=True, volumes_from=None, port_bindings=None, log_syslog=False): <NEW_LINE> <INDENT> binds = ro_rw_to_binds(ro, rw) <NEW_LINE> host_config = create_host_config(binds=binds, log_config=LogConfig( type=('syslog' if log_sysl... | Wrapper for docker create_container, start calls
:returns: container info dict or None if container couldn't be created
Raises PortAllocatedError if container couldn't start on the
requested port. | 625941c94e4d5625662d4452 |
def get_paper_count(self, candidate_id): <NEW_LINE> <INDENT> return self._paper_count[candidate_id] | returns the number of papers held by the candidate | 625941c960cbc95b062c65bc |
def nearest_data(self, pt, k=2, n_jobs=-1): <NEW_LINE> <INDENT> pt = np.asarray(pt, dtype=np.float32) <NEW_LINE> if len(pt.shape) == 1: <NEW_LINE> <INDENT> r = self.nearest_data([pt], k=k, n_jobs=n_jobs)[0]; <NEW_LINE> return (r[0][0], r[1][0], r[2][0]) <NEW_LINE> <DEDENT> pt = pt.T if pt.shape[0] == self.coordinates.s... | mesh.nearest_data(pt) yields a tuple (k, d, x) of the matrix x containing the point(s)
nearest the given point(s) pt that is/are in the mesh; a vector d if the distances between
the point(s) pt and x; and k, the face index/indices of the triangles containing the
point(s) in x.
Note that this function and those of this... | 625941c901c39578d7e74eb4 |
def is_staff_address(email): <NEW_LINE> <INDENT> if email is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if '@' in email: <NEW_LINE> <INDENT> parts = email.split('@') <NEW_LINE> domain = parts[1] <NEW_LINE> if domain in AUTH_STAFF_EMAIL_DOMAINS: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT... | This function determines whether a particular email address is a
staff address or not. | 625941c966656f66f7cbc224 |
def action(self, post, mod): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.subreddit.modmail.create( self.subject, self.body, post.author, author_hidden=True ) <NEW_LINE> <DEDENT> except prawcore.PrawcoreException as exception: <NEW_LINE> <INDENT> logging.error( "Failed to send modmail on %s: %s", post.name, except... | Add, distinguish, and (if top-level) sticky reply to target. | 625941c91f037a2d8b946277 |
@login_required(login_url='login') <NEW_LINE> @genehmigte_user(allowed_roles=['mitarbeiter']) <NEW_LINE> def auftragsliste(request): <NEW_LINE> <INDENT> auftraege = Auftrag.objects.all() <NEW_LINE> auftrag_filter = AuftragsFilter(request.GET, queryset=auftraege) <NEW_LINE> auftrag = auftrag_filter.qs <NEW_LINE> context... | Gibt die Auftragsdaten und den Auftragsfilter an das Template weiter zum Anzeigen der Auftragsliste
Parameters:
request (HttpRequest): Ein Request-Objekt
Returns:
render(): Methode, die das Auftragslisten-Template mit dem Context-Dict samt
Au... | 625941c9d99f1b3c44c67609 |
def after_process_boot(self, broker): <NEW_LINE> <INDENT> pass | Called immediately after subprocess start up.
| 625941c950485f2cf553ce13 |
def letterCasePermutation(self, S): <NEW_LINE> <INDENT> if S.isdigit() or S == '': <NEW_LINE> <INDENT> return [S] <NEW_LINE> <DEDENT> permutation = [''] <NEW_LINE> for s in S: <NEW_LINE> <INDENT> if s.isdigit(): <NEW_LINE> <INDENT> permutation = [ i+s for i in permutation] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ... | :type S: str
:rtype: List[str] | 625941c96fb2d068a760f116 |
def plot_results(): <NEW_LINE> <INDENT> fig = plt.figure() <NEW_LINE> ax = fig.gca(projection='3d') <NEW_LINE> x = data_plot[:, 1] <NEW_LINE> y = data_plot[:, 2] <NEW_LINE> z = data_plot[:, 3] <NEW_LINE> ax.plot(x, y, z, label='z = f(x, y)') <NEW_LINE> ax.legend() <NEW_LINE> plt.savefig('helical.png') | Plot 3d curve z = f(x, y)
with ds_state = [x, y, z] | 625941c910dbd63aa1bd2c1d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.