code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def vec_to_so3(vec): <NEW_LINE> <INDENT> return np.array([[0, -vec[2], vec[1]], [vec[2], 0, -vec[0]], [-vec[1], vec[0], 0]]) | LICENSE: Modern Robotics
Converts a 3-vector to an so(3) representation
:param omg: A 3-vector
:return: The skew symmetric representation of omg
Example Input:
vec = np.array([1, 2, 3])
Output:
np.array([[ 0, -3, 2],
[ 3, 0, -1],
[-2, 1, 0]]) | 625941babe7bc26dc91cd49e |
def evolve(self, t): <NEW_LINE> <INDENT> cliques = list() <NEW_LINE> for c in range(3): <NEW_LINE> <INDENT> cliques.append(t * [0]) <NEW_LINE> <DEDENT> for i in range(t): <NEW_LINE> <INDENT> clique = cn.findCliques() <NEW_LINE> r = random.random() <NEW_LINE> node1id = random.choice(list(self.nodes)) <NEW_LINE> node1 = ... | function that takes a parameter t representing the number of time steps, as well as a network; for each time
step, randomly insert or delete one edge in the network
:param t: number of time steps | 625941bae8904600ed9f1dc2 |
def setDhcpDbAgentIDL(self, sessionId, url, writeDelay, timeOut): <NEW_LINE> <INDENT> pass | Parameters:
- sessionId
- url
- writeDelay
- timeOut | 625941bad7e4931a7ee9ddb5 |
def group_by(keyfunc, iterable): <NEW_LINE> <INDENT> grouped = {} <NEW_LINE> for item in iterable: <NEW_LINE> <INDENT> grouped.setdefault(keyfunc(item), []).append(item) <NEW_LINE> <DEDENT> return grouped | Returns a dict of the elements from given iterable keyed by result
of keyfunc on each element. The value at each key will be a list of
the corresponding elements, in the order they appeared in the iterable. | 625941bae1aae11d1e749b4e |
def create_assists_model(team_abbrev): <NEW_LINE> <INDENT> log_filename = "{}datasets/{}_2015_to_2018.csv".format(filepath, team_abbrev) <NEW_LINE> log_df = load_dataset(log_filename) <NEW_LINE> stats_filename = "{}datasets/team_stats/{}_Stats_By_Year.csv".format(filepath, team_abbrev) <NEW_LINE> stats_df = load_datase... | Given a dataframe
:param team_abbrev: string representing the team to generate a model that predicts their assists in a game
:param matchup: the matchup to predict the assists for
:return: | 625941ba2eb69b55b151c744 |
def is_active(self): <NEW_LINE> <INDENT> return True | Returns if a user is active or not
:return: | 625941ba3317a56b86939b02 |
@macro() <NEW_LINE> def go_to_pinhole(self): <NEW_LINE> <INDENT> self.output("You are here:") <NEW_LINE> self.execMacro('wa',) <NEW_LINE> self.output("Going to pinhole...") <NEW_LINE> self.execMacro('umv', 'zs', '-10') <NEW_LINE> self.execMacro('umv', 'th', '90') | Macro go_to_pinhole | 625941ba0383005118ecf47e |
def get_result_by_xyz_cell_id(self, node_xyz, cell_id): <NEW_LINE> <INDENT> case_key = self.case_keys[self.icase] <NEW_LINE> result_name = self.result_name <NEW_LINE> cell = self.grid_selected.GetCell(cell_id) <NEW_LINE> nnodes = cell.GetNumberOfPoints() <NEW_LINE> points = cell.GetPoints() <NEW_LINE> point0 = points.G... | won't handle multiple cell_ids/node_xyz | 625941ba004d5f362079a1d0 |
def iter_layer_states(model, audios, batch_size=128): <NEW_LINE> <INDENT> lens = (numpy.array(map(len, audios)) + model.config['filter_length']) // model.config['stride'] <NEW_LINE> rs = (r for batch in util.grouper(audios, batch_size) for r in model.task.pile(vector_padder(batch))) <NEW_LINE> for (r,l) in itertools.iz... | Pass audios through the model and for each audio return the state of each timestep and each layer. | 625941baa17c0f6771cbdeed |
def get_raum(self): <NEW_LINE> <INDENT> return self._raum | Auslesen welcher Raum gewünscht ist | 625941baaad79263cf3908d5 |
def get_cookie_header(self, req): <NEW_LINE> <INDENT> mocked_req = MockRequest(req) <NEW_LINE> self.cookiejar.add_cookie_header(mocked_req) <NEW_LINE> return mocked_req.get_new_headers().get('Cookie') | :param req: object with httplib.Request interface
Actually, it have to have `url` and `headers` attributes | 625941ba1d351010ab8559b7 |
def parse_task_obj(task_obj): <NEW_LINE> <INDENT> timestamp, target_path = task_obj.split('-', 1) <NEW_LINE> timestamp = Timestamp(timestamp) <NEW_LINE> target_account, target_container, target_obj = split_path('/' + target_path, 3, 3, True) <NEW_LINE> return timestamp, target_account, target_container, target_o... | :param task_obj: a task object name in format of
"<timestamp>-<target_account>/<target_container>" +
"/<target_obj>"
:return: 4-tuples of (delete_at_time, target_account, target_container,
target_obj) | 625941ba97e22403b379ce32 |
def folder_browser(self): <NEW_LINE> <INDENT> self.output_folder = QtGui.QFileDialog.getExistingDirectory(self, "Select Output Folder", "C:\\", QtGui.QFileDialog.ShowDirsOnly) <NEW_LINE> self.txtOutputFolder.setText(self.output_folder) | Set QT QLineEdit control to user-specified folder name.
:param txtControl: name of the QLineEdit control | 625941bacdde0d52a9e52ec9 |
def test4_1(): <NEW_LINE> <INDENT> return "a" in s | searching 'a' in s = "ab" * 10000 + "c" | 625941ba66673b3332b91f2c |
def get_actual_username_and_password(self): <NEW_LINE> <INDENT> return ( self.get_config_value(self._section_epp_login, 'username', OMIT_ERROR), self.get_config_value(self._section_epp_login, 'password', OMIT_ERROR), ) | Returns tuple (username, password) what was used to login | 625941babaa26c4b54cb0fbd |
def bootup(port, delay): <NEW_LINE> <INDENT> click.echo( colored(f"Port: ", "yellow") + colored(f"{port}", "red", attrs=['underline']) ) <NEW_LINE> click.echo( colored(f"Delay: ", "yellow") + colored(f"{delay}s", "red", attrs=['underline']) ) <NEW_LINE> global DELAY <NEW_LINE> DELAY = delay <NEW_LINE> app = make_app() ... | Main entry point
:param port: Running port | 625941ba63d6d428bbe44389 |
def tp_hyper(data): <NEW_LINE> <INDENT> return c2ri(ri2c(data).transpose()) | Hypercomplex tranpose.
Use when both dimension are complex.
Parameters
----------
data : ndarray
Array of hypercomplex NMR data.
Returns
-------
ndata : ndarray
Array of hypercomplex NMR data with axes transposed. | 625941bae5267d203edcdb3a |
def get_file_count_by_extension(file_path: str, file_ext: str) -> int: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if os.path.exists(file_path): <NEW_LINE> <INDENT> file_ext_count = len( list(filter(lambda x: os.path.splitext(x)[-1] == '.'+file_ext, list(map(lambda y: os.path.join(file_path, y), os.listdir(file_path))... | Get the count of files of a specified file extension from a given path | 625941ba3c8af77a43ae3637 |
def testBinary(self): <NEW_LINE> <INDENT> index = open("temp/dists/foo/main/binary-i386/Packages") <NEW_LINE> factory = picax.package.PackageFactory(index, "temp", "foo", "main") <NEW_LINE> packages = factory.get_packages() <NEW_LINE> assert len(packages) > 0 <NEW_LINE> index.close() | Test a binary package index. | 625941ba9b70327d1c4e0c6d |
def get_short_trend_by_code(self, code=None, sdate=None, edate=None): <NEW_LINE> <INDENT> in_params = {"date":sdate, "sdate":sdate, "edate":edate, "shcode":code} <NEW_LINE> out_params = ["date", "price", "sign", "change", "diff", "volume", "value", "gm_vo", "gm_va", "gm_per", "gm_avg", "gm_vo_sum"] <NEW_LINE> result = ... | TR: t1927 공매도일별추이
:param code: str 종목코드
:param sdate: str 시작일자
:param edate: str 종료일자
:return: list 시장 별 종목 리스트 | 625941ba5e10d32532c5edc8 |
def atoms(self): <NEW_LINE> <INDENT> return set(self.array_form) | Returns all the elements of a permutation
Examples
========
>>> from sympy.combinatorics import Permutation
>>> Permutation([0, 1, 2, 3, 4, 5]).atoms()
{0, 1, 2, 3, 4, 5}
>>> Permutation([[0, 1], [2, 3], [4, 5]]).atoms()
{0, 1, 2, 3, 4, 5} | 625941bad10714528d5ffb79 |
def hal_backlight_on(self): <NEW_LINE> <INDENT> if self.backlight_pin: <NEW_LINE> <INDENT> self.backlight_pin.value(1) | Allows the hal layer to turn the backlight on. | 625941ba67a9b606de4a7d56 |
def update_file_system_snapshots_with_http_info(self, attributes, **kwargs): <NEW_LINE> <INDENT> all_params = ['attributes', 'ids', 'name', 'latest_replica'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_pa... | Update an existing file system snapshot.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.update_file_system_sna... | 625941ba6aa9bd52df036c3c |
def _add_recurring_item(self): <NEW_LINE> <INDENT> return RecurringLineItem.objects.create(cart=self.cart, name="Recurring", quantity=1, sku="42", duration=12, duration_unit="MONTH", recurring_price=Decimal("20.00"), thankyou="Thank you") | Add a RecurringLineItem to self.cart. | 625941ba26238365f5f0ed04 |
def run(self, thread_count=1, count=0, interval=2): <NEW_LINE> <INDENT> suites = self.__classification_suite() <NEW_LINE> if thread_count>1: <NEW_LINE> <INDENT> with ThreadPoolExecutor(max_workers=thread_count) as ts: <NEW_LINE> <INDENT> for i in suites: <NEW_LINE> <INDENT> res = ReRunResult(count=count, interval=inter... | The entrance to running tests
Note: if multiple test classes share a global variable, errors may occur due to resource competition
:param thread_count:Number of threads. default 1
:param count: Rerun times, default 0
:param interval: Rerun interval, default 2
:return: Test run results | 625941bab545ff76a8913cb8 |
def test_upload_file(self): <NEW_LINE> <INDENT> data = dict(additionalMetadata='additionalMetadata_example', file=(BytesIO(b'some file data'), 'file.txt')) <NEW_LINE> response = self.client.open( '/johnct4/JM-Petstore/1.0.0/pet/{petId}/uploadImage'.format(petId=789), method='POST', data=data, content_type='multipart/fo... | Test case for upload_file
uploads an image | 625941ba15baa723493c3e0c |
def __init__(self): <NEW_LINE> <INDENT> super(LeNetEncoder, self).__init__() <NEW_LINE> self.restored = False <NEW_LINE> self.encoder = nn.Sequential( nn.Conv2d(1, 20, kernel_size=5), nn.MaxPool2d(kernel_size=2), nn.ReLU(), nn.Conv2d(20, 50, kernel_size=5), nn.Dropout2d(), nn.MaxPool2d(kernel_size=2), nn.ReLU() ) <NEW_... | Init LeNet encoder. | 625941ba99cbb53fe6792a81 |
def generate_short_id_raw(): <NEW_LINE> <INDENT> return unpack("<Q", urandom(8))[0] | Short ID generator - v4 - without any encoding | 625941ba293b9510aa2c3133 |
def is_spent(self): <NEW_LINE> <INDENT> return self.used | query method
:return: true if used, false if not | 625941ba96565a6dacc8f56f |
def dummyLoad(self, other, pBar=None): <NEW_LINE> <INDENT> other.getAllShapeVertices(other.simplex.shapes, pBar=pBar) <NEW_LINE> points, faces, counts, uvs, uvFaces = other.getMeshTopology(other.mesh) <NEW_LINE> dummyMesh = self.buildRawTopology( other.name, points, faces, counts, uvs, uvFaces ) <NEW_LINE> self.loadNod... | Method to copy the information in a DCC to a DummyDCC
Parameters
----------
other : DCC
The DCC to load into the dummy
pBar : QProgressDialog, optional
An optional progress dialog (Default value = None)
Returns
-------
: DummyDCC :
The new DummyDCC | 625941ba32920d7e50b28067 |
def _initialize_weights(self, nvis, rng=None, irange=None): <NEW_LINE> <INDENT> if rng is None: <NEW_LINE> <INDENT> rng = self.rng <NEW_LINE> <DEDENT> if irange is None: <NEW_LINE> <INDENT> irange = self.irange <NEW_LINE> <DEDENT> self.weights = sharedX( (.5 - rng.rand(nvis, self.nhid)) * irange, name='W', borrow=True ... | .. todo::
WRITEME | 625941ba15fb5d323cde09a4 |
def VLAQuack(uv, err, Stokes = " ", BIF=1, EIF=0, Sources=[" "], FreqID=0, subA=0, timeRange=[0.,0.], Antennas=[0], flagVer=1, begDrop=0.0, endDrop=0.0, Reason="Quack", logfile = ""): <NEW_LINE> <INDENT> if (begDrop<=0) and (endDrop<=0): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT... | Flags beginning and end of each scan
Trim start and end of each selected scan,
nothing done if begDrop=endDrop=0.0
See documentation for task Quack for details
uv = UV data object to flag
err = Obit error/message stack
Stokes = Limit flagging by Stokes
BIF = Limit flagging to BIF-EIF
EIF = Limit... | 625941ba6fece00bbac2d5d6 |
def _remove_boundaries(self, interval): <NEW_LINE> <INDENT> begin = interval.begin <NEW_LINE> end = interval.end <NEW_LINE> if self.boundary_table[begin] == 1: <NEW_LINE> <INDENT> del self.boundary_table[begin] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.boundary_table[begin] -= 1 <NEW_LINE> <DEDENT> if self.bou... | Removes the boundaries of the interval from the boundary table. | 625941ba851cf427c661a3ac |
def full_kernel(v, i, ksize, full_output=False): <NEW_LINE> <INDENT> vi = zeros(ksize) <NEW_LINE> ii = zeros(ksize) <NEW_LINE> vref = mean(v) <NEW_LINE> iref = mean(i) <NEW_LINE> v_corrected = v-vref <NEW_LINE> i_corrected = i-iref <NEW_LINE> for k in range(ksize): <NEW_LINE> <INDENT> vi[k] = mean(v_corrected[k:] * i_c... | Calculates the full kernel from the recording v and the input
current i. The last ksize steps of i should be null.
ksize = size of the resulting kernel
full_output = returns K,v0 if True (v0 is the resting potential) | 625941ba6aa9bd52df036c3d |
def unique_name(name, sequence): <NEW_LINE> <INDENT> return '{}_{}'.format(name.rsplit('_S', 1)[0], sequence_hash(sequence)) | Create a unique name based on the current name and the sequence
The returned name looks like name_S1234. If the current name contains
already a S_.... suffix, it is removed before the new suffix is appended.
name -- current name | 625941badd821e528d63b045 |
def test_vm_filter_save_and_cancel_load(request, vm_view): <NEW_LINE> <INDENT> filter_name = fauxfactory.gen_alphanumeric() <NEW_LINE> vm_view.entities.search.save_filter( "fill_field(Virtual Machine : Name, =)", filter_name) <NEW_LINE> @request.addfinalizer <NEW_LINE> def cleanup(): <NEW_LINE> <INDENT> vm_view.entitie... | Polarion:
assignee: gtalreja
casecomponent: WebUI
caseimportance: medium
initialEstimate: 1/10h | 625941ba8c0ade5d55d3e85a |
@app.route('/watcher/<watcher>', methods=['GET', 'DELETE']) <NEW_LINE> def watcher_handler(watcher): <NEW_LINE> <INDENT> watcher = stringify(watcher) <NEW_LINE> if request.method == 'DELETE': <NEW_LINE> <INDENT> if client.rm_watcher(watcher) is True: <NEW_LINE> <INDENT> return jsonify({'status': 200, 'reason': 'Watcher... | handle specific watcher given as parameter <watcher>
GET Retrieve a list of PIDs handled by watcher
DELETE Delete the watcher | 625941ba8e05c05ec3eea20c |
def append_operation(self, operation, start=True): <NEW_LINE> <INDENT> assert (isinstance(operation, Operation)) <NEW_LINE> iter = self.store.append([operation]) <NEW_LINE> operation.set_iter(self.store, iter) <NEW_LINE> if start: <NEW_LINE> <INDENT> operation.start() <NEW_LINE> <DEDENT> self.timeout_update() | Append an operation to the store
@param operation an Operation object
@param start if the operation should be started | 625941baa17c0f6771cbdeee |
def adapt(self, query, result): <NEW_LINE> <INDENT> if not result: <NEW_LINE> <INDENT> raise AdaptationError("Cannot adapt from empty result") <NEW_LINE> <DEDENT> sim,best = result[0] <NEW_LINE> adaptable = [k for (k,v) in query.items() if v.adaptable and query[k] != best[k]] <NEW_LINE> if not adaptable: <NEW_LINE> <IN... | Adapt a result to a query, if possible.
The return value is a tuple ('adapted', case), to conform to
the format of the return values of match(). | 625941bae64d504609d746db |
def delete_any(self, table_name, primary_column, item_id): <NEW_LINE> <INDENT> delete_command = "DELETE FROM %s WHERE %s = %s" % (table_name, primary_column, item_id) <NEW_LINE> self.cursor.execute(delete_command) | method accepts a table name and deletes the item with the specified. | 625941ba15baa723493c3e0d |
@cross_origin <NEW_LINE> def show_merchandise_data(request, categories, states="Total"): <NEW_LINE> <INDENT> start_time = time.time() <NEW_LINE> logger.info("New API request: {}".format(request.get_full_path())) <NEW_LINE> start_date = request.GET.get('startDate') <NEW_LINE> end_date = request.GET.get('endDate') <NEW_L... | get the request, return merchandise data
:param request: contain date
:param categories: Categories string
:param states: str, List of states
:return: JSON of merch data | 625941ba287bf620b61d3908 |
def forwards(migrator, model): <NEW_LINE> <INDENT> model.Rating.create_table() | Create rating table. | 625941ba31939e2706e4cd0a |
def __init__(self, capacity): <NEW_LINE> <INDENT> self._size = 0 <NEW_LINE> self._capacity = capacity <NEW_LINE> self._node = dict() <NEW_LINE> self._dlist = DLinkedList() | :type capacity: int | 625941bae5267d203edcdb3b |
def _sympysage_integral(self): <NEW_LINE> <INDENT> from sage.misc.functional import integral <NEW_LINE> f, limits = self.function._sage_(), list(self.limits) <NEW_LINE> for limit in limits: <NEW_LINE> <INDENT> if len(limit) == 1: <NEW_LINE> <INDENT> x = limit[0] <NEW_LINE> f = integral(f, x._sage_(), hold=True) <NEW_LI... | EXAMPLES::
sage: from sympy import Symbol, Integral
sage: sx = Symbol('x')
sage: assert integral(x, x, hold=True)._sympy_() == Integral(sx, sx)
sage: assert integral(x, x, hold=True) == Integral(sx, sx)._sage_()
sage: assert integral(x, x, 0, 1, hold=True)._sympy_() == Integral(sx, (sx,0,1))
sa... | 625941ba6e29344779a624af |
def init_website_management_client( experiment_secrets: Secrets, experiment_configuration: Configuration) -> WebSiteManagementClient: <NEW_LINE> <INDENT> secrets = load_secrets(experiment_secrets) <NEW_LINE> configuration = load_configuration(experiment_configuration) <NEW_LINE> with auth(secrets) as authentication: <N... | Initializes Website management client for webapp resource under Azure
Resource manager. | 625941ba7d847024c06be15b |
def load(path, module_name=None, include_dir=None): <NEW_LINE> <INDENT> real_module = bool(module_name) <NEW_LINE> thrift = parse(path, module_name, include_dir=include_dir) <NEW_LINE> if real_module: <NEW_LINE> <INDENT> sys.modules[module_name] = thrift <NEW_LINE> <DEDENT> return thrift | Load thrift_file as a module
The module loaded and objects inside may only be pickled if module_name
was provided. | 625941ba283ffb24f3c557a6 |
def clean_name(self): <NEW_LINE> <INDENT> name = self.cleaned_data['name'] <NEW_LINE> if self.job and self.job.name == name: <NEW_LINE> <INDENT> return name <NEW_LINE> <DEDENT> if Job.objects.filter( user=self.request.user, name=self.cleaned_data.get('name') ).exists(): <NEW_LINE> <INDENT> logger.info("You already have... | Validates the name of the job. For a user, a job should must a unique name.
:return: String value of the name field | 625941ba8a349b6b435e800f |
def validate_product_data(product): <NEW_LINE> <INDENT> if product['product_name'] == '': <NEW_LINE> <INDENT> return {'warning': 'product_name is a required field'}, 400 <NEW_LINE> <DEDENT> elif product['product_category'] == '': <NEW_LINE> <INDENT> return {'warning': 'product_category is a required field'}, 400 <NEW_L... | this funtion validates the product data | 625941bacb5e8a47e48b7949 |
def _on_open_all_cards(self): <NEW_LINE> <INDENT> for member in self._model.get_members(): <NEW_LINE> <INDENT> packet = outcoming.SetHandValuePacket(member, member.get_hand_value()) <NEW_LINE> self._send_to_all(packet) | При вскрытии карт рассылаем всем суммы карт других игроков. | 625941ba004d5f362079a1d1 |
def _count_values(self): <NEW_LINE> <INDENT> indices = {yi: [i] for i, yi in enumerate(self.y) if self.status[i]} <NEW_LINE> return indices | Return dict mapping relevance level to sample index | 625941bab7558d58953c4db5 |
def post_init(cr, registry): <NEW_LINE> <INDENT> from openerp import SUPERUSER_ID <NEW_LINE> from openerp.addons.base.ir.ir_config_parameter import _default_parameters <NEW_LINE> ICP = registry['ir.config_parameter'] <NEW_LINE> for k, func in _default_parameters.items(): <NEW_LINE> <INDENT> v = ICP.get_param(cr, SUPERU... | Rewrite ICP's to force groups | 625941ba15fb5d323cde09a5 |
def has_object_permission(self, request, view, obj): <NEW_LINE> <INDENT> if obj == request.user: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if request.method == DELETE: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if request.method in SAFE_METHODS: <NEW_LINE> <INDENT> return True | Show/edit/delete object permission.
:param request: django request instance.
:type request: django.http.request.HttpRequest.
:param view: view set.
:type view: mk42.apps.users.api.viewsets.user.UserViewset.
:param obj: user model instance.
:type obj: mk42.apps.users.models.user.User.
:return: permission is granted.
:r... | 625941ba92d797404e304024 |
def get_profile(self, account_id=None, web_property_id=None, name=None, id=None, **kwargs): <NEW_LINE> <INDENT> profile_store = self.service.management().profiles() <NEW_LINE> kwds = {} <NEW_LINE> if account_id is not None: <NEW_LINE> <INDENT> kwds['accountId'] = account_id <NEW_LINE> <DEDENT> if web_property_id is not... | Retrieve the right profile for the given account, web property, and
profile attribute (name, id, or arbitrary parameter in kwargs)
Parameters
----------
account_id : str, optional
web_property_id : str, optional
name : str, optional
id : str, optional | 625941bade87d2750b85fc29 |
def test(): <NEW_LINE> <INDENT> data = np.genfromtxt("NiCr-xcr-tem.txt") <NEW_LINE> m, n = data.shape <NEW_LINE> output = open("./sigma-NiCr.txt", "w") <NEW_LINE> for i in range(m): <NEW_LINE> <INDENT> T = data[i][1] <NEW_LINE> x0 = [data[i][0]] <NEW_LINE> db = Database("NiAlCrHuang1999.tdb") <NEW_LINE> comps = ["NI", ... | Calculate solid/liquid interfacial energies of the Ni-Cr system. | 625941ba30bbd722463cbc5e |
def get_terminal_width(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> import termios <NEW_LINE> import fcntl <NEW_LINE> import struct <NEW_LINE> call = fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('hhhh', 0, 0, 0, 0)) <NEW_LINE> height, width = struct.unpack('hhhh', call)[:2] <NEW_LINE> terminal_width = width <NEW_L... | Borrowed from the py lib. | 625941baa934411ee3751535 |
def reset_password(self, new_password): <NEW_LINE> <INDENT> self.set_password(new_password) <NEW_LINE> self.reset_validation_token() | Resets the password for this user to the given `new_password`. | 625941ba3539df3088e2e1e6 |
def list( self, resource_group_name: str, load_balancer_name: str, **kwargs: Any ) -> AsyncIterable["_models.InboundNatRuleListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.... | Gets all the inbound nat rules in a load balancer.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param load_balancer_name: The name of the load balancer.
:type load_balancer_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
... | 625941bad58c6744b4257afb |
def get_preferred_max_military_portion_for_single_battle() -> float: <NEW_LINE> <INDENT> if fo.currentTurn() < 40: <NEW_LINE> <INDENT> return 1.0 <NEW_LINE> <DEDENT> best_ship_equivalents = (get_concentrated_tot_mil_rating() / cur_best_mil_ship_rating()) ** 0.5 <NEW_LINE> _MAX_SHIPS_BEFORE_PREFERRING_LESS_THAN_FULL_ENG... | Determine and return the preferred max portion of military to be allocated to a single battle.
May be used to downgrade various possible actions requiring military support if they would require an excessive
allocation of military forces. At the beginning of the game this max portion starts as 1.0, then is slightly
re... | 625941ba7b180e01f3dc469f |
def pre_order_traversal(self, node=root): <NEW_LINE> <INDENT> if node: <NEW_LINE> <INDENT> yield node <NEW_LINE> self.in_order_traversal(node.left) <NEW_LINE> self.in_order_traversal(node.right) | Pre-order traversal visits the current node before its child nodes (hence the name "pre-order"). | 625941ba4428ac0f6e5ba68d |
def select_similar(type: typing.Union[int, str] = 'WEIGHT', compare: typing.Union[int, str] = 'EQUAL', threshold: float = 0.1): <NEW_LINE> <INDENT> pass | Select similar curve points by property type
:param type: Type
:type type: typing.Union[int, str]
:param compare: Compare
:type compare: typing.Union[int, str]
:param threshold: Threshold
:type threshold: float | 625941ba50812a4eaa59c1bf |
def __getattr__(self, attr): <NEW_LINE> <INDENT> if self._file is None: <NEW_LINE> <INDENT> raise IOError("file '%s' is not open" % self._filename) <NEW_LINE> <DEDENT> return getattr(self._file, attr) | Proxy all other attributes of file.
Raises IOError if file is not open.
:param attr: attribute name
:type attr: str
:raises: IOError
:returns: mixed | 625941bafff4ab517eb2f2d5 |
def __call__(self, *args, **kwargs): <NEW_LINE> <INDENT> if args: <NEW_LINE> <INDENT> return RE(self, *args) <NEW_LINE> <DEDENT> return self | Calling an RE object returns a reference to that same object. This
is done to support no-ops like then() and followed_by() such that
they can be invoked as attributes or methods.
If args are passed, then call returns a new RE that has the given
args appended. This allows 'of' to work as a conjunction or a way
to add... | 625941bab57a9660fec3371b |
def add(self, proxy, score=INITIAL_SCORE): <NEW_LINE> <INDENT> if not self.db.zscore(REDIS_KEY, proxy): <NEW_LINE> <INDENT> self.db.zadd(REDIS_KEY, score, proxy) | 添加代理, 设置分数
:param proxy: 代理
:param score: 分数
:return: | 625941ba23849d37ff7b2f2c |
def initAlgorithm(self, config): <NEW_LINE> <INDENT> self.addParameter( QgsProcessingParameterMultipleLayers( self.INPUTLAYERS, self.tr('Polygon Layers'), QgsProcessing.TypeVectorPolygon ) ) <NEW_LINE> self.addParameter( QgsProcessingParameterBoolean( self.SELECTED, self.tr('Process only selected features') ) ) <NEW_LI... | Parameter setting. | 625941babe7bc26dc91cd4a0 |
def is_job_flow_running(job_flow): <NEW_LINE> <INDENT> steps = getattr(job_flow, 'steps', None) or [] <NEW_LINE> active_steps = [step for step in steps if step.state != 'CANCELLED'] <NEW_LINE> if not active_steps: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return not getattr(active_steps[-1], 'enddatetime', N... | Return ``True`` if the given job has any steps which are currently
running. | 625941ba925a0f43d2549d0f |
def create_user(self, username, email, password=None): <NEW_LINE> <INDENT> now = datetime.datetime.now() <NEW_LINE> try: <NEW_LINE> <INDENT> email_name, domain_part = email.strip().split('@', 1) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> email = '@'.joi... | Creates and saves a User with the given username, email and password. | 625941ba76e4537e8c351513 |
def NCC(self, coeffs, cutoff, max_terms): <NEW_LINE> <INDENT> if max_terms is None: <NEW_LINE> <INDENT> max_terms = self.coeff_size <NEW_LINE> <DEDENT> n_terms = max_term = matrix = 0 <NEW_LINE> for p in range(max_terms): <NEW_LINE> <INDENT> if abs(coeffs[p]) >= cutoff: <NEW_LINE> <INDENT> matrix = matrix + coeffs[p]*s... | Build NCC multiplication matrix. | 625941ba71ff763f4b54952a |
def findMedianSortedArrays(nums1, nums2): <NEW_LINE> <INDENT> merged = nums1 + nums2 <NEW_LINE> merged.sort() <NEW_LINE> middle = len(merged)/2 <NEW_LINE> if len(merged) % 2 > 0: <NEW_LINE> <INDENT> return float(merged[middle]) <NEW_LINE> <DEDENT> return float((merged[middle-1] + merged[middle]) / 2.0) | :type nums1: List[int]
:type nums2: List[int]
:rtype: float | 625941ba26238365f5f0ed05 |
def _read_tokens(treebank_dir: str) -> List[str]: <NEW_LINE> <INDENT> def _extract_tokens_from(line: str) -> Generator[str, None, None]: <NEW_LINE> <INDENT> if line.isspace(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> column = line.split() <NEW_LINE> if not len(column) >= 2: <NEW_LINE> <INDENT> raise EvaluationErr... | Reads tokens from CoNLL data and returns them in a list. | 625941ba090684286d50eb7c |
def end(self): <NEW_LINE> <INDENT> while self._current_workunit: <NEW_LINE> <INDENT> self.report.end_workunit(self._current_workunit) <NEW_LINE> self._current_workunit.end() <NEW_LINE> self._current_workunit = self._current_workunit.parent <NEW_LINE> <DEDENT> self.report.close() <NEW_LINE> try: <NEW_LINE> <INDENT> if s... | This pants run is over, so stop tracking it.
Note: If end() has been called once, subsequent calls are no-ops. | 625941bae1aae11d1e749b4f |
def slash_right(url='', index=1): <NEW_LINE> <INDENT> return url.rstrip('/').rsplit('/', index)[1] | 获取由/分割的字符串url的最后第index段,忽略结尾空串
:param url: 字符串
:param index: 第几个
:return: str | 625941ba379a373c97cfa9e5 |
def start(self): <NEW_LINE> <INDENT> self.to_index() <NEW_LINE> self.login(self.get_key()) | 启动
:return: | 625941ba167d2b6e31218a35 |
def enrich_logging(self): <NEW_LINE> <INDENT> if self.input.args.get('log_to_file') or self.input.environment.get('log_to_file') or self.cfg.pyt.get('config.log_to_file'): <NEW_LINE> <INDENT> set_root_logger(log_to_file=self.path.run() / "pyterraform.logs") <NEW_LINE> logger.info("Enabled logging to file... | Based on cli inputs, enrich logging | 625941baa4f1c619b28afedc |
def populate_env(self): <NEW_LINE> <INDENT> os.putenv('PCOCC_JOB_ID', str(self.batchid)) <NEW_LINE> os.putenv('PCOCC_JOB_NAME', os.environ.get('SLURM_JOB_NAME', '')) | Populate environment variables with batch related info to propagate | 625941bad53ae8145f87a111 |
def test_geocode_esri_eu_soap(self): <NEW_LINE> <INDENT> candidates = self.g_esri_eu_soap.get_candidates(PlaceQuery( address='31 Maiden Lane', city='London', country='UK')) <NEW_LINE> self.assertEqual(len(candidates) > 0, True, 'No candidates returned.') | Test ESRI Europe SOAP geocoder | 625941bad6c5a10208143ee3 |
def trace(self, iter, reset=False): <NEW_LINE> <INDENT> Es = [] <NEW_LINE> States = [] <NEW_LINE> if reset is True: <NEW_LINE> <INDENT> self.acccnt = 0 <NEW_LINE> <DEDENT> for it in tqdm(range(iter)): <NEW_LINE> <INDENT> self.mcstep() <NEW_LINE> Es.append(self.energy) <NEW_LINE> States.append(np.array(self.s)) <NEW_LIN... | interation multi MC step | 625941ba462c4b4f79d1d56c |
def _getMinPossibleValue(self): <NEW_LINE> <INDENT> decmax = 0 <NEW_LINE> for i in range(self.getDecDigitCount()): <NEW_LINE> <INDENT> decmax += 9 * math.pow(10, -(i + 1)) <NEW_LINE> <DEDENT> return -math.pow(10.0, self.getIntDigitCount()) + 1 - decmax | _getMinPossibleValue(self) -> None
Determines which is the minimum possible value that can be represented
with the current total number of digits.
@return (float) the minimum possible value | 625941ba0383005118ecf480 |
def create_user_account(request): <NEW_LINE> <INDENT> if request.method == "GET": <NEW_LINE> <INDENT> name = request.GET.get("name", "") <NEW_LINE> age = request.GET.get("age", "") <NEW_LINE> Class = request.GET.get("class", "") <NEW_LINE> if name and age: <NEW_LINE> <INDENT> user_obj = UserAccount() <NEW_LINE> user_ob... | take parameter from url and create user_account in the database | 625941ba50485f2cf553cc34 |
def has_edge(self, v_vals): <NEW_LINE> <INDENT> return v_vals in self._vals_to_edges_map | Checks if a certain edge already exists in this graph | 625941ba3317a56b86939b04 |
def testAccessors(self): <NEW_LINE> <INDENT> self.attr_statem.attribute.append(saml.Attribute()) <NEW_LINE> self.attr_statem.attribute.append(saml.Attribute()) <NEW_LINE> self.attr_statem.attribute[0].name = "testAttribute" <NEW_LINE> self.attr_statem.attribute[0].name_format = saml.NAME_FORMAT_URI <NEW_LINE> self.attr... | Test for Attribute accessors | 625941ba91af0d3eaac9b8b0 |
def copy(self): <NEW_LINE> <INDENT> copy = type(self)() <NEW_LINE> copy.name = self.name <NEW_LINE> copy.contents = [content.copy() for content in self.contents] <NEW_LINE> copy.exclusions = list(self.exclusions) <NEW_LINE> return copy | Return a copy of the package. | 625941ba099cdd3c635f0af8 |
@tf.keras.utils.register_keras_serializable(package='Text') <NEW_LINE> def simple_swish(features): <NEW_LINE> <INDENT> features = tf.convert_to_tensor(features) <NEW_LINE> return features * tf.nn.sigmoid(features) | Computes the Swish activation function.
The tf.nn.swish operation uses a custom gradient to reduce memory usage.
Since saving custom gradients in SavedModel is currently not supported, and
one would not be able to use an exported TF-Hub module for fine-tuning, we
provide this wrapper that can allow to select whether t... | 625941ba1b99ca400220a94c |
def get_margin_position(self, pair=None): <NEW_LINE> <INDENT> if pair: <NEW_LINE> <INDENT> return self.private_api({'command': 'getMarginPosition', 'currencyPair': self.format_pair(pair) }) <NEW_LINE> <DEDENT> return self.private_api({'command': 'getMarginPosition'}) | get margin position for <pair> or for all pairs | 625941bad486a94d0b98dfe8 |
def set_default_init_cli_cmds(self): <NEW_LINE> <INDENT> init_cli_cmds = [] <NEW_LINE> init_cli_cmds.append("set --retcode true") <NEW_LINE> init_cli_cmds.append("echo off") <NEW_LINE> init_cli_cmds.append("set --vt100 off") <NEW_LINE> init_cli_cmds.append('set dut "'+self.name+'"') <NEW_LINE> init_cli_cmds.append(['se... | Default init commands are set --retcode true, echo off, set --vt100 off, set dut <dut name>
and set testcase <tc name>
:return: List of default cli initialization commands. | 625941ba4527f215b584c2f6 |
def _fields(self): <NEW_LINE> <INDENT> cmd = "-e {0}" <NEW_LINE> return " ".join([cmd.format(field) for field in self.fields]) | construct fields that tshark should output | 625941ba1d351010ab8559b9 |
def blueprints(app): <NEW_LINE> <INDENT> manage.utils.load_blueprints( app, 'manage', app.config.get('MANAGE_BLUEPRINTS', []) ) | Register the blueprints for the application | 625941ba507cdc57c6306b6f |
def check_valid_port(p): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> p = int(p) <NEW_LINE> assert 0 < p < 65536 <NEW_LINE> return p <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise argparse.ArgumentTypeError('invalid port [1, 65535]: %s' % p) | True if p is a valid port number | 625941ba7cff6e4e81117821 |
def eval(self, expr): <NEW_LINE> <INDENT> context = Context(_globals=self.globals, engine=self, doc_vars=self.doc_vars, loaded_excel=self.loaded_excel) <NEW_LINE> self.actions = [] <NEW_LINE> e = expression.parseString(expr)[0] <NEW_LINE> if (log.getEffectiveLevel() == logging.DEBUG): <NEW_LINE> <INDENT> log.debug('e=%... | Parse and evaluate a single VBA expression
:param expr: str, expression to be evaluated
:return: value of the evaluated expression | 625941baf548e778e58cd418 |
def get_history(self): <NEW_LINE> <INDENT> return self.train_batch_history, self.valid_batch_history | get history | 625941ba4e696a04525c92e8 |
def loadyaml(fin): <NEW_LINE> <INDENT> f = open(fin, 'r') <NEW_LINE> hdr = yaml.load(f) <NEW_LINE> return hdr | Loads a yaml file into the assigned variable:
hdr = loadyaml(fin)
hdr.keys() gives the dictionary | 625941ba82261d6c526ab33e |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg._Header.Header() <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 12 <NEW_LINE> (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.n... | unpack serialized message in str into this message instance
@param str: byte array of serialized message
@type str: str | 625941ba4d74a7450ccd405f |
def __init__(self, data_manager: DataManager, attribute: WithingsAttribute) -> None: <NEW_LINE> <INDENT> self._data_manager = data_manager <NEW_LINE> self._attribute = attribute <NEW_LINE> self._profile = self._data_manager.profile <NEW_LINE> self._user_id = self._data_manager.user_id <NEW_LINE> self._name = f"Withings... | Initialize the Withings sensor. | 625941ba7d43ff24873a2b3c |
def candle_check(self, df, candle_period): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> indicator_conf = {} <NEW_LINE> if 'candle_recognition' in self.indicator_config: <NEW_LINE> <INDENT> for config in self.indicator_config['candle_recognition']: <NEW_LINE> <INDENT> if config['enabled'] and config['candle_period'] == ... | df : dataframe with ohlcv values
candle_period : period for candles
return : dataframe with candle patterns | 625941ba097d151d1a222cf8 |
def card_ranks(hand): <NEW_LINE> <INDENT> return sorted([dict_card.get(x[0]) for x in hand], reverse=True) | Возвращает список рангов (его числовой эквивалент),
отсортированный от большего к меньшему | 625941ba01c39578d7e74cdf |
def objdump_file( self, filepath=None, syntax='intel', sections=None, ignore_sections=None): <NEW_LINE> <INDENT> filepath = filepath or self.filepath <NEW_LINE> if not os.path.exists(filepath): <NEW_LINE> <INDENT> print_err(f'File doesn\'t exist: {filepath}') <NEW_LINE> return None <NEW_LINE> <DEDENT> cmd = ['objdump',... | Run objdump on an executable file, and format it's output.
Arguments:
filepath : Executable to dump.
syntax : Syntax for objdump -M
sections : Only include section names in this list.
ignore_sections : Ignore any sections starting/ending with
strings in this ... | 625941ba6aa9bd52df036c3e |
def isDone(self): <NEW_LINE> <INDENT> return self.offset >= len(self.msgset_ids_to_remove) | See `TunableLoop`. | 625941ba796e427e537b045e |
@csrf_exempt <NEW_LINE> def handle_xmlrpc(request): <NEW_LINE> <INDENT> if request.method == "POST": <NEW_LINE> <INDENT> if DEBUG: <NEW_LINE> <INDENT> print(request.raw_post_data) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> response = HttpResponse(content_type='text/xml') <NEW_LINE> result = rpc.xmlrpcdispatcher._mars... | Handles XML-RPC requests. All XML-RPC calls should be forwarded here
request
The HttpRequest object that carries the XML-RPC call. If this is a
GET request, nothing will happen (we only accept POST requests) | 625941ba63b5f9789fde6f81 |
def getStatus(self): <NEW_LINE> <INDENT> return self.__status | return job status | 625941babe7bc26dc91cd4a1 |
def strings2symbols(strings, go2type = None): <NEW_LINE> <INDENT> symbols = {} <NEW_LINE> if go2type is None: <NEW_LINE> <INDENT> raise TypeError("The type of keys in the dictionary to be transfered " "into must supply") <NEW_LINE> <DEDENT> elif go2type is "orsymbols": <NEW_LINE> <INDENT> for key, value in strings.item... | Returns a dictionary with keys being symbols instead of strings.
Symbols here can be ordinary symbols or dynamic symbols.
Parameter
---------
strings: a dictionary
A dictionary with keys being strings.
go2type: string
A type of keys of the dictionary to be transfered into.
Two options only: "orsymbols" for... | 625941ba656771135c3eb70e |
@csrf.csrf_protect <NEW_LINE> def subscribe_for_tags(request): <NEW_LINE> <INDENT> tag_names = getattr(request,request.method).get('tags','').strip().split() <NEW_LINE> pure_tag_names, wildcards = forms.clean_marked_tagnames(tag_names) <NEW_LINE> if request.user.is_authenticated: <NEW_LINE> <INDENT> if request.method =... | process subscription of users by tags | 625941ba442bda511e8be2c1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.