code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def popup(self): <NEW_LINE> <INDENT> self.win.show() | function to start popup window object | 625941f5ec188e330fd5add1 |
def test_04(self, ssgyc:Songshaoguangyuncheng): <NEW_LINE> <INDENT> ssgyc.open("/dashiyunchengheji/index?channel=online_paytest") <NEW_LINE> ssgyc.english_name() <NEW_LINE> acturl_tips = ssgyc.get_tips() <NEW_LINE> expect_tips = "请输入中文" <NEW_LINE> assert acturl_tips == expect_tips | 英文名称提示是否正常 | 625941f515fb5d323cde115a |
def test_the_morphology_complete_endpoint(api, json_response, doc_params): <NEW_LINE> <INDENT> httpretty.enable() <NEW_LINE> httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", body=json_response, status=200, content_type="application/json") <NEW_LINE> httpretty.register_uri(httpretty.POST, "... | Test the morphology complete endpoint | 625941f5187af65679ca5761 |
def get_current_pose(self): <NEW_LINE> <INDENT> return self.move_group.get_current_pose() | @return: | 625941f523e79379d52eeb9b |
def yes_or_no(question, default="yes"): <NEW_LINE> <INDENT> valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} <NEW_LINE> if default is None: <NEW_LINE> <INDENT> prompt = " [y/n] " <NEW_LINE> <DEDENT> elif default == "yes": <NEW_LINE> <INDENT> prompt = " [Y/n] " <NEW_LINE> <DEDENT> elif default == "n... | Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is True for "... | 625941f576d4e153a657f173 |
def base_ortho_1(size): <NEW_LINE> <INDENT> symHNF = [] <NEW_LINE> diags = find_HNF_diagonal(size) <NEW_LINE> for i in diags: <NEW_LINE> <INDENT> a = i[0] <NEW_LINE> c = i[1] <NEW_LINE> f = i[2] <NEW_LINE> if (c / a) % 1 == 0: <NEW_LINE> <INDENT> j = 0 <NEW_LINE> while a * j < c: <NEW_LINE> <INDENT> b = a * j <NEW_LINE... | Generates symmetry preserving HNF's of a given size
for a base centered monoclinic basis
Args:
size (int): The determinate of the HNF matricies
Returns:
list (int): The generated HNF matricies | 625941f523849d37ff7b36cb |
def build(structure, config, env={}, extra={}): <NEW_LINE> <INDENT> get_blogs(structure, config, config.get("root", "/")) | Метод запуска | 625941f5ec188e330fd5add2 |
def indifferent_scores(scores): <NEW_LINE> <INDENT> N, D = scores.shape <NEW_LINE> if N > 1: <NEW_LINE> <INDENT> mu = np.copy(scores).mean(axis=1, keepdims=True) <NEW_LINE> mu = np.broadcast_to(mu, scores.shape) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> mu = np.full(scores.shape, np.copy(scores).mean()) <NEW_LINE> ... | Check whether class scores are all close to eachother
If class scores are all nearly same, it means model
is indifferent to class and makes equally distributed
values on each.
This means that, even in the case where the model was
unable to learn, it would still get 1/3 accuracy by default
This function attempts pres... | 625941f510dbd63aa1bd31e2 |
def remove_iam_role(handler): <NEW_LINE> <INDENT> handler.detach_role_policy(RoleName=DWH_ROLE_NAME, PolicyArn="arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess") <NEW_LINE> print(datetime.now(), ': Revoked policy: AmazonS3ReadOnlyAccess') <NEW_LINE> handler.delete_role(RoleName=DWH_ROLE_NAME) <NEW_LINE> print(datetime.n... | Revokes policy for S3 access which was assigned in function 'setup_iam_role'
Returns: Nothing | 625941f5009cb60464c639ed |
def save_related(self, request, form, formsets, change): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> super(BranchOfficeAdmin, self).save_related(request, form, formsets, change) <NEW_LINE> branch_office = form.instance <NEW_LINE> if branch_office.administrator not in branch_office.employees.all(): <NEW_LINE> <INDENT> ... | Overrides the save related method to add by default the administrator
to the branch's employees if it's not already part of them. | 625941f5004d5f362079a96f |
def run(self): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> expect_agent_entries = AgentUtils.map_agent_with_expected(self.registered_agents) <NEW_LINE> results = self.database.query(expect_agent_entries) <NEW_LINE> if len(results) == 0: <NEW_LINE> <INDENT> self.notify_agents_end(expect_agent_entries) <NEW_LINE>... | The main loop | 625941f5be8e80087fb21277 |
def get_physical_characteristics(sed_name): <NEW_LINE> <INDENT> sed_name = sed_name.strip() <NEW_LINE> if sed_name.endswith('.gz'): <NEW_LINE> <INDENT> sed_name = sed_name.replace('.gz','') <NEW_LINE> <DEDENT> if sed_name.endswith('.txt.'): <NEW_LINE> <INDENT> sed_name = sed_name.replace('.txt','') <NEW_LINE> <DEDENT> ... | Read in the name of an SED file.
Return (in this order) Teff, metallicity (FeH), log(g) | 625941f5442bda511e8bea4f |
def generate_emission2(self, M): <NEW_LINE> <INDENT> emission = [] <NEW_LINE> states = [] <NEW_LINE> i = 0 <NEW_LINE> while i < M: <NEW_LINE> <INDENT> rnum = random.random() <NEW_LINE> if i == 0: <NEW_LINE> <INDENT> y = random.choices(list(range(self.L)), self.A_start)[0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> y... | Generates an emission of length M, assuming that the starting state
is chosen uniformly at random.
Arguments:
M: Length of the emission to generate.
Returns:
emission: The randomly generated emission as a list.
states: The randomly generated states as a list. | 625941f526068e7796caf32a |
def make_one(size=48, display=0, title='', density=1, complexity=1): <NEW_LINE> <INDENT> xmax = ymax = (size // 4) * 2 + 1 <NEW_LINE> M = maze(xmax, ymax, complexity, density) <NEW_LINE> walls = [] <NEW_LINE> for x in range(xmax): <NEW_LINE> <INDENT> walls.extend(make_vertical_walls(xmax,ymax,x,M)) <NEW_LINE> <DEDENT> ... | Create a random racetrack and print out its definition. The parameters are:
size: each racetrack is a square grid of dimensions approximately size x size.
Because of some idiosyncracies involving the maze subroutine, the dimensions are
rounded to the nearest multiple of 4.
title: a string to use as part of each race... | 625941f5d6c5a10208144691 |
def f_reversible_inverse(self, program): <NEW_LINE> <INDENT> raise NotImplementedError | Inverts a program from its reversibe IR to its original representation. | 625941f5796e427e537b0c0c |
def t_WeaponPhaseCannonMaxPower(): <NEW_LINE> <INDENT> g = Game() <NEW_LINE> g.board[(1, 1)].createUnitHere(Unit_TechnoHornet_Mech(g, weapon1=Weapon_PhaseCannon(power1=True, power2=True))) <NEW_LINE> g.board[(2, 1)].createUnitHere(Unit_Building(g)) <NEW_LINE> g.board[(3, 1)].createUnitHere(Unit_AlphaScorpion(g)) <NEW_L... | Fire the PhaseCannon weapon with max power. | 625941f55f7d997b871750de |
def delete_event_type(self, event_type_name): <NEW_LINE> <INDENT> headers = self.authorization_header() <NEW_LINE> page = "{}/event-types/{}".format(self.nakadi_url, event_type_name) <NEW_LINE> response = requests.delete(page, headers=headers) <NEW_LINE> response_content_str = response.content.decode('utf-8') <NEW_LINE... | DELETE /event-types/{name}
:param event_type_name:
:return: | 625941f50c0af96317bb8827 |
def __cid_from_socket(self, sock): <NEW_LINE> <INDENT> for cid, client_sock in self.__clients.items(): <NEW_LINE> <INDENT> if sock is client_sock: <NEW_LINE> <INDENT> return cid <NEW_LINE> <DEDENT> <DEDENT> return 0 | return cid of a given client socket
:param sock: a client socket
:return: if client - cid associated with client socket, else - 0 | 625941f5cad5886f8bd27619 |
def __init__(self, action='android.intent.action.VIEW', activity=None, category=None, component=None, data=None, extras=None, flags=None, package=None): <NEW_LINE> <INDENT> self._action = action <NEW_LINE> self._activity = activity <NEW_LINE> if isinstance(category, list) or category is None: <NEW_LINE> <INDENT> self._... | Creates an Intent.
Args:
action: A string containing the action.
activity: A string that, with |package|, can be used to specify the
component.
category: A string or list containing any categories.
component: A string that specifies the component to send the intent to.
data: A string containing a... | 625941f58e05c05ec3eea9bb |
def test15(self): <NEW_LINE> <INDENT> channel1, channel2, p1, p2 = self.setup_test_channels() <NEW_LINE> channels = datamodel.Channels() <NEW_LINE> channels.add_channel(channel1) <NEW_LINE> channels2 = datamodel.Channels() <NEW_LINE> channels2.add_channel(channel2) <NEW_LINE> channels2.add_channels(channels) <NEW_LINE>... | Test Channels add channels | 625941f51f037a2d8b94683d |
def chromBegin(self, chrom: 'size_t') -> "size_t": <NEW_LINE> <INDENT> return _simuPOP_linop.GenoStruTrait_chromBegin(self, chrom) | Usage:
x.chromBegin(chrom)
Details:
return the index of the first locus on chromosome chrom. | 625941f526238365f5f0f4b7 |
def get_default_key( self, resource_group_name, monitor_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "2... | Get the default api key.
Get the default api key.
:param resource_group_name: The name of the resource group to which the Datadog resource
belongs.
:type resource_group_name: str
:param monitor_name: Monitor resource name.
:type monitor_name: str
:keyword callable cls: A custom type or function that will be passed t... | 625941f5236d856c2ad44e25 |
def create_rnn(self, is_training=False): <NEW_LINE> <INDENT> rnn_cell = tf.contrib.rnn.BasicLSTMCell(self.numunits) <NEW_LINE> if self.dropout < 1 and is_training: <NEW_LINE> <INDENT> rnn_cell = tf.contrib.rnn.DropoutWrapper( rnn_cell, output_keep_prob=self.dropout) <NEW_LINE> <DEDENT> rnn_cell = tf.contrib.rnn.MultiRN... | created the decoder rnn cell
Args:
is_training: whether or not the network is in training mode
Returns:
an rnn cell | 625941f5379a373c97cfb188 |
def get_line(file_name, line_no, errors='ignore'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with io.open(file_name, mode='r', encoding='utf-8', errors=errors) as source_file: <NEW_LINE> <INDENT> for line in source_file: <NEW_LINE> <INDENT> line_no -= 1 <NEW_LINE> if line_no == 0: <NEW_LINE> <INDENT> return line <NE... | Return the given line from the file. If line_no is larger than the number
of lines in the file then empty string returns.
If the file can't be opened for read, the function also returns empty
string.
Try to encode every file as utf-8 to read the line content do not depend
on the platform settings. By default locale.ge... | 625941f5956e5f7376d714ac |
def cursor_sorted(q,keyfield,mycore,highlights=False): <NEW_LINE> <INDENT> assert isinstance(mycore,solrJson.SolrCore) <NEW_LINE> mycore.ping() <NEW_LINE> assert isinstance(keyfield,str) <NEW_LINE> assert isinstance(q,str) <NEW_LINE> unsortedcursor=cursor(mycore,keyfield=keyfield,searchterm=q,highlights=highlights) <NE... | iteration of entire Solr index, sorted by a keyfield | 625941f566673b3332b926d2 |
def __eq__(self, obj): <NEW_LINE> <INDENT> if obj.name == self.name and obj.gender == self.gender and self.__class__ == obj.__class__: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Called whenever a comparison of a person object is made | 625941f5293b9510aa2c38d1 |
def create(self, cluster_name, num_masters=1, num_workers=2, master_type='n1-standard-1', worker_type='n1-standard-1', master_disk_gb=50, worker_disk_gb=50, init_scripts=[], block=True): <NEW_LINE> <INDENT> log.info("Creating cluster '{}'".format(cluster_name)) <NEW_LINE> zone_uri = 'https://www.googleapis.com/compute/... | Creates a DataProc cluster with the provided settings, returning a dict
of the results returned from the API. It can wait for cluster creation if desired.
If block is set to True, the method will block until the cluster reaches either
a RUNNING or an ERROR state. If the cluster errors, an Exception will be raised.
:p... | 625941f5d99f1b3c44c67bc3 |
def pack(self): <NEW_LINE> <INDENT> writer = msgbuffers.BinaryWriter() <NEW_LINE> self.pack_to(writer) <NEW_LINE> return writer.dumps() | Writes the current SetRobotVolume, returning bytes. | 625941f50a366e3fb873ee61 |
def test_post_same(self): <NEW_LINE> <INDENT> regions = self.make_regions() <NEW_LINE> structure = self.get_structure(regions) <NEW_LINE> data = {'data': json.dumps(structure)} <NEW_LINE> self.assertSuccessResponse(data, structure) | Test when hierarchy and boundaries do not change. | 625941f55510c4643540fa14 |
def setup_routing(self): <NEW_LINE> <INDENT> for host in self.hosts: <NEW_LINE> <INDENT> host_id = int(host.name[1:]) <NEW_LINE> for i, intf_name in enumerate(host.intfNames()): <NEW_LINE> <INDENT> ip = self.HOST_IP.format(i, host_id) <NEW_LINE> gateway = self.HOST_IP.format(i, 0) <NEW_LINE> mac = self.HOST_MAC.format(... | Set IP and MAC address for each interface on each host.
:return: None | 625941f58c0ade5d55d3f002 |
def get_delete_resource_guard_proxy_requests_objects( self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> AsyncIterable["_models.DppBaseResourceList"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: Re... | Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource.
Returns collection of operation request objects for a critical operation protected by the given
ResourceGuard resource.
:param resource_group_name: The name of the resource group where the backup va... | 625941f50a366e3fb873ee62 |
def shift(self, delta: datetime.timedelta) -> None: <NEW_LINE> <INDENT> if not isinstance(delta, datetime.timedelta): <NEW_LINE> <INDENT> raise TypeError('{} is wrong type. Must be datetime.timedelta'.format(delta)) <NEW_LINE> <DEDENT> for time_value in self._members: <NEW_LINE> <INDENT> time_value.increment(seconds=de... | Shift the time of the range.
Works by incrementing start_time and end_time equally by the increment given in delta. | 625941f5167d2b6e312191d5 |
def travel(self): <NEW_LINE> <INDENT> cur = self._head <NEW_LINE> while cur != None: <NEW_LINE> <INDENT> print(cur.val) <NEW_LINE> cur = cur.next <NEW_LINE> <DEDENT> print("") | 遍历链表 | 625941f515fb5d323cde115b |
def xps(s): <NEW_LINE> <INDENT> return ET.parse(StringIO(s)).getroot() | XML Parse String (internal helper function). | 625941f55510c4643540fa15 |
def highlight_code(self, html): <NEW_LINE> <INDENT> from BeautifulSoup import BeautifulSoup <NEW_LINE> from pygments import highlight <NEW_LINE> from pygments.lexers import get_lexer_by_name <NEW_LINE> from pygments.formatters import HtmlFormatter <NEW_LINE> soup = BeautifulSoup(html) <NEW_LINE> preblocks = soup.findAl... | Highlight code snippets. Based on:
http://www.saltycrane.com/blog/2008/08/django-blog-project-12-adding-pygments-syntax-highlighting/ | 625941f53317a56b8693a289 |
def get_templates_from_spykingcircus_file(spykingcircus_result_dirpath, filename, unit_pos, gain=4): <NEW_LINE> <INDENT> f_whitening = h5py.File(os.path.join(spykingcircus_result_dirpath, filename+'.basis.hdf5'), 'r') <NEW_LINE> f_template = h5py.File(os.path.join(spykingcircus_result_dirpath, filename+'.templates.hdf5... | Get the templates (shapes) for a specific unit. Designed for tetrode recordings, this return the template of
the unit on each wire of the tetrode. It requires the .basis.hdf5, .templates.hdf5 and the .clusters.hdf5 files
from Spyking Circus.
Parameters
----------
spykingcircus_result_dirpath : str
Path where the S... | 625941f582261d6c526abaea |
def __bool__(self): <NEW_LINE> <INDENT> return len(self._values) > 0 | Return True if this node contains any objects. | 625941f524f1403a926011a2 |
def __init__(self, hardware_api: HardwareControlAPI) -> None: <NEW_LINE> <INDENT> self._hardware_api = hardware_api <NEW_LINE> self._default_engine: Optional[ProtocolEngine] = None <NEW_LINE> self._runner_engine_pair: Optional[RunnerEnginePair] = None <NEW_LINE> self._engines_by_run_id: Dict[str, ProtocolEngine] = {} | Initialize an engine storage interface.
Arguments:
hardware_api: Hardware control API instance used for ProtocolEngine
construction. | 625941f53cc13d1c6d3c79b8 |
def __init__(self, log_p, name='First Order Expectation Functional'): <NEW_LINE> <INDENT> super(FirstOrderExpectationFunctional, self).__init__(log_p, name=name) | Initialize the object. | 625941f5e1aae11d1e74a2ff |
def main(argv): <NEW_LINE> <INDENT> (opts, args) = parse_args(argv) <NEW_LINE> output = sys.stdout <NEW_LINE> if opts.output_log is not None: <NEW_LINE> <INDENT> output = open(opts.output_log, "w") <NEW_LINE> <DEDENT> if opts.svn_log: <NEW_LINE> <INDENT> log_file = opts.svn_log <NEW_LINE> parser = parse_svn_log <NEW_LI... | Calls the parse_args function based on the
command-line inputs and handles parsed arguments. | 625941f52ae34c7f2600d771 |
@app.route('/messaging_center', methods = ['GET','POST']) <NEW_LINE> @login_required <NEW_LINE> def messaging_center(): <NEW_LINE> <INDENT> usersComms = [x.community for x in current_user.users_communities] <NEW_LINE> users = set() <NEW_LINE> for comm in usersComms : <NEW_LINE> <INDENT> for srcOut in [x.srcOutRelation... | Users can send messages to other users in their
communities. This page allows them to do that. | 625941f59b70327d1c4e141a |
def parse_action(s): <NEW_LINE> <INDENT> m = re.match('(turn on|turn off|toggle) (\d+),(\d+) through (\d+),(\d+)', s) <NEW_LINE> return (m.group(1), Point(int(m.group(2)), int(m.group(3))), Point(int(m.group(4)), int(m.group(5)))) | Parse an action string into a tuple suitable for `perform_action`
Returns a tuple consisting of (action string, top left point, bottom right point)
>>> parse_action('turn on 0,0 through 1,1')
('turn on', Point(x=0, y=0), Point(x=1, y=1)) | 625941f5e5267d203edce2d6 |
def params_to_skopt(param_space: ParamSpace): <NEW_LINE> <INDENT> dimensions = [] <NEW_LINE> for param_name in param_space.param_names(): <NEW_LINE> <INDENT> domain_param = param_space.domain(param_name) <NEW_LINE> domain = domain_param["domain"] <NEW_LINE> dtype = DTypes.from_type(domain_param["dtype"]) <NEW_LINE> if ... | Converts a parameter space to a list of Dimention objects that can be used with
a skopt Optimizer.
A skopt Optimizer only receives 3 types of Dimensions: Categorical, Real, or Integer
we convert parameters from our parameter space into one of those 3 types. Note that we only
convert parameters that have either bounds ... | 625941f54e4d5625662d4a0f |
def set_cpu0(device_string): <NEW_LINE> <INDENT> parsed_device = pydev.DeviceSpec.from_string(device_string) <NEW_LINE> parsed_device.device_type = "CPU" <NEW_LINE> parsed_device.device_index = 0 <NEW_LINE> return parsed_device.to_string() | Creates a new device string based on `device_string' but using /CPU:0.
If the device is already on /CPU:0, this is a no-op.
Args:
device_string: A device string.
Returns:
A device string. | 625941f5d486a94d0b98e788 |
def get_hostname(self): <NEW_LINE> <INDENT> return self._hostname | Get hostname/ip of the machine
This will return the hostname/ip of the machine's controller
interface. | 625941f5cc40096d61595f8f |
def custom_pop(input_list): <NEW_LINE> <INDENT> pass | like input_list.pop(), should remove the last item in the list and
return it | 625941f5287bf620b61d40a1 |
def src_len(self): <NEW_LINE> <INDENT> return len(self.src()) | ! Get number of source lines
@param self The current class
@return number of source lines | 625941f53539df3088e2e98d |
def parse_known_args(parser, subparser=False): <NEW_LINE> <INDENT> subparser_value = [sys.argv[1]] if subparser else [] <NEW_LINE> config_values = config_to_list(config_name=get_config_name()) <NEW_LINE> values = subparser_value + config_values + sys.argv[1:] <NEW_LINE> args = parser.parse_known_args(values)[0] <NEW_LI... | Parse arguments from file and then override by the ones specified on the command line. Use
*parser* for parsing and is *subparser* is True take into account that there is a value on the
command line specifying the subparser. | 625941f560cbc95b062c6b85 |
def forward(self, x): <NEW_LINE> <INDENT> x = x + self.block1(x) <NEW_LINE> x = self.relu(x) <NEW_LINE> x = x + self.block2(x) <NEW_LINE> x = self.relu(x) <NEW_LINE> return self.out_conv(x) | Args:
x (tensor - B x c_in x W x H)
Return:
x (tensor - B x c_out x W x H) | 625941f54e4d5625662d4a10 |
def parse_log_level(log_level_arg): <NEW_LINE> <INDENT> LOG_LEVELS = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'] <NEW_LINE> if log_level_arg not in LOG_LEVELS: <NEW_LINE> <INDENT> msg = 'Invalid option: {0} (Valid choices are {1})'.format( log_level_arg, LOG_LEVELS) <NEW_LINE> raise argparse.ArgumentTypeError(msg... | Parse the log level from the args.
Args:
log_level_arg: String representation of log level | 625941f5a17c0f6771cbe690 |
def __rmod__(self, other): <NEW_LINE> <INDENT> return frac(other) % self | built-in A%B alternative support for frac | 625941f507f4c71912b11ac7 |
def getMechanismName(self): <NEW_LINE> <INDENT> pass | @returns: The name of the authentication mechanism | 625941f51b99ca400220b0f6 |
def setVolumeSize(self, *args): <NEW_LINE> <INDENT> return _simvoleon.SoVolumeData_setVolumeSize(self, *args) | setVolumeSize(self, SbBox3f size) | 625941f5d7e4931a7ee9e561 |
def newEpisode(self): <NEW_LINE> <INDENT> self.explmatrix = random.normal(0., expln(self.sigma), self.explmatrix.shape) | Randomize the matrix values for exploration during one episode. | 625941f529b78933be1e5ce6 |
def token_to_features(self, sentence, index): <NEW_LINE> <INDENT> raise NotImplementedError("token_to_features not implemented") | feature set for a token | 625941f5f548e778e58cdbc2 |
@pytest.mark.parametrize('container', controller_containers) <NEW_LINE> def test_container_running(host, container): <NEW_LINE> <INDENT> return helpers.test_container_running(host, container) | Verify that containers are running and healthy | 625941f599fddb7c1c9de9cf |
def calculate_inner_layer_derivative(self, j: int) -> None: <NEW_LINE> <INDENT> assert j != self.layers-1 <NEW_LINE> a = self.activation_outputs[j] <NEW_LINE> W = self.weights[j+1] <NEW_LINE> delta_jPlusOne = self.layer_derivatives[j+1] <NEW_LINE> d_layer = (self.d_sigmoid(a) * np.dot(W.T, delta_jPlusOne)) <NEW_LINE> r... | Calculates the partial derivative of the error with respect to the current
layer: delta_j = a_j * (1 - a_j) * W^T_j+1 dot delta_j+1
where j = layer, a_j = activation output matrix of layer j, W_j+1 = weights
matrix of layer j+1 and delta_j+1 is the derivative matrix of layer j+1.
Here * means elementwise multiplication... | 625941f594891a1f4081c0ee |
def __init__(self, height, width, channel, rng, max_steps=10000): <NEW_LINE> <INDENT> self.width = width <NEW_LINE> self.height = height <NEW_LINE> self.channel = channel <NEW_LINE> self.max_steps = max_steps <NEW_LINE> self.phi_length = PHI_LENGTH <NEW_LINE> self.rng = rng <NEW_LINE> self.imgs = np.zeros((max_steps, c... | Construct a DataSet.
Arguments:
width, height, channel - image size
max_steps - the number of time steps to store
phi_length - number of images to concatenate into a state
rng - initialized numpy random number generator, used to
choose random minibatches | 625941f567a9b606de4a84f7 |
def init_folders(self): <NEW_LINE> <INDENT> self.create_folder_if_not_exists(self.duplicate_folder) <NEW_LINE> self.create_folder_if_not_exists(self.processed_folder) | Create the base folder (processed, duplicate folder) | 625941f5dd821e528d63b7e5 |
def _get_ldap_agent(self): <NEW_LINE> <INDENT> return _get_ldap_agent(self) | get the ldap agent | 625941f58c3a873295158a05 |
def test_reconstitute_url(self): <NEW_LINE> <INDENT> url_1 = 'http://www.naver.com' <NEW_LINE> url_2 = 'www.naver.com' <NEW_LINE> url_3 = 'naver.com' <NEW_LINE> response_1 = reconstitute_url(url_1) <NEW_LINE> response_2 = reconstitute_url(url_2) <NEW_LINE> response_3 = reconstitute_url(url_3) <NEW_LINE> self.assertEqua... | reconstitute_url 함수를 테스트하는 함수
:return: | 625941f54a966d76dd551658 |
def test_host_tests_with_multiple_testplans_perpackage(self): <NEW_LINE> <INDENT> distribution_model = "perpackage" <NEW_LINE> image_url = 'http://image/url/image.bin' <NEW_LINE> test_plan = StringIO("hulapaloo") <NEW_LINE> test_plan.name = "testplan.xml" <NEW_LINE> test_plan2 = StringIO("hulapaloo2") <NEW_LINE> test_p... | Test host test plan based - one test plan | 625941f54c3428357757c965 |
def preprocess_pointclouds(S3DIS_PATH): <NEW_LINE> <INDENT> for n in range(1,7): <NEW_LINE> <INDENT> pathP = '{}/parsed/Area_{:d}/'.format(S3DIS_PATH, n) <NEW_LINE> pathD = '{}/features/Area_{:d}/'.format(S3DIS_PATH, n) <NEW_LINE> pathC = '{}/superpoint_graphs/Area_{:d}/'.format(S3DIS_PATH, n) <NEW_LINE> if not os.path... | Preprocesses data by splitting them by components and normalizing. | 625941f5be383301e01b5abb |
def testResolveSelectorExceptions(self): <NEW_LINE> <INDENT> resource = current.s3db.resource("project_project") <NEW_LINE> selector = "organisation_id.test" <NEW_LINE> self.assertRaises(AttributeError, S3ResourceField, resource, selector) | Exception for invalid selectors | 625941f5c4546d3d9de7307c |
def test_y_type(self): <NEW_LINE> <INDENT> with self.assertRaisesRegex(TypeError, "y must be an integer"): <NEW_LINE> <INDENT> s1 = Square(3, 2, '4') | check y is string | 625941f5283ffb24f3c55f3c |
@app.route("/cdn/js/<path:filename>/") <NEW_LINE> def serve_other_thirdpartyjs(filename): <NEW_LINE> <INDENT> dolog("INFO", repr((app.config["js_staging_dir"], filename))) <NEW_LINE> return send_from_directory(app.config["js_staging_dir"], filename) | see :def:serve_aloha | 625941f599cbb53fe6793226 |
def computeValueFromQValues(self, state): <NEW_LINE> <INDENT> actions = self.getLegalActions(state) <NEW_LINE> if len(actions) == 0: <NEW_LINE> <INDENT> return 0.0 <NEW_LINE> <DEDENT> max_action = None <NEW_LINE> max_qvalue = -9999 <NEW_LINE> for a in actions: <NEW_LINE> <INDENT> q = self.getQValue(state, a) <NEW_LINE>... | Returns max_action Q(state,action)
where the max is over legal actions. Note that if
there are no legal actions, which is the case at the
terminal state, you should return a value of 0.0. | 625941f521bff66bcd684f8e |
def save_data(df, database_filename): <NEW_LINE> <INDENT> engine = create_engine('sqlite:///' + database_filename) <NEW_LINE> df.to_sql('messages', engine, index=False) | Saves the dataframe into sqlite database.
Arguments:
df: Dataframe consisting of messages and their categories.
database_filename: Filepath to which the database should be saved.
Return:
None | 625941f5b7558d58953c5548 |
def open_project_space_using_put_with_http_info(self, name, path, **kwargs): <NEW_LINE> <INDENT> all_params = ['name', 'path'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout'... | openProjectSpace # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.open_project_space_using_put_with_http_info(name, path, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name (requi... | 625941f5d486a94d0b98e789 |
def serialize(self, root): <NEW_LINE> <INDENT> res = [] <NEW_LINE> def preorder(root): <NEW_LINE> <INDENT> if not root: <NEW_LINE> <INDENT> res.append("#") <NEW_LINE> return <NEW_LINE> <DEDENT> res.append(str(root.val)) <NEW_LINE> preorder(root.left) <NEW_LINE> preorder(root.right) <NEW_LINE> <DEDENT> preorder(root) <N... | Encodes a tree to a single string.
:type root: TreeNode
:rtype: str | 625941f5377c676e912727e8 |
def create_metadata(train_raw, classes, flags): <NEW_LINE> <INDENT> word_embedding_metadata_filename = flags.word_meta_file <NEW_LINE> if not path.isfile(word_embedding_metadata_filename): <NEW_LINE> <INDENT> print("Creating word-embedding metadata for TensorBoard...") <NEW_LINE> vocabulary_processor_path = path.join(f... | Create word-embedding and sentence-embedding metadata files for TensorBoard if they do not already exist. | 625941f516aa5153ce362abb |
def pretty_use_unicode(flag=None): <NEW_LINE> <INDENT> global _use_unicode <NEW_LINE> global unicode_warnings <NEW_LINE> if flag is None: <NEW_LINE> <INDENT> return _use_unicode <NEW_LINE> <DEDENT> if flag and unicode_warnings: <NEW_LINE> <INDENT> warnings.warn(unicode_warnings) <NEW_LINE> unicode_warnings = '' <NEW_LI... | Set whether pretty-printer should use unicode by default | 625941f544b2445a339326d3 |
def storeCachedEntry(self): <NEW_LINE> <INDENT> return slugify(self.name)+"entry" | Builds a key for caching an entry. | 625941f53346ee7daa2b33b4 |
@backoff.on_exception( backoff.expo, RedisError, max_tries=backoff_max_tries, max_value=backoff_max_value ) <NEW_LINE> def log_job_info(job): <NEW_LINE> <INDENT> set_redis_job_info_pool() <NEW_LINE> global JOB_INFO_POOL <NEW_LINE> filtered_info = {} <NEW_LINE> for info in ( "job_info", "job_id", "task_id", "delivery_in... | Print job info. | 625941f555399d3f05588cfb |
def _moment(self, n): <NEW_LINE> <INDENT> total_concentration = self.concentration1 + self.concentration0 <NEW_LINE> expanded_concentration1 = array_ops.ones_like( total_concentration, dtype=self.dtype) * self.concentration1 <NEW_LINE> expanded_concentration0 = array_ops.ones_like( total_concentration, dtype=self.dtype... | Compute the n'th (uncentered) moment. | 625941f566673b3332b926d3 |
@pytest.mark.apidoc( coderoot='test-apidoc-subpackage-in-toc', options=['--separate'] ) <NEW_LINE> def test_subpackage_in_toc(make_app, apidoc): <NEW_LINE> <INDENT> outdir = apidoc.outdir <NEW_LINE> assert (outdir / 'conf.py').isfile() <NEW_LINE> assert (outdir / 'parent.rst').isfile() <NEW_LINE> with open(outdir / 'pa... | Make sure that empty subpackages with non-empty subpackages in them
are not skipped (issue #4520) | 625941f57c178a314d6efaad |
def do_open(self, http_class, req): <NEW_LINE> <INDENT> host_port = req.get_host() <NEW_LINE> if not host_port: <NEW_LINE> <INDENT> raise URLError('no host given') <NEW_LINE> <DEDENT> h = http_class(host_port, timeout=req.timeout) <NEW_LINE> h.set_debuglevel(self._debuglevel) <NEW_LINE> headers = OrderedDict(req.header... | Return an addinfourl object for the request, using http_class.
http_class must implement the HTTPConnection API from httplib.
The addinfourl return value is a file-like object. It also
has methods and attributes including:
- info(): return a HTTPMessage object for the headers
- geturl(): return the original r... | 625941f515baa723493c45bd |
def readAtom(url): <NEW_LINE> <INDENT> with open(url) as f: <NEW_LINE> <INDENT> line=f.readline().strip() <NEW_LINE> AtomDict={} <NEW_LINE> while(line): <NEW_LINE> <INDENT> if line.startswith("ATOM") or line.startswith("HETATM"): <NEW_LINE> <INDENT> result = processAtom(line) <NEW_LINE> AtomDict[result[0]] = result[1] ... | this function is to read the atom file
the atom file contains atom line starts with ATOM and hetatm line starts with HETATM which is similar to atom
process every line use processAtom function
the function can process Atom line and Hetatm line and return a tuple
:param url: Atom filename
:return: | 625941f5a8370b7717052edf |
def numFactoredBinaryTrees(self, A): <NEW_LINE> <INDENT> MOD = 10 ** 9 + 7 <NEW_LINE> num_to_trees = Counter(A) <NEW_LINE> A.sort() <NEW_LINE> for i, num in enumerate(A): <NEW_LINE> <INDENT> for left in A[:i]: <NEW_LINE> <INDENT> right, remainder = divmod(num, left) <NEW_LINE> if right <= 1: <NEW_LINE> <INDENT> break <... | :type A: List[int]
:rtype: int | 625941f5a4f1c619b28b066b |
def NOTICE(self, msg): <NEW_LINE> <INDENT> if self.timestamp: <NEW_LINE> <INDENT> sys.stderr.write(self.TSTAMP() + " " + msg + "\n") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sys.stderr.write(msg + "\n") | Internal print wrapper, so it can be easily overloaded--Notice is for human readable | 625941f5d10714528d60032d |
def create_app(self, name=None, stack_id_or_name='cedar', region_id_or_name=None): <NEW_LINE> <INDENT> payload = {} <NEW_LINE> if name: <NEW_LINE> <INDENT> payload['name'] = name <NEW_LINE> <DEDENT> if stack_id_or_name: <NEW_LINE> <INDENT> payload['stack'] = stack_id_or_name <NEW_LINE> <DEDENT> if region_id_or_name: <N... | Creates a new app. | 625941f5b5575c28eb68e649 |
def _export(self) -> None: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> metric_data = self._metrics_translator() <NEW_LINE> self._logger.debug("Pickling metrics to push to Graphite...") <NEW_LINE> payload = pickle.dumps(metric_data, protocol=self._pickle_protocol) <NEW_LINE> header = str... | This function is the target of the exporters thread, and will run continuously until application shutdown,
sending metrics to the Graphite instance at the requested push interval.
:return: | 625941f5bf627c535bc13812 |
def test_java_find_function_calls(self): <NEW_LINE> <INDENT> self.filename = "parser_tests/java_functions.txt" <NEW_LINE> expected_functions = ['updateSprite', 'foo', 'foo'] <NEW_LINE> self.run_parser() <NEW_LINE> self.assertListEqual(expected_functions, self.p.scanner.functions_calls) | This test is testing parser for finding all function calls in java code | 625941f563b5f9789fde7728 |
def get_indicators(search_query='', *, subject_code=''): <NEW_LINE> <INDENT> query = f'subjectCode EQ "{subject_code}"' if subject_code else '' <NEW_LINE> response = api_indicators.get_indicators(q=query, limit=1000) <NEW_LINE> indicators = [] <NEW_LINE> for item in response['items']: <NEW_LINE> <INDENT> code = item['c... | Get available indicators on the API.
Parameters
----------
search_query : str
Free text to look for against.
subject_code : str
Subject code to restrict search within that context.
Returns
-------
tuple
Tuple of tuples with first value as indicator code and second value as
indicator title. | 625941f5cc0a2c11143dd4d4 |
def cols_to_dt(df, col_list,set_format = None,infer_format = True,dest = False): <NEW_LINE> <INDENT> if not dest: <NEW_LINE> <INDENT> return _pd.DataFrame({col_name:col_to_dt(df,col_name,set_format,infer_format) for col_name in col_list}) <NEW_LINE> <DEDENT> for col_name in col_list: <NEW_LINE> <INDENT> col_to_dt(df,co... | Coerces a list of columns to datetime
Parameters:
df - DataFrame
DataFrame to operate on
col_list - list of strings
names of columns to coerce
dest - bool, default False
Whether to apply the result to the DataFrame or return it.
True is apply, False is return. | 625941f507d97122c4178edd |
def intersect_csv_and_shapefiles(in_csv_filename, geodata1, geodata2, ancillary_path, out_csv_filename, from_gbif): <NEW_LINE> <INDENT> pth, basefname = os.path.split(out_csv_filename) <NEW_LINE> logbasename, _ = os.path.splitext(basefname) <NEW_LINE> logfname = os.path.join(pth, '{}.log'.format(logbasename)) <NEW_LINE... | Intersect the records in the csv file with the two provided shapefiles.
Args:
csv_filename (str): Path to a CSV file of records.
shapefile_1_filename (str): Path to the first shapefile to check for
intersection.
shapefile_2_filename (str): Path to the second shapefile to check for
intersect... | 625941f592d797404e3047cf |
def __call__(self): <NEW_LINE> <INDENT> x = self.x_prev + self.theta * (self.mu - self.x_prev) + self.sigma * np.random.normal(size=len(self.mu)) <NEW_LINE> self.x_prev = x <NEW_LINE> return x | Compute *x-1* + theta *(mu - *x-1*) * dt + sigma * sqrt(dt) * normal(shape(mu))
| 625941f532920d7e50b28818 |
def maxNumberOfFamilies(self, n: int, reservedSeats: List[List[int]]) -> int: <NEW_LINE> <INDENT> cache = defaultdict(int) <NEW_LINE> for seat in reservedSeats: <NEW_LINE> <INDENT> row, col = seat[0], seat[1] <NEW_LINE> cache[row] = cache[row] | (1 << (10 - col)) <NEW_LINE> <DEDENT> res = 0 <NEW_LINE> for reserved in c... | TLE if loop from 1 to n
TLE if loop from 1 to n and pop reserved seats inside the loop | 625941f57b25080760e39a97 |
def _getdirpath_ext(self): <NEW_LINE> <INDENT> if self._dirpath_ext: <NEW_LINE> <INDENT> return self._dirpath_ext <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if isinstance(self, InputSequence): <NEW_LINE> <INDENT> return pub.sequencemanager.inputpath <NEW_LINE> <DEDENT> elif isinstance(self, ... | Absolute path of the directory of the external data file. | 625941f5cdde0d52a9e5367b |
def _repr_(self): <NEW_LINE> <INDENT> return "Increasing tableaux of shape %s and weight %s" % (self.shape, self.weight) | TESTS::
sage: IncreasingTableaux([2,1], (1,0,1))
Increasing tableaux of shape [2, 1] and weight (1, 0, 1) | 625941f5d10714528d60032e |
def findRedundantConnection1(self,edges): <NEW_LINE> <INDENT> self.findSet={} <NEW_LINE> num=len(edges) <NEW_LINE> def find(i): <NEW_LINE> <INDENT> while i!=self.findSet[i]: <NEW_LINE> <INDENT> i=self.findSet[i] <NEW_LINE> <DEDENT> return i <NEW_LINE> <DEDENT> def judge(edges,i): <NEW_LINE> <INDENT> self.findSet={i:i f... | 由于这道题是树的操作,因此可以简化问题
在寻找节点的双亲过程中,如果发现两个节点的双亲相同,那么说明这
不是一个树,构成了环,
那么返回false
:type edges: List[List[int]]
:rtype: List[int] | 625941f5091ae35668667596 |
def gen_body(self, method, params, headers): <NEW_LINE> <INDENT> if params and method != 'GET': <NEW_LINE> <INDENT> if headers['Content-Type'] == 'application/x-www-form-urlencoded': <NEW_LINE> <INDENT> return urlencode(params) <NEW_LINE> <DEDENT> <DEDENT> return None | 生成请求body | 625941f5ec188e330fd5add3 |
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: <NEW_LINE> <INDENT> return { "login": [self.from_entity(entity="user_in", intent=["login"]), self.from_text()], "domain": [self.from_entity(entity="user_in", intent=["domain"]), self.from_text() ], } | A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked. | 625941f594891a1f4081c0ef |
def setUp(self): <NEW_LINE> <INDENT> super().setUp() <NEW_LINE> self.orig_login_manager = pywikibot.data.api.LoginManager <NEW_LINE> pywikibot.data.api.LoginManager = FakeLoginManager | Patch the LoginManager to avoid UI interaction. | 625941f55fcc89381b1e1d07 |
def test_create_risk_model(self): <NEW_LINE> <INDENT> pass | Test case for create_risk_model
Creates New Risk Model # noqa: E501 | 625941f5796e427e537b0c0e |
def __init__(self, max_reward: float = 1., min_reward: float = 0., min_action: float = -1., max_action: float = 1., target_action: float = 0.5, reward_function: str = "linear"): <NEW_LINE> <INDENT> self.max_reward = max_reward <NEW_LINE> self.min_reward = min_reward <NEW_LINE> self.min_action = min_action <NEW_LINE> se... | Creates a new simple continuous game
Args:
max_reward: Maximum reward per step
min_reward: Minimum reward per step
min_action: Lowest possible action
max_action: Biggest possible action
target_action: Best possible action
reward_function: The function to use. One of ["linear"]. | 625941f596565a6dacc8fd0c |
def __init__(self, vec_func, i): <NEW_LINE> <INDENT> self._vec_func = vec_func <NEW_LINE> self._i = i | returning the ith dimension of vec_funct's output
:vec_func: a function with vector outputs
:i: the ith dimension of the outputs to return | 625941f58c0ade5d55d3f003 |
def get(self): <NEW_LINE> <INDENT> app_id = app_identity.get_application_id() <NEW_LINE> users = User.query(User.email != None) <NEW_LINE> for user in users: <NEW_LINE> <INDENT> games = Game.query(Game.user == user.key, Game.game_over == False) <NEW_LINE> if games: <NEW_LINE> <INDENT> subject = 'This is a reminder!' <N... | Send a reminder email to each User with an unfinished game | 625941f566656f66f7cbc7f0 |
def load(self, infile): <NEW_LINE> <INDENT> self.infile = infile <NEW_LINE> if infile.endswith('pkl'): <NEW_LINE> <INDENT> name2recarr = pickle.load(open(infile,'rb'), encoding='latin1') <NEW_LINE> for name, recarr in name2recarr.items(): <NEW_LINE> <INDENT> self.name2table[name] = npy_table(recarr) <NEW_LINE> <DEDEN... | Load from pickle | 625941f592d797404e3047d0 |
def off(self) -> None: <NEW_LINE> <INDENT> self.set_state(0) | Turn this device off. If already off, will return "Error". | 625941f5ec188e330fd5add4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.