code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def convert_to_epoch1(date_time): <NEW_LINE> <INDENT> converted = date_time.timetuple() <NEW_LINE> epoch_time = time.mktime(converted) <NEW_LINE> return epoch_time
convert date time to epoch (version 1) :param date_time: :return:
625941dae5267d203edcdf49
@permission_required(['experiments.add_experiment', 'experiments.add_experimentplate']) <NEW_LINE> def add_experiment_plate(request): <NEW_LINE> <INDENT> if request.POST: <NEW_LINE> <INDENT> form = AddExperimentPlateForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> data = form.cleaned_data <NEW_LINE...
Render the page to add a new experiment plate. Adding an experiment plate also adds the corresponding experiment wells.
625941da76e4537e8c351923
def preprocessing(config): <NEW_LINE> <INDENT> print("Processing Data......") <NEW_LINE> data_loader = DataLoader(path=[config.train_file, config.dev_file, config.test_file], shuffle=True, config=config) <NEW_LINE> train_data, dev_data, test_data = data_loader.dataLoader() <NEW_LINE> print("train sentence {}, dev sente...
:param config: config :return:
625941da498bea3a759b9d5d
def retrieve_data(self, **args): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> dbname = args['dbname'] <NEW_LINE> series = args['series'] <NEW_LINE> time_start = args['start'] <NEW_LINE> time_end = args['end'] <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> exit(e) <NEW_LINE> <DEDENT> query = "SELECT * FR...
Sends a GET requet to the remote server.
625941da507cdc57c6306f8f
def downCmd(self, *args): <NEW_LINE> <INDENT> idx = self.tDisp.selIdx <NEW_LINE> if idx != len(self.conflict.infeasibles) - 1: <NEW_LINE> <INDENT> self.activeDM.misperceptions.moveCondition(idx, idx + 1) <NEW_LINE> self.activeDM.calculatePerceived() <NEW_LINE> self.event_generate('<<ValueChange>>') <NEW_LINE> self.tDis...
Called whenever an item is moved downwards.
625941da07d97122c4178b3f
def click_menu(self,driver,text): <NEW_LINE> <INDENT> try : <NEW_LINE> <INDENT> driver.find_element_by_link_text(text).click() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> driver.find_element_by_partial_link_text(text).click() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <...
Click on a element by it's text. :param driver: :param text: :return:
625941da009cb60464c6365f
def isAdmin( self, user): <NEW_LINE> <INDENT> if user.priv == 'courseclass' and user == self.admin: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False
user is the admin of the course_class or not
625941da7cff6e4e81117c34
def remove_edge(self, edge): <NEW_LINE> <INDENT> self.edges.remove(edge) <NEW_LINE> edge.target.in_edges.remove(edge)
Remove the given edge from the graph, as well as the nodes to which it is incident.
625941dacad5886f8bd27288
def _channel(self, *parts): <NEW_LINE> <INDENT> channel = [self._namespace, "channels"] <NEW_LINE> for part in parts: <NEW_LINE> <INDENT> channel.append(str(part)) <NEW_LINE> <DEDENT> return "/".join(channel).encode(self._encoding)
Construct a Redis pub/sub channel name from contituent parts. :return: a bytestring containing the encoded channel name.
625941daeab8aa0e5d26de07
@view_config( route_name='revision_comment', permission='comment', ) <NEW_LINE> def revision_comment(request): <NEW_LINE> <INDENT> revision = request.context <NEW_LINE> user = request.user <NEW_LINE> comment_text = request.params.get('comment') <NEW_LINE> status = request.params.get('status') <NEW_LINE> vote = int(requ...
Comment/vote on a Revision POST /revisions/:id/comment
625941da15baa723493c4226
def test_global_insignificant_param(self): <NEW_LINE> <INDENT> class MyTask(luigi.Task): <NEW_LINE> <INDENT> x_g2 = luigi.Parameter(default='y', is_global=True, significant=False) <NEW_LINE> <DEDENT> self.assertRaises(luigi.parameter.UnknownParameterException, lambda: MyTask('arg'))
We don't want any kind of global param to be positional
625941da85dfad0860c3b10a
def get_numeric_predicate_bounds(predicate: Predicate) -> ConstructivePredicate: <NEW_LINE> <INDENT> unchanged = ConstructivePredicate.unchanged(predicate) <NEW_LINE> if ( isinstance(predicate, partial) and len(predicate.args) == 1 and not predicate.keywords ): <NEW_LINE> <INDENT> arg = predicate.args[0] <NEW_LINE> if ...
Shared logic for understanding numeric bounds. We then specialise this in the other functions below, to ensure that e.g. all the values are representable in the types that we're planning to generate so that the strategy validation doesn't complain.
625941da24f1403a92600e13
def crossProduct(self, *args): <NEW_LINE> <INDENT> return _MEDCouplingClient.MEDCouplingNoTimeLabel_crossProduct(self, *args)
crossProduct(self, MEDCouplingTimeDiscretization other) -> MEDCouplingTimeDiscretization 1
625941daeab8aa0e5d26de08
def _run_first_time(self, query, reviewed, ratio): <NEW_LINE> <INDENT> if reviewed: <NEW_LINE> <INDENT> results = search_reviewed(query, frmt="txt", file_handle=True) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> results = search_all(query, frmt="txt", file=True) <NEW_LINE> <DEDENT> entries = parse_txt(results) <NEW_LI...
Run an analysis for the first time, i.e., results are not cached.
625941da5fcc89381b1e1970
def notify_work_done(self, amt=1): <NEW_LINE> <INDENT> self.handler.notify_work_done(amt)
Notifies the factory of an amount of work done. It will then relay this to its handler, and it will be reflected in the progress bar.
625941da91af0d3eaac9bcca
def _find_changed(old, new, both): <NEW_LINE> <INDENT> old_edges = [] <NEW_LINE> for edge in old.edges(data=True): <NEW_LINE> <INDENT> if set((edge[0], edge[1])) not in both: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> hashable = tuple(sorted(edge[2].items())) <NEW_LINE> old_edges.append(set((edge[0], edge[1], has...
returns links that have changed weight
625941da187af65679ca53ce
def close(self): <NEW_LINE> <INDENT> if self._socket: <NEW_LINE> <INDENT> self._socket.close() <NEW_LINE> self._socket = None
Close the connection with the Serf agent.
625941da9f2886367277ab3b
def search_all(self, show_element: ShowElement) -> List[Recording]: <NEW_LINE> <INDENT> pass
Returns all the recordings with a title that matches the given query. They are sorted by ascending date. Arguments: show_element: Search for all recordings that match this ShowElement.
625941da711fe17d82542615
@pytest.mark.parametrize("dim", ["t", "time"]) <NEW_LINE> @pytest.mark.parametrize("detrend_type", ["constant", "linear"]) <NEW_LINE> def test_dim_format(dim, detrend_type): <NEW_LINE> <INDENT> data = xr.DataArray( np.random.random([10]), dims=[dim], coords={dim: range(10)}, ) <NEW_LINE> dt = detrend(data, dim=dim, det...
Check that detrend can deal with dim in various formats
625941da85dfad0860c3b10b
def combinedField(self, color = None): <NEW_LINE> <INDENT> a = [a[:] for a in self.field] <NEW_LINE> for yip in range(0, len(self.piece[self.paf])): <NEW_LINE> <INDENT> for xip in range(0, len(self.piece[self.paf][yip])): <NEW_LINE> <INDENT> if self.piece[self.paf][yip][xip] != 0: <NEW_LINE> <INDENT> a[self.py + yip][s...
returns the field together with the floating piece.
625941da3eb6a72ae02ec792
def __init__(self, sid=None, ipaddr=None, host='localhost', port=6379, db=0, password=None, socket_timeout=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._redis = redis.StrictRedis(host=host, port=port, db=db, password=password, socket_timeout=socket_timeout) <NEW_LINE> <DEDENT> except redis.RedisError: <NEW_...
Initial redis. Generate sid if sid is None. @param sid: sid @param ipaddr: remote addr used to generate sid @param host: redis host addr @param port: redis port @param db: redis db @param password: redis password @param socket_timeout: redis timeout
625941da92d797404e30443a
def zsh_generate_optionspecs(click_command): <NEW_LINE> <INDENT> results = [] <NEW_LINE> for param in click_command.params: <NEW_LINE> <INDENT> if isinstance(param, click.Option): <NEW_LINE> <INDENT> for opt in param.opts: <NEW_LINE> <INDENT> desc = param.make_metavar() <NEW_LINE> if hasattr(param, "help") and param.he...
Given a command, dump the appropriate optionspecs. See the man page for zshcompsys, as these are arguments destined for _arguments. :param Click.Command click_command: the command :returns: completion code :rtype: str
625941dabe7bc26dc91cd8ab
def panyushev_orbit_iter(self, antichain, element_constructor=set, stop=True, check=True): <NEW_LINE> <INDENT> if check: <NEW_LINE> <INDENT> if not self.is_antichain_of_poset(antichain): <NEW_LINE> <INDENT> raise ValueError("the given antichain is not an antichain") <NEW_LINE> <DEDENT> <DEDENT> starter = set(antichain)...
Iterate over the Panyushev orbit of an antichain ``antichain`` of ``self``. The Panyushev orbit of an antichain is its orbit under Panyushev complementation (see :meth:`panyushev_complement`). INPUT: - ``antichain`` -- an antichain of ``self``, given as an iterable. - ``element_constructor`` (defaults to ``set``)...
625941dab7558d58953c51bf
def i0(x): <NEW_LINE> <INDENT> return special.iv(0, x)
Modified Bessel function of the first kind
625941da046cf37aa974cff5
def test_active_paid_booking(self): <NEW_LINE> <INDENT> active_booking = Booking(schedule_start=yesterday, schedule_end=tomorrow, vehicle=self.v1, user=self.u) <NEW_LINE> active_booking.invoice = Invoice(booking=active_booking, amount=active_booking.calculate_cost(), date=timezone.now()) <NEW_LINE> self.assertTrue(acti...
Active booking returns expected results
625941dad18da76e23532787
@login_required <NEW_LINE> def new_topic(request): <NEW_LINE> <INDENT> if request.method != 'POST': <NEW_LINE> <INDENT> form = TopicForm() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> form = TopicForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> new_topic = form.save(commit=False) <NEW_LINE> new_to...
add new topic to log
625941da29b78933be1e5957
def check_all_images(self) -> bool: <NEW_LINE> <INDENT> for image_url in self.urls: <NEW_LINE> <INDENT> if self.link_is_image(image_url): <NEW_LINE> <INDENT> image_path = self.download_image(image_url) <NEW_LINE> scores = self.check_message(image_path) <NEW_LINE> if self.message_is_bad(scores): <NEW_LINE> <INDENT> self...
Classify all images in Slack post
625941dabaa26c4b54cb13cc
def solution(l): <NEW_LINE> <INDENT> l = sorted(l, reverse=True) <NEW_LINE> sum_ = sum(l) <NEW_LINE> to_remove = list() <NEW_LINE> if sum_ % 3 == 1: <NEW_LINE> <INDENT> for i, int_ in enumerate(reversed(l)): <NEW_LINE> <INDENT> if int_ % 3 == 1: <NEW_LINE> <INDENT> to_remove.append(len(l)-i-1) <NEW_LINE> break <NEW_LIN...
Function to find the largest number that can be made from some or all of these digits in l and is divisible by 3. :param l: list :return:
625941da5166f23b2e1a5408
def print_statistics(self): <NEW_LINE> <INDENT> print("Replay-memory statistics:") <NEW_LINE> msg = "\tQ-values Before, Min: {0:5.2f}, Mean: {1:5.2f}, Max: {2:5.2f}" <NEW_LINE> print(msg.format(np.min(self.q_values_old), np.mean(self.q_values_old), np.max(self.q_values_old))) <NEW_LINE> msg = "\tQ-values After, Min: {...
Print statistics for the contents of the replay-memory.
625941da1b99ca400220ad61
def get_channel_data(client, **kwargs): <NEW_LINE> <INDENT> kwargs = remove_empty_kwargs(**kwargs) <NEW_LINE> response = client.channels().list( **kwargs ).execute() <NEW_LINE> myChannelId = response['items'][0]['id'] <NEW_LINE> myChannelName = response['items'][0]['snippet']['title'] <NEW_LINE> myChannelSubs = respons...
Get channel name, # of subscribers, video count, and view count from a channel ID
625941da4f88993c3716c315
def push_notification_devices_destroy_many(self, data, **kwargs): <NEW_LINE> <INDENT> api_path = "/api/v2/push_notification_devices/destroy_many.json" <NEW_LINE> return self.call(api_path, method="POST", data=data, **kwargs)
https://developer.zendesk.com/rest_api/docs/core/push_notification_devices
625941da097d151d1a223107
def set_server_metadata_item(self, server_id, key, meta): <NEW_LINE> <INDENT> post_body = json.dumps({'meta': meta}) <NEW_LINE> resp, body = self.put('servers/%s/metadata/%s' % (server_id, key), post_body) <NEW_LINE> body = json.loads(body) <NEW_LINE> self.validate_response(schema.set_show_server_metadata_item, resp, b...
Sets a metadata item, by key, for a server. For a full list of available parameters, please refer to the official API reference: https://developer.openstack.org/api-ref/compute/#create-or-update-metadata-item
625941da26238365f5f0f121
def solution(num: int = 100) -> int: <NEW_LINE> <INDENT> nfact = factorial(num) <NEW_LINE> result = split_and_add(nfact) <NEW_LINE> return result
Returns the sum of the digits in the factorial of num >>> solution(100) 648 >>> solution(50) 216 >>> solution(10) 27 >>> solution(5) 3 >>> solution(3) 6 >>> solution(2) 2 >>> solution(1) 1
625941da8c0ade5d55d3ec6c
def features(self, data_set, feature_tbl, extend=0): <NEW_LINE> <INDENT> labels = [] <NEW_LINE> X = [] <NEW_LINE> Y = [] <NEW_LINE> for label in data_set: <NEW_LINE> <INDENT> for l, y, x in feature_tbl[label]: <NEW_LINE> <INDENT> lb = (label, l) <NEW_LINE> if y == 1 and extend > 1: <NEW_LINE> <INDENT> labels.extend([lb...
get features for a fold number
625941da851cf427c661a7bc
def _prep_pub(self, tgt, fun, arg, expr_form, ret, jid, timeout, **kwargs): <NEW_LINE> <INDENT> if expr_form == 'nodegroup': <NEW_LINE> <INDENT> if tgt not in self.opts['nodegroups']: <NEW_LINE> <INDENT> conf_file = self.opts.get( 'conf_file', 'the master config file' ) <NEW_LINE> raise SaltInvocationError( 'Node group...
Set up the payload_kwargs to be sent down to the master
625941da3317a56b86939f02
def test_connect_to_server_200(mocker): <NEW_LINE> <INDENT> status_code = 200 <NEW_LINE> url = "http://127.0.0.1" <NEW_LINE> mocker.patch("exercise_python.interaction.connect", return_value=status_code) <NEW_LINE> assert connect_to_server(url) == status_code
Cause the 'connect' function to return status code '200'.
625941da99fddb7c1c9de640
def __init__(__self__, *, url: str, access_key: Optional[str] = None, buffering_interval: Optional[int] = None, buffering_size: Optional[int] = None, cloudwatch_logging_options: Optional['outputs.FirehoseDeliveryStreamHttpEndpointConfigurationCloudwatchLoggingOptions'] = None, name: Optional[str] = None, processing_con...
:param str url: The HTTP endpoint URL to which Kinesis Firehose sends your data. :param str access_key: The access key required for Kinesis Firehose to authenticate with the HTTP endpoint selected as the destination. :param int buffering_interval: Buffer incoming data for the specified period of time, in seconds, befor...
625941da097d151d1a223108
def sort(self, Ncol, order): <NEW_LINE> <INDENT> self.emit(SIGNAL("layoutAboutToBeChanged()")) <NEW_LINE> cmpFunc = None <NEW_LINE> if Ncol == self.headerLiteral.index('ID') or Ncol == self.headerLiteral.index('Price'): <NEW_LINE> <INDENT> cmpFunc = lambda l,r: (int(l) - int(r)) <NEW_LINE> <DEDENT> self.dataArray = sor...
Sort table by given column number.
625941da3d592f4c4ed1d318
def _update_ipmi_properties(task): <NEW_LINE> <INDENT> node = task.node <NEW_LINE> info = node.driver_info <NEW_LINE> info['ipmi_address'] = info['ilo_address'] <NEW_LINE> info['ipmi_username'] = info['ilo_username'] <NEW_LINE> info['ipmi_password'] = info['ilo_password'] <NEW_LINE> if 'console_port' in info: <NEW_LINE...
Update ipmi properties to node driver_info :param task: a task from TaskManager.
625941dafff4ab517eb2f6ed
def _createMenu(self): <NEW_LINE> <INDENT> from .E5ModelMenu import E5ModelMenu <NEW_LINE> return E5ModelMenu(self)
Protected method to create the menu for a tool bar action. @return menu for a tool bar action (E5ModelMenu)
625941da73bcbd0ca4b2c326
def relative_to_absolute_range(range_: 'Range', full_scale: 'Range', relative_pattern: str = '%') -> Optional['Range']: <NEW_LINE> <INDENT> if not isinstance(range_, Range): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> lo = range_.lo <NEW_LINE> up = range_.up <NEW_LINE> distr = range_.distr <NEW_LINE> is_...
Calculates absolute values of bounds of 'range_' which are defined relative to span of 'full_scale'. Relative bounds are of type str and must contain '%' after the number, e.g. '2%' or '-5%FS' Args: range_: range with absolute or relative bounds: 7, '7', '2%', '2%FS' full_scale: range with abs...
625941da71ff763f4b549940
def rotateX(self, _angle): <NEW_LINE> <INDENT> rad = _angle * math.pi / 180 <NEW_LINE> cosA = math.cos(rad) <NEW_LINE> sinA = math.sin(rad) <NEW_LINE> y = self.y * cosA - self.z * sinA <NEW_LINE> z = self.y * sinA + self.z * cosA <NEW_LINE> return Point(self.x, y, z)
Rotates the underlying 3-dimensional vector representing a point in the space around the X axis by the given angle in degrees. @toDo: Replace the sinus-calculations with matrix-rotations.
625941da63d6d428bbe447a0
def save_app(self, context, cancellation_context): <NEW_LINE> <INDENT> with AwsShellContext(context=context, aws_session_manager=self.aws_session_manager) as shell_context: <NEW_LINE> <INDENT> shell_context.logger.info('Save Snapshot') <NEW_LINE> resource = context.remote_endpoints[0] <NEW_LINE> data_holder = self.mode...
:param context: :param cancellation_context: :return:
625941da24f1403a92600e14
def setall(self, section, keyvalues): <NEW_LINE> <INDENT> for key, value in keyvalues.items(): <NEW_LINE> <INDENT> self.set(section, key, value)
Sets multiple key-value pairs in a section. keyvalues should be a dictionary containing the key-value pairs to be set.
625941da6e29344779a628c0
def _convert_attribute_info(self): <NEW_LINE> <INDENT> monitoring_pts = {} <NEW_LINE> for mpt_name, mpt_metadata in self._device_attributes.items(): <NEW_LINE> <INDENT> monitoring_pts[mpt_name] = {} <NEW_LINE> for metadata_prop_name, metadata_prop_val in mpt_metadata.items(): <NEW_LINE> <INDENT> if metadata_prop_name =...
Converts the monitoring points data structure into a dictionary to make searching easier. A dictionary of all the element's monitoring points together with their metadata specified in the DSL generated xml file. The key represents the name of the monitoring point and the value is a dictionary of all the monitoring poi...
625941da5fdd1c0f98dc04e4
def parse_video(self, response): <NEW_LINE> <INDENT> video = Selector(response) <NEW_LINE> items = [] <NEW_LINE> item = JavlibrarycrawlItem() <NEW_LINE> item['url'] = response.request.url <NEW_LINE> item['image_urls'] = video.xpath("//*[@id='video_jacket_img']/@src").extract() <NEW_LINE> item['title'] = video.xpath("//...
The lines below is a spider contract. For more info see: http://www.javlibrary.com/cn/star_list.php @url http://www.javlibrary.com/cn/star_list.php @scrapes name
625941da32920d7e50b28482
def test_noop(): <NEW_LINE> <INDENT> with pytest.raises(DocoptExit): <NEW_LINE> <INDENT> main([]) <NEW_LINE> <DEDENT> with pytest.raises(DocoptExit): <NEW_LINE> <INDENT> main(['foobar'])
Ensure docopt exit (displays usage)
625941daa05bb46b383ecad0
def inner_update(self): <NEW_LINE> <INDENT> pass
Update inner counters
625941daa79ad161976cc3f6
def load_protocols(self, channel, filenames=None, symbols=None): <NEW_LINE> <INDENT> stub = reflection_pb2_grpc.ServerReflectionStub(channel) <NEW_LINE> requests = [] <NEW_LINE> if filenames: <NEW_LINE> <INDENT> requests.extend( reflection_pb2.ServerReflectionRequest(file_by_filename=name) for name in filenames) <NEW_L...
Implementation of `GrpcReflectionClient.load_protocols`
625941dab57a9660fec33b38
def test_weights_get_missing_params(self): <NEW_LINE> <INDENT> response = self.client.get(reverse('weights'), {}) <NEW_LINE> assert response.status_code == 400 <NEW_LINE> assert response.json() == {'user_id': ['This field is required.']}
Testing GET weights view with missing params
625941da63f4b57ef00013c3
def create_paypal_link_for_request(request): <NEW_LINE> <INDENT> shop = lfs_get_object_or_404(Shop, pk=1) <NEW_LINE> current_site = Site.objects.get(id=settings.SITE_ID) <NEW_LINE> customer = lfs.customer.utils.get_customer(request) <NEW_LINE> invoice_address = customer.selected_invoice_address <NEW_LINE> cart = lfs.ca...
Creates paypal link for given request.
625941da7d847024c06be56f
def createTable(self): <NEW_LINE> <INDENT> if not self.hasSchemas: <NEW_LINE> <INDENT> schema = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> schema = unicode(self.cboSchema.currentText()) <NEW_LINE> if len(schema) == 0: <NEW_LINE> <INDENT> QMessageBox.information(self, self.tr("DB Manager"), self.tr("select schem...
create table with chosen fields, optionally add a geometry column
625941da96565a6dacc8f97b
def stop(self): <NEW_LINE> <INDENT> self._controller.stop()
Sends a stop signal to ThreadController Note: Thread will not finish immediately, it will finish the current iteration first
625941dad486a94d0b98e3f7
def map_setting_to_aspect(**aspectable_setting): <NEW_LINE> <INDENT> def _func_decorator(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def _new_func(self, *args, **kwargs): <NEW_LINE> <INDENT> if self.section.aspects: <NEW_LINE> <INDENT> aspects = self.section.aspects <NEW_LINE> for arg, aspect_value in aspectable...
Map function arguments with aspect and override it if appropriate. This decorator can be used by ``Bear.run()`` to automatically map and override bear's setting value with their equivalent aspect or taste. The order of setting override from the lowest to highest is: - Setting default (in bear's run argument) - Aspect...
625941da23e79379d52ee811
def MatchMaterial(source, destination): <NEW_LINE> <INDENT> source_id = rhutil.coerceguid(source) <NEW_LINE> source_mat = None <NEW_LINE> if source_id: <NEW_LINE> <INDENT> rhobj = rhutil.coercerhinoobject(source_id, True, True) <NEW_LINE> source = rhobj.Attributes.MaterialIndex <NEW_LINE> <DEDENT> mat = scriptcontext.d...
Copies the material definition from one material to one or more objects Parameters: source (number|guid): source material index -or- identifier of the source object. The object must have a material assigned destination ([guid, ...]) identifiers(s) of the destination object(s) Returns: number: number of object...
625941da6fb2d068a760f351
def show_error(self, user_interface): <NEW_LINE> <INDENT> user_interface.error(*self._error)
Display helpful message if available. INPUT: - ``user_interface`` -- an instance of :class:`~sage.dev.user_interface.UserInterface`. TESTS:: sage: from sage.dev.sagedev import SageDevValueError sage: e = SageDevValueError("message >{0}<", 123).info('1{0}3', 2) sage: e.show_error(dev._sagedev._UI) ...
625941da4428ac0f6e5baaa4
def test_single_user(self): <NEW_LINE> <INDENT> user = add_user(username='michael', email='michael@realpython.com') <NEW_LINE> with self.client: <NEW_LINE> <INDENT> response = self.client.get(f'/users/{user.id}') <NEW_LINE> data = json.loads(response.data.decode()) <NEW_LINE> self.assertEqual(response.status_code, 200)...
Ensure get single user behaves correctly.
625941dad58c6744b4257f0f
def do_exit(self, line): <NEW_LINE> <INDENT> pickle.dump(self.saves, open("../saves", "wb+"), -1) <NEW_LINE> sys.exit('bye!\n')
syntax 'exit' exit the game
625941dae76e3b2f99f3aab8
def connectionMade(self): <NEW_LINE> <INDENT> self.conn.initiate_connection() <NEW_LINE> self.transport.write(self.conn.data_to_send())
Called by the reactor when a connection is received. May also be called by the L{twisted.web.http._GenericHTTPChannelProtocol} during upgrade to HTTP/2.
625941da287bf620b61d3d13
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(PledgeAdmin, self).__init__(*args, **kwargs) <NEW_LINE> for field_name in get_user_search_fields(): <NEW_LINE> <INDENT> self.search_fields.append('backer__user__{0}'.format(field_name))
Dynamically generate search_fields values Due to the possibility of custom user models the search fields cant't be set statically.
625941dab5575c28eb68e2b3
def get_creator_data(h5group): <NEW_LINE> <INDENT> attrs = h5group.attrs <NEW_LINE> d = dict() <NEW_LINE> for attr in ['creation_program', 'creation_user', 'creation_hostname', 'creation_unix_time', 'creation_time']: <NEW_LINE> <INDENT> d[attr] = attrs.get(attr) <NEW_LINE> <DEDENT> return d
Read back creator data as written by ``stamp_creator_data``, returning a dictionary with keys as described for ``stamp_creator_data``. Missing fields are denoted with None. The ``creation_time`` field is returned as a string.
625941daa219f33f34628c17
def _open(self, name, mode="rb"): <NEW_LINE> <INDENT> pass
仅仅用来保存文件,因此用不到打开,但又必须实现此方法,直接pass即可
625941da15fb5d323cde0dc3
def test_build_two(self): <NEW_LINE> <INDENT> bucket, bucket_builder = self.get_two_bucket_test() <NEW_LINE> msg = r"SimpleBucket 'test_bucket' has 2 values for attribute '.*' but spec allows '\?'\." <NEW_LINE> with self.assertWarnsRegex(IncorrectQuantityBuildWarning, msg): <NEW_LINE> <INDENT> builder = self.manager.bu...
Test building a container which contains multiple containers as the spec allows.
625941daf9cc0f698b1408aa
def flush(self): <NEW_LINE> <INDENT> self._string_io.flush()
Flush the internal buffer.
625941da377c676e91272458
def _out(self, text, end='\n'): <NEW_LINE> <INDENT> print(text, end=end)
Prints a text into stdout.
625941da090684286d50ef98
def abiopen(filepath: str): <NEW_LINE> <INDENT> filepath = os.path.expanduser(filepath) <NEW_LINE> root, ext = os.path.splitext(filepath) <NEW_LINE> if ext in (".bz2", ".gz", ".z"): <NEW_LINE> <INDENT> from monty.io import zopen <NEW_LINE> with zopen(filepath, "rt") as f: <NEW_LINE> <INDENT> import tempfile <NEW_LINE> ...
Factory function that opens any file supported by abipy. File type is detected from the extension Args: filepath: string with the filename.
625941dacb5e8a47e48b7d57
def test_upload_parse_fail(self): <NEW_LINE> <INDENT> self.write_to_config_file( client_id=tests_integration.client_id, client_secret=tests_integration.client_secret, username=tests_integration.username, password=tests_integration.password, base_url=tests_integration.base_url, parser="miseq" ) <NEW_LINE> test_api = api...
Given an invalid sample sheet, make sure that the upload does not happen :return:
625941dacad5886f8bd27289
def load(self): <NEW_LINE> <INDENT> if( os.path.exists(self._output_file) ) : <NEW_LINE> <INDENT> out_fh = open( self._output_file, "rb" ) <NEW_LINE> session_obj = marshal.load( out_fh ) <NEW_LINE> out_fh.close() <NEW_LINE> if( session_obj["sid"] == self.sid() ) : <NEW_LINE> <INDENT> self._session_obj = session_obj <NE...
load session.
625941dad6c5a102081442fd
def end(self, command_status: CommandStatus): <NEW_LINE> <INDENT> target_robot = self.team_bots.robots[self.target_robot_id] <NEW_LINE> if target_robot is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> from simclient.test.catch_ball import CatchBall <NEW_LINE> target_robot.run_command(CatchBall(self.master)) <NEW...
Runs the catch ball command on the receiving robot if this command completed successfully :param command_status: The status of the command when its execution was ended
625941dadc8b845886cb57e7
def Vortex(df, n): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> TR = [0] <NEW_LINE> while i < len(df) - 1: <NEW_LINE> <INDENT> Range = max(df.iat[i + 1, df.columns.get_loc('High')], df.iat[i, df.columns.get_loc('Close')]) - min(df.iat[i + 1, df.columns.get_loc('Low')], df.iat[i, df.columns.get_loc('Close')]) <NEW_LINE> TR.appe...
Vortex Indicator
625941da507cdc57c6306f91
def readsap(file,time,nav): <NEW_LINE> <INDENT> result = librtk.readsap(file,time,nav) <NEW_LINE> return result
readsap(const char *file, gtime_t time, nav_t *nav
625941da15fb5d323cde0dc4
def test_follow_307_and_308_redirect(self): <NEW_LINE> <INDENT> methods = ('get', 'post', 'head', 'options', 'put', 'patch', 'delete', 'trace') <NEW_LINE> codes = (307, 308) <NEW_LINE> for method, code in itertools.product(methods, codes): <NEW_LINE> <INDENT> with self.subTest(method=method, code=code): <NEW_LINE> <IND...
A 307 or 308 redirect preserves the request method after the redirect.
625941dad164cc6175782fff
def configure_tree_location(self, distro): <NEW_LINE> <INDENT> base = self.rootdir <NEW_LINE> if self.network_root is None: <NEW_LINE> <INDENT> dest_link = os.path.join(self.settings.webdir, "links", distro.name) <NEW_LINE> if not os.path.exists(dest_link): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.logger.info(...
Once a distribution is identified, find the part of the distribution that has the URL in it that we want to use for kickstarting the distribution, and create a ksmeta variable $tree that contains this.
625941da498bea3a759b9d5f
def changeReferenceTransposePosition3DInPlace(pT, pPosOut): <NEW_LINE> <INDENT> return _almathswig.changeReferenceTransposePosition3DInPlace(pT, pPosOut)
changeReferenceTransposePosition3DInPlace(Transform pT, Position3D pPosOut)
625941da009cb60464c63661
def read_bitcoin_config(dbdir): <NEW_LINE> <INDENT> from ConfigParser import SafeConfigParser <NEW_LINE> class FakeSecHead(object): <NEW_LINE> <INDENT> def __init__(self, fp): <NEW_LINE> <INDENT> self.fp = fp <NEW_LINE> self.sechead = '[all]\n' <NEW_LINE> <DEDENT> def readline(self): <NEW_LINE> <INDENT> if self.sechead...
Read the nakedcash.conf file from dbdir, returns dictionary of settings
625941dacad5886f8bd2728a
def __init__(self, model_Loc, kenlm_query_loc, tmpdir=None): <NEW_LINE> <INDENT> self.model_loc = model_Loc <NEW_LINE> self.kenlm_query_loc = kenlm_query_loc <NEW_LINE> self.tmpdir=tmpdir
Initialize a KenLMSubprocessWrapper Note that this class writes both the KenLM input AND output to disk to ensure subprocess calls reliably terminate. If the documents passed to KenLM are very large, and/or your OS's default temporary directory is on an SSD, consider using the tmpdir parameter to write temp files to a...
625941da21a7993f00bc7fa4
def create_unknown_board(board): <NEW_LINE> <INDENT> return [['*' for i in board] for i in board]
This function returns the board as an unknown board
625941da8c3a87329515866e
def countAndSay(self, n: int) -> str: <NEW_LINE> <INDENT> def nextNum(s): <NEW_LINE> <INDENT> cur, count = s[0], 0 <NEW_LINE> res = '' <NEW_LINE> for c in s: <NEW_LINE> <INDENT> if c == cur: <NEW_LINE> <INDENT> count += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res += (str(count) + cur) <NEW_LINE> cur, count = c,...
f(1) = '1' f(2) = nextNum(f(1))
625941da4f88993c3716c316
def sgd_momentum(w, dw, config=None): <NEW_LINE> <INDENT> if config is None: config = {} <NEW_LINE> config.setdefault('learning_rate', 1e-2) <NEW_LINE> config.setdefault('momentum', 0.9) <NEW_LINE> v = config.get('velocity', np.zeros_like(w)) <NEW_LINE> next_w = None <NEW_LINE> next_w = w - config['learning_rate'] * dw...
Performs stochastic gradient descent with momentum. config format: - learning_rate: Scalar learning rate. - momentum: Scalar between 0 and 1 giving the momentum value. Setting momentum = 0 reduces to sgd. - velocity: A numpy array of the same shape as w and dw used to store a moving average of the gradients.
625941da3cc13d1c6d3c762a
def scanForAdditions(self): <NEW_LINE> <INDENT> new = listdir(self.currentpath) <NEW_LINE> old = self.entry.getAttachments() <NEW_LINE> if old != new: <NEW_LINE> <INDENT> for item in new: <NEW_LINE> <INDENT> if item not in old: <NEW_LINE> <INDENT> self.entry.addAttachment(item) <NEW_LINE> <DEDENT> <DEDENT> return True ...
[For later.] Allows manual addition of attachments that will be added to associated folder upon opening the JEntry.
625941daeab8aa0e5d26de0a
def loss_function(self, recon_x, x, reparam_map): <NEW_LINE> <INDENT> nll = distributions.nll(x, recon_x, self.config['nll_type']) <NEW_LINE> utils.nan_check_and_break(nll, "nll") <NEW_LINE> return { 'loss': nll, 'loss_mean': torch.mean(nll), 'elbo_mean': torch.mean(torch.zeros_like(nll)), 'nll_mean': torch.mean(nll), ...
VAE with no KL objective. Still uses reparam. :param recon_x: the unactivated reconstruction preds. :param x: input tensor. :returns: loss dict :rtype: dict
625941dafff4ab517eb2f6ee
@registry.architectures("spacy.MaxoutWindowEncoder.v2") <NEW_LINE> def MaxoutWindowEncoder( width: int, window_size: int, maxout_pieces: int, depth: int ) -> Model[List[Floats2d], List[Floats2d]]: <NEW_LINE> <INDENT> cnn = chain( expand_window(window_size=window_size), Maxout( nO=width, nI=width * ((window_size * 2) + ...
Encode context using convolutions with maxout activation, layer normalization and residual connections. width (int): The input and output width. These are required to be the same, to allow residual connections. This value will be determined by the width of the inputs. Recommended values are between 64 and 300....
625941da99fddb7c1c9de641
def snap_deactivate(snapname, mnode=None): <NEW_LINE> <INDENT> if mnode is None: <NEW_LINE> <INDENT> mnode = tc.servers[0] <NEW_LINE> <DEDENT> cmd = "gluster snapshot deactivate %s --mode=script" % snapname <NEW_LINE> return tc.run(mnode, cmd)
Deactivates the given snapshot Example: snap_deactivate(testsnap) Args: snapname (str): snapshot name to be cloned Kwargs: mnode (str): Node on which cmd has to be executed. If None, defaults to nodes[0]. Returns: tuple: Tuple containing three elements (ret, out, err). The first elem...
625941da91af0d3eaac9bccc
def _cleanup(self): <NEW_LINE> <INDENT> pass
Clean the optimizer state (optional).
625941da85dfad0860c3b10d
def create_organization(self, name, description, owner): <NEW_LINE> <INDENT> url = urljoin(self._host, '/v1/organizations') <NEW_LINE> response = requests.post(url, headers={ 'X-Auth-Token': self._access_token }, json={ 'organization': { 'name': name, 'description': description } }, verify=VERIFY_REQUESTS) <NEW_LINE> i...
Creates a new organization and asigns the given user as owner
625941da498bea3a759b9d60
def riccati_psi_xi(x, nstop): <NEW_LINE> <INDENT> if np.imag(x) != 0.: <NEW_LINE> <INDENT> raise TypeError('Cannot handle complex arguments.') <NEW_LINE> <DEDENT> psin = riccati_jn(nstop, x) <NEW_LINE> xin = psin[0] + 1j*riccati_yn(nstop, x)[0] <NEW_LINE> rbh = array([psin[0], xin]) <NEW_LINE> return rbh
Calculate Riccati-Bessel functions psi and xi for real argument. Parameters ---------- x : float Argument nstop : int Maximum order to calculate to Returns ------- ndarray(2, nstop) psi and xi Notes ----- Uses upwards recursion.
625941da6aa9bd52df037056
def show_version(self, dut, *args, **kwargs): <NEW_LINE> <INDENT> return dut.run_shell("version")
Returns the ontap running version
625941daad47b63b2c50a22f
def _set_send_default_route(self, v, load=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> t = YANGDynClass(v,base=YANGBool, default=YANGBool("false"), is_leaf=True, yang_name="send-default-route", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openco...
Setter method for send_default_route, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/ipv4_unicast/state/send_default_route (boolean) If this variable is read-only (config: false) in the source YANG file, then _set_send_default_route is considered as a private method. Backends looking to populate t...
625941dab7558d58953c51c1
def set_ResponseFormat(self, value): <NEW_LINE> <INDENT> InputSet._set_input(self, 'ResponseFormat', value)
Set the value of the ResponseFormat input for this Choreo. ((optional, string) Format of the response returned by Education.com. Defaluts to XML. JSON is also possible.)
625941da30dc7b7665901c15
def get_desmond_energy_from_file(energy_file): <NEW_LINE> <INDENT> with open(energy_file, 'r') as f: <NEW_LINE> <INDENT> data = [] <NEW_LINE> types = [] <NEW_LINE> line = f.readline() <NEW_LINE> if line.startswith('time=0.000000'): <NEW_LINE> <INDENT> terms = line.split() <NEW_LINE> terms = terms[1:-2] <NEW_LINE> for t...
Parses the desmond energy file.
625941daf548e778e58cd830
def test_merge_bridged_contig_pair1(self): <NEW_LINE> <INDENT> hits = [ '\t'.join(['721', '999', '5', '283', '279', '279', '100.00', '1000', '753', '1', '1', 'ref1', 'reassembly']), '\t'.join(['1', '420', '324', '743', '420', '420', '100.00', '1000', '753', '1', '1', 'ref2', 'reassembly']), ] <NEW_LINE> start_hit, end_...
test _merge_bridged_contig_pair1
625941dad18da76e23532789
def make_feature(self, fid, data): <NEW_LINE> <INDENT> if len(data.shape) < 2: <NEW_LINE> <INDENT> raise ValueError("Data array should at least have dimension 2") <NEW_LINE> <DEDENT> if len(data.shape) > 3: <NEW_LINE> <INDENT> raise ValueError("Data array should have <4 dimensions") <NEW_LINE> <DEDENT> if ((data.shape[...
Compute parcel-level averages of data Parameters ---------- fid: string, the feature identifier data: array of shape (self.domain.size, self.nb_subj, dim) or (self.domain.sire, self.nb_subj) Some information at the voxel level Returns ------- pfeature: array of shape(self.nb_parcel, self.nbsubj, dim) ...
625941da167d2b6e31218e46
def set_cmap(self, cmap, base=True, overlays=False, **kwa): <NEW_LINE> <INDENT> for p in self._plots: <NEW_LINE> <INDENT> p.set_cmap(cmap, base, overlays) <NEW_LINE> <DEDENT> self.draw()
Change the colormap in the topomaps Parameters ---------- cmap : str | colormap New colormap. base : bool Apply the new colormap in the lowest layer of each plot. overlays : bool Apply the new colormap to the layers above the first layer.
625941da7b180e01f3dc4aaa
def wait_visible(driver, locator, by=By.XPATH, timeout=60): <NEW_LINE> <INDENT> logging.info("Waiting for {0} to be visible".format(locator)) <NEW_LINE> try: <NEW_LINE> <INDENT> if ui.WebDriverWait(driver, timeout).until(EC.visibility_of_element_located((by, locator))): <NEW_LINE> <INDENT> logging.info("Found element."...
:param driver: :param locator: :param by: :param timeout: :return:
625941da6fece00bbac2d9f2
def _to_xml_node(self, doc, metadata, nodename, data): <NEW_LINE> <INDENT> result = doc.createElement(nodename) <NEW_LINE> xmlns = metadata.get('xmlns', None) <NEW_LINE> if xmlns: <NEW_LINE> <INDENT> result.setAttribute('xmlns', xmlns) <NEW_LINE> <DEDENT> if type(data) is list: <NEW_LINE> <INDENT> collections = metadat...
Recursive method to convert data members to XML nodes.
625941da4e4d5625662d4686
def _compute_likelihood(self): <NEW_LINE> <INDENT> if self.equal_variances: <NEW_LINE> <INDENT> if self.args.device_type == 'gpu': <NEW_LINE> <INDENT> return (0.5 * self.d * torch.log(torch.square(torch.linalg.norm(self.X - self.X @ self.B))) - torch.linalg.slogdet(torch.eye(self.d).cuda(self.args.device_ids) - self.B)...
Compute (negative log) likelihood in the linear Gaussian case. Return ------ torch.Tensor: Likelihood term (scalar-valued).
625941daa8370b7717052b50
def test_fillCenterAsSecondMove(self): <NEW_LINE> <INDENT> turn = 1 <NEW_LINE> startingBoard = ['X', '_', '_', '_', '_', '_', '_', '_', '_',] <NEW_LINE> expected = self.__translateBoard(['X', '_', '_', '_', 'O', '_', '_', '_', '_']) <NEW_LINE> game = self.__setupGame(startingBoard, turn) <NEW_LINE> game.nextTurn(Game.O...
Following the logic of the game, if the opponent has made their first move in a corner, then the second move should be in the center.
625941dad18da76e2353278a
def cleanupLayers(instance, item=None, container=None): <NEW_LINE> <INDENT> pass
Optionally process all layers attempting their cleanupInstance and cleanupField methods if they exist.
625941dacdde0d52a9e532e6
def update(args): <NEW_LINE> <INDENT> print("[coil] Attempting to fetch chain from node") <NEW_LINE> connected = False <NEW_LINE> for node in nodes: <NEW_LINE> <INDENT> response = requests.get("http://" + node.netloc + "/resolve/chain") <NEW_LINE> if response.status_code == 200 and response.headers["Content-Type"] == "...
coil.py update Read nodes from nodes.txt, attempt to connect with a node and then download
625941da63b5f9789fde7397
def updaterunInventoryButton(self): <NEW_LINE> <INDENT> inventory_bttn = self.window.runInventoryButton <NEW_LINE> if inventory_bttn.isChecked(): <NEW_LINE> <INDENT> inventory_bttn.setText("Stop inventory") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> inventory_bttn.setText("Start inventory")
update the state of the run inventory button
625941da60cbc95b062c67f5